Skip to content

Commit d3366e9

Browse files
authored
Merge pull request #269 from mcdemarco/develop
Fix multiplayer issue in Stawvs
2 parents 8ba41d0 + 7b79c25 commit d3366e9

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/games/stawvs.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interface IMoveState extends IIndividualState {
4242
currplayer: playerid;
4343
mode: Mode;
4444
board: Map<string, CellContents>;
45-
captured: [Pyramid[], Pyramid[]];
45+
captured: Pyramid[][];
4646
lastmove?: string;
4747
eliminated: playerid[];
4848
}
@@ -58,7 +58,7 @@ export class StawvsGame extends GameBase {
5858
uid: "stawvs",
5959
playercounts: [2,3,4],
6060
version: "20251113",
61-
dateAdded: "2025-11-13",
61+
dateAdded: "2025-11-16",
6262
// i18next.t("apgames:descriptions.stawvs")
6363
description: "apgames:descriptions.stawvs",
6464
urls: [
@@ -104,7 +104,7 @@ export class StawvsGame extends GameBase {
104104
public gameover = false;
105105
public winner: playerid[] = [];
106106
public variants: string[] = [];
107-
public captured: [Pyramid[], Pyramid[]] = [[], []];
107+
public captured: Pyramid[][] = [];
108108
public eliminated: playerid[] = [];
109109
public stack!: Array<IMoveState>;
110110
public results: Array<APMoveResult> = []
@@ -145,6 +145,8 @@ export class StawvsGame extends GameBase {
145145
}
146146
}
147147
}
148+
149+
const captured = Array(this.numplayers).fill([]);
148150

149151
const fresh: IMoveState = {
150152
_version: StawvsGame.gameinfo.version,
@@ -153,7 +155,7 @@ export class StawvsGame extends GameBase {
153155
currplayer: 1,
154156
mode: "place",
155157
board: board,
156-
captured: [[], []],
158+
captured: captured,
157159
eliminated: [],
158160
};
159161
this.stack = [fresh];
@@ -188,7 +190,7 @@ export class StawvsGame extends GameBase {
188190
this.mode = state.mode;
189191
this.board = new Map(state.board);
190192
this.lastmove = state.lastmove;
191-
this.captured = clone(state.captured) as [Pyramid[], Pyramid[]];
193+
this.captured = clone(state.captured) as Pyramid[][];
192194
this.eliminated = [...state.eliminated];
193195

194196
return this;
@@ -853,7 +855,7 @@ export class StawvsGame extends GameBase {
853855
lastmove: this.lastmove,
854856
eliminated: [...this.eliminated],
855857
board: new Map(this.board),
856-
captured: clone(this.captured) as [Pyramid[], Pyramid[]]
858+
captured: clone(this.captured) as Pyramid[][],
857859
};
858860
}
859861

@@ -894,7 +896,7 @@ export class StawvsGame extends GameBase {
894896
// Use lighter colors from the end of the palette.
895897
const color = c + 8;
896898
//The board pyramids.
897-
myLegend[allColours[c] as string + "1"] = {
899+
myLegend[allColours[c].toString() + "1"] = {
898900
name: "pyramid-up-small-upscaled",
899901
colour: color
900902
};
@@ -907,7 +909,7 @@ export class StawvsGame extends GameBase {
907909
colour: color
908910
};
909911
//The stash area pyramids.
910-
myLegend[allColours[c] as string + "1c"] = {
912+
myLegend[allColours[c].toString() + "1c"] = {
911913
name: "pyramid-flattened-small",
912914
colour: color
913915
};
@@ -922,27 +924,26 @@ export class StawvsGame extends GameBase {
922924
}
923925

924926
//An extra set of "ghost" board pyramids for the end state
925-
const color = "#aaa";
926927
myLegend["GH1"] = {
927928
name: "pyramid-up-small-upscaled",
928-
colour: color,
929+
colour: "#aaa",
929930
opacity: 0.25
930931
};
931932
myLegend["GH2"] = {
932933
name: "pyramid-up-medium-upscaled",
933-
colour: color,
934+
colour: "#aaa",
934935
opacity: 0.25
935936
};
936937
myLegend["GH3"] = {
937938
name: "pyramid-up-large-upscaled",
938-
colour: color,
939+
colour: "#aaa",
939940
opacity: 0.25
940941
};
941942

942943
//Player pieces.
943944
for (let p = 0; p < this.numplayers; p++) {
944945
const color = p + 1;
945-
myLegend["P" + color] = {
946+
myLegend["P" + color.toString()] = {
946947
name: "piece",
947948
scale: 0.3,
948949
colour: color,

0 commit comments

Comments
 (0)