- // Delete corresponding challenge:
- ArrayFun.remove(this.challenges, c => c.id == data.cid);
- // New game just started: data contain all informations
- this.newGame(data.gameInfo);
- break;
- }
-// * - receive "accept/withdraw/cancel challenge": apply action to challenges list
- // NOTE: challenge "socket" actions accept+withdraw only for live challenges
- case "acceptchallenge":
- {
- // Someone accept an open (or targeted) challenge
- const cIdx = this.challenges.findIndex(c => c.id == data.cid);
- let c = this.challenges[cIdx];
- if (!c.seats)
- c.seats = [...Array(c.to.length)];
- const pIdx = this.players.findIndex(p => p.sid == data.from);
- // Put this player in the first empty seat we find:
- let sIdx = 0;
- for (; sIdx<c.seats.length; sIdx++)