From b245b493b83a3277807c3dbe5553812539712d20 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 24 Sep 2019 21:41:02 -0400 Subject: [PATCH] Implemented Outlaws' Merriment --- .../src/mage/cards/o/OutlawsMerriment.java | 55 +++++++++++++++++++ Mage.Sets/src/mage/sets/ThroneOfEldraine.java | 1 + .../ThroneOfEldraineCollectorsEdition.java | 1 + Mage/src/main/java/mage/abilities/Modes.java | 30 ++++++++-- .../token/OutlawsMerrimentClericToken.java | 35 ++++++++++++ .../token/OutlawsMerrimentRogueToken.java | 40 ++++++++++++++ .../token/OutlawsMerrimentWarriorToken.java | 35 ++++++++++++ 7 files changed, 193 insertions(+), 4 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/o/OutlawsMerriment.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentClericToken.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentRogueToken.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentWarriorToken.java diff --git a/Mage.Sets/src/mage/cards/o/OutlawsMerriment.java b/Mage.Sets/src/mage/cards/o/OutlawsMerriment.java new file mode 100644 index 0000000000..653fa86cf9 --- /dev/null +++ b/Mage.Sets/src/mage/cards/o/OutlawsMerriment.java @@ -0,0 +1,55 @@ +package mage.cards.o; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.TargetController; +import mage.game.permanent.token.OutlawsMerrimentClericToken; +import mage.game.permanent.token.OutlawsMerrimentRogueToken; +import mage.game.permanent.token.OutlawsMerrimentWarriorToken; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class OutlawsMerriment extends CardImpl { + + public OutlawsMerriment(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}{W}{W}"); + + // At the beginning of your upkeep, choose one at random. Create a red and white creature token with those characteristics. + // • 3/1 Human Warrior with trample and haste. + Ability ability = new BeginningOfUpkeepTriggeredAbility( + new CreateTokenEffect(new OutlawsMerrimentWarriorToken()) + .setText("3/1 Human Warrior with trample and haste"), + TargetController.YOU, false + ); + + // • 2/1 Human Cleric with lifelink and haste. + ability.addMode(new Mode(new CreateTokenEffect(new OutlawsMerrimentClericToken()) + .setText("2/1 Human Cleric with lifelink and haste"))); + + // • 1/2 Human Rogue with haste and "When this creature enters the battlefield, it deals 1 damage to any target." + ability.addMode(new Mode(new CreateTokenEffect(new OutlawsMerrimentRogueToken()) + .setText("1/2 Human Rogue with haste and \"When this creature enters the battlefield, it deals 1 damage to any target.\""))); + + ability.getModes().setChooseText("choose one at random. Create a red and white creature token with those characteristics."); + ability.getModes().setRandom(true); + + this.addAbility(ability); + } + + private OutlawsMerriment(final OutlawsMerriment card) { + super(card); + } + + @Override + public OutlawsMerriment copy() { + return new OutlawsMerriment(this); + } +} diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java index 778ce2282f..2a8c83a769 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraine.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraine.java @@ -206,6 +206,7 @@ public final class ThroneOfEldraine extends ExpansionSet { cards.add(new SetCardInfo("Opt", 59, Rarity.COMMON, mage.cards.o.Opt.class)); cards.add(new SetCardInfo("Order of Midnight", 99, Rarity.UNCOMMON, mage.cards.o.OrderOfMidnight.class)); cards.add(new SetCardInfo("Outflank", 23, Rarity.COMMON, mage.cards.o.Outflank.class)); + cards.add(new SetCardInfo("Outlaws' Merriment", 198, Rarity.MYTHIC, mage.cards.o.OutlawsMerriment.class)); cards.add(new SetCardInfo("Outmuscle", 170, Rarity.COMMON, mage.cards.o.Outmuscle.class)); cards.add(new SetCardInfo("Overwhelmed Apprentice", 60, Rarity.UNCOMMON, mage.cards.o.OverwhelmedApprentice.class)); cards.add(new SetCardInfo("Piper of the Swarm", 100, Rarity.RARE, mage.cards.p.PiperOfTheSwarm.class)); diff --git a/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java b/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java index 3d22d30c87..9606cef6f0 100644 --- a/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java +++ b/Mage.Sets/src/mage/sets/ThroneOfEldraineCollectorsEdition.java @@ -78,6 +78,7 @@ public final class ThroneOfEldraineCollectorsEdition extends ExpansionSet { cards.add(new SetCardInfo("Once Upon a Time", 371, Rarity.RARE, mage.cards.o.OnceUponATime.class)); cards.add(new SetCardInfo("Opportunistic Dragon", 364, Rarity.RARE, mage.cards.o.OpportunisticDragon.class)); cards.add(new SetCardInfo("Order of Midnight", 288, Rarity.UNCOMMON, mage.cards.o.OrderOfMidnight.class)); + cards.add(new SetCardInfo("Outlaws' Merriment", 382, Rarity.MYTHIC, mage.cards.o.OutlawsMerriment.class)); cards.add(new SetCardInfo("Piper of the Swarm", 355, Rarity.RARE, mage.cards.p.PiperOfTheSwarm.class)); cards.add(new SetCardInfo("Queen of Ice", 285, Rarity.COMMON, mage.cards.q.QueenOfIce.class)); cards.add(new SetCardInfo("Questing Beast", 372, Rarity.MYTHIC, mage.cards.q.QuestingBeast.class)); diff --git a/Mage/src/main/java/mage/abilities/Modes.java b/Mage/src/main/java/mage/abilities/Modes.java index d74e678baf..68bccffbd6 100644 --- a/Mage/src/main/java/mage/abilities/Modes.java +++ b/Mage/src/main/java/mage/abilities/Modes.java @@ -9,6 +9,7 @@ import mage.filter.FilterPlayer; import mage.game.Game; import mage.players.Player; import mage.target.common.TargetOpponent; +import mage.util.RandomUtil; import java.util.*; @@ -27,6 +28,8 @@ public class Modes extends LinkedHashMap { private final Map duplicateModes = new LinkedHashMap<>(); private OptionalAdditionalModeSourceCosts optionalAdditionalModeSourceCosts = null; // only set if costs have to be paid private Filter maxModesFilter = null; // calculates the max number of available modes + private boolean isRandom = false; + private String chooseText = null; public Modes() { this.currentMode = new Mode(); @@ -56,6 +59,8 @@ public class Modes extends LinkedHashMap { this.optionalAdditionalModeSourceCosts = modes.optionalAdditionalModeSourceCosts; this.maxModesFilter = modes.maxModesFilter; // can't change so no copy needed + this.isRandom = modes.isRandom; + this.chooseText = modes.chooseText; if (modes.getSelectedModes().isEmpty()) { this.currentMode = values().iterator().next(); } else { @@ -163,6 +168,12 @@ public class Modes extends LinkedHashMap { if (this.size() > 1) { this.selectedModes.clear(); this.duplicateModes.clear(); + if (this.isRandom) { + List modes = getAvailableModes(source, game); + int r = RandomUtil.nextInt(modes.size()); + this.addSelectedMode(modes.get(r).getId()); + return true; + } // check if mode modifying abilities exist Card card = game.getCard(source.getSourceId()); if (card != null) { @@ -332,7 +343,9 @@ public class Modes extends LinkedHashMap { return this.getMode().getEffects().getText(this.getMode()); } StringBuilder sb = new StringBuilder(); - if (this.getMaxModesFilter() != null) { + if (this.chooseText != null) { + sb.append(chooseText); + } else if (this.getMaxModesFilter() != null) { sb.append("choose one or more. Each mode must target ").append(getMaxModesFilter().getMessage()); } else if (this.getMinModes() == 0 && this.getMaxModes() == 1) { sb.append("choose up to one"); @@ -357,11 +370,13 @@ public class Modes extends LinkedHashMap { } if (isEachModeMoreThanOnce()) { - sb.append(". You may choose the same mode more than once.
"); - } else { - sb.append(" —
"); + sb.append(". You may choose the same mode more than once."); + } else if (chooseText == null) { + sb.append(" —"); } + sb.append("
"); + for (Mode mode : this.values()) { sb.append("&bull "); sb.append(mode.getEffects().getTextStartingUpperCase(mode)); @@ -401,4 +416,11 @@ public class Modes extends LinkedHashMap { this.optionalAdditionalModeSourceCosts = optionalAdditionalModeSourceCosts; } + public void setRandom(boolean isRandom) { + this.isRandom = isRandom; + } + + public void setChooseText(String chooseText) { + this.chooseText = chooseText; + } } diff --git a/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentClericToken.java b/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentClericToken.java new file mode 100644 index 0000000000..e6553091f6 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentClericToken.java @@ -0,0 +1,35 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.LifelinkAbility; +import mage.constants.CardType; +import mage.constants.SubType; + +/** + * @author TheElk801 + */ +public final class OutlawsMerrimentClericToken extends TokenImpl { + + public OutlawsMerrimentClericToken() { + super("Human Cleric", "2/1 Human Cleric with lifelink and haste"); + cardType.add(CardType.CREATURE); + subtype.add(SubType.HUMAN); + subtype.add(SubType.CLERIC); + color.setWhite(true); + color.setRed(true); + power = new MageInt(2); + toughness = new MageInt(1); + + this.addAbility(LifelinkAbility.getInstance()); + this.addAbility(HasteAbility.getInstance()); + } + + private OutlawsMerrimentClericToken(final OutlawsMerrimentClericToken token) { + super(token); + } + + public OutlawsMerrimentClericToken copy() { + return new OutlawsMerrimentClericToken(this); + } +} diff --git a/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentRogueToken.java b/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentRogueToken.java new file mode 100644 index 0000000000..11d4f52d8f --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentRogueToken.java @@ -0,0 +1,40 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.abilities.keyword.HasteAbility; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.target.common.TargetAnyTarget; + +/** + * @author TheElk801 + */ +public final class OutlawsMerrimentRogueToken extends TokenImpl { + + public OutlawsMerrimentRogueToken() { + super("Human Rogue", "1/2 Human Rogue with haste and \"When this creature enters the battlefield, it deals 1 damage to any target.\""); + cardType.add(CardType.CREATURE); + subtype.add(SubType.HUMAN); + subtype.add(SubType.ROGUE); + color.setWhite(true); + color.setRed(true); + power = new MageInt(1); + toughness = new MageInt(2); + + this.addAbility(HasteAbility.getInstance()); + Ability ability = new EntersBattlefieldTriggeredAbility(new DamageTargetEffect(1, "it")); + ability.addTarget(new TargetAnyTarget()); + this.addAbility(ability); + } + + private OutlawsMerrimentRogueToken(final OutlawsMerrimentRogueToken token) { + super(token); + } + + public OutlawsMerrimentRogueToken copy() { + return new OutlawsMerrimentRogueToken(this); + } +} diff --git a/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentWarriorToken.java b/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentWarriorToken.java new file mode 100644 index 0000000000..fdf816a51d --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/OutlawsMerrimentWarriorToken.java @@ -0,0 +1,35 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.keyword.HasteAbility; +import mage.abilities.keyword.TrampleAbility; +import mage.constants.CardType; +import mage.constants.SubType; + +/** + * @author TheElk801 + */ +public final class OutlawsMerrimentWarriorToken extends TokenImpl { + + public OutlawsMerrimentWarriorToken() { + super("Human Warrior", "3/1 Human Warrior with trample and haste"); + cardType.add(CardType.CREATURE); + subtype.add(SubType.HUMAN); + subtype.add(SubType.WARRIOR); + color.setWhite(true); + color.setRed(true); + power = new MageInt(3); + toughness = new MageInt(1); + + this.addAbility(TrampleAbility.getInstance()); + this.addAbility(HasteAbility.getInstance()); + } + + private OutlawsMerrimentWarriorToken(final OutlawsMerrimentWarriorToken token) { + super(token); + } + + public OutlawsMerrimentWarriorToken copy() { + return new OutlawsMerrimentWarriorToken(this); + } +}