Skip to content

Commit 06218c0

Browse files
committed
Pigs2: Fix blocking validation issue and try to clean up render
1 parent d325315 commit 06218c0

File tree

1 file changed

+27
-29
lines changed

1 file changed

+27
-29
lines changed

src/games/pigs2.ts

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -194,35 +194,35 @@ export class Pigs2Game extends GameBaseSimultaneous {
194194
if (this.stack.length > 1) {
195195
return [
196196
{
197-
label: "Move backward",
197+
label: "pigs.back",
198198
move: "v"
199199
},
200200
{
201-
label: "Move forward",
201+
label: "pigs.forward",
202202
move: "^"
203203
},
204204
{
205-
label: "Move forward left",
205+
label: "pigs.left",
206206
move: "\\"
207207
},
208208
{
209-
label: "Move forward right",
209+
label: "pigs.right",
210210
move: "/"
211211
},
212212
{
213-
label: "Rotate clockwise",
213+
label: "pigs.cw",
214214
move: ">"
215215
},
216216
{
217-
label: "Rotate counterclockwise",
217+
label: "pigs.ccw",
218218
move: "<"
219219
},
220220
{
221-
label: "Fire laser",
221+
label: "pigs.fire",
222222
move: "f"
223223
},
224224
{
225-
label: "Swing snout",
225+
label: "pigs.hit",
226226
move: "h"
227227
},
228228
];
@@ -245,8 +245,6 @@ export class Pigs2Game extends GameBaseSimultaneous {
245245
result.message = i18next.t("apgames:validation._general.VALID_MOVE");
246246
return result;
247247
}
248-
} else if (this.isEliminated(player)) {
249-
throw new Error("Eliminated players should never have moves being validated.");
250248
}
251249

252250
if (m.length === 0) {
@@ -601,24 +599,24 @@ export class Pigs2Game extends GameBaseSimultaneous {
601599
const player2label = new Map<playerid,string>([[1,"A"],[2,"B"],[3,"C"],[4,"D"],[5, "E"],[6, "F"],[7, "G"],[8, "H"]]);
602600
const facing2rot = new Map<Facing,number>([["N", 0],["E", 90],["S", 180],["W", 270]]);
603601
const cmd2glyph = new Map<string, string>([
604-
["f", "F"],
605-
["h", "H"],
606-
["<", "CCW"],
607-
[">", "CW"],
608-
["^", "MF"],
609-
["v", "MB"],
610-
["\\", "FL"],
611-
["/", "FR"],
602+
["f", "mF"],
603+
["h", "mH"],
604+
["<", "mCCW"],
605+
[">", "mCW"],
606+
["^", "mMF"],
607+
["v", "mMB"],
608+
["\\", "mFL"],
609+
["/", "mFR"],
612610
]);
613611
const glyph2unicode = new Map<string, string>([
614-
["F", "\u26ef"],
615-
["H", "\u2927"],
616-
["CCW", "\u21b6"],
617-
["CW", "\u21b7"],
618-
["MF", "\u2191"],
619-
["MB", "\u2193"],
620-
["FL", "\u2196"],
621-
["FR", "\u2197"],
612+
["mF", "\u26ef"],
613+
["mH", "\u2927"],
614+
["mCCW", "\u21b6"],
615+
["mCW", "\u21b7"],
616+
["mMF", "\u2191"],
617+
["mMB", "\u2193"],
618+
["mFL", "\u2196"],
619+
["mFR", "\u2197"],
622620
]);
623621
// Build piece string
624622
let pstr = "";
@@ -680,11 +678,11 @@ export class Pigs2Game extends GameBaseSimultaneous {
680678
const areas: AreaPieces[] = [];
681679
for (let p = 1; p <= this.numplayers; p++) {
682680
const order = this.orders[p-1];
683-
if (order.length > 0) {
681+
if (Array.isArray(order) && order.length > 0) {
684682
areas.push({
685683
type: "pieces",
686684
pieces: order.map(c => cmd2glyph.get(c)!) as [string, ...string[]],
687-
label: i18next.t("apgames:validation.pigs2.LABEL_ORDERS", {playerNum: p}) || "local",
685+
label: i18next.t("apgames:validation.pigs2.LABEL_ORDERS", {playerNum: p}) || `Player ${p}'s orders`,
688686
});
689687
}
690688
}
@@ -698,7 +696,7 @@ export class Pigs2Game extends GameBaseSimultaneous {
698696
},
699697
legend,
700698
pieces: pstr,
701-
areas,
699+
areas: areas.length > 0 ? areas : undefined,
702700
};
703701

704702
if (this.stack[this.stack.length - 1]._results.length > 0) {

0 commit comments

Comments
 (0)