Skip to content

Commit 40469ec

Browse files
authored
Merge pull request #15 from jwyce/fix-marshal-stacking-game-modes
fix: marshal stacking allowed for diff game modes
2 parents 46434d2 + 4c8fe60 commit 40469ec

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.changeset/olive-comics-build.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'gungi.js': patch
3+
---
4+
5+
Marshals should not be able to stack in intro and beginner game modes

src/gungi/move_gen.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,16 @@ export function generateMovesForSquare(square: string, fen: string) {
129129
const t = get(s, board);
130130

131131
const maxTier = mode === 'advanced' ? 3 : 2;
132+
const marshalCanStack = ['advanced', 'intermediate'].includes(mode);
132133

133134
if (!p || !t) {
134135
acc.push(createMove(piece, `${s}-1`, fen, 'route'));
135136
} else {
136137
// tsuke
137138
if (p.tier < maxTier && p.type !== pieceType.marshal) {
138-
acc.push(createMove(piece, `${s}-${p.tier + 1}`, fen, 'tsuke'));
139+
if (piece.type !== pieceType.marshal || marshalCanStack) {
140+
acc.push(createMove(piece, `${s}-${p.tier + 1}`, fen, 'tsuke'));
141+
}
139142

140143
// betrayal
141144
if (piece.type === pieceType.tactician && p.color !== piece.color) {

0 commit comments

Comments
 (0)