Skip to content

Commit

Permalink
fix chaos draft (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
HerveH44 authored and ZeldaZach committed Nov 29, 2019
1 parent b19d8e7 commit 09bb535
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
35 changes: 16 additions & 19 deletions src/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,33 @@ let games = {};
module.exports = class Game extends Room {
constructor({ hostId, title, seats, type, sets, cube, isPrivate, modernOnly, totalChaos, chaosPacksNumber }) {
super({ isPrivate });
this.modernOnly = modernOnly;
this.totalChaos = totalChaos;
this.cube = cube;
this.bots = 0;
this.sets = sets || [];
this.chaosPacksNumber = chaosPacksNumber;
const gameID = _.id();
Object.assign(this, {
title, seats, type, isPrivate, modernOnly, totalChaos, cube, chaosPacksNumber,
delta: -1,
hostID: hostId,
id: gameID,
players: [],
round: 0,
bots: 0,
sets: sets || [],
secret: uuid.v4()
});

// Handle packsInfos to show various informations about the game
switch(type) {
case "draft":
case "sealed":
this.packsInfo = this.sets.join(" / ");
this.rounds = this.sets.length;
break;
case "cube draft":
this.packsInfo = `${cube.packs} packs with ${cube.cards} cards from a pool of ${cube.list.length} cards`;
this.rounds = this.cube.packs;
break;
case "cube sealed":
this.packsInfo = `${cube.cubePoolSize} cards per player from a pool of ${cube.list.length} cards`;
this.rounds = this.cube.packs;
break;
case "chaos draft":
case "chaos sealed": {
Expand All @@ -65,25 +74,13 @@ module.exports = class Game extends Room {
chaosOptions.push(modernOnly ? "Modern sets only" : "Not modern sets only");
chaosOptions.push(totalChaos ? "Total Chaos" : "Not Total Chaos");
this.packsInfo = `${chaosOptions.join(", ")}`;
this.rounds = this.chaosPacksNumber;
break;
}
default:
this.packsInfo = "";
}

var gameID = _.id();
const secret = uuid.v4();
Object.assign(this, {
title, seats, type, isPrivate,
delta: -1,
hostID: hostId,
id: gameID,
players: [],
round: 0,
rounds: cube ? cube.packs : this.sets.length,
secret
});

if (cube) {
Object.assign(this, {
cubePoolSize: cube.cubePoolSize,
Expand Down
4 changes: 2 additions & 2 deletions test/pool.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ describe("Acceptance tests for Pool class", () => {

it("should return a draft chaos pool with length equal to player length per playersPack", () => {
const playersLength = 8;
const got = Pool.SealedChaos({ modernOnly: true, totalChaos: true, playersLength });
assert.equal(playersLength, got.length);
const got = Pool.DraftChaos({ modernOnly: true, totalChaos: true, playersLength });
assert.equal(playersLength * 3, got.length);
});
});

Expand Down

0 comments on commit 09bb535

Please sign in to comment.