Skip to content

Commit

Permalink
[LTR] Implement Dawn of a New Age (#10492)
Browse files Browse the repository at this point in the history
  • Loading branch information
LePwnerer authored Jun 24, 2023
1 parent 1d5ee8b commit 3896c28
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
88 changes: 88 additions & 0 deletions Mage.Sets/src/mage/cards/d/DawnOfANewAge.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package mage.cards.d;

import mage.abilities.Ability;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;

import java.util.UUID;

/**
*
* @author LePwnerer
*/
public final class DawnOfANewAge extends CardImpl {

public DawnOfANewAge(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}");

// Dawn of a New Age enters the battlefield with a hope counter on it for each creature you control.
DynamicValue numberCounters = new PermanentsOnBattlefieldCount(StaticFilters.FILTER_PERMANENT_CREATURE_CONTROLLED);
this.addAbility(new EntersBattlefieldAbility(new AddCountersSourceEffect(
CounterType.HOPE.createInstance(0), numberCounters, true),
"with a Hope counter on it for each creature you control")
);

// At the beginning of your end step, remove a hope counter from Dawn of a New Age. If you do, draw a card. Then if Dawn of a New Age has no hope counters on it, sacrifice it and you gain 4 life.
this.addAbility(new BeginningOfEndStepTriggeredAbility(new DawnOfANewAgeEffect(), TargetController.YOU, false));
}

private DawnOfANewAge(final DawnOfANewAge card) {
super(card);
}

@Override
public DawnOfANewAge copy() {
return new DawnOfANewAge(this);
}
}

class DawnOfANewAgeEffect extends OneShotEffect {

public DawnOfANewAgeEffect() {
super(Outcome.Sacrifice);
staticText = "remove a hope counter from {this}. If you do, draw a card. Then if {this} has no hope counters on it, sacrifice it and you gain 4 life";
}

private DawnOfANewAgeEffect(final DawnOfANewAgeEffect effect) {
super(effect);
}

@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (permanent != null && controller != null) {
int numCounters = permanent.getCounters(game).getCount(CounterType.HOPE);
if (numCounters >= 1) {
permanent.removeCounters(CounterType.HOPE.getName(), 1, source, game);
controller.drawCards(1, source, game);
numCounters -= 1;
}
if (numCounters == 0) {
permanent.sacrifice(source, game);
controller.gainLife(4, game, source);
}
return true;
}
return false;
}

@Override
public DawnOfANewAgeEffect copy() {
return new DawnOfANewAgeEffect(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ private TheLordOfTheRingsTalesOfMiddleEarth() {
cards.add(new SetCardInfo("Cirith Ungol Patrol", 80, Rarity.COMMON, mage.cards.c.CirithUngolPatrol.class));
cards.add(new SetCardInfo("Claim the Precious", 81, Rarity.COMMON, mage.cards.c.ClaimThePrecious.class));
cards.add(new SetCardInfo("Council's Deliberation", 46, Rarity.UNCOMMON, mage.cards.c.CouncilsDeliberation.class));
cards.add(new SetCardInfo("Dawn of a New Age", 5, Rarity.MYTHIC, mage.cards.d.DawnOfANewAge.class));
cards.add(new SetCardInfo("Deceive the Messenger", 47, Rarity.COMMON, mage.cards.d.DeceiveTheMessenger.class));
cards.add(new SetCardInfo("Delighted Halfling", 158, Rarity.RARE, mage.cards.d.DelightedHalfling.class));
cards.add(new SetCardInfo("Denethor, Ruling Steward", 198, Rarity.UNCOMMON, mage.cards.d.DenethorRulingSteward.class));
Expand Down
3 changes: 2 additions & 1 deletion Mage/src/main/java/mage/counters/CounterType.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public enum CounterType {
HIT("hit"),
HOOFPRINT("hoofprint"),
HONE("hone"),
HOPE("hope"),
HOUR("hour", "an"),
HOURGLASS("hourglass", "an"),
HUNGER("hunger"),
Expand Down Expand Up @@ -225,7 +226,7 @@ public enum CounterType {
}

CounterType(String name) {
this(name, "aeiou".contains("" + name.charAt(0)) ? "an" : "a");
this(name, "aeiou".contains( String.valueOf( name.charAt( 0 ) ) ) ? "an" : "a");
}

CounterType(String name, String article) {
Expand Down

0 comments on commit 3896c28

Please sign in to comment.