uno-game-js/src/js/bot.js
2021-07-19 22:27:12 +09:00

20 lines
394 B
JavaScript

import Player from './player.js';
export default class Bot extends Player {
constructor(name, id) {
super(name+id, id);
this._type = 'bot';
}
playCard(top_card) {
for (let i=0; i<this._cards.length; i++) {
const card = this._cards[i];
if ( top_card.isMatch(card) ) {
this._cards.splice(i, 1)[0];
return card;
}
}
return null;
}
}