Skip to content

Commit bccdbe4

Browse files
committed
Pacru: Two tweaks
1 parent dc4dd78 commit bccdbe4

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/games/pacru.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,17 +531,25 @@ export class PacruGame extends GameBase {
531531
// select a destination
532532
else if (move.length === 2) {
533533
let operator = "-";
534+
let isOwn = false;
534535
if (this.board.has(cell)) {
535536
const contents = this.board.get(cell)!;
536537
if (contents.chevron !== undefined) {
538+
if (contents.chevron.owner === this.currplayer) {
539+
isOwn = true;
540+
}
537541
operator = "x";
538542
}
539543
}
540-
newmove = move + operator + cell;
541-
// if only a connection change, then auto-add the asterisk
542-
const sideEffects = this.getSideEffects(move, cell, operator === "x");
543-
if (sideEffects.has("connChange") && sideEffects.size === 1) {
544-
newmove += "(*)";
544+
if (isOwn) {
545+
newmove = cell;
546+
} else {
547+
newmove = move + operator + cell;
548+
// if only a connection change, then auto-add the asterisk
549+
const sideEffects = this.getSideEffects(move, cell, operator === "x");
550+
if (sideEffects.has("connChange") && sideEffects.size === 1) {
551+
newmove += "(*)";
552+
}
545553
}
546554
}
547555
// otherwise we're selecting side effected cells
@@ -570,6 +578,16 @@ export class PacruGame extends GameBase {
570578
}
571579
}
572580

581+
// auto-trigger reorientation if the selected piece has no base moves
582+
if (newmove.length === 2) {
583+
console.log(`newmove: ${newmove}`)
584+
const matches = this.baseMoves().filter(mv => mv.startsWith(newmove));
585+
if (matches.length === 0) {
586+
console.log("no matches")
587+
newmove += "*";
588+
}
589+
}
590+
573591
const result = this.validateMove(newmove) as IClickResult;
574592
if (! result.valid) {
575593
result.move = move;

0 commit comments

Comments
 (0)