2020-01-15 18:01:07 +01:00
|
|
|
import * as Card from GUI.Card;
|
|
|
|
import * as State from GUI.Screen.Game.State;
|
2020-01-14 17:27:56 +01:00
|
|
|
|
2020-01-15 18:01:07 +01:00
|
|
|
return {
|
|
|
|
make: HandCard
|
2020-01-14 17:27:56 +01:00
|
|
|
};
|
|
|
|
|
2020-01-15 18:01:07 +01:00
|
|
|
function HandCard(name) {
|
|
|
|
var card = Card.make(name);
|
2020-01-16 16:44:19 +01:00
|
|
|
card.dom.addEventListener('click', onClick);
|
2020-01-15 18:01:07 +01:00
|
|
|
return card;
|
2020-01-14 17:27:56 +01:00
|
|
|
|
2020-01-15 18:01:07 +01:00
|
|
|
function onClick() {
|
2020-01-16 16:44:19 +01:00
|
|
|
if(State.state.playing && State.state.step == "ToPlay") {
|
|
|
|
if(State.getSelected() != undefined) {
|
|
|
|
State.select(false);
|
|
|
|
} else {
|
|
|
|
play();
|
2020-01-15 18:01:07 +01:00
|
|
|
}
|
2020-01-16 16:44:19 +01:00
|
|
|
}
|
2020-01-15 18:01:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function play() {
|
|
|
|
var matching = State.matchingInRiver(card.value);
|
|
|
|
if(matching.length > 1) {
|
|
|
|
State.select(card);
|
|
|
|
} else {
|
2020-01-16 16:45:23 +01:00
|
|
|
State.play({play: name});
|
2020-01-15 18:01:07 +01:00
|
|
|
}
|
|
|
|
}
|
2020-01-14 17:27:56 +01:00
|
|
|
}
|
2020-01-15 18:01:07 +01:00
|
|
|
|