"Southron Commander"

This commit is contained in:
marcins78@gmail.com
2011-10-12 16:45:33 +00:00
parent 1db62ec267
commit c37b4e2749
19 changed files with 174 additions and 41 deletions

View File

@@ -221,6 +221,14 @@ public class PlayConditions {
return false;
}
public static boolean canCardAssignToSkirmish(PhysicalCard source, LotroGame game, PhysicalCard card) {
return Filters.canBeAssignedToSkirmishByEffect(source.getBlueprint().getSide()).accepts(game.getGameState(), game.getModifiersQuerying(), card);
}
public static boolean canCardAssignToSkirmish(PhysicalCard source, LotroGame game, Filter filter) {
return Filters.countSpottable(game.getGameState(), game.getModifiersQuerying(), Filters.canBeAssignedToSkirmishByEffect(source.getBlueprint().getSide()), filter) > 0;
}
public static boolean isWounded(EffectResult effectResult, PhysicalCard character) {
if (effectResult.getType() == EffectResult.Type.WOUND) {
return ((WoundResult) effectResult).getWoundedCards().contains(character);

View File

@@ -41,7 +41,7 @@ public class Card1_169 extends AbstractEvent {
@Override
protected void cardSelected(PhysicalCard minion) {
action.appendEffect(
new AssignmentEffect(playerId, ringBearer, Collections.singletonList(minion), "The End Comes effect"));
new AssignmentEffect(playerId, ringBearer, Collections.singletonList(minion)));
}
});
}

View File

@@ -36,7 +36,7 @@ public class Card1_171 extends AbstractEvent {
@Override
protected void cardSelected(PhysicalCard moriaOrc) {
action.appendEffect(
new AssignmentEffect(playerId, companion, Collections.singletonList(moriaOrc), "Frenzy effect"));
new AssignmentEffect(playerId, companion, Collections.singletonList(moriaOrc)));
}
});
}

View File

@@ -49,7 +49,7 @@ public class Card1_262 extends AbstractMinion {
new ChooseActiveCardEffect(self, game.getGameState().getCurrentPlayerId(), "Choose a Hobbit", Filters.race(Race.HOBBIT), Filters.notAssignedToSkirmish(), Filters.type(CardType.COMPANION), Filters.canBeAssignedToSkirmish(Side.SHADOW)) {
@Override
protected void cardSelected(PhysicalCard hobbit) {
action.appendEffect(new AssignmentEffect(hobbit.getOwner(), hobbit, Collections.singletonList(self), "Orc Assassin effect"));
action.appendEffect(new AssignmentEffect(hobbit.getOwner(), hobbit, Collections.singletonList(self)));
}
});
return Collections.singletonList(action);

View File

@@ -55,7 +55,7 @@ public class Card1_224 extends AbstractResponseEvent {
@Override
protected void cardSelected(PhysicalCard nazgul) {
PhysicalCard ringBearer = game.getGameState().getRingBearer(game.getGameState().getCurrentPlayerId());
action.appendEffect(new AssignmentEffect(playerId, ringBearer, Collections.singletonList(nazgul), "Return to Its Master effect"));
action.appendEffect(new AssignmentEffect(playerId, ringBearer, Collections.singletonList(nazgul)));
action.appendEffect(
new AddUntilEndOfPhaseModifierEffect(
new SpecialFlagModifier(self, ModifierFlag.RING_TEXT_INACTIVE), Phase.SKIRMISH));

View File

@@ -43,7 +43,7 @@ public class Card1_236 extends AbstractMinion {
@Override
protected void cardSelected(PhysicalCard companion) {
action.appendEffect(
new AssignmentEffect(playerId, companion, Collections.singletonList(self), "Ulaire Toldea effect"));
new AssignmentEffect(playerId, companion, Collections.singletonList(self)));
}
});
}

View File

