webclient/js/GUI/Card/RiverCard.js

31 lines
620 B
JavaScript
Raw Permalink Normal View History

import * as Card from GUI.Card;
import * as State from GUI.Screen.Game.State;
return {
make: RiverCard
};
function RiverCard(name) {
var card = Card.make(name);
var candidate = false;
card.dom.addEventListener('click', onClick);
card.setCandidate = setCandidate;
return card;
function onClick() {
if(candidate) {
var withCard = State.getSelected().value.name;
State.select(false);
State.play(
State.globalState.step == 'ToPlay' ?
{capture: [withCard, name]} : {choose: name}
);
}
}
function setCandidate(yes) {
candidate = yes;
card.dom.classList.toggle("candidate", yes);
}
}