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,19 +7,17 @@ return {
|
||||||
|
|
||||||
function HandCard(name) {
|
function HandCard(name) {
|
||||||
var card = Card.make(name);
|
var card = Card.make(name);
|
||||||
card.onClick = onClick;
|
card.dom.addEventListener('click', onClick);
|
||||||
return card;
|
return card;
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
return function() {
|
if(State.state.playing && State.state.step == "ToPlay") {
|
||||||
if(State.state.playing && State.state.step == "ToPlay") {
|
if(State.getSelected() != undefined) {
|
||||||
if(State.getSelected() != undefined) {
|
State.select(false);
|
||||||
State.select(false);
|
} else {
|
||||||
} else {
|
play();
|
||||||
play();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function play() {
|
function play() {
|
||||||
|
|
|
@ -8,21 +8,19 @@ return {
|
||||||
function RiverCard(name) {
|
function RiverCard(name) {
|
||||||
var card = Card.make(name);
|
var card = Card.make(name);
|
||||||
var candidate = false;
|
var candidate = false;
|
||||||
card.onClick = onClick;
|
card.dom.addEventListener('click', onClick);
|
||||||
card.setCandidate = setCandidate;
|
card.setCandidate = setCandidate;
|
||||||
return card;
|
return card;
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
return function() {
|
if(candidate) {
|
||||||
if(candidate) {
|
var withCard = State.getSelected().value.name;
|
||||||
var withCard = State.getSelected().name;
|
State.select(false);
|
||||||
State.select(false);
|
State.play(
|
||||||
State.play(
|
State.state.step == 'ToPlay' ?
|
||||||
State.state.step == 'ToPlay' ?
|
{capture: [withCard, name]} : {choose: name}
|
||||||
{capture: [withCard, card.name]} : {choose: card.name}
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCandidate(yes) {
|
function setCandidate(yes) {
|
||||||
|
|
Loading…
Reference in a new issue