import * as Card from GUI.Card; import * as State from GUI.Screen.Game.State; return { make: HandCard }; function HandCard(name) { var card = Card.make(name); card.onClick = onClick; return card; function onClick() { return function() { if(State.state.playing && State.state.step == "ToPlay") { if(State.getSelected() != undefined) { State.select(false); } else { play(); } } }; } function play() { var matching = State.matchingInRiver(card.value); if(matching.length > 1) { State.select(card); } else { State.play({play: card.name}); } } }