diff --git a/Mage.Sets/src/mage/cards/s/SamLoyalAttendant.java b/Mage.Sets/src/mage/cards/s/SamLoyalAttendant.java new file mode 100644 index 00000000000..0cf26437cd9 --- /dev/null +++ b/Mage.Sets/src/mage/cards/s/SamLoyalAttendant.java @@ -0,0 +1,89 @@ +package mage.cards.s; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.ActivatedAbility; +import mage.abilities.common.BeginningOfCombatTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.cost.CostModificationEffectImpl; +import mage.abilities.keyword.PartnerWithAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.FoodToken; +import mage.util.CardUtil; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class SamLoyalAttendant extends CardImpl { + + public SamLoyalAttendant(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HALFLING); + this.subtype.add(SubType.PEASANT); + this.power = new MageInt(2); + this.toughness = new MageInt(4); + + // Partner with Frodo, Adventurous Hobbit + this.addAbility(new PartnerWithAbility("Frodo, Adventurous Hobbit")); + + // At the beginning of combat on your turn, create a Food token. + this.addAbility(new BeginningOfCombatTriggeredAbility( + new CreateTokenEffect(new FoodToken()), TargetController.YOU, false + )); + + // Activated abilities of Foods you control cost {1} less to activate. + this.addAbility(new SimpleStaticAbility(new SamLoyalAttendantEffect())); + } + + private SamLoyalAttendant(final SamLoyalAttendant card) { + super(card); + } + + @Override + public SamLoyalAttendant copy() { + return new SamLoyalAttendant(this); + } +} + +class SamLoyalAttendantEffect extends CostModificationEffectImpl { + + SamLoyalAttendantEffect() { + super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); + staticText = "activated abilities of Foods you control cost {1} less to activate"; + } + + private SamLoyalAttendantEffect(SamLoyalAttendantEffect effect) { + super(effect); + } + + @Override + public SamLoyalAttendantEffect copy() { + return new SamLoyalAttendantEffect(this); + } + + @Override + public boolean apply(Game game, Ability source, Ability abilityToModify) { + CardUtil.reduceCost(abilityToModify, 1); + return true; + } + + @Override + public boolean applies(Ability abilityToModify, Ability source, Game game) { + if (!(abilityToModify instanceof ActivatedAbility)) { + return false; + } + Permanent permanent = abilityToModify.getSourcePermanentIfItStillExists(game); + return permanent != null + && permanent.isControlledBy(source.getControllerId()) + && permanent.hasSubtype(SubType.FOOD, game); + } +} diff --git a/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java b/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java index fdc6edc48c5..a498c9564f5 100644 --- a/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java +++ b/Mage.Sets/src/mage/sets/TalesOfMiddleEarthCommander.java @@ -17,6 +17,7 @@ public final class TalesOfMiddleEarthCommander extends ExpansionSet { this.hasBasicLands = false; cards.add(new SetCardInfo("Ensnaring Bridge", 350, Rarity.MYTHIC, mage.cards.e.EnsnaringBridge.class)); + cards.add(new SetCardInfo("Sam, Loyal Attendant", 7, Rarity.MYTHIC, mage.cards.s.SamLoyalAttendant.class)); cards.add(new SetCardInfo("Sol Ring", 284, Rarity.UNCOMMON, mage.cards.s.SolRing.class)); cards.add(new SetCardInfo("The Great Henge", 348, Rarity.MYTHIC, mage.cards.t.TheGreatHenge.class)); cards.add(new SetCardInfo("Wasteland", 376, Rarity.MYTHIC, mage.cards.w.Wasteland.class));