"Dwarf-lords"

This commit is contained in:
marcins78@gmail.com
2011-12-15 13:55:01 +00:00
parent e748925ba4
commit 902ffdf6a5
5 changed files with 252 additions and 0 deletions

View File

@@ -45,6 +45,10 @@ public class PlayConditions {
return Filters.filter(game.getGameState().getHand(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(cardFilter, Filters.not(source))).size() >= count;
}
public static boolean canRemoveFromDiscardToPlay(PhysicalCard source, LotroGame game, String playerId, int count, Filterable... cardFilter) {
return Filters.filter(game.getGameState().getDiscard(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(cardFilter, Filters.not(source))).size() >= count;
}
public static boolean canPlayCardDuringPhase(LotroGame game, Phase phase, PhysicalCard self) {
return (phase == null || game.getGameState().getCurrentPhase() == phase)
&& self.getZone() == Zone.HAND

View File

@@ -0,0 +1,59 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.common.Zone;
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 java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class RemoveCardsFromDiscardEffect extends AbstractEffect {
private String _playerPerforming;
private PhysicalCard _source;
private Collection<PhysicalCard> _cardsToRemove;
public RemoveCardsFromDiscardEffect(String playerPerforming, PhysicalCard source, Collection<PhysicalCard> cardsToRemove) {
_playerPerforming = playerPerforming;
_source = source;
_cardsToRemove = cardsToRemove;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
for (PhysicalCard physicalCard : _cardsToRemove) {
if (physicalCard.getZone() != Zone.DISCARD)
return false;
}
return true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
Set<PhysicalCard> removedCards = new HashSet<PhysicalCard>();
for (PhysicalCard physicalCard : _cardsToRemove)
if (physicalCard.getZone() == Zone.DISCARD)
removedCards.add(physicalCard);
game.getGameState().removeCardsFromZone(_playerPerforming, removedCards);
for (PhysicalCard removedCard : removedCards)
game.getGameState().addCardToZone(game, removedCard, Zone.REMOVED);
game.getGameState().sendMessage(_playerPerforming + " removed " + GameUtils.getAppendedNames(removedCards) + " from discard using " + GameUtils.getCardLink(_source));
return new FullEffectResult(_cardsToRemove.size() == removedCards.size(), _cardsToRemove.size() == removedCards.size());
}
}

View File

@@ -0,0 +1,41 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
public class RemovePlayedEventFromGameEffect extends AbstractEffect {
private PlayEventAction _action;
public RemovePlayedEventFromGameEffect(PlayEventAction action) {
_action = action;
}
@Override
public String getText(LotroGame game) {
return "Remove " + GameUtils.getCardLink(_action.getEventPlayed()) + " from the game";
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (isPlayableInFull(game)) {
game.getGameState().sendMessage(_action.getPerformingPlayer() + " removes " + GameUtils.getCardLink(_action.getEventPlayed()) + " from the game");
_action.skipDiscardPart();
game.getGameState().addCardToZone(game, _action.getEventPlayed(), Zone.REMOVED);
return new FullEffectResult(true, true);
}
return new FullEffectResult(false, false);
}
}

View File

@@ -0,0 +1,94 @@
package com.gempukku.lotro.cards.effects.choose;
import com.gempukku.lotro.cards.effects.RemoveCardsFromDiscardEffect;
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.SubAction;
import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collection;
import java.util.List;
public class ChooseAndRemoveCardsFromDiscardEffect extends AbstractSubActionEffect {
private Action _action;
private PhysicalCard _source;
private String _playerId;
private int _minimum;
private int _maximum;
private Filterable[] _filters;
public ChooseAndRemoveCardsFromDiscardEffect(Action action, PhysicalCard source, String playerId, int minimum, int maximum, Filterable... filters) {
_action = action;
_source = source;
_playerId = playerId;
_minimum = minimum;
_maximum = maximum;
_filters = filters;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return Filters.filter(game.getGameState().getDiscard(_playerId), game.getGameState(), game.getModifiersQuerying(), _filters).size() >= _minimum;
}
@Override
public void playEffect(LotroGame game) {
final Collection<PhysicalCard> possibleTargets = Filters.filter(game.getGameState().getDiscard(_playerId), game.getGameState(), game.getModifiersQuerying(), _filters);
if (possibleTargets.size() <= _minimum) {
processForCards(possibleTargets);
} else {
int min = _minimum;
int max = Math.min(_maximum, possibleTargets.size());
game.getUserFeedback().sendAwaitingDecision(_playerId,
new ArbitraryCardsSelectionDecision(1, "Choose cards to remove from play", possibleTargets, min, max) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
final List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
processForCards(selectedCards);
}
});
}
}
private void processForCards(Collection<PhysicalCard> cards) {
SubAction subAction = new SubAction(_action);
subAction.appendEffect(
new RemoveCardsFromDiscardEffect(_playerId, _source, cards));
if (cards.size() < _minimum) {
// It has failed...
subAction.appendEffect(
new UnrespondableEffect() {
@Override
protected void doPlayEffect(LotroGame game) {
}
@Override
public boolean wasCarriedOut() {
return false;
}
@Override
public boolean wasSuccessful() {
return false;
}
});
}
}
}

View File

@@ -0,0 +1,54 @@
package com.gempukku.lotro.cards.set13.dwarven;
import com.gempukku.lotro.cards.AbstractEvent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.RemovePlayedEventFromGameEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveCardsFromDiscardEffect;
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.timing.Action;
import java.util.Collections;
import java.util.List;
/**
* Set: Bloodlines
* Side: Free
* Culture: Dwarven
* Twilight Cost: 2
* Type: Event • Skirmish
* Game Text: You may remove from the game 4 other [DWARVEN] cards in your discard pile to play this event from your
* discard pile. Then remove this event from the game. Make your Dwarf bearing a hand weapon strength +3.
*/
public class Card13_004 extends AbstractEvent {
public Card13_004() {
super(Side.FREE_PEOPLE, 2, Culture.DWARVEN, "Dwarf-lords", Phase.SKIRMISH);
}
@Override
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) {
PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseAndAddUntilEOPStrengthBonusEffect(action, self, playerId, 3, Filters.owner(playerId), Race.DWARF, Filters.hasAttached(PossessionClass.HAND_WEAPON)));
return action;
}
@Override
public List<? extends Action> getPhaseActionsFromDiscard(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.isPhase(game, Phase.SKIRMISH)
&& PlayConditions.canPlayFromDiscard(playerId, game, self)
&& PlayConditions.canRemoveFromDiscardToPlay(self, game, playerId, 4, Culture.DWARVEN)) {
final PlayEventAction action = getPlayCardAction(playerId, game, self, 0, false);
action.appendCost(
new ChooseAndRemoveCardsFromDiscardEffect(action, self, playerId, 4, 4, Culture.DWARVEN));
action.appendEffect(
new RemovePlayedEventFromGameEffect(action));
return Collections.singletonList(action);
}
return null;
}
}