Simplify the minions code.

This commit is contained in:
marcins78@gmail.com
2011-09-02 20:48:19 +00:00
parent daf999f411
commit 60da592274
17 changed files with 70 additions and 162 deletions

View File

@@ -10,6 +10,7 @@ import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.List;
public class AbstractMinion extends AbstractLotroCardBlueprint {
@@ -30,13 +31,39 @@ public class AbstractMinion extends AbstractLotroCardBlueprint {
_site = site;
}
protected void appendPlayMinionAction(List<Action> actions, LotroGame lotroGame, PhysicalCard self) {
ModifiersQuerying modifiersQuerying = lotroGame.getModifiersQuerying();
if (PlayConditions.canPlayMinionDuringShadow(lotroGame.getGameState(), modifiersQuerying, self)) {
actions.add(new PlayPermanentAction(self, Zone.SHADOW_CHARACTERS));
private void appendPlayMinionActions(List<Action> actions, LotroGame game, PhysicalCard self) {
ModifiersQuerying modifiersQuerying = game.getModifiersQuerying();
if (PlayConditions.canPlayMinionDuringShadow(game.getGameState(), modifiersQuerying, self)) {
actions.add(getPlayMinionAction(game, self));
}
}
@Override
public final List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
if (checkPlayRequirements(playerId, game, self))
appendPlayMinionActions(actions, game, self);
List<? extends Action> extraActions = getExtraPhaseActions(playerId, game, self);
if (extraActions != null)
actions.addAll(extraActions);
return actions;
}
protected boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self) {
return true;
}
protected Action getPlayMinionAction(LotroGame game, PhysicalCard self) {
return new PlayPermanentAction(self, Zone.SHADOW_CHARACTERS);
}
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
return null;
}
@Override
public int getTwilightCost() {
return _twilightCost;

View File

@@ -13,7 +13,7 @@ import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
/**
@@ -36,11 +36,7 @@ public class Card1_127 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.MANEUVER, self, 0)
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.URUK_HAI), Filters.not(Filters.sameCard(self)))) {
CostToEffectAction action = new CostToEffectAction(self, Keyword.MANEUVER, "Spot another Uruk-hai to make Lurtz fierce until the regroup phase.");
@@ -48,8 +44,8 @@ public class Card1_127 extends AbstractMinion {
new AddUntilStartOfPhaseModifierEffect(
new KeywordModifier(self, Filters.sameCard(self), Keyword.FIERCE), Phase.REGROUP));
actions.add(action);
return Collections.singletonList(action);
}
return actions;
return null;
}
}

View File

@@ -3,12 +3,6 @@ package com.gempukku.lotro.cards.set1.isengard;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
@@ -28,13 +22,4 @@ public class Card1_131 extends AbstractMinion {
addKeyword(Keyword.ARCHER);
addKeyword(Keyword.DAMAGE);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
return actions;
}
}

View File

@@ -8,14 +8,9 @@ import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.game.state.Skirmish;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
@@ -35,15 +30,6 @@ public class Card1_143 extends AbstractMinion {
addKeyword(Keyword.DAMAGE);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
return actions;
}
@Override
public Modifier getAlwaysOnEffect(final PhysicalCard self) {
return new CancelStrengthBonusModifier(self, Filters.and(

View File

@@ -17,7 +17,7 @@ import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
/**
@@ -39,18 +39,14 @@ public class Card1_145 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActions(String playerId, final LotroGame lotroGame, final PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, lotroGame, self);
if (PlayConditions.canUseShadowCardDuringPhase(lotroGame.getGameState(), Phase.SKIRMISH, self, 2)) {
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self, 2)) {
final CostToEffectAction action = new CostToEffectAction(self, Keyword.SKIRMISH, "Remove (2) to make this minion strength +1 for each other Uruk-hai you spot");
action.addCost(new RemoveTwilightEffect(2));
action.addEffect(
new PlayoutDecisionEffect(lotroGame.getUserFeedback(), playerId,
new ForEachYouSpotDecision(1, "Choose number of minions you wish to spot", lotroGame, Filters.and(Filters.keyword(Keyword.URUK_HAI), Filters.not(Filters.sameCard(self))), Integer.MAX_VALUE) {
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new ForEachYouSpotDecision(1, "Choose number of minions you wish to spot", game, Filters.and(Filters.keyword(Keyword.URUK_HAI), Filters.not(Filters.sameCard(self))), Integer.MAX_VALUE) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int spotCount = getValidatedResult(result);
@@ -62,9 +58,8 @@ public class Card1_145 extends AbstractMinion {
}
));
actions.add(action);
return Collections.singletonList(action);
}
return actions;
return null;
}
}

View File

@@ -14,7 +14,7 @@ import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
/**
@@ -36,20 +36,15 @@ public class Card1_146 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame lotroGame, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, lotroGame, self);
if (PlayConditions.canUseShadowCardDuringPhase(lotroGame.getGameState(), Phase.MANEUVER, self, 0)
&& Filters.countActive(lotroGame.getGameState(), lotroGame.getModifiersQuerying(), Filters.type(CardType.COMPANION)) >= 5) {
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.MANEUVER, self, 0)
&& Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.type(CardType.COMPANION)) >= 5) {
CostToEffectAction action = new CostToEffectAction(self, Keyword.MANEUVER, "Spot 5 companions to make this minion fierce until the regroup phase");
action.addEffect(new AddUntilStartOfPhaseModifierEffect(new KeywordModifier(self, Filters.sameCard(self), Keyword.FIERCE), Phase.REGROUP));
actions.add(action);
return Collections.singletonList(action);
}
return actions;
return null;
}
}

View File

@@ -16,7 +16,7 @@ import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
/**
@@ -39,11 +39,7 @@ public class Card1_147 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.ASSIGNMENT, self, 0)
&& PlayConditions.canExert(game.getGameState(), game.getModifiersQuerying(), self)) {
final CostToEffectAction action = new CostToEffectAction(self, Keyword.ASSIGNMENT, "Exert this minion and spot a companion to prevent the opponent from assigning that companion to this minion.");
@@ -58,9 +54,8 @@ public class Card1_147 extends AbstractMinion {
, Phase.ASSIGNMENT));
}
});
actions.add(action);
return Collections.singletonList(action);
}
return actions;
return null;
}
}

View File

@@ -6,14 +6,9 @@ import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.modifiers.AbstractModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
@@ -42,13 +37,4 @@ public class Card1_148 extends AbstractMinion {
}
};
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame lotroGame, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, lotroGame, self);
return actions;
}
}

View File

@@ -9,13 +9,8 @@ import com.gempukku.lotro.filters.Filter;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
@@ -47,13 +42,4 @@ public class Card1_149 extends AbstractMinion {
}
}), 3);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame lotroGame, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, lotroGame, self);
return actions;
}
}

View File

@@ -12,7 +12,6 @@ import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
@@ -34,15 +33,6 @@ public class Card1_150 extends AbstractMinion {
addKeyword(Keyword.DAMAGE);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
return actions;
}
@Override
public List<? extends Action> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (PlayConditions.winsSkirmish(effectResult, self)) {

View File

@@ -3,12 +3,6 @@ package com.gempukku.lotro.cards.set1.isengard;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
@@ -27,11 +21,4 @@ public class Card1_151 extends AbstractMinion {
addKeyword(Keyword.URUK_HAI);
addKeyword(Keyword.DAMAGE);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
return actions;
}
}

View File

@@ -14,7 +14,7 @@ import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.effects.HealCharacterEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
/**
@@ -36,10 +36,7 @@ public class Card1_152 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.MANEUVER, self, 2)) {
final CostToEffectAction action = new CostToEffectAction(self, Keyword.MANEUVER, "Remove (2) to heal an Uruk-hai");
action.addCost(new RemoveTwilightEffect(2));
@@ -51,8 +48,8 @@ public class Card1_152 extends AbstractMinion {
}
});
actions.add(action);
return Collections.singletonList(action);
}
return actions;
return null;
}
}

View File

@@ -15,7 +15,7 @@ import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
/**
@@ -37,10 +37,7 @@ public class Card1_153 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self, 1)) {
final CostToEffectAction action = new CostToEffectAction(self, Keyword.SKIRMISH, "Remove (1) to make this minion strength +1 (limit +3).");
action.addCost(new RemoveTwilightEffect(1));
@@ -49,9 +46,8 @@ public class Card1_153 extends AbstractMinion {
new AddUntilEndOfPhaseModifierEffect(
new StrengthModifier(self, Filters.sameCard(self), 1), Phase.SKIRMISH)));
actions.add(action);
return Collections.singletonList(action);
}
return actions;
return null;
}
}

View File

@@ -13,7 +13,6 @@ import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
@@ -35,13 +34,6 @@ public class Card1_154 extends AbstractMinion {
addKeyword(Keyword.DAMAGE);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
return actions;
}
@Override
public List<? extends Action> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (PlayConditions.played(game.getGameState(), game.getModifiersQuerying(), effectResult, Filters.sameCard(self))) {

View File

@@ -18,7 +18,6 @@ import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
@@ -39,13 +38,6 @@ public class Card1_155 extends AbstractMinion {
addKeyword(Keyword.URUK_HAI);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
return actions;
}
@Override
public List<? extends Action> getOptionalAfterActions(final String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (effectResult.getType() == EffectResult.Type.PUT_ON_THE_ONE_RING

View File

@@ -14,7 +14,7 @@ import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
/**
@@ -36,10 +36,7 @@ public class Card1_156 extends AbstractMinion {
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
List<Action> actions = new LinkedList<Action>();
appendPlayMinionAction(actions, game, self);
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.SHADOW, self, 0)
&& Filters.countActive(game.getGameState(), game.getModifiersQuerying(), Filters.type(CardType.COMPANION)) >= 6) {
CostToEffectAction action = new CostToEffectAction(self, Keyword.MANEUVER, "Make this minion fierce until the regroup phase.");
@@ -47,9 +44,8 @@ public class Card1_156 extends AbstractMinion {
new AddUntilStartOfPhaseModifierEffect(
new KeywordModifier(self, Filters.sameCard(self), Keyword.FIERCE), Phase.REGROUP));
actions.add(action);
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -88,8 +88,15 @@ var AdvPathCardGroup = CardGroup.extend({
var index = 0;
for (var cardId in cardsToLayout) {
var cardElem = cardsToLayout[cardId];
var cardData = cardsToLayout[cardId].data("card");
var cardHeight = (cardElem.data("card").getHeightForWidth(this.width));
this.layoutCard(cardElem, x, y, this.width, cardHeight, index);
for (var i = 0; i < cardData.attachedCards.length; i++) {
this.layoutCard(cardData.attachedCards[i], x + (this.width - cardHeight) / 2, y - (this.width - cardHeight) / 2, cardHeight, this.width, index);
index++;
}
y += cardHeight + resultPadding;
index++;
}