32 lines
583 B
JavaScript
32 lines
583 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.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});
|
|
}
|
|
}
|
|
}
|
|
|