"Calculated Risk"

This commit is contained in:
marcins78@gmail.com
2011-10-27 10:24:52 +00:00
parent d4ae6dc887
commit 7c74490f5c
3 changed files with 101 additions and 0 deletions

View File

@@ -136,6 +136,10 @@ public class PlayConditions {
return Filters.countSpottable(game.getGameState(), game.getModifiersQuerying(), filters) >= count;
}
public static boolean canAddThreat(LotroGame game, PhysicalCard card, int count) {
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION) - game.getGameState().getThreats() >= count;
}
public static boolean canExertMultiple(PhysicalCard source, LotroGame game, int times, int count, Filterable... filters) {
return canExertMultiple(source, game.getGameState(), game.getModifiersQuerying(), times, count, filters);
}

View File

@@ -0,0 +1,44 @@
package com.gempukku.lotro.cards.set7.dwarven;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.effects.AddThreatsEffect;
import com.gempukku.lotro.logic.effects.DrawCardEffect;
/**
* Set: The Return of the King
* Side: Free
* Culture: Dwarven
* Twilight Cost: 2
* Type: Event • Fellowship
* Game Text: Spot a Dwarf and add a threat to draw 3 cards.
*/
public class Card7_004 extends AbstractEvent {
public Card7_004() {
super(Side.FREE_PEOPLE, 2, Culture.DWARVEN, "Calculated Risk", Phase.FELLOWSHIP);
}
@Override
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
return super.checkPlayRequirements(playerId, game, self, twilightModifier)
&& PlayConditions.canSpot(game, Race.DWARF)
&& PlayConditions.canAddThreat(game, self, 1);
}
@Override
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
PlayEventAction action = new PlayEventAction(self);
action.appendCost(
new AddThreatsEffect(playerId, self, 1));
action.appendEffect(
new DrawCardEffect(playerId, 3));
return action;
}
}

View File

@@ -0,0 +1,53 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.common.CardType;
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.Action;
public class AddThreatsEffect extends AbstractEffect {
private Action _action;
private String _performingPlayer;
private PhysicalCard _source;
private int _count;
public AddThreatsEffect(String performingPlayer, PhysicalCard source, int count) {
_performingPlayer = performingPlayer;
_source = source;
_count = count;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return _count <= getThreatsPossibleToAdd(game);
}
@Override
public String getText(LotroGame game) {
return "Add " + _count + " threats";
}
@Override
public Type getType() {
return null;
}
private int getThreatsPossibleToAdd(LotroGame game) {
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION)
- game.getGameState().getThreats();
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
int toAdd = Math.min(_count, getThreatsPossibleToAdd(game));
if (toAdd > 0) {
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " adds " + toAdd + " threat" + ((toAdd > 1) ? "s" : ""));
game.getGameState().addThreats(game.getGameState().getCurrentPlayerId(), toAdd);
return new FullEffectResult(null, toAdd == _count, toAdd == _count);
}
return new FullEffectResult(null, false, false);
}
}