"No Defense"

This commit is contained in:
marcins78@gmail.com
2011-10-06 08:30:04 +00:00
parent eee78478c0
commit ef21be858e
6 changed files with 174 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package com.gempukku.lotro.cards;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Token;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.filters.Filter;
import com.gempukku.lotro.filters.Filters;
@@ -212,4 +213,12 @@ public class PlayConditions {
}
return false;
}
public static boolean canRemoveToken(GameState gameState, PhysicalCard from, Token token) {
return canRemoveToken(gameState, from, token, 1);
}
public static boolean canRemoveToken(GameState gameState, PhysicalCard from, Token token, int count) {
return gameState.getTokenCount(from, token) >= count;
}
}

View File

@@ -0,0 +1,47 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.common.Token;
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;
public class AddTokenEffect extends AbstractEffect {
private PhysicalCard _source;
private PhysicalCard _target;
private Token _token;
private int _count;
public AddTokenEffect(PhysicalCard source, PhysicalCard target, Token token) {
this(source, target, token, 1);
}
public AddTokenEffect(PhysicalCard source, PhysicalCard target, Token token, int count) {
_source = source;
_target = target;
_token = token;
_count = count;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return true;
}
@Override
public EffectResult.Type getType() {
return null;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
game.getGameState().addTokens(_target, _token, _count);
return new FullEffectResult(null, true, true);
}
}

View File

@@ -0,0 +1,49 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.common.Token;
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;
public class RemoveTokenEffect extends AbstractEffect {
private PhysicalCard _source;
private PhysicalCard _target;
private Token _token;
private int _count;
public RemoveTokenEffect(PhysicalCard source, PhysicalCard target, Token token) {
this(source, target, token, 1);
}
public RemoveTokenEffect(PhysicalCard source, PhysicalCard target, Token token, int count) {
_source = source;
_target = target;
_token = token;
_count = count;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return game.getGameState().getTokenCount(_target, _token) >= _count;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public EffectResult.Type getType() {
return null;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
int tokenCount = game.getGameState().getTokenCount(_target, _token);
int removeTokens = Math.min(tokenCount, _count);
game.getGameState().removeTokens(_target, _token, removeTokens);
return new FullEffectResult(null, removeTokens == _count, removeTokens == _count);
}
}

View File

@@ -0,0 +1,65 @@
package com.gempukku.lotro.cards.set4.dunland;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.AddTokenEffect;
import com.gempukku.lotro.cards.effects.AddUntilEndOfPhaseModifierEffect;
import com.gempukku.lotro.cards.effects.RemoveTokenEffect;
import com.gempukku.lotro.cards.effects.RemoveTwilightEffect;
import com.gempukku.lotro.cards.modifiers.CancelStrengthBonusModifier;
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.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collections;
import java.util.List;
/**
* Set: The Two Towers
* Side: Shadow
* Culture: Dunland
* Twilight Cost: 0
* Type: Condition
* Game Text: Plays to your support area. Shadow: Remove (3) to place a [DUNLAND] token here. Skirmish: Spot
* a [DUNLAND] Man and remove a [DUNLAND] token from this card. A character skirmishing that [DUNLAND] Man does not gain
* strength bonuses from possessions.
*/
public class Card4_028 extends AbstractPermanent {
public Card4_028() {
super(Side.SHADOW, 0, CardType.CONDITION, Culture.DUNLAND, Zone.SUPPORT, "No Defense");
}
@Override
protected List<? extends Action> getExtraPhaseActions(String playerId, LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.SHADOW, self, 3)) {
ActivateCardAction action = new ActivateCardAction(self, Keyword.SHADOW);
action.appendCost(
new RemoveTwilightEffect(3));
action.appendEffect(
new AddTokenEffect(self, self, Token.DUNLAND));
return Collections.singletonList(action);
}
if (PlayConditions.canUseShadowCardDuringPhase(game.getGameState(), Phase.SKIRMISH, self, 0)
&& PlayConditions.canRemoveToken(game.getGameState(), self, Token.DUNLAND)
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.DUNLAND), Filters.race(Race.MAN))) {
final ActivateCardAction action = new ActivateCardAction(self, Keyword.SKIRMISH);
action.appendCost(
new RemoveTokenEffect(self, self, Token.DUNLAND));
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose DUNLAND Man", Filters.culture(Culture.DUNLAND), Filters.race(Race.MAN)) {
@Override
protected void cardSelected(PhysicalCard dunlandMan) {
action.appendEffect(
new AddUntilEndOfPhaseModifierEffect(
new CancelStrengthBonusModifier(self, Filters.and(Filters.type(CardType.POSSESSION), Filters.attachedTo(Filters.inSkirmishAgainst(Filters.sameCard(dunlandMan))))), Phase.SKIRMISH));
}
});
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -1,5 +1,7 @@
package com.gempukku.lotro.common;
public enum Token {
BURDEN, WOUND
BURDEN, WOUND,
DUNLAND
}

View File

@@ -457,7 +457,7 @@ public class GameState {
return _playerPosition.get(playerId);
}
private int getTokenCount(PhysicalCard physicalCard, Token token) {
public int getTokenCount(PhysicalCard physicalCard, Token token) {
Map<Token, Integer> tokens = _cardTokens.get(physicalCard);
if (tokens == null)
return 0;