[LTR] Implement Aragorn, Company Leader

This commit is contained in:
theelk801 2023-06-14 22:00:17 -04:00
parent 04f1327816
commit 018a815eb1
3 changed files with 100 additions and 5 deletions

View file

@ -0,0 +1,95 @@
package mage.cards.a;
import mage.MageInt;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.TheRingTemptsYouChooseAnotherTriggeredAbility;
import mage.abilities.effects.common.counter.AddCounterChoiceSourceEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class AragornCompanyLeader extends CardImpl {
public AragornCompanyLeader(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{W}");
this.supertype.add(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.RANGER);
this.power = new MageInt(3);
this.toughness = new MageInt(3);
// Whenever the Ring tempts you, if you chose a creature other than Aragorn, Company Leader as your Ring-bearer, put your choice of a counter from among first strike, vigilance, deathtouch, and lifelink on Aragorn.
this.addAbility(new TheRingTemptsYouChooseAnotherTriggeredAbility(new AddCounterChoiceSourceEffect(
CounterType.FIRST_STRIKE, CounterType.VIGILANCE, CounterType.DEATHTOUCH, CounterType.LIFELINK
).setText("put your choice of a counter from among first strike, vigilance, deathtouch, and lifelink on {this}")));
// Whenever you put one or more counters on Aragorn, put one of each of those kinds of counters on up to one other target creature.
this.addAbility(new AragornCompanyLeaderTriggeredAbility());
}
private AragornCompanyLeader(final AragornCompanyLeader card) {
super(card);
}
@Override
public AragornCompanyLeader copy() {
return new AragornCompanyLeader(this);
}
}
class AragornCompanyLeaderTriggeredAbility extends TriggeredAbilityImpl {
AragornCompanyLeaderTriggeredAbility() {
super(Zone.BATTLEFIELD, null);
this.addTarget(new TargetPermanent(0, 1, StaticFilters.FILTER_ANOTHER_TARGET_CREATURE));
}
private AragornCompanyLeaderTriggeredAbility(final AragornCompanyLeaderTriggeredAbility ability) {
super(ability);
}
@Override
public AragornCompanyLeaderTriggeredAbility copy() {
return new AragornCompanyLeaderTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.COUNTERS_ADDED;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!isControlledBy(event.getPlayerId()) || !event.getTargetId().equals(getSourceId())) {
return false;
}
CounterType counterType = CounterType.findByName(event.getData());
if (counterType == null) {
return false;
}
this.getEffects().clear();
this.addEffect(new AddCountersTargetEffect(counterType.createInstance()));
return true;
}
@Override
public String getRule() {
return "Whenever you put one or more counters on {this}, " +
"put one of each of those kinds of counters on up to one other target creature.";
}
}

View file

@ -19,6 +19,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet {
this.hasBoosters = false; // temporary
cards.add(new SetCardInfo("Aragorn and Arwen, Wed", 287, Rarity.MYTHIC, mage.cards.a.AragornAndArwenWed.class));
cards.add(new SetCardInfo("Aragorn, Company Leader", 191, Rarity.RARE, mage.cards.a.AragornCompanyLeader.class));
cards.add(new SetCardInfo("Aragorn, the Uniter", 192, Rarity.MYTHIC, mage.cards.a.AragornTheUniter.class));
cards.add(new SetCardInfo("Arwen Undomiel", 194, Rarity.UNCOMMON, mage.cards.a.ArwenUndomiel.class));
cards.add(new SetCardInfo("Arwen's Gift", 39, Rarity.COMMON, mage.cards.a.ArwensGift.class));

View file

@ -12,10 +12,7 @@ import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -56,7 +53,9 @@ public class AddCounterChoiceSourceEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
Permanent permanent = Optional
.ofNullable(game.getPermanentEntering(source.getSourceId()))
.orElseGet(() -> source.getSourcePermanentIfItStillExists(game));
if (player == null || permanent == null) {
return false;
}