Added init discard pile
This commit is contained in:
parent
3466f4e4e7
commit
375a33c33b
File diff suppressed because one or more lines are too long
@ -71,11 +71,24 @@ export default class Room extends BasicCanvas {
|
|||||||
this._draw4 = false;
|
this._draw4 = false;
|
||||||
this._current_player = this._players[0];
|
this._current_player = this._players[0];
|
||||||
|
|
||||||
await( this.changeTopCard( this._cards.pop() ) );
|
await( this.initDiscardPile() );
|
||||||
|
|
||||||
this.initTurn();
|
this.initTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Not allow special card to be first discard pile
|
||||||
|
initDiscardPile() {
|
||||||
|
while (true) {
|
||||||
|
const card = this._cards.pop();
|
||||||
|
if (card.num <= 9) {
|
||||||
|
this.changeTopCard( card );
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
this._cards.splice( Math.floor(Math.random()*this._cards.length), 0, card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async initTurn() {
|
async initTurn() {
|
||||||
console.log('Turn count: ' + this._turn_count + ', current player: ' + this._current_player.name);
|
console.log('Turn count: ' + this._turn_count + ', current player: ' + this._current_player.name);
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user