@@ -92,7 +92,7 @@ public class Card3_069 extends AbstractMinion {
action.appendEffect(
new PreventableEffect(
action,
new AssignmentEffect(playerId, companion, Collections.singletonList(minion), "Assign " + minion.getBlueprint().getName() + " to skirmish " + companion.getBlueprint().getName()),
new AssignmentEffect(playerId, companion, Collections.singletonList(minion)),
Collections.singletonList(game.getGameState().getCurrentPlayerId()),
new ExertCharactersEffect(self, companion)));
}

View File

@@ -55,7 +55,7 @@ public class Card4_015 extends AbstractMinion {
@Override
protected void cardSelected(PhysicalCard ally) {
action.appendEffect(
new AssignmentEffect(playerId, ally, Collections.singletonList(self), "Dunlending Ravager effect"));
new AssignmentEffect(playerId, ally, Collections.singletonList(self)));
}
});
return Collections.singletonList(action);

View File

@@ -41,7 +41,7 @@ public class Card4_018 extends AbstractMinion {
@Override
protected void cardSelected(PhysicalCard ally) {
action.appendEffect(
new AssignmentEffect(playerId, ally, Collections.singletonList(self), "Dunlending Ravager effect"));
new AssignmentEffect(playerId, ally, Collections.singletonList(self)));
}
});
return Collections.singletonList(action);

View File

@@ -45,7 +45,7 @@ public class Card4_031 extends AbstractPermanent {
@Override
protected void cardSelected(PhysicalCard unboundCompanion) {
action.insertEffect(
new AssignmentEffect(playerId, unboundCompanion, Collections.singletonList(dunlandMan), "Over the Isen effect"));
new AssignmentEffect(playerId, unboundCompanion, Collections.singletonList(dunlandMan)));
}
});
}

View File

