Closed airtoxin closed 6 years ago
What's an example? Just want to make sure there isn't too much feature creep (I don't want to add API support for every single game type if it is possible to handle some cases in a custom way using G
).
Yavalath is good example https://boardgamegeek.com/boardgame/33767/yavalath
Players strive to make a straight line of 4 pieces of their colour, but lose if they make a line of 3 before doing so.
Sorry, I found way to define loser, returning object containing loser's id in victory function.
victory: (G, ctx) => {
if (isDefeat(G.cells)) return { loser: ctx.currentPlayer };
if (isVictory(G.cells)) return { winner: ctx.currentPlayer };
return null;
}
But victory
naming is bit bad :(
victory
is a very familiar concept for most games, and I think it's OK to overload it for cases like this too. Let me know if you need any help or run into other issues while developing Yavalath!
Some games have both of winning condition and losing condition, but boardgame.io support winning condition only.
If game have only losing condition, developer can use victory condition to define loser. Otherwise, may need implementation of new feature.