Some refactoring.

This commit is contained in:
marcins78
2013-04-19 14:05:27 +00:00
parent 8c61ffc7df
commit 3bee9ed0f6
2 changed files with 41 additions and 63 deletions

View File

@@ -3,20 +3,16 @@ package com.gempukku.lotro.cards.set1.dwarven;
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
import com.gempukku.lotro.cards.TriggerConditions;
import com.gempukku.lotro.cards.effects.DiscardTopCardFromDeckEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.common.PossessionClass;
import com.gempukku.lotro.common.Race;
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.actions.RequiredTriggerAction;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.CharacterWonSkirmishResult;
import com.gempukku.lotro.logic.timing.results.CharacterLostSkirmishResult;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* Set: The Fellowship of the Ring
@@ -29,36 +25,25 @@ import java.util.Set;
* top card from his draw deck.
*/
public class Card1_009 extends AbstractAttachableFPPossession {
public Card1_009() {
super(0, 2, 0, Culture.DWARVEN, PossessionClass.HAND_WEAPON, "Dwarven Axe");
}
public Card1_009() {
super(0, 2, 0, Culture.DWARVEN, PossessionClass.HAND_WEAPON, "Dwarven Axe");
}
@Override
protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Race.DWARF;
}
@Override
protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Race.DWARF;
}
@Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.winsSkirmish(game, effectResult, self.getAttachedTo())) {
CharacterWonSkirmishResult skirmishResult = ((CharacterWonSkirmishResult) effectResult);
Set<PhysicalCard> losers = skirmishResult.getInvolving();
@Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.losesSkirmishInvolving(game, effectResult, CardType.MINION, Filters.hasAttached(self))) {
CharacterLostSkirmishResult skirmishResult = ((CharacterLostSkirmishResult) effectResult);
PhysicalCard loser = skirmishResult.getLoser();
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(new DiscardTopCardFromDeckEffect(self, loser.getOwner(), 1, true));
return Collections.singletonList(action);
}
List<RequiredTriggerAction> actions = new LinkedList<RequiredTriggerAction>();
Set<String> losingPlayers = new HashSet<String>();
for (PhysicalCard loser : losers)
losingPlayers.add(loser.getOwner());
for (String losingPlayer : losingPlayers) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(new DiscardTopCardFromDeckEffect(self, losingPlayer, true));
actions.add(action);
}
return actions;
}
return null;
}
return null;
}
}

View File

@@ -1,20 +1,18 @@
package com.gempukku.lotro.cards.set1.dwarven;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.TriggerConditions;
import com.gempukku.lotro.cards.effects.SelfDiscardEffect;
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.RequiredTriggerAction;
import com.gempukku.lotro.logic.effects.DiscardCardsFromPlayEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.CharacterWonSkirmishResult;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
@@ -27,28 +25,23 @@ import java.util.List;
* this condition if a Dwarf loses a skirmish.
*/
public class Card1_020 extends AbstractPermanent {
public Card1_020() {
super(Side.FREE_PEOPLE, 2, CardType.CONDITION, Culture.DWARVEN, Zone.SUPPORT, "Let Them Come!");
}
public Card1_020() {
super(Side.FREE_PEOPLE, 2, CardType.CONDITION, Culture.DWARVEN, Zone.SUPPORT, "Let Them Come!");
}
@Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.winsSkirmishInvolving(game, effectResult, Race.DWARF, Race.ORC)) {
CharacterWonSkirmishResult wonResult = (CharacterWonSkirmishResult) effectResult;
List<RequiredTriggerAction> actions = new LinkedList<RequiredTriggerAction>();
for (PhysicalCard losingOrc : Filters.filter(wonResult.getInvolving(), game.getGameState(), game.getModifiersQuerying(), Race.ORC)) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.setText("Discard " + GameUtils.getFullName(losingOrc));
action.appendEffect(new DiscardCardsFromPlayEffect(self, losingOrc));
actions.add(action);
}
return actions;
}
if (TriggerConditions.losesSkirmish(game, effectResult, Race.DWARF)) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(new SelfDiscardEffect(self));
return Collections.singletonList(action);
}
return null;
}
@Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.winsSkirmish(game, effectResult, Race.DWARF) && PlayConditions.isActive(game, Filters.inSkirmish, Race.ORC)) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(
new DiscardCardsFromPlayEffect(self, Filters.inSkirmish, Race.ORC));
return Collections.singletonList(action);
}
if (TriggerConditions.losesSkirmish(game, effectResult, Race.DWARF)) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(new SelfDiscardEffect(self));
return Collections.singletonList(action);
}
return null;
}
}