From 06dc5be2d8de6cdf9402a1ab070acdec5e382faa Mon Sep 17 00:00:00 2001 From: Susucre <34709007+Susucre@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:36:36 +0200 Subject: [PATCH] [WHO] Implement Davros, Dalek Creator (#11313) --- .../src/mage/cards/d/DavrosDalekCreator.java | 168 ++++++++++++++++++ .../src/mage/cards/s/SyggRiverCutthroat.java | 20 +-- Mage.Sets/src/mage/sets/DoctorWho.java | 1 + .../common/OpponentLostLifeCondition.java | 6 + 4 files changed, 184 insertions(+), 11 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java diff --git a/Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java b/Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java new file mode 100644 index 00000000000..419e23c33d7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DavrosDalekCreator.java @@ -0,0 +1,168 @@ +package mage.cards.d; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfEndStepTriggeredAbility; +import mage.abilities.condition.common.OpponentLostLifeCondition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.hint.Hint; +import mage.abilities.keyword.MenaceAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.FaceVillainousChoice; +import mage.choices.VillainousChoice; +import mage.constants.*; +import mage.game.Game; +import mage.game.permanent.token.DalekToken; +import mage.players.Player; +import mage.watchers.common.PlayerLostLifeWatcher; + +import java.util.Set; +import java.util.UUID; + +/** + * @author Susucr + */ +public final class DavrosDalekCreator extends CardImpl { + + public DavrosDalekCreator(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}{U}{B}{R}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.ALIEN); + this.subtype.add(SubType.SCIENTIST); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // Menace + this.addAbility(new MenaceAbility(false)); + + // At the beginning of your end step, create a 3/3 black Dalek artifact creature token with menace if an opponent lost 3 or more life this turn. Then each opponent who lost 3 or more life this turn faces a villainous choice -- You draw a card, or that player discards a card. + Ability ability = new BeginningOfEndStepTriggeredAbility( + new ConditionalOneShotEffect( + new CreateTokenEffect(new DalekToken()), + new OpponentLostLifeCondition(ComparisonType.OR_GREATER, 3) + ), + TargetController.YOU, false + ); + ability.addHint(DavrosDalekCreatorHint.instance); + ability.addEffect(new DavrosDalekCreatorEffect()); + + this.addAbility(ability); + } + + private DavrosDalekCreator(final DavrosDalekCreator card) { + super(card); + } + + @Override + public DavrosDalekCreator copy() { + return new DavrosDalekCreator(this); + } +} + +enum DavrosDalekCreatorHint implements Hint { + + instance; + + @Override + public String getText(Game game, Ability ability) { + if (!game.isActivePlayer(ability.getControllerId())) { + return ""; + } + + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); + String sep = ""; + String hint = "Opponents that lost 3 or more this turn: ["; + Set opponents = game.getOpponents(ability.getControllerId()); + if (watcher != null) { + for (UUID playerId : game.getState().getPlayersInRange(ability.getControllerId(), game)) { + if (!opponents.contains(playerId)) { + continue; + } + int lostLive = watcher.getLifeLost(playerId); + if (lostLive >= 3) { + Player player = game.getPlayer(playerId); + if (player != null) { + hint += sep + player.getName(); + sep = ", "; + } + } + } + } + return hint + "]"; + } + + @Override + public Hint copy() { + return instance; + } +} + + +class DavrosDalekCreatorEffect extends OneShotEffect { + + private static final FaceVillainousChoice choice = new FaceVillainousChoice( + Outcome.Detriment, new DavrosDalekCreatorFirstChoice(), new DavrosDalekCreatorSecondChoice() + ); + + DavrosDalekCreatorEffect() { + super(Outcome.Benefit); + staticText = "Then each opponent who lost 3 or more life this turn " + choice.generateRule(); + } + + private DavrosDalekCreatorEffect(final DavrosDalekCreatorEffect effect) { + super(effect); + } + + @Override + public DavrosDalekCreatorEffect copy() { + return new DavrosDalekCreatorEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class); + Set opponents = game.getOpponents(source.getControllerId()); + if (watcher != null) { + for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { + if (!opponents.contains(playerId)) { + continue; + } + int lostLive = watcher.getLifeLost(playerId); + if (lostLive >= 3) { + Player player = game.getPlayer(playerId); + if (player != null) { + choice.faceChoice(player, game, source); + } + } + } + } + return true; + } +} + +class DavrosDalekCreatorFirstChoice extends VillainousChoice { + DavrosDalekCreatorFirstChoice() { + super("You draw a card", "{controller} draws a card"); + } + + @Override + public boolean doChoice(Player player, Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + return controller != null && controller.drawCards(1, source, game) > 0; + } +} + +class DavrosDalekCreatorSecondChoice extends VillainousChoice { + DavrosDalekCreatorSecondChoice() { + super("that player discards a card", "you discard a card"); + } + + @Override + public boolean doChoice(Player player, Game game, Ability source) { + return !player.discard(1, false, false, source, game).isEmpty(); + } +} diff --git a/Mage.Sets/src/mage/cards/s/SyggRiverCutthroat.java b/Mage.Sets/src/mage/cards/s/SyggRiverCutthroat.java index a51d8e2cc32..4c7531deefa 100644 --- a/Mage.Sets/src/mage/cards/s/SyggRiverCutthroat.java +++ b/Mage.Sets/src/mage/cards/s/SyggRiverCutthroat.java @@ -1,6 +1,5 @@ package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.common.BeginningOfEndStepTriggeredAbility; import mage.abilities.condition.common.OpponentLostLifeCondition; @@ -8,21 +7,17 @@ import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.abilities.hint.ConditionHint; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.ComparisonType; -import mage.constants.SuperType; -import mage.constants.TargetController; -import mage.constants.Zone; +import mage.constants.*; + +import java.util.UUID; /** - * * @author LevelX2 */ public final class SyggRiverCutthroat extends CardImpl { public SyggRiverCutthroat(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{U/B}{U/B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{U/B}{U/B}"); this.supertype.add(SuperType.LEGENDARY); this.subtype.add(SubType.MERFOLK); this.subtype.add(SubType.ROGUE); @@ -34,9 +29,12 @@ public final class SyggRiverCutthroat extends CardImpl { this.addAbility(new BeginningOfEndStepTriggeredAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), TargetController.ANY, - new OpponentLostLifeCondition(ComparisonType.MORE_THAN, 2), + new OpponentLostLifeCondition(ComparisonType.OR_GREATER, 3), true - ).addHint(new ConditionHint(new OpponentLostLifeCondition(ComparisonType.MORE_THAN, 2), "An opponent lost 3 or more life this turn"))); + ).addHint(new ConditionHint( + new OpponentLostLifeCondition(ComparisonType.OR_GREATER, 3), + "An opponent lost 3 or more life this turn" + ))); } private SyggRiverCutthroat(final SyggRiverCutthroat card) { diff --git a/Mage.Sets/src/mage/sets/DoctorWho.java b/Mage.Sets/src/mage/sets/DoctorWho.java index c01322d9321..e8f5f0d6550 100644 --- a/Mage.Sets/src/mage/sets/DoctorWho.java +++ b/Mage.Sets/src/mage/sets/DoctorWho.java @@ -61,6 +61,7 @@ public final class DoctorWho extends ExpansionSet { cards.add(new SetCardInfo("Dalek Squadron", 65, Rarity.UNCOMMON, mage.cards.d.DalekSquadron.class)); cards.add(new SetCardInfo("Dan Lewis", 78, Rarity.RARE, mage.cards.d.DanLewis.class)); cards.add(new SetCardInfo("Darkwater Catacombs", 269, Rarity.RARE, mage.cards.d.DarkwaterCatacombs.class)); + cards.add(new SetCardInfo("Davros, Dalek Creator", 1, Rarity.MYTHIC, mage.cards.d.DavrosDalekCreator.class)); cards.add(new SetCardInfo("Day of Destiny", 206, Rarity.RARE, mage.cards.d.DayOfDestiny.class)); cards.add(new SetCardInfo("Decaying Time Loop", 80, Rarity.UNCOMMON, mage.cards.d.DecayingTimeLoop.class)); cards.add(new SetCardInfo("Delete", 81, Rarity.RARE, mage.cards.d.Delete.class)); diff --git a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java index 18e4a1552e7..03b27e9564d 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java @@ -42,12 +42,18 @@ public class OpponentLostLifeCondition extends IntCompareCondition { case MORE_THAN: sb.append(value + 1).append(" or more life this turn"); break; + case OR_GREATER: + sb.append(value).append(" or more life this turn"); + break; case EQUAL_TO: sb.append(value).append(" life this turn"); break; case FEWER_THAN: sb.append(" less than ").append(value).append(" life this turn"); break; + case OR_LESS: + sb.append(value).append(" or less life this turn"); + break; } return sb.toString(); }