"Cair Andros"

This commit is contained in:
marcins78
2013-02-13 14:36:14 +00:00
parent 7bdd11710d
commit c5fca345b8
18 changed files with 143 additions and 29 deletions

View File

@@ -34,19 +34,19 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
private boolean _exertTarget;
private PhysicalCard _target;
private boolean _discountResolved;
private DiscountEffect _discountEffect;
private boolean _discountApplied;
private int _twilightModifier;
private Zone _playedFrom;
private PhysicalCard _target;
public AttachPermanentAction(final LotroGame game, final PhysicalCard card, Filter filter, final Map<Filter, Integer> attachCostModifiers, final int twilightModifier) {
_cardToAttach = card;
final Zone playedFromZone = card.getZone();
_playedFrom = card.getZone();
_chooseTargetEffect =
new ChooseActiveCardEffect(null, card.getOwner(), "Attach " + GameUtils.getFullName(card) + ". Choose target to attach to", filter) {
@@ -65,9 +65,7 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
_twilightModifier = modifier;
game.getGameState().sendMessage(card.getOwner() + " plays " + GameUtils.getCardLink(card) + " from " + playedFromZone.getHumanReadable() + " on " + GameUtils.getCardLink(target));
_playCardEffect = new PlayCardEffect(playedFromZone, card, target, null);
game.getGameState().sendMessage(card.getOwner() + " plays " + GameUtils.getCardLink(card) + " from " + _playedFrom.getHumanReadable() + " on " + GameUtils.getCardLink(target));
}
};
}
@@ -147,12 +145,14 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
if (!_discountApplied) {
_discountApplied = true;
if (_discountEffect != null)
if (_discountEffect != null) {
_twilightModifier -= _discountEffect.getDiscountPaidFor();
_discountEffect.afterDiscountCallback(this);
}
insertCost(new PayPlayOnTwilightCostEffect(_cardToAttach, _target, _twilightModifier));
}
if (_playCardEffect != null) {
if (_target != null) {
if (!isCostFailed()) {
Effect cost = getNextCost();
if (cost != null)
@@ -160,6 +160,8 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
if (!_cardPlayed) {
_cardPlayed = true;
_playCardEffect = new PlayCardEffect(_playedFrom, _cardToAttach, _target, null, isPaidToil());
return _playCardEffect;
}

View File

@@ -33,6 +33,7 @@ public class PlayEventAction extends AbstractCostToEffectAction implements Disco
private DiscountEffect _discountEffect;
private boolean _discountApplied;
private Zone _playedFrom;
public PlayEventAction(PhysicalCard card) {
this(card, false);
@@ -42,7 +43,7 @@ public class PlayEventAction extends AbstractCostToEffectAction implements Disco
_eventPlayed = card;
_requiresRanger = requiresRanger;
_playCardEffect = new PlayEventEffect(this, card.getZone(), card, requiresRanger);
_playedFrom = card.getZone();
_text = "Play " + GameUtils.getFullName(_eventPlayed);
}
@@ -132,8 +133,10 @@ public class PlayEventAction extends AbstractCostToEffectAction implements Disco
if (!_discountApplied) {
_discountApplied = true;
int twilightModifier = 0;
if (_discountEffect != null)
if (_discountEffect != null) {
twilightModifier -= _discountEffect.getDiscountPaidFor();
_discountEffect.afterDiscountCallback(this);
}
insertCost(new PayTwilightCostEffect(_eventPlayed, twilightModifier));
}
@@ -144,10 +147,11 @@ public class PlayEventAction extends AbstractCostToEffectAction implements Disco
if (!_cardPlayed) {
_cardPlayed = true;
_playCardEffect = new PlayEventEffect(this, _playedFrom, _eventPlayed, _requiresRanger, isPaidToil());
return _playCardEffect;
}
if (!_playCardEffect.getPlayEventResult().isEventCancelled()) {
if (_playCardEffect != null && !_playCardEffect.getPlayEventResult().isEventCancelled()) {
Effect effect = getNextEffect();
if (effect != null)
return effect;

View File

@@ -17,7 +17,6 @@ import java.util.Collections;
public class PlayPermanentAction extends AbstractCostToEffectAction implements DiscountableAction {
private PhysicalCard _permanentPlayed;
private Zone _zone;
private int _twilightModifier;
private boolean _ignoreRoamingPenalty;
@@ -34,21 +33,23 @@ public class PlayPermanentAction extends AbstractCostToEffectAction implements D
private boolean _discountApplied;
private boolean _skipShuffling;
private Zone _fromZone;
private Zone _toZone;
private PhysicalCard _playedFromCard;
public PlayPermanentAction(PhysicalCard card, Zone zone, int twilightModifier, boolean ignoreRoamingPenalty) {
_permanentPlayed = card;
setPerformingPlayer(card.getOwner());
_zone = zone;
_twilightModifier = twilightModifier;
_ignoreRoamingPenalty = ignoreRoamingPenalty;
PhysicalCard playedFromCard = null;
if (card.getZone() == Zone.STACKED)
playedFromCard = card.getStackedOn();
_playedFromCard = card.getStackedOn();
else if (card.getZone() == Zone.ATTACHED)
playedFromCard = card.getAttachedTo();
_playedFromCard = card.getAttachedTo();
_playCardEffect = new PlayCardEffect(card.getZone(), card, zone, playedFromCard);
_fromZone = card.getZone();
_toZone = zone;
}
public void skipShufflingDeck() {
@@ -118,8 +119,10 @@ public class PlayPermanentAction extends AbstractCostToEffectAction implements D
if (!_discountApplied) {
_discountApplied = true;
if (_discountEffect != null)
if (_discountEffect != null) {
_twilightModifier -= _discountEffect.getDiscountPaidFor();
_discountEffect.afterDiscountCallback(this);
}
insertCost(new PayTwilightCostEffect(_permanentPlayed, _twilightModifier, _ignoreRoamingPenalty));
}
@@ -130,6 +133,7 @@ public class PlayPermanentAction extends AbstractCostToEffectAction implements D
if (!_cardPlayed) {
_cardPlayed = true;
_playCardEffect = new PlayCardEffect(_fromZone, _permanentPlayed, _toZone, _playedFromCard, isPaidToil());
return _playCardEffect;
}
@@ -148,6 +152,6 @@ public class PlayPermanentAction extends AbstractCostToEffectAction implements D
}
public boolean wasCarriedOut() {
return _cardPlayed && _playCardEffect.wasCarriedOut();
return _cardPlayed && _playCardEffect != null && _playCardEffect.wasCarriedOut();
}
}

View File

@@ -1,9 +1,12 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.logic.actions.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.timing.Effect;
public interface DiscountEffect extends Effect {
public void setMinimalRequiredDiscount(int minimalDiscount);
public int getDiscountPaidFor();
public void afterDiscountCallback(AbstractCostToEffectAction action);
}

View File

@@ -11,10 +11,10 @@ public class PlayEventEffect extends PlayCardEffect {
private PhysicalCard _cardPlayed;
private PlayEventResult _playEventResult;
public PlayEventEffect(PlayEventAction action, Zone playedFrom, PhysicalCard cardPlayed, boolean requiresRanger) {
super(playedFrom, cardPlayed, (Zone) null, null);
public PlayEventEffect(PlayEventAction action, Zone playedFrom, PhysicalCard cardPlayed, boolean requiresRanger, boolean paidToil) {
super(playedFrom, cardPlayed, (Zone) null, null, paidToil);
_cardPlayed = cardPlayed;
_playEventResult = new PlayEventResult(action, playedFrom, getPlayedCard(), requiresRanger);
_playEventResult = new PlayEventResult(action, playedFrom, getPlayedCard(), requiresRanger, paidToil);
}
public PlayEventResult getPlayEventResult() {

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.common.Filterable;
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.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.effects.ChooseAndDiscardCardsFromHandEffect;
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
@@ -64,4 +65,9 @@ public class DiscardCardFromHandDiscountEffect extends AbstractSubActionEffect i
processSubAction(game, subAction);
}
}
@Override
public void afterDiscountCallback(AbstractCostToEffectAction action) {
}
}

View File

@@ -6,6 +6,7 @@ import com.gempukku.lotro.common.Filterable;
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.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
import com.gempukku.lotro.logic.timing.Action;
@@ -75,4 +76,7 @@ public class ExertCharactersDiscountEffect extends AbstractSubActionEffect imple
return _exertedCount * _multiplier;
}
@Override
public void afterDiscountCallback(AbstractCostToEffectAction action) {
}
}

View File

@@ -7,6 +7,7 @@ import com.gempukku.lotro.cards.effects.choose.ChooseAndDiscardCardsFromPlayEffe
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
import com.gempukku.lotro.logic.timing.Action;
@@ -79,4 +80,9 @@ public class OptionalDiscardDiscountEffect extends AbstractSubActionEffect imple
protected void discountPaidCallback() {
}
@Override
public void afterDiscountCallback(AbstractCostToEffectAction action) {
}
}

View File

@@ -7,6 +7,7 @@ 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.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.decisions.YesNoDecision;
@@ -103,4 +104,9 @@ public class RemoveCardsFromDiscardDiscountEffect implements DiscountEffect {
public boolean wasCarriedOut() {
return !_required || _paid;
}
@Override
public void afterDiscountCallback(AbstractCostToEffectAction action) {
}
}

View File

@@ -2,6 +2,7 @@ package com.gempukku.lotro.cards.effects.discount;
import com.gempukku.lotro.cards.effects.DiscountEffect;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision;
@@ -73,4 +74,9 @@ public class RemoveThreatsToDiscountEffect extends AbstractSubActionEffect imple
public int getDiscountPaidFor() {
return _threatsRemoved;
}
@Override
public void afterDiscountCallback(AbstractCostToEffectAction action) {
}
}

View File

@@ -6,6 +6,7 @@ import com.gempukku.lotro.common.Culture;
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.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
import com.gempukku.lotro.logic.timing.Action;
@@ -84,4 +85,9 @@ public class ToilDiscountEffect extends AbstractSubActionEffect implements Disco
return (_exertedCount + _paidToil) * _toilCount;
}
@Override
public void afterDiscountCallback(AbstractCostToEffectAction action) {
if (_exertedCount>0)
action.setPaidToil(true);
}
}

