webclient/js/GUI/Card/HandCard.js

33 lines
595 B
JavaScript
Raw Normal View History

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