[LTR] Implement Faramir, Prince of Ithilien (#10595)

This commit is contained in:
Susucre 2023-07-08 19:09:10 +02:00 committed by GitHub
parent 5006ecc820
commit a7d49e1f45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 150 additions and 0 deletions

View file

@ -0,0 +1,144 @@
package mage.cards.f;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfPlayersNextEndStepDelayedTriggeredAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.game.Game;
import mage.game.permanent.token.HumanSoldierToken;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetOpponent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.common.PlayersAttackedThisTurnWatcher;
import java.util.UUID;
/**
*
* @author Susucr
*/
public final class FaramirPrinceOfIthilien extends CardImpl {
public FaramirPrinceOfIthilien(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{U}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.NOBLE);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// At the beginning of your end step, choose an opponent.
// At the beginning of that player's next end step,
// you draw a card if they didn't attack you that turn.
// Otherwise, create three 1/1 white Human Soldier creature tokens.
this.addAbility(new BeginningOfYourEndStepTriggeredAbility(new FaramirPrinceOfIthilienEffect(), false));
}
private FaramirPrinceOfIthilien(final FaramirPrinceOfIthilien card) {
super(card);
}
@Override
public FaramirPrinceOfIthilien copy() {
return new FaramirPrinceOfIthilien(this);
}
}
class FaramirPrinceOfIthilienEffect extends OneShotEffect {
FaramirPrinceOfIthilienEffect() {
super(Outcome.Neutral);
staticText = "choose an opponent. " +
"At the beginning of that player's next end step, " +
"you draw a card if they didn't attack you that turn. " +
"Otherwise, create three 1/1 white Human Soldier creature tokens.";
}
FaramirPrinceOfIthilienEffect(final FaramirPrinceOfIthilienEffect effect) {
super(effect);
}
@Override
public FaramirPrinceOfIthilienEffect copy() {
return new FaramirPrinceOfIthilienEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Target target = new TargetOpponent(true);
target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), source, game);
Player opponent = game.getPlayer(target.getFirstTarget());
if (opponent == null) {
return false;
}
Effect effect = new FaramirPrinceOfIthilienDelayedEffect();
effect.setTargetPointer(new FixedTarget(opponent.getId(), game));
game.addDelayedTriggeredAbility(
new AtTheBeginOfPlayersNextEndStepDelayedTriggeredAbility(
effect,
opponent.getId()
), source);
return true;
}
}
class FaramirPrinceOfIthilienDelayedEffect extends OneShotEffect {
FaramirPrinceOfIthilienDelayedEffect() {
super(Outcome.Benefit);
staticText = "you draw a card if the chosen player didn't attack you that turn. " +
"Otherwise, create three 1/1 white Human Soldier creature tokens.";
}
FaramirPrinceOfIthilienDelayedEffect(final FaramirPrinceOfIthilienDelayedEffect effect) {
super(effect);
}
@Override
public FaramirPrinceOfIthilienDelayedEffect copy() {
return new FaramirPrinceOfIthilienDelayedEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
PlayersAttackedThisTurnWatcher watcher = game.getState().getWatcher(PlayersAttackedThisTurnWatcher.class);
if(watcher == null){
return false;
}
UUID controllerId = source.getControllerId();
UUID targetId = getTargetPointer().getFirst(game, source);
Player controller = game.getPlayer(controllerId);
if(controller == null){
return false;
}
if(watcher.hasPlayerAttackedPlayer(targetId, controllerId)){
return new CreateTokenEffect(new HumanSoldierToken(), 3).apply(game, source);
} else {
return new DrawCardSourceControllerEffect(1).apply(game, source);
}
}
}

View file

@ -86,6 +86,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet {
cards.add(new SetCardInfo("Fall of Gil-galad", 165, Rarity.RARE, mage.cards.f.FallOfGilGalad.class));
cards.add(new SetCardInfo("Fangorn, Tree Shepherd", 166, Rarity.RARE, mage.cards.f.FangornTreeShepherd.class));
cards.add(new SetCardInfo("Faramir, Field Commander", 14, Rarity.UNCOMMON, mage.cards.f.FaramirFieldCommander.class));
cards.add(new SetCardInfo("Faramir, Prince of Ithilien", 202, Rarity.RARE, mage.cards.f.FaramirPrinceOfIthilien.class));
cards.add(new SetCardInfo("Fear, Fire, Foes!", 125, Rarity.UNCOMMON, mage.cards.f.FearFireFoes.class));
cards.add(new SetCardInfo("Fiery Inscription", 126, Rarity.UNCOMMON, mage.cards.f.FieryInscription.class));
cards.add(new SetCardInfo("Fire of Orthanc", 127, Rarity.COMMON, mage.cards.f.FireOfOrthanc.class));

View file

@ -59,6 +59,11 @@ public class PlayersAttackedThisTurnWatcher extends Watcher {
}
}
public boolean hasPlayerAttackedPlayer(UUID attacker, UUID defender){
PlayerList defendersList = playersAttackedThisTurn.getOrDefault(attacker, null);
return defendersList != null && defendersList.contains(defender);
}
public int getAttackedPlayersCount(UUID playerID) {
PlayerList defendersList = playersAttackedThisTurn.getOrDefault(playerID, null);
if (defendersList != null) {