View File

@@ -10,8 +10,8 @@ public class PlayEventResult extends PlayCardResult {
private PlayEventAction _action;
private boolean _requiresRanger;
public PlayEventResult(PlayEventAction action, Zone playedFrom, PhysicalCard playedCard, boolean requiresRanger) {
super(playedFrom, playedCard, null, null);
public PlayEventResult(PlayEventAction action, Zone playedFrom, PhysicalCard playedCard, boolean requiresRanger, boolean paidToil) {
super(playedFrom, playedCard, null, null, paidToil);
_action = action;
_requiresRanger = requiresRanger;
}

View File

@@ -2,6 +2,7 @@ package com.gempukku.lotro.cards.set13.men;
import com.gempukku.lotro.cards.effects.DiscountEffect;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.AbstractCostToEffectAction;
import com.gempukku.lotro.logic.decisions.YesNoDecision;
import com.gempukku.lotro.logic.timing.AbstractSuccessfulEffect;
@@ -51,4 +52,9 @@ public class DiscountChoiceEffect extends AbstractSuccessfulEffect implements Di
});
}
}
@Override
public void afterDiscountCallback(AbstractCostToEffectAction action) {
}
}

View File

@@ -0,0 +1,43 @@
package com.gempukku.lotro.cards.set20.site;
import com.gempukku.lotro.cards.AbstractSite;
import com.gempukku.lotro.cards.TriggerConditions;
import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect;
import com.gempukku.lotro.common.Block;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Keyword;
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.PlayCardResult;
import java.util.Collections;
import java.util.List;
/**
* Cair Andros
* 8 8
* River.
* Each time you play an Easterling using toil, the Free Peoples player must exert a companion.
*/
public class Card20_458 extends AbstractSite {
public Card20_458() {
super("Cair Andros", Block.SECOND_ED, 8, 8, null);
addKeyword(Keyword.RIVER);
}
@Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (TriggerConditions.played(game, effectResult, Keyword.EASTERLING)) {
PlayCardResult playResult = (PlayCardResult) effectResult;
if (playResult.isPaidToil()) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(
new ChooseAndExertCharactersEffect(action, game.getGameState().getCurrentPlayerId(), 1, 1, CardType.COMPANION));
return Collections.singletonList(action);
}
}
return null;
}
}

