Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24.x

- name: Setup Bun
uses: oven-sh/setup-bun@b7a1c7ccf290d58743029c4f6903da283811b979 # v2.1.0
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest

Expand All @@ -28,3 +33,6 @@ jobs:

- name: Lint code
run: bun run lint

- name: Build
run: bun run build
39 changes: 39 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy

on:
push:
branches: [main]

jobs:
test:
name: Test and Lint
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version: 24.x

- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: latest

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Test code
run: bun run test

- name: Lint code
run: bun run lint

- name: Build
run: bun run build

- name: Deploy
run: bun run deploy
2 changes: 2 additions & 0 deletions apps/2048/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# 2048

<https://2048.rman.dev>
3 changes: 1 addition & 2 deletions apps/2048/astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineConfig } from "astro/config";

import solid from "@astrojs/solid-js";
import { defineConfig } from "astro/config";

export default defineConfig({
output: "static",
Expand Down
6 changes: 2 additions & 4 deletions apps/2048/src/components/Game.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { onMount } from "solid-js";

import { useGame } from "~/hooks/useGame";

import MenuSection from "./MenuSection";
import GameSection from "./GameSection";

import type { Direction } from "~/types";
import GameSection from "./GameSection";
import MenuSection from "./MenuSection";

export default function App() {
const CONFIG = {
Expand Down
3 changes: 1 addition & 2 deletions apps/2048/src/components/GameSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Show } from "solid-js";

import type { Component } from "solid-js";
import { Show } from "solid-js";

type GameSectionProps = {
inMenu: boolean;
Expand Down
3 changes: 1 addition & 2 deletions apps/2048/src/components/MenuSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Show } from "solid-js";

import type { Component } from "solid-js";
import { Show } from "solid-js";

type MenuSectionProps = {
inMenu: boolean;
Expand Down
18 changes: 9 additions & 9 deletions apps/2048/src/hooks/useGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function useGame(gridSize: number, initialTiles: number) {
}

function pushNumbers(arr: number[], addScore: (val: number) => void) {
let newArr = arr.filter((x) => x !== 0);
const newArr = arr.filter((x) => x !== 0);
for (let i = 0; i < newArr.length - 1; i++) {
if (newArr[i] === newArr[i + 1]) {
newArr[i]! *= 2;
Expand All @@ -63,8 +63,8 @@ export function useGame(gridSize: number, initialTiles: number) {
switch (direction) {
case "up":
for (let j = 0; j < gridSize; j++) {
let column = newGrid.map((row) => row[j]!);
let newColumn = pushNumbers(column, addScore);
const column = newGrid.map((row) => row[j]!);
const newColumn = pushNumbers(column, addScore);
for (let i = 0; i < gridSize; i++) {
if (newGrid[i]![j] !== newColumn[i]) {
moved = true;
Expand All @@ -75,8 +75,8 @@ export function useGame(gridSize: number, initialTiles: number) {
break;
case "down":
for (let j = 0; j < gridSize; j++) {
let column = newGrid.map((row) => row[j]!).reverse();
let newColumn = pushNumbers(column, addScore).reverse();
const column = newGrid.map((row) => row[j]!).reverse();
const newColumn = pushNumbers(column, addScore).reverse();
for (let i = 0; i < gridSize; i++) {
if (newGrid[i]![j] !== newColumn[i]) {
moved = true;
Expand All @@ -87,8 +87,8 @@ export function useGame(gridSize: number, initialTiles: number) {
break;
case "left":
for (let i = 0; i < gridSize; i++) {
let row = newGrid[i]!;
let newRow = pushNumbers(row, addScore);
const row = newGrid[i]!;
const newRow = pushNumbers(row, addScore);
for (let j = 0; j < gridSize; j++) {
if (newGrid[i]![j] !== newRow[j]) {
moved = true;
Expand All @@ -99,8 +99,8 @@ export function useGame(gridSize: number, initialTiles: number) {
break;
case "right":
for (let i = 0; i < gridSize; i++) {
let row = [...newGrid[i]!].reverse();
let newRow = pushNumbers(row, addScore).reverse();
const row = [...newGrid[i]!].reverse();
const newRow = pushNumbers(row, addScore).reverse();
for (let j = 0; j < gridSize; j++) {
if (newGrid[i]![j] !== newRow[j]) {
moved = true;
Expand Down
2 changes: 1 addition & 1 deletion apps/2048/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
import "~/styles/game.css";

import Layout from "~/layouts/Layout.astro";
import Game from "~/components/Game.tsx";
import Layout from "~/layouts/Layout.astro";

const id = "2048";
const title = "2048 Game";
Expand Down
3 changes: 1 addition & 2 deletions apps/app/astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineConfig } from "astro/config";

import solid from "@astrojs/solid-js";
import { defineConfig } from "astro/config";

export default defineConfig({
output: "static",
Expand Down
6 changes: 6 additions & 0 deletions apps/app/public/_redirects
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/ https://rman.dev/games 301

/nim https://nim.rman.dev/ 301
/nim/ https://nim.rman.dev/ 301

/2048 https://2048.rman.dev/ 301
/2048/ https://2048.rman.dev/ 301

Expand All @@ -14,3 +17,6 @@

/bulls-and-cows https://bulls-and-cows.rman.dev/ 301
/bulls-and-cows/ https://bulls-and-cows.rman.dev/ 301

/water-sort-puzzle https://water-sort-puzzle.rman.dev/ 301
/water-sort-puzzle/ https://water-sort-puzzle.rman.dev/ 301
Loading