mirror of
https://github.com/correl/mage.git
synced 2024-11-25 11:09:53 +00:00
[LTR] Implement Peregrin Took (#10451)
Tested with Chatterfang and Academy Manufactor, functions as expected. Replacement effect obviously based off Chatterfang's.
This commit is contained in:
parent
7daafe27f1
commit
ad9d8ec2df
2 changed files with 105 additions and 0 deletions
104
Mage.Sets/src/mage/cards/p/PeregrinTook.java
Normal file
104
Mage.Sets/src/mage/cards/p/PeregrinTook.java
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
package mage.cards.p;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import mage.MageInt;
|
||||||
|
import mage.abilities.Ability;
|
||||||
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
|
import mage.abilities.effects.ReplacementEffectImpl;
|
||||||
|
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
|
||||||
|
import mage.constants.*;
|
||||||
|
import mage.cards.CardImpl;
|
||||||
|
import mage.cards.CardSetInfo;
|
||||||
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.events.CreateTokenEvent;
|
||||||
|
import mage.game.events.GameEvent;
|
||||||
|
import mage.game.permanent.token.FoodToken;
|
||||||
|
import mage.game.permanent.token.Token;
|
||||||
|
import mage.target.common.TargetControlledPermanent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Grath
|
||||||
|
*/
|
||||||
|
public final class PeregrinTook extends CardImpl {
|
||||||
|
|
||||||
|
private static final FilterControlledPermanent filter = new FilterControlledPermanent(SubType.FOOD, "Foods");
|
||||||
|
|
||||||
|
public PeregrinTook(UUID ownerId, CardSetInfo setInfo) {
|
||||||
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
|
||||||
|
|
||||||
|
this.supertype.add(SuperType.LEGENDARY);
|
||||||
|
this.subtype.add(SubType.HALFLING);
|
||||||
|
this.subtype.add(SubType.CITIZEN);
|
||||||
|
this.power = new MageInt(2);
|
||||||
|
this.toughness = new MageInt(3);
|
||||||
|
|
||||||
|
// If one or more tokens would be created under your control, those tokens plus an additional Food token are created instead.
|
||||||
|
this.addAbility(new SimpleStaticAbility(new PeregrinTookReplacementEffect()));
|
||||||
|
|
||||||
|
// Sacrifice three Foods: Draw a card.
|
||||||
|
this.addAbility(new SimpleActivatedAbility(
|
||||||
|
new DrawCardSourceControllerEffect(1),
|
||||||
|
new SacrificeTargetCost(new TargetControlledPermanent(3, filter))
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
private PeregrinTook(final PeregrinTook card) {
|
||||||
|
super(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PeregrinTook copy() {
|
||||||
|
return new PeregrinTook(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PeregrinTookReplacementEffect extends ReplacementEffectImpl {
|
||||||
|
|
||||||
|
public PeregrinTookReplacementEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||||
|
this.staticText = "If one or more tokens would be created under your control, those tokens plus an additional Food token are created instead";
|
||||||
|
}
|
||||||
|
|
||||||
|
private PeregrinTookReplacementEffect(final PeregrinTookReplacementEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PeregrinTookReplacementEffect copy() {
|
||||||
|
return new PeregrinTookReplacementEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checksEventType(GameEvent event, Game game) {
|
||||||
|
return event.getType() == GameEvent.EventType.CREATE_TOKEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||||
|
return source.isControlledBy(event.getPlayerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
|
||||||
|
if (event instanceof CreateTokenEvent) {
|
||||||
|
CreateTokenEvent tokenEvent = (CreateTokenEvent) event;
|
||||||
|
FoodToken foodToken = null;
|
||||||
|
Map<Token, Integer> tokens = tokenEvent.getTokens();
|
||||||
|
for (Map.Entry<Token, Integer> entry : tokens.entrySet()) {
|
||||||
|
if (entry.getKey() instanceof FoodToken) {
|
||||||
|
foodToken = (FoodToken) entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (foodToken == null) {
|
||||||
|
foodToken = new FoodToken();
|
||||||
|
}
|
||||||
|
tokens.put(foodToken, tokens.getOrDefault(foodToken, 0) + 1);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -105,6 +105,7 @@ public final class TheLordOfTheRingsTalesOfMiddleEarth extends ExpansionSet {
|
||||||
cards.add(new SetCardInfo("Oliphaunt", 139, Rarity.COMMON, mage.cards.o.Oliphaunt.class));
|
cards.add(new SetCardInfo("Oliphaunt", 139, Rarity.COMMON, mage.cards.o.Oliphaunt.class));
|
||||||
cards.add(new SetCardInfo("Olog-hai Crusher", 140, Rarity.COMMON, mage.cards.o.OlogHaiCrusher.class));
|
cards.add(new SetCardInfo("Olog-hai Crusher", 140, Rarity.COMMON, mage.cards.o.OlogHaiCrusher.class));
|
||||||
cards.add(new SetCardInfo("One Ring to Rule Them All", 102, Rarity.RARE, mage.cards.o.OneRingToRuleThemAll.class));
|
cards.add(new SetCardInfo("One Ring to Rule Them All", 102, Rarity.RARE, mage.cards.o.OneRingToRuleThemAll.class));
|
||||||
|
cards.add(new SetCardInfo("Peregrin Took", 181, Rarity.UNCOMMON, mage.cards.p.PeregrinTook.class));
|
||||||
cards.add(new SetCardInfo("Pippin's Bravery", 182, Rarity.COMMON, mage.cards.p.PippinsBravery.class));
|
cards.add(new SetCardInfo("Pippin's Bravery", 182, Rarity.COMMON, mage.cards.p.PippinsBravery.class));
|
||||||
cards.add(new SetCardInfo("Plains", 262, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS));
|
cards.add(new SetCardInfo("Plains", 262, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS));
|
||||||
cards.add(new SetCardInfo("Prince Imrahil the Fair", 219, Rarity.UNCOMMON, mage.cards.p.PrinceImrahilTheFair.class));
|
cards.add(new SetCardInfo("Prince Imrahil the Fair", 219, Rarity.UNCOMMON, mage.cards.p.PrinceImrahilTheFair.class));
|
||||||
|
|
Loading…
Reference in a new issue