View File

@@ -16,6 +16,15 @@ public abstract class AbstractCostToEffectAction implements CostToEffectAction {
private String _performingPlayer;
private boolean _virtualCardAction = false;
private boolean _paidToil = false;
public boolean isPaidToil() {
return _paidToil;
}
public void setPaidToil(boolean paidToil) {
_paidToil = paidToil;
}
@Override
public void setVirtualCardAction(boolean virtualCardAction) {

View File

@@ -16,19 +16,22 @@ public class PlayCardEffect extends AbstractEffect {
private PhysicalCard _attachedToCard;
private Zone _zone;
private PhysicalCard _attachedOrStackedPlayedFrom;
private boolean _paidToil;
public PlayCardEffect(Zone playedFrom, PhysicalCard cardPlayed, Zone playedTo, PhysicalCard attachedOrStackedPlayedFrom) {
public PlayCardEffect(Zone playedFrom, PhysicalCard cardPlayed, Zone playedTo, PhysicalCard attachedOrStackedPlayedFrom, boolean paidToil) {
_playedFrom = playedFrom;
_cardPlayed = cardPlayed;
_zone = playedTo;
_attachedOrStackedPlayedFrom = attachedOrStackedPlayedFrom;
_paidToil = paidToil;
}
public PlayCardEffect(Zone playedFrom, PhysicalCard cardPlayed, PhysicalCard attachedToCard, PhysicalCard attachedOrStackedPlayedFrom) {
public PlayCardEffect(Zone playedFrom, PhysicalCard cardPlayed, PhysicalCard attachedToCard, PhysicalCard attachedOrStackedPlayedFrom, boolean paidToil) {
_playedFrom = playedFrom;
_cardPlayed = cardPlayed;
_attachedToCard = attachedToCard;
_attachedOrStackedPlayedFrom = attachedOrStackedPlayedFrom;
_paidToil = paidToil;
_zone = Zone.ATTACHED;
}
@@ -64,7 +67,7 @@ public class PlayCardEffect extends AbstractEffect {
game.getGameState().addCardToZone(game, _cardPlayed, _zone);
}
game.getActionsEnvironment().emitEffectResult(new PlayCardResult(_playedFrom, _cardPlayed, _attachedToCard, _attachedOrStackedPlayedFrom));
game.getActionsEnvironment().emitEffectResult(new PlayCardResult(_playedFrom, _cardPlayed, _attachedToCard, _attachedOrStackedPlayedFrom, _paidToil));
return new FullEffectResult(true);
}

View File

@@ -140,7 +140,7 @@ public class PlaySiteEffect extends AbstractEffect {
}
sitePlayedCallback(newSite);
game.getActionsEnvironment().emitEffectResult(new PlayCardResult(Zone.ADVENTURE_DECK, newSite, null, null));
game.getActionsEnvironment().emitEffectResult(new PlayCardResult(Zone.ADVENTURE_DECK, newSite, null, null, false));
}
});

View File

@@ -9,13 +9,19 @@ public class PlayCardResult extends EffectResult {
private PhysicalCard _playedCard;
private PhysicalCard _attachedTo;
private PhysicalCard _attachedOrStackedPlayedFrom;
private boolean _paidToil;
public PlayCardResult(Zone playedFrom, PhysicalCard playedCard, PhysicalCard attachedTo, PhysicalCard attachedOrStackedPlayedFrom) {
public PlayCardResult(Zone playedFrom, PhysicalCard playedCard, PhysicalCard attachedTo, PhysicalCard attachedOrStackedPlayedFrom, boolean paidToil) {
super(EffectResult.Type.PLAY);
_playedFrom = playedFrom;
_playedCard = playedCard;
_attachedTo = attachedTo;
_attachedOrStackedPlayedFrom = attachedOrStackedPlayedFrom;
_paidToil = paidToil;
}
public boolean isPaidToil() {
return _paidToil;
}
public PhysicalCard getPlayedCard() {