webclient/js/GUI/Card/RiverCard.js

32 lines
632 B
JavaScript

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.onClick = onClick;
card.setCandidate = setCandidate;
return card;
function onClick() {
return function() {
if(candidate) {
var withCard = State.getSelected().name;
State.select(false);
State.play(
State.state.step == 'ToPlay' ?
{capture: [withCard, card.name]} : {choose: card.name}
);
}
};
}
function setCandidate(yes) {
candidate = yes;
card.dom.classList.toggle("candidate", yes);
}
}