From 2ba07048ab9c70c48685b1b7b05c262d8730c3c4 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Tue, 11 Oct 2011 13:20:48 +0000 Subject: [PATCH] "Arrow From the South" --- .../lotro/cards/set1/site/Card1_362.java | 30 ++----- .../lotro/cards/set2/dwarven/Card2_014.java | 10 ++- .../lotro/cards/set2/site/Card2_120.java | 10 ++- .../lotro/cards/set4/dunland/Card4_027.java | 8 +- .../java/com/gempukku/lotro/common/Zone.java | 16 ++-- .../lotro/logic/timing/TurnProcedure.java | 35 +++++--- .../src/main/webapp/js/gameUi.js | 90 +++++++++---------- 7 files changed, 107 insertions(+), 92 deletions(-) diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/site/Card1_362.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/site/Card1_362.java index 06627a8a4..2855efa3b 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/site/Card1_362.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/site/Card1_362.java @@ -4,14 +4,11 @@ import com.gempukku.lotro.cards.AbstractSite; import com.gempukku.lotro.common.Block; import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; -import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.actions.OptionalTriggerAction; -import com.gempukku.lotro.logic.decisions.MultipleChoiceAwaitingDecision; import com.gempukku.lotro.logic.effects.DrawCardEffect; -import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect; import com.gempukku.lotro.logic.timing.EffectResult; -import java.util.LinkedList; +import java.util.Collections; import java.util.List; /** @@ -30,29 +27,12 @@ public class Card1_362 extends AbstractSite { public List getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) { if (effectResult.getType() == EffectResult.Type.WHEN_MOVE_TO && game.getGameState().getCurrentSite() == self) { - List actions = new LinkedList(); - - String fpPlayerId = game.getGameState().getCurrentPlayerId(); - final int burdens = game.getGameState().getBurdens(); - - String[] opponents = GameUtils.getOpponents(game, fpPlayerId); - for (String opponent : opponents) { - final String opp = opponent; - final OptionalTriggerAction action = new OptionalTriggerAction(self); + if (!playerId.equals(game.getGameState().getCurrentPlayerId())) { + OptionalTriggerAction action = new OptionalTriggerAction(self); action.appendEffect( - new PlayoutDecisionEffect(game.getUserFeedback(), opponent, - new MultipleChoiceAwaitingDecision(1, "Do you want to draw a card for each burder?", new String[]{"Yes", "No"}) { - @Override - protected void validDecisionMade(int index, String result) { - if (result.equals("Yes")) { - action.appendEffect(new DrawCardEffect(opp, burdens)); - } - } - })); - actions.add(action); + new DrawCardEffect(playerId, game.getGameState().getBurdens())); + return Collections.singletonList(action); } - - return actions; } return null; } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/dwarven/Card2_014.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/dwarven/Card2_014.java index 5470dd20b..64ec4579b 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/dwarven/Card2_014.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/dwarven/Card2_014.java @@ -5,6 +5,7 @@ import com.gempukku.lotro.common.*; import com.gempukku.lotro.filters.Filters; import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.actions.OptionalTriggerAction; import com.gempukku.lotro.logic.effects.HealCharactersEffect; import com.gempukku.lotro.logic.timing.EffectResult; @@ -34,8 +35,13 @@ public class Card2_014 extends AbstractPermanent { && game.getModifiersQuerying().hasKeyword(game.getGameState(), game.getGameState().getCurrentSite(), Keyword.UNDERGROUND)) { Collection dwarfCompanions = Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.DWARF), Filters.type(CardType.COMPANION)); List actions = new LinkedList(); - for (PhysicalCard dwarfCompanion : dwarfCompanions) { - OptionalTriggerAction action = new OptionalTriggerAction(self); + for (final PhysicalCard dwarfCompanion : dwarfCompanions) { + OptionalTriggerAction action = new OptionalTriggerAction(self) { + @Override + public String getText(LotroGame game) { + return "Heal " + GameUtils.getCardLink(dwarfCompanion); + } + }; action.appendEffect( new HealCharactersEffect(playerId, dwarfCompanion)); actions.add(action); diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/site/Card2_120.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/site/Card2_120.java index 6dc2ff7ab..d06949808 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/site/Card2_120.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/site/Card2_120.java @@ -8,6 +8,7 @@ import com.gempukku.lotro.common.Race; import com.gempukku.lotro.filters.Filters; import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.actions.OptionalTriggerAction; import com.gempukku.lotro.logic.effects.HealCharactersEffect; import com.gempukku.lotro.logic.timing.EffectResult; @@ -37,8 +38,13 @@ public class Card2_120 extends AbstractSite { List actions = new LinkedList(); Collection hobbitCompanions = Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.HOBBIT), Filters.type(CardType.COMPANION)); - for (PhysicalCard hobbitCompanion : hobbitCompanions) { - OptionalTriggerAction action = new OptionalTriggerAction(self); + for (final PhysicalCard hobbitCompanion : hobbitCompanions) { + OptionalTriggerAction action = new OptionalTriggerAction(self) { + @Override + public String getText(LotroGame game) { + return "Heal " + GameUtils.getCardLink(hobbitCompanion); + } + }; action.appendEffect( new HealCharactersEffect(playerId, hobbitCompanion)); actions.add(action); diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/dunland/Card4_027.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/dunland/Card4_027.java index 97c9b45bb..092bd8443 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/dunland/Card4_027.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set4/dunland/Card4_027.java @@ -8,6 +8,7 @@ import com.gempukku.lotro.common.*; import com.gempukku.lotro.filters.Filters; import com.gempukku.lotro.game.PhysicalCard; import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.GameUtils; import com.gempukku.lotro.logic.actions.OptionalTriggerAction; import com.gempukku.lotro.logic.modifiers.KeywordModifier; import com.gempukku.lotro.logic.timing.EffectResult; @@ -42,7 +43,12 @@ public class Card4_027 extends AbstractPermanent { List actions = new LinkedList(); for (final PhysicalCard physicalCard : winningDunlandMan) { - OptionalTriggerAction action = new OptionalTriggerAction(physicalCard); + OptionalTriggerAction action = new OptionalTriggerAction(self) { + @Override + public String getText(LotroGame game) { + return "Make " + GameUtils.getCardLink(physicalCard) + " strength +2 and Fierce"; + } + }; action.appendEffect( new AddUntilStartOfPhaseModifierEffect( new StrengthModifier(self, Filters.sameCard(physicalCard), 2), Phase.REGROUP)); diff --git a/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/Zone.java b/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/Zone.java index b0560f512..19d5f4cfd 100644 --- a/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/Zone.java +++ b/gemp-lotr/gemp-lotr-common/src/main/java/com/gempukku/lotro/common/Zone.java @@ -1,18 +1,24 @@ package com.gempukku.lotro.common; public enum Zone { - FREE_CHARACTERS("play"), SUPPORT("play"), SHADOW_CHARACTERS("play"), - ADVENTURE_PATH("play"), - HAND("hand"), DECK("deck"), ATTACHED("play"), STACKED("stacked"), - DISCARD("discard"), DEAD("dead pile"); + FREE_CHARACTERS("play", true), SUPPORT("play", true), SHADOW_CHARACTERS("play", true), + ADVENTURE_PATH("play", true), + HAND("hand", false), DECK("deck", false), ATTACHED("play", true), STACKED("stacked", false), + DISCARD("discard", false), DEAD("dead pile", false); private String _humanReadable; + private boolean _inPlay; - private Zone(String humanReadable) { + private Zone(String humanReadable, boolean inPlay) { _humanReadable = humanReadable; + _inPlay = inPlay; } public String getHumanReadable() { return _humanReadable; } + + public boolean isInPlay() { + return _inPlay; + } } diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/TurnProcedure.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/TurnProcedure.java index 03c4500d3..d8e21c84f 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/TurnProcedure.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/timing/TurnProcedure.java @@ -108,8 +108,16 @@ public class TurnProcedure { if (!_checkedOptionalWhenResponses) { _checkedOptionalWhenResponses = true; ActivateCardAction action = new ActivateCardAction(null, null); + + Map> optionalAfterTriggers = new HashMap>(); + for (String playerId : _game.getGameState().getPlayerOrder().getAllPlayers()) { + List actions = new LinkedList(); + actions.addAll(_game.getActionsEnvironment().getOptionalAfterTriggers(playerId, _effectResults)); + optionalAfterTriggers.put(playerId, actions); + } + action.appendEffect( - new PlayoutOptionalAfterResponsesEffect(action, new HashSet(), _game.getGameState().getPlayerOrder().getCounterClockwisePlayOrder(_game.getGameState().getCurrentPlayerId(), true), 0, _effect, _effectResults)); + new PlayoutOptionalAfterResponsesEffect(action, optionalAfterTriggers, _game.getGameState().getPlayerOrder().getCounterClockwisePlayOrder(_game.getGameState().getCurrentPlayerId(), true), 0, _effect, _effectResults)); return new StackActionEffect(action); } } @@ -177,15 +185,15 @@ public class TurnProcedure { private class PlayoutOptionalAfterResponsesEffect extends UnrespondableEffect { private ActivateCardAction _action; - private Set _cardTriggersUsed; + private Map> _unplayedAfterTriggers; private PlayOrder _playOrder; private int _passCount; private Effect _effect; private EffectResult[] _effectResults; - private PlayoutOptionalAfterResponsesEffect(ActivateCardAction action, Set cardTriggersUsed, PlayOrder playOrder, int passCount, Effect effect, EffectResult[] effectResults) { + private PlayoutOptionalAfterResponsesEffect(ActivateCardAction action, Map> unplayedAfterTriggers, PlayOrder playOrder, int passCount, Effect effect, EffectResult[] effectResults) { _action = action; - _cardTriggersUsed = cardTriggersUsed; + _unplayedAfterTriggers = unplayedAfterTriggers; _playOrder = playOrder; _passCount = passCount; _effect = effect; @@ -196,12 +204,15 @@ public class TurnProcedure { public void doPlayEffect(LotroGame game) { final String activePlayer = _playOrder.getNextPlayer(); - final List optionalAfterTriggers = game.getActionsEnvironment().getOptionalAfterTriggers(activePlayer, _effectResults); - // Remove triggers already resolved + final List optionalAfterTriggers = _unplayedAfterTriggers.get(activePlayer); + + // Remove triggers for cards no longer in play final Iterator triggersIterator = optionalAfterTriggers.iterator(); - while (triggersIterator.hasNext()) - if (_cardTriggersUsed.contains(triggersIterator.next().getActionSource())) + while (triggersIterator.hasNext()) { + final PhysicalCard actionSource = triggersIterator.next().getActionSource(); + if (!actionSource.getZone().isInPlay()) triggersIterator.remove(); + } final List optionalAfterActions = _game.getActionsEnvironment().getOptionalAfterActions(activePlayer, _effectResults); @@ -217,18 +228,18 @@ public class TurnProcedure { if (action != null) { _game.getActionsEnvironment().addActionToStack(action); if (optionalAfterTriggers.contains(action)) - _cardTriggersUsed.add(action.getActionSource()); - _action.appendEffect(new PlayoutOptionalAfterResponsesEffect(_action, _cardTriggersUsed, _playOrder, 0, _effect, _effectResults)); + optionalAfterActions.remove(action); + _action.appendEffect(new PlayoutOptionalAfterResponsesEffect(_action, _unplayedAfterTriggers, _playOrder, 0, _effect, _effectResults)); } else { if ((_passCount + 1) < _playOrder.getPlayerCount()) { - _action.appendEffect(new PlayoutOptionalAfterResponsesEffect(_action, _cardTriggersUsed, _playOrder, _passCount + 1, _effect, _effectResults)); + _action.appendEffect(new PlayoutOptionalAfterResponsesEffect(_action, _unplayedAfterTriggers, _playOrder, _passCount + 1, _effect, _effectResults)); } } } }); } else { if ((_passCount + 1) < _playOrder.getPlayerCount()) { - _action.appendEffect(new PlayoutOptionalAfterResponsesEffect(_action, _cardTriggersUsed, _playOrder, _passCount + 1, _effect, _effectResults)); + _action.appendEffect(new PlayoutOptionalAfterResponsesEffect(_action, _unplayedAfterTriggers, _playOrder, _passCount + 1, _effect, _effectResults)); } } } diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js index 57ee79c2d..a50b532fc 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js @@ -273,21 +273,21 @@ var GempLotrGameUI = Class.extend({ initializeDialogs: function() { this.smallDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: false, - resizable: false, - width: 400, - height: 200 - }); + autoOpen: false, + closeOnEscape: false, + resizable: false, + width: 400, + height: 200 + }); this.cardActionDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: false, - resizable: true, - width: 600, - height: 300 - }); + autoOpen: false, + closeOnEscape: false, + resizable: true, + width: 600, + height: 300 + }); var that = this; @@ -302,15 +302,15 @@ var GempLotrGameUI = Class.extend({ this.infoDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: true, - resizable: true, - title: "Card information", - minHeight: 80, - minWidth: 200, - width: Math.max(600, width * 0.75), - height: Math.max(300, height * 0.75) - }); + autoOpen: false, + closeOnEscape: true, + resizable: true, + title: "Card information", + minHeight: 80, + minWidth: 200, + width: Math.max(600, width * 0.75), + height: Math.max(300, height * 0.75) + }); var swipeOptions = { threshold: 20, @@ -603,9 +603,9 @@ var GempLotrGameUI = Class.extend({ else if (zone == "DISCARD") $("#discard" + this.getPlayerIndex(playerId)).text("Discard: " + count); else if (zone == "DEAD") - $("#deadPile" + this.getPlayerIndex(playerId)).text("Dead pile: " + count); - else if (zone == "DECK") - $("#deck" + this.getPlayerIndex(playerId)).text("Deck: " + count); + $("#deadPile" + this.getPlayerIndex(playerId)).text("Dead pile: " + count); + else if (zone == "DECK") + $("#deck" + this.getPlayerIndex(playerId)).text("Deck: " + count); }, playerPosition: function(element) { @@ -773,7 +773,7 @@ var GempLotrGameUI = Class.extend({ if (index != -1) cardData.attachedCards.splice(index, 1); } - ); + ); var card = $(".card:cardId(" + cardId + ")"); var cardData = card.data("card"); @@ -895,7 +895,7 @@ var GempLotrGameUI = Class.extend({ if (index != -1) cardData.attachedCards.splice(index, 1); } - ); + ); } card.remove(); @@ -967,13 +967,13 @@ var GempLotrGameUI = Class.extend({ this.smallDialog .html(text + "
") .dialog("option", "buttons", - { - "OK": function() { - $(this).dialog("close"); - that.decisionFunction(id, $("#integerDecision").val()); - } - } - ); + { + "OK": function() { + $(this).dialog("close"); + that.decisionFunction(id, $("#integerDecision").val()); + } + } + ); $("#integerDecision").SpinnerControl({ type: 'range', typedata: { @@ -1005,13 +1005,13 @@ var GempLotrGameUI = Class.extend({ this.smallDialog .html(html) .dialog("option", "buttons", - { - "OK": function() { - $(this).dialog("close"); - that.decisionFunction(id, $("#multipleChoiceDecision").val()); - } - } - ); + { + "OK": function() { + $(this).dialog("close"); + that.decisionFunction(id, $("#multipleChoiceDecision").val()); + } + } + ); this.smallDialog.dialog("open"); }, @@ -1156,7 +1156,7 @@ var GempLotrGameUI = Class.extend({ var selectedCardIds = new Array(); - this.alertText.text(text); + this.alertText.html(text); var processButtons = function() { that.alertButtons.html(""); @@ -1260,8 +1260,8 @@ var GempLotrGameUI = Class.extend({ $(div).find('LI.hover').removeClass('hover'); $(this).parent().addClass('hover'); }).mouseout(function() { - $(div).find('LI.hover').removeClass('hover'); - }); + $(div).find('LI.hover').removeClass('hover'); + }); var getRidOfContextMenu = function() { $(div).remove(); @@ -1380,7 +1380,7 @@ var GempLotrGameUI = Class.extend({ var that = this; - this.alertText.text(text); + this.alertText.html(text); var selectedCardIds = new Array(); @@ -1448,7 +1448,7 @@ var GempLotrGameUI = Class.extend({ var that = this; - this.alertText.text(text); + this.alertText.html(text); this.alertButtons.html(""); $("#Done").button().click(function() { that.alertText.html("");