@dumpster-fire/game
Advanced tools
Comparing version 1.8.0 to 1.9.0
{ | ||
"name": "@dumpster-fire/game", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"main": "src/index", | ||
"dependencies": { | ||
"@dumpster-fire/boardgame.io": "^0.32.1", | ||
"@dumpster-fire/cards": "^1.8.0", | ||
"@dumpster-fire/constants": "^1.4.0", | ||
"@dumpster-fire/cards": "^1.9.0", | ||
"@dumpster-fire/constants": "^1.9.0", | ||
"uuid": "^3.3.2" | ||
@@ -24,3 +24,3 @@ }, | ||
}, | ||
"gitHead": "a76c10bc7715c28488ddc259cf6f97155c7e3afa" | ||
"gitHead": "0d8dff877b3815df1984e58305e4815b15cf5f16" | ||
} |
@@ -210,13 +210,23 @@ import { Game, PlayerView, TurnOrder } from "@dumpster-fire/boardgame.io/core"; | ||
[CardType.BLAME]: (G, ctx, target) => { | ||
if (!G.incidents.hasOwnProperty(target)) { | ||
throw new Error("Invalid player to blame"); | ||
} | ||
try { | ||
if (!G.incidents.hasOwnProperty(target)) { | ||
throw new Error("Invalid player to blame"); | ||
} | ||
if (G.incidents[target].length > 1) { | ||
throw new Error("You cannot blame a player with more than 1 incident."); | ||
if (G.incidents[target].length > 1) { | ||
throw new Error( | ||
"You cannot blame a player with more than 1 incident." | ||
); | ||
} | ||
if (target === ctx.currentPlayer) { | ||
throw new Error("You cannot blame yourself"); | ||
} | ||
const incident = G.incidents[ctx.currentPlayer].shift(); | ||
G.incidents[target].push(incident); | ||
ctx.events.endPhase(); | ||
} catch (err) { | ||
setError(G, ctx, err.message); | ||
} | ||
const incident = G.incidents[ctx.currentPlayer].shift(); | ||
G.incidents[target].push(incident); | ||
ctx.events.endPhase(); | ||
}, | ||
@@ -290,4 +300,2 @@ | ||
try { | ||
checkPlayerHasCard(G, ctx, card); | ||
// Card gets added to `phaseState.played` at the end of the function | ||
@@ -492,11 +500,3 @@ // so check here if card has been played this turn already | ||
next: "play", | ||
turnOrder: TurnOrder.ANY_ONCE, | ||
onPhaseBegin: (G, ctx) => { | ||
// go to next phase if everyone is ready | ||
console.log("phase begin", G.gameStarted); | ||
if (G.gameStarted) { | ||
ctx.events.endPhase(); | ||
} | ||
}, | ||
turnOrder: TurnOrder.ANY, | ||
}, | ||
@@ -507,2 +507,3 @@ | ||
next: "draw", | ||
turnOrder: TurnOrder.DEFAULT, | ||
onPhaseBegin: (G, ctx) => { | ||
@@ -509,0 +510,0 @@ // Check for winner |
@@ -0,1 +1,3 @@ | ||
import { CardType } from "@dumpster-fire/cards"; | ||
import createPublicCard from "./createPublicCard"; | ||
@@ -6,3 +8,7 @@ | ||
G.players[player].hand.push(card); | ||
G.publicHands[player].push(createPublicCard(card)); | ||
// Incidents do not belong in publicHands | ||
if (card.type !== CardType.INCIDENT) { | ||
G.publicHands[player].push(createPublicCard(card)); | ||
} | ||
} |
59751
664