Added ESC key dismissal for arbitrary card dialogs whose minimum is satisified. Fixed stacked cards never getting marked inactive.
This commit is contained in:
@@ -81,6 +81,8 @@ var GempLotrGameUI = Class.extend({
|
||||
decisionTime: 0,
|
||||
totalTime: 0,
|
||||
countdownIntervalId: 0,
|
||||
|
||||
escFunction: null,
|
||||
|
||||
init: function (url, replayMode) {
|
||||
this.replayMode = replayMode;
|
||||
@@ -121,6 +123,15 @@ var GempLotrGameUI = Class.extend({
|
||||
var cardData = $(obj).data("card");
|
||||
return (cardData != null && ($.inArray(cardData.cardId, cardIds) > -1));
|
||||
};
|
||||
|
||||
if(!this.replayMode) {
|
||||
$(document).keydown(function(e) {
|
||||
//console.log(e.keyCode);
|
||||
if(e.keyCode == 27 && that.escFunction != null) {
|
||||
that.escFunction();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.replayMode) {
|
||||
var replayDiv = $("<div class='replay' style='position:absolute'></div>");
|
||||
@@ -1915,7 +1926,7 @@ var GempLotrGameUI = Class.extend({
|
||||
this.cardActionDialog
|
||||
.html("<div id='arbitraryChoice'></div>")
|
||||
.dialog("option", "title", text);
|
||||
|
||||
|
||||
// Create the action cards and fill the dialog with them
|
||||
for (var i = 0; i < blueprintIds.length; i++) {
|
||||
var cardId = cardIds[i];
|
||||
@@ -1941,11 +1952,18 @@ var GempLotrGameUI = Class.extend({
|
||||
}
|
||||
|
||||
var finishChoice = function () {
|
||||
if (selectedCardIds.length < min)
|
||||
return;
|
||||
|
||||
that.cardActionDialog.dialog("close");
|
||||
$("#arbitraryChoice").html("");
|
||||
that.clearSelection();
|
||||
that.decisionFunction(id, "" + selectedCardIds);
|
||||
|
||||
that.escFunction = null;
|
||||
};
|
||||
|
||||
this.escFunction = finishChoice;
|
||||
|
||||
var resetChoice = function () {
|
||||
selectedCardIds = new Array();
|
||||
|
||||
@@ -14,6 +14,7 @@ import java.security.InvalidParameterException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class GameState {
|
||||
private static final Logger _log = LogManager.getLogger(GameState.class);
|
||||
@@ -831,7 +832,7 @@ public class GameState {
|
||||
}
|
||||
|
||||
public Set<PhysicalCard> getInactiveCards() {
|
||||
return _inPlay.stream()
|
||||
return Stream.concat(_inPlay.stream(), _stacked.values().stream().flatMap(Collection::stream))
|
||||
.filter(x -> !isCardInPlayActive(x))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
@@ -870,15 +871,18 @@ public class GameState {
|
||||
if (card.getBlueprint().getCardType() == CardType.THE_ONE_RING)
|
||||
return card.getOwner().equals(_currentPlayerId);
|
||||
|
||||
if (card.getAttachedTo() != null)
|
||||
return isCardInPlayActive(card.getAttachedTo());
|
||||
|
||||
if(card.getStackedOn() != null)
|
||||
return isCardInPlayActive(card.getStackedOn());
|
||||
|
||||
if (card.getOwner().equals(_currentPlayerId) && side == Side.SHADOW)
|
||||
return false;
|
||||
|
||||
if (!card.getOwner().equals(_currentPlayerId) && side == Side.FREE_PEOPLE)
|
||||
return false;
|
||||
|
||||
if (card.getAttachedTo() != null)
|
||||
return isCardInPlayActive(card.getAttachedTo());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user