-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Big fefactor the way we define moves
Also fix some of the linting.
- Loading branch information
Showing
31 changed files
with
612 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
packages/*/dist | ||
pnpm-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
# Game Template | ||
|
||
This is a very minimalist game example. | ||
This is a very minimalist game example. | ||
|
||
See [Dudo][dudo] for a more complex example. | ||
|
||
|
||
## Run the game locally | ||
|
||
pnpm install | ||
cd ui | ||
pnpm dev | ||
|
||
|
||
[dudo]: https://github.com/lefun-fun/dudo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { expectTypeOf, test } from "vitest"; | ||
|
||
import { MatchTester, PlayerMove } from "@lefun/game"; | ||
|
||
import { game, RollGame, RollGameState as GS } from "."; | ||
|
||
test("inside PlayerMove", () => { | ||
expectTypeOf(game).toEqualTypeOf<RollGame>(); | ||
|
||
const move: PlayerMove<GS, { x: number }> = { | ||
executeNow() { | ||
// | ||
}, | ||
}; | ||
|
||
expectTypeOf(move.executeNow).parameter(0).toMatchTypeOf<{ | ||
board: GS["B"]; | ||
playerboard: GS["PB"]; | ||
payload: { x: number }; | ||
}>(); | ||
|
||
expectTypeOf(move.executeNow).parameter(0).toMatchTypeOf<{ | ||
board: { count: number }; | ||
}>(); | ||
}); | ||
|
||
test("match tester", () => { | ||
const match = new MatchTester<GS, typeof game>({ game, numPlayers: 2 }); | ||
expectTypeOf(match.board.count).toEqualTypeOf<number>(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { test } from "vitest"; | ||
|
||
import { MatchTester as _MatchTester } from "@lefun/game"; | ||
|
||
import { game, RollGame as G, RollGameState as GS } from "."; | ||
|
||
class MatchTester extends _MatchTester<GS, G> {} | ||
|
||
test("sanity check", () => { | ||
const match = new MatchTester({ game, numPlayers: 2 }); | ||
const { players } = match.board; | ||
|
||
const userId = Object.keys(players)[0]; | ||
|
||
match.makeMove(userId, "roll"); | ||
match.makeMove(userId, "moveWithArg", { someArg: "123" }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
export default defineConfig({ | ||
test: { | ||
typecheck: { | ||
enabled: true, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
["^node:"], | ||
["^@?\\w"], | ||
["^@lefun/"], | ||
["^roll-game$"], | ||
["roll-game"], | ||
["^"], | ||
["^\\."] | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import Board from "./Board"; | ||
|
||
export { Board } | ||
export { Board }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import { render } from "@lefun/dev-server"; | ||
|
||
import { Board, game } from "roll-game"; | ||
import { game } from "roll-game"; | ||
|
||
// @ts-expect-error abc | ||
import { messages as en } from "./locales/en/messages"; | ||
// @ts-expect-error abc | ||
import { messages as fr } from "./locales/fr/messages"; | ||
|
||
render<Board>({ | ||
render({ | ||
board: async () => { | ||
const { default: Board } = await import("./Board"); | ||
// @ts-expect-error the import is there even if TS does not see it! | ||
await import("./index.css"); | ||
return <Board />; | ||
}, | ||
gameDef: game, | ||
game, | ||
messages: { en, fr }, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"version": "1.5.0", | ||
"npmClient": "pnpm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.