webclient/js/GUI/Card/HandCard.js

32 lines
595 B
JavaScript

import * as Card from GUI.Card;
import * as State from GUI.Screen.Game.State;
return {
make: HandCard
};
function HandCard(name) {
var card = Card.make(name);
card.dom.addEventListener('click', onClick);
return card;
function onClick() {
if(State.globalState.playing && State.globalState.step == "ToPlay") {
if(State.getSelected() != undefined) {
State.select(false);
} else {
play();
}
}
}
function play() {
var matching = State.matchingInRiver(card.value);
if(matching.length > 1) {
State.select(card);
} else {
State.play({play: name});
}
}
}