Skip to content

Commit 4df4226

Browse files
committed
Biscuit: Add score change and end of round to lastmove
1 parent 453728c commit 4df4226

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

src/games/biscuit.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ export class BiscuitGame extends GameBase {
419419

420420
m = m.toLowerCase();
421421
m = m.replace(/\s+/g, "");
422+
// if parenthetical is present, strip it
423+
const idx = m.indexOf("(");
424+
if (idx >= 0) {
425+
m = m.substring(0, idx);
426+
}
422427

423428
if (m.length === 0) {
424429
result.valid = true;
@@ -631,6 +636,11 @@ export class BiscuitGame extends GameBase {
631636

632637
m = m.toLowerCase();
633638
m = m.replace(/\s+/g, "");
639+
// if parenthetical is present, strip it
640+
const idx = m.indexOf("(");
641+
if (idx >= 0) {
642+
m = m.substring(0, idx);
643+
}
634644
if (m !== "pass") {
635645
const [c,t] = m.split(">");
636646
m = `${c.toUpperCase()}>${t || ""}`;
@@ -760,11 +770,24 @@ export class BiscuitGame extends GameBase {
760770
// no bonus points awarded
761771
}
762772

773+
// calculate total deltaScore
774+
let scoreChange = 0;
775+
for (const {delta} of this.results.filter(r => r.type === "deltaScore")) {
776+
scoreChange += delta!;
777+
}
778+
let tag = "";
779+
if (scoreChange > 0) {
780+
tag += scoreChange.toString();
781+
}
782+
if (roundOver) {
783+
tag += "*";
784+
}
785+
763786
// update currplayer
764787
// Regardless of whether the round just ended,
765788
// play continues in sequence. Other approaches require
766789
// more complicated state manipulation.
767-
this.lastmove = lastmove;
790+
this.lastmove = lastmove + (tag === "" ? "" : `(${tag})`);
768791
let newplayer = (this.currplayer as number) + 1;
769792
if (newplayer > this.numplayers) {
770793
newplayer = 1;

0 commit comments

Comments
 (0)