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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
cache: 'pnpm'
- run: make install
- run: make build
- run: make check-format
- run: make check
- run: make test
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ build:
test:
pnpm run -r test

.PHONY: format
format:
.PHONY: fix
fix:
pnpm prettier ui game --write
cd game && pnpm eslint . --fix
cd ui && pnpm eslint . --fix

.PHONY: check-format
check-format:
.PHONY: check
check:
pnpm prettier ui game --check
cd game && pnpm eslint . --quiet
cd ui && pnpm eslint . --quiet
cd game && pnpm eslint . --quiet && pnpm tsc --noEmit --skipLibCheck
cd ui && pnpm eslint . --quiet && pnpm tsc --noEmit --skipLibCheck

.PHONY: watch
watch:
Expand All @@ -29,3 +29,6 @@ watch:
.PHONY: dev
dev:
cd ui && pnpm run dev

.PHONY: all
all: fix check test
8 changes: 4 additions & 4 deletions game/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"lodash-es": "^4.17.21"
},
"devDependencies": {
"@lefun/core": "2.5.1",
"@lefun/game": "2.5.1",
"@lefun/core": "3.0.0-alpha.3",
"@lefun/game": "3.0.0-alpha.3",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-node-resolve": "^13.0.6",
"@typescript-eslint/eslint-plugin": "^7.11.0",
Expand All @@ -37,7 +37,7 @@
"vitest": "^2.0.5"
},
"peerDependencies": {
"@lefun/core": ">=2.5.0",
"@lefun/game": ">=2.5.0"
"@lefun/core": ">=3.0.0",
"@lefun/game": ">=3.0.0"
}
}
5 changes: 2 additions & 3 deletions game/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,8 @@ test("its your turn", () => {
}

match.meta.players.allIds.forEach((userId) => {
expect(match.meta.players.byId[userId].itsYourTurn).toBe(
(userIds as UserId[]).includes(userId),
);
const shouldHaveTurn = userIds.includes(userId);
expect(match.hasTurn(userId)).toBe(shouldHaveTurn);
});
};

Expand Down
10 changes: 5 additions & 5 deletions game/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const bet: PlayerMove<DudoGameState, BetPayload> = {
incrementCurrentPlayer(board);
},
execute({ turns, board }) {
turns.end("all");
turns.endAll();
turns.begin(board.playerOrder[board.currentPlayerIndex]);
},
};
Expand Down Expand Up @@ -281,7 +281,7 @@ const call: PlayerMove<DudoGameState, null> = {
});

// The turn is over, all the people alive must roll.
turns.end("all");
turns.endAll();
turns.begin(alivePlayers.map((p) => p.userId));

if (winner != null) {
Expand Down Expand Up @@ -312,7 +312,7 @@ const roll: PlayerMove<DudoGameState, null> = {
const { numDice } = playerboards[userId];

// Roll the dice for the player that is ready.
const diceValues = random.d6(numDice);
const diceValues = random.d6({ size: numDice });
playerboards[userId].diceValues = diceValues;
playerboards[userId].isRolling = false;

Expand Down Expand Up @@ -359,7 +359,7 @@ const roll: PlayerMove<DudoGameState, null> = {
board.bet = undefined;

// `everyoneHasRolled` has changed the current player
turns.end("all");
turns.endAll();
turns.begin(board.playerOrder[board.currentPlayerIndex]);
} else {
turns.end(userId);
Expand Down Expand Up @@ -413,7 +413,7 @@ export const game = {

playerboards[userId] = {
numDice: startNumDice,
diceValues: random.d6(startNumDice),
diceValues: random.d6({ size: startNumDice }),
isRolling: false,
};
});
Expand Down
Loading
Loading