Added init discard pile

This commit is contained in:
Eunchong Kim 2021-07-25 18:32:48 +09:00
parent 3466f4e4e7
commit 375a33c33b
2 changed files with 15 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@ -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));