From 0b85d145d43a6afb6532d396fc0441d3cb4001fe Mon Sep 17 00:00:00 2001 From: Sidorovich77 Date: Fri, 9 Aug 2024 12:46:56 +0300 Subject: [PATCH 1/2] Implemented cards: The Red Terror --- Mage.Sets/src/mage/cards/t/TheRedTerror.java | 92 ++++++++++++++++++++ Mage.Sets/src/mage/sets/Warhammer40000.java | 1 + 2 files changed, 93 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/t/TheRedTerror.java diff --git a/Mage.Sets/src/mage/cards/t/TheRedTerror.java b/Mage.Sets/src/mage/cards/t/TheRedTerror.java new file mode 100644 index 000000000000..4fd8169beefd --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TheRedTerror.java @@ -0,0 +1,92 @@ +package mage.cards.t; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.counter.AddCountersSourceEffect; +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.game.Game; +import mage.game.events.DamagedBatchAllEvent; +import mage.game.events.DamagedEvent; +import mage.game.events.GameEvent; + +import java.util.UUID; + +/** + * @author Sidorovich77 + */ +public final class TheRedTerror extends CardImpl { + + + public TheRedTerror(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.TYRANID); + this.power = new MageInt(4); + this.toughness = new MageInt(3); + + // Whenever a red source you control deals damage to one or more permanents and/or players, put a +1/+1 counter on The Red Terror. + this.addAbility(new TheRedTerrorTriggeredAbility().withFlavorWord("Advanced Species")); + + } + + private TheRedTerror(final TheRedTerror card) { + super(card); + } + + @Override + public TheRedTerror copy() { + return new TheRedTerror(this); + } +} + +class TheRedTerrorTriggeredAbility extends TriggeredAbilityImpl { + + TheRedTerrorTriggeredAbility() { + super(Zone.BATTLEFIELD, new AddCountersSourceEffect( + CounterType.P1P1.createInstance(1), false + ).setText("put a +1/+1 counter on {this}")); + setTriggerPhrase("Whenever a red source you control deals damage to one or more permanents and/or players, "); + } + + private TheRedTerrorTriggeredAbility(final TheRedTerrorTriggeredAbility ability) { + super(ability); + } + + @Override + public TheRedTerrorTriggeredAbility copy() { + return new TheRedTerrorTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGED_BATCH_FOR_ALL; + } + + public boolean checkTrigger(GameEvent event, Game game) { + DamagedBatchAllEvent batchAllEvent = (DamagedBatchAllEvent) event; + for (DamagedEvent batchAllEvent1 : batchAllEvent.getEvents()) { + int damage = ((DamagedBatchAllEvent) event) + .getEvents() + .stream() + .filter(damagedEvent -> isControlledBy(game.getControllerId(damagedEvent.getAttackerId()))) + .mapToInt(GameEvent::getAmount) + .sum(); + if (damage < 1) { + return false; + } + MageObject sourceObject = game.getObject(batchAllEvent1.getSourceId()); + if (sourceObject != null && sourceObject.getColor(game).isRed()) { + return true; + } + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/Warhammer40000.java b/Mage.Sets/src/mage/sets/Warhammer40000.java index b08d1cf8c48d..89f825bc5552 100644 --- a/Mage.Sets/src/mage/sets/Warhammer40000.java +++ b/Mage.Sets/src/mage/sets/Warhammer40000.java @@ -265,6 +265,7 @@ private Warhammer40000() { cards.add(new SetCardInfo("The Golden Throne", 157, Rarity.RARE, mage.cards.t.TheGoldenThrone.class)); cards.add(new SetCardInfo("The Horus Heresy", 126, Rarity.RARE, mage.cards.t.TheHorusHeresy.class)); cards.add(new SetCardInfo("The Lost and the Damned", 129, Rarity.UNCOMMON, mage.cards.t.TheLostAndTheDamned.class)); + cards.add(new SetCardInfo("The Red Terror", 83, Rarity.RARE, mage.cards.t.TheRedTerror.class)); cards.add(new SetCardInfo("The Swarmlord", 4, Rarity.MYTHIC, mage.cards.t.TheSwarmlord.class)); cards.add(new SetCardInfo("The War in Heaven", 69, Rarity.RARE, mage.cards.t.TheWarInHeaven.class)); cards.add(new SetCardInfo("Their Name Is Death", 62, Rarity.RARE, mage.cards.t.TheirNameIsDeath.class)); From 3a8b1ede59e4eb241842cbc8f307baef8c71a985 Mon Sep 17 00:00:00 2001 From: karapuzz14 Date: Wed, 14 Aug 2024 22:21:34 +0300 Subject: [PATCH 2/2] Minor fix. --- Mage.Sets/src/mage/cards/t/TheRedTerror.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Mage.Sets/src/mage/cards/t/TheRedTerror.java b/Mage.Sets/src/mage/cards/t/TheRedTerror.java index 4fd8169beefd..26261c7acf32 100644 --- a/Mage.Sets/src/mage/cards/t/TheRedTerror.java +++ b/Mage.Sets/src/mage/cards/t/TheRedTerror.java @@ -82,6 +82,7 @@ public boolean checkTrigger(GameEvent event, Game game) { if (damage < 1) { return false; } + MageObject sourceObject = game.getObject(batchAllEvent1.getSourceId()); if (sourceObject != null && sourceObject.getColor(game).isRed()) { return true;