@@ -53,7 +53,7 @@ public class Card4_143 extends AbstractEvent {
@Override
protected void cardSelected(PhysicalCard companion) {
Race race = companion.getBlueprint().getRace();
AssignmentEffect assignmentEffect = new AssignmentEffect(playerId, companion, Collections.singletonList(minion), "Assigned with Brought Back Alive");
AssignmentEffect assignmentEffect = new AssignmentEffect(playerId, companion, Collections.singletonList(minion));
if (race == Race.HOBBIT) {
action.insertEffect(
assignmentEffect);

View File

@@ -74,7 +74,7 @@ public class Card4_159 extends AbstractAttachable {
protected void forEachCardExertedCallback(PhysicalCard minion) {
action.appendEffect(
new PreventableEffect(action,
new AssignmentEffect(playerId, self.getAttachedTo(), Collections.singletonList(minion), "Assigned by card effect"),
new AssignmentEffect(playerId, self.getAttachedTo(), Collections.singletonList(minion)),
game.getGameState().getCurrentPlayerId(),
new ExertCharactersEffect(self, self.getAttachedTo())));
}

View File

@@ -48,7 +48,7 @@ public class Card4_164 extends AbstractMinion {
protected void cardSelected(PhysicalCard companion) {
action.insertEffect(
new PreventableEffect(action,
new AssignmentEffect(playerId, companion, Collections.singletonList(self), "assigned by card effect"),
new AssignmentEffect(playerId, companion, Collections.singletonList(self)),
game.getGameState().getCurrentPlayerId(),
new ExertCharactersEffect(self, companion)));
}

View File

@@ -0,0 +1,59 @@
package com.gempukku.lotro.cards.set4.raider;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ChooseAndDiscardCardsFromPlayEffect;
import com.gempukku.lotro.cards.effects.PreventableEffect;
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.ActivateCardAction;
import com.gempukku.lotro.logic.effects.AssignmentEffect;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collections;
import java.util.List;
/**
* Set: The Two Towers
* Side: Shadow
* Culture: Raider
* Twilight Cost: 5
* Type: Minion • Man
* Strength: 10
* Vitality: 3
* Site: 4
* Game Text: Southron. Ambush (1). Assignment: Spot 6 companions to assign this minion to the Ring-bearer. The Free
* Peoples player may discard an unbound companion to prevent this.
*/
public class Card4_249 extends AbstractMinion {
public Card4_249() {
super(5, 10, 3, 4, Race.MAN, Culture.RAIDER, "Southron Commander");
addKeyword(Keyword.SOUTHRON);
addKeyword(Keyword.AMBUSH, 1);
}
@Override
protected List<? extends Action> getExtraPhaseActions(final String playerId, final LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.ASSIGNMENT, self, 0)
&& PlayConditions.canSpot(game, 6, Filters.type(CardType.COMPANION))
&& PlayConditions.canCardAssignToSkirmish(self, game, self)
&& PlayConditions.canCardAssignToSkirmish(self, game, Filters.keyword(Keyword.RING_BEARER))) {
final ActivateCardAction action = new ActivateCardAction(self);
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose Ring-bearer", Filters.keyword(Keyword.RING_BEARER)) {
@Override
protected void cardSelected(PhysicalCard card) {
action.insertEffect(new PreventableEffect(action,
new AssignmentEffect(playerId, card, self),
game.getGameState().getCurrentPlayerId(),
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Filters.unboundCompanion())));
}
});
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -66,6 +66,17 @@ public class Filters {
};
}
public static Filter canBeAssignedToSkirmishByEffect(final Side sidePlayer) {
return Filters.and(
Filters.notAssignedToSkirmish(),
new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canBeAssignedToSkirmish(gameState, sidePlayer, physicalCard);
}
});
}
public static Filter canBeAssignedToSkirmish(final Side sidePlayer) {
return new Filter() {
@Override

View File

@@ -1,36 +1,27 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.common.Side;
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.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.AssignmentResult;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AssignmentEffect extends AbstractEffect {
private Map<PhysicalCard, List<PhysicalCard>> _assignments;
private String _text;
private String _playerId;
private PhysicalCard _fpChar;
private PhysicalCard _minion;
public AssignmentEffect(String playerId, Map<PhysicalCard, List<PhysicalCard>> assignments, String text) {
public AssignmentEffect(String playerId, PhysicalCard fpChar, PhysicalCard minion) {
_playerId = playerId;
// Sanitize the assignments
_assignments = new HashMap<PhysicalCard, List<PhysicalCard>>();
for (Map.Entry<PhysicalCard, List<PhysicalCard>> physicalCardListEntry : assignments.entrySet()) {
PhysicalCard fpChar = physicalCardListEntry.getKey();
List<PhysicalCard> minions = physicalCardListEntry.getValue();
if (minions != null && minions.size() > 0)
_assignments.put(fpChar, minions);
}
_text = text;
}
public AssignmentEffect(String playerId, PhysicalCard fpChar, List<PhysicalCard> minions, String text) {
this(playerId, Collections.singletonMap(fpChar, minions), text);
_fpChar = fpChar;
_minion = minion;
}
@Override
@@ -40,22 +31,25 @@ public class AssignmentEffect extends AbstractEffect {
@Override
public String getText(LotroGame game) {
return _text;
return "Assign " + GameUtils.getCardLink(_minion) + " to skirmish " + GameUtils.getCardLink(_fpChar);
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return true;
Side side = _playerId.equals(game.getGameState().getCurrentPlayerId()) ? Side.FREE_PEOPLE : Side.SHADOW;
return Filters.canBeAssignedToSkirmishByEffect(side).accepts(game.getGameState(), game.getModifiersQuerying(), _fpChar)
&& Filters.canBeAssignedToSkirmishByEffect(side).accepts(game.getGameState(), game.getModifiersQuerying(), _minion);
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
game.getGameState().sendMessage(_playerId + " assigns minion(s) to skirmish");
for (Map.Entry<PhysicalCard, List<PhysicalCard>> physicalCardListEntry : _assignments.entrySet()) {
PhysicalCard fpChar = physicalCardListEntry.getKey();
List<PhysicalCard> minions = physicalCardListEntry.getValue();
game.getGameState().assignToSkirmishes(fpChar, minions);
if (isPlayableInFull(game)) {
game.getGameState().sendMessage(_playerId + " assigns " + GameUtils.getCardLink(_minion) + " to skirmish " + GameUtils.getCardLink(_fpChar));
game.getGameState().assignToSkirmishes(_fpChar, Collections.singletonList(_minion));
final Map<PhysicalCard, List<PhysicalCard>> assignments = Collections.singletonMap(_fpChar, Collections.singletonList(_minion));
return new FullEffectResult(new EffectResult[]{new AssignmentResult(_playerId, assignments)}, true, true);
}
return new FullEffectResult(new EffectResult[]{new AssignmentResult(_playerId, _assignments)}, true, true);
return new FullEffectResult(null, false, false);
}
}

View File

@@ -0,0 +1,61 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.AssignmentResult;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AssignmentPhaseEffect extends AbstractEffect {
private Map<PhysicalCard, List<PhysicalCard>> _assignments;
private String _text;
private String _playerId;
public AssignmentPhaseEffect(String playerId, Map<PhysicalCard, List<PhysicalCard>> assignments, String text) {
_playerId = playerId;
// Sanitize the assignments
_assignments = new HashMap<PhysicalCard, List<PhysicalCard>>();
for (Map.Entry<PhysicalCard, List<PhysicalCard>> physicalCardListEntry : assignments.entrySet()) {
PhysicalCard fpChar = physicalCardListEntry.getKey();
List<PhysicalCard> minions = physicalCardListEntry.getValue();
if (minions != null && minions.size() > 0)
_assignments.put(fpChar, minions);
}
_text = text;
}
public AssignmentPhaseEffect(String playerId, PhysicalCard fpChar, List<PhysicalCard> minions, String text) {
this(playerId, Collections.singletonMap(fpChar, minions), text);
}
@Override
public EffectResult.Type getType() {
return EffectResult.Type.ASSIGNMENT;
}
@Override
public String getText(LotroGame game) {
return _text;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
game.getGameState().sendMessage(_playerId + " assigns minion(s) to skirmish");
for (Map.Entry<PhysicalCard, List<PhysicalCard>> physicalCardListEntry : _assignments.entrySet()) {
PhysicalCard fpChar = physicalCardListEntry.getKey();
List<PhysicalCard> minions = physicalCardListEntry.getValue();
game.getGameState().assignToSkirmishes(fpChar, minions);
}
return new FullEffectResult(new EffectResult[]{new AssignmentResult(_playerId, _assignments)}, true, true);
}
}

View File

@@ -11,7 +11,7 @@ import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.decisions.PlayerAssignMinionsDecision;
import com.gempukku.lotro.logic.effects.AssignmentEffect;
import com.gempukku.lotro.logic.effects.AssignmentPhaseEffect;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
@@ -79,7 +79,7 @@ public class FreePeoplePlayerAssignsMinionsGameProcess implements GameProcess {
ActivateCardAction action = new ActivateCardAction(null);
action.appendEffect(
new AssignmentEffect(gameState.getCurrentPlayerId(), assignments, "Free People player assignments"));
new AssignmentPhaseEffect(gameState.getCurrentPlayerId(), assignments, "Free People player assignments"));
_game.getActionsEnvironment().addActionToStack(action);
}
});

View File

@@ -12,7 +12,7 @@ import com.gempukku.lotro.logic.PlayOrder;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.decisions.PlayerAssignMinionsDecision;
import com.gempukku.lotro.logic.effects.AssignmentEffect;
import com.gempukku.lotro.logic.effects.AssignmentPhaseEffect;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
@@ -70,7 +70,7 @@ public class ShadowPlayerAssignsHisMinionsGameProcess implements GameProcess {
ActivateCardAction action = new ActivateCardAction(null);
action.appendEffect(
new AssignmentEffect(_playerId, assignments, "Shadow player assignments"));
new AssignmentPhaseEffect(_playerId, assignments, "Shadow player assignments"));
if (!_game.getModifiersQuerying().isValidAssignments(_game.getGameState(), Side.SHADOW, assignments))
throw new DecisionResultInvalidException("Assignments are not valid for the effects affecting the cards");