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
5 changes: 3 additions & 2 deletions locales/en/apresults.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"biscuit": "The following cards were in opposing hands: {{cards}}.",
"deckfish": "{{player}} was unable to move and must pass from now on.",
"quincunx": "Player {{playerNum}} had the following cards left in their hand: {{cards}}.",
"stawvs": "{{player}} was unable to move and must pass from now on."
"stawvs": "{{player}} was unable to move and must pass from now on. Their pieces remain on the following pyramids: {{pyramids}}."
},
"BEAROFF": {
"complete_one": "{{player}} bore off one piece from {{from}}.",
Expand Down Expand Up @@ -100,6 +100,7 @@
"spook_lateral_opponent_other": "{{player}} has {{count}} of their opponent's balls captured by Spooky on the same level at {{where}}.",
"spook_lateral_self_one": "{{player}} has 1 of their own ball captured by Spooky on the same level at {{where}}.",
"spook_lateral_self_other": "{{player}} has {{count}} of their own balls captured by Spooky on the same level at {{where}}.",
"stawvs": "{{player}} captured the {{what}} at {{where}}.",
"tafl": "{{player}} captured a piece at {{where}}.",
"terrace_other": "{{player}} captured a size {{what}} piece at {{where}}.",
"terrace_self": "{{player}} cannibalized their own size {{what}} piece at {{where}}.",
Expand Down Expand Up @@ -316,7 +317,7 @@
"saltire": "{{player}} swapped the pieces at {{from}} and {{to}}.",
"slyde": "{{player}} slid a piece from {{from}} to {{to}}.",
"spook": "{{player}} moved Spooky from {{from}} to {{to}}.",
"stawvs": "{{player}} moved a piece from {{from}} to {{to}} and captured the {{what}} at {{how}}.",
"stawvs": "{{player}} moved a piece from {{from}} to {{to}} and captured {{what}} at {{how}}.",
"susan": "{{player}} slid a piece from {{from}} to {{to}}.",
"tafl": "{{player}} moved a piece from {{from}} to {{to}}.",
"tafl_jump": "{{player}} jumped a piece from {{from}} to {{to}}.",
Expand Down
41 changes: 36 additions & 5 deletions src/games/stawvs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,31 @@ export class StawvsGame extends GameBase {
return mycells;
}

public getPyramidsByPlayer(player: playerid): Pyramid[] {
//Used for final collections.
const tempcaps: Pyramid[] = [];
for (let row = 0; row < boardDim; row++) {
for (let col = 0; col < boardDim; col++) {
const cell = StawvsGame.coords2algebraic(col, row);
if (this.board.has(cell)) {
const contents = this.board.get(cell);
if (contents!.length > 1) {
const cellplayer = contents![1];
if (cellplayer === player)
tempcaps.push(contents![0]);
}
}
}
}
return tempcaps;
}

public getPyramidsByName(): string[] {
//Used for final collection logging.
const mymids = this.getPyramidsByPlayer(this.currplayer);
return mymids.map(mid => this.namePyramid(mid));
}

public getOwner(cell: string): playerid | undefined {
if (! this.board.has(cell)) {
return undefined;
Expand Down Expand Up @@ -367,7 +392,7 @@ export class StawvsGame extends GameBase {
//Name the captured pyramid for the chat log.
const colors = ["pink","blue","green","orange"];
const sizes = ["small","medium","large"];
let name = "";
let name = "a ";
name += sizes[pyramid[1] as number - 1] + " ";
name += colors[allColours.indexOf(pyramid[0])] + " pyramid";
return name;
Expand Down Expand Up @@ -612,10 +637,8 @@ export class StawvsGame extends GameBase {
//passing is forevah
if (this.eliminated.indexOf(this.currplayer) < 0) {
this.eliminated.push(this.currplayer);
if (this.eliminated.length < this.numplayers)
this.results = [{type: "eliminated", who: this.currplayer.toString()}];
else
this.results = [{type: "pass"}];
const finalMids = this.getPyramidsByName();
this.results = [{type: "announce", payload: finalMids}];
} else {
this.results = [{type: "pass"}];
}
Expand Down Expand Up @@ -1067,6 +1090,10 @@ export class StawvsGame extends GameBase {
node.push(i18next.t("apresults:MOVE.stawvs", {player, what: r.what, from: r.from, to: r.to, how: r.how}));
resolved = true;
break;
case "capture":
node.push(i18next.t("apresults:CAPTURE.stawvs", {what: r.what, where: r.where}));
resolved = true;
break;
case "pass":
node.push(i18next.t("apresults:PASS.simple", {player}));
resolved = true;
Expand All @@ -1075,6 +1102,10 @@ export class StawvsGame extends GameBase {
node.push(i18next.t("apresults:ELIMINATED", {player}));
resolved = true;
break;
case "announce":
node.push(i18next.t("apresults:ANNOUNCE.stawvs", {player, pyramids: (r.payload as string[]).join(", ")}));
resolved = true;
break;
case "eog":
node.push(i18next.t("apresults:EOG.stawvs", {player}));
resolved = true;
Expand Down