Fix onClick event issues with River- and HandCards

This commit is contained in:
Tissevert 2020-01-16 16:44:19 +01:00
parent 3bb2c5c246
commit 8bb722863a
2 changed files with 16 additions and 20 deletions

View file

@ -7,11 +7,10 @@ return {
function HandCard(name) {
var card = Card.make(name);
card.onClick = onClick;
card.dom.addEventListener('click', onClick);
return card;
function onClick() {
return function() {
if(State.state.playing && State.state.step == "ToPlay") {
if(State.getSelected() != undefined) {
State.select(false);
@ -19,7 +18,6 @@ function HandCard(name) {
play();
}
}
};
}
function play() {

View file

@ -8,21 +8,19 @@ return {
function RiverCard(name) {
var card = Card.make(name);
var candidate = false;
card.onClick = onClick;
card.dom.addEventListener('click', onClick);
card.setCandidate = setCandidate;
return card;
function onClick() {
return function() {
if(candidate) {
var withCard = State.getSelected().name;
var withCard = State.getSelected().value.name;
State.select(false);
State.play(
State.state.step == 'ToPlay' ?
{capture: [withCard, card.name]} : {choose: card.name}
{capture: [withCard, name]} : {choose: name}
);
}
};
}
function setCandidate(yes) {