This commit is contained in:
marcins78@gmail.com
2011-09-05 23:41:57 +00:00
parent fe12254cc1
commit e391086507
3 changed files with 115 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package com.gempukku.lotro.cards.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.timing.UnrespondableEffect;
public class MakeRingBearerEffect extends UnrespondableEffect {
private PhysicalCard _newRingBearer;
public MakeRingBearerEffect(PhysicalCard newRingBearer) {
_newRingBearer = newRingBearer;
}
@Override
public void playEffect(LotroGame game) {
if (game.getGameState().isWearingRing())
game.getGameState().setWearingRing(false);
PhysicalCard theOneRing = Filters.findFirstActive(game.getGameState(), game.getModifiersQuerying(), Filters.type(CardType.THE_ONE_RING));
game.getGameState().transferCard(theOneRing, _newRingBearer);
game.getGameState().setRingBearer(_newRingBearer);
}
}

View File

@@ -0,0 +1,80 @@
package com.gempukku.lotro.cards.set1.shire;
import com.gempukku.lotro.cards.AbstractCompanion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.MakeRingBearerEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Signet;
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.DefaultCostToEffectAction;
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.KillResult;
import java.util.Collections;
import java.util.List;
/**
* Set: The Fellowship of the Ring
* Side: Free
* Culture: Shire
* Twilight Cost: 2
* Type: Companion • Hobbit
* Strength: 3
* Vitality: 4
* Resistance: 6
* Signet: Frodo
* Game Text: Fellowship: Play Bill the Pony from your draw deck. Response: If Frodo dies, make Sam the Ring-bearer
* (resistance 5).
*/
public class Card1_310 extends AbstractCompanion {
public Card1_310() {
super(2, 3, 4, Culture.SHIRE, "Sam", true);
addKeyword(Keyword.HOBBIT);
setSignet(Signet.FRODO);
}
@Override
public int getResistance() {
return 5;
}
@Override
protected List<? extends Action> getExtraPhaseActions(final String playerId, final LotroGame game, final PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.FELLOWSHIP, self)) {
DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, Keyword.FELLOWSHIP, "Play Bill the Pony from your draw deck.");
action.addEffect(
new ChooseArbitraryCardsEffect(playerId, "Choose Bill the Pony to play", game.getGameState().getDeck(playerId),
Filters.and(Filters.name("Bill the Pony"), Filters.playable(game)), 0, 1) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
if (selectedCards.size() > 0) {
PhysicalCard selectedCard = selectedCards.get(0);
game.getActionsEnvironment().addActionToStack(selectedCard.getBlueprint().getPlayCardAction(playerId, game, selectedCard, 0));
}
}
});
return Collections.singletonList(action);
}
return null;
}
@Override
public List<? extends Action> getOptionalBeforeTriggers(String playerId, LotroGame lotroGame, Effect effect, EffectResult effectResult, PhysicalCard self) {
if (effectResult.getType() == EffectResult.Type.KILL) {
KillResult killResult = (KillResult) effectResult;
if (killResult.getKilledCard().getBlueprint().getName().equals("Frodo")) {
DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, Keyword.RESPONSE, "Make Sam the Ring-Bearer");
action.addEffect(new MakeRingBearerEffect(self));
return Collections.singletonList(action);
}
}
return null;
}
}

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.game.CompletePhysicalCardVisitor;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.PhysicalCardVisitor;
import com.gempukku.lotro.game.state.GameState;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import java.util.LinkedList;
@@ -60,6 +61,15 @@ public class Filters {
return visitor.getCounter();
}
public static Filter playable(final LotroGame game) {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return physicalCard.getBlueprint().checkPlayRequirements(physicalCard.getOwner(), game, physicalCard);
}
};
}
public static Filter any() {
return new Filter() {
@Override