webclient/js/GUI/Card/HandCard.js

33 lines
583 B
JavaScript
Raw Permalink 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.state.playing && State.state.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});
}
}
}