Fix onClick event issues with River- and HandCards
This commit is contained in:
parent
3bb2c5c246
commit
8bb722863a
2 changed files with 16 additions and 20 deletions
|
@ -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() {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue