[RNA] implemented Awaken the Erstwhile

This commit is contained in:
Oleg Agafonov 2019-01-09 04:58:29 +04:00
parent 8aa44b28a4
commit 563028043c
2 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,85 @@
package mage.cards.a;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.token.ZombieToken;
import mage.players.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author JayDi85
*/
public final class AwakenTheErstwhile extends CardImpl {
public AwakenTheErstwhile(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
// Each player discards all the cards in their hand, then creates that many 2/2 black Zombie creature tokens.
this.getSpellAbility().addEffect(new AwakenTheErstwhileEffect());
}
public AwakenTheErstwhile(final AwakenTheErstwhile card) {
super(card);
}
@Override
public AwakenTheErstwhile copy() {
return new AwakenTheErstwhile(this);
}
}
class AwakenTheErstwhileEffect extends OneShotEffect {
public AwakenTheErstwhileEffect() {
super(Outcome.Detriment);
this.staticText = "each player discards all the cards in their hand, then creates that many 2/2 black Zombie creature tokens";
}
public AwakenTheErstwhileEffect(final AwakenTheErstwhileEffect effect) {
super(effect);
}
@Override
public AwakenTheErstwhileEffect copy() {
return new AwakenTheErstwhileEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
// discard hands
Map<UUID, Integer> cardsAmount = new HashMap<>();
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int cardsInHand = player.getHand().size();
if (cardsInHand > 0) {
player.discard(cardsInHand, false, source, game);
cardsAmount.put(playerId, cardsInHand);
}
}
}
// create tokens
for (UUID playerId : cardsAmount.keySet()) {
Player player = game.getPlayer(playerId);
int tokensCount = cardsAmount.get(playerId);
if (player != null && tokensCount > 0) {
new ZombieToken().putOntoBattlefield(tokensCount, game, source.getSourceId(), player.getId());
}
}
return true;
}
return false;
}
}

View file

@ -39,6 +39,7 @@ public final class RavnicaAllegiance extends ExpansionSet {
cards.add(new SetCardInfo("Angelic Exaltation", 2, Rarity.UNCOMMON, mage.cards.a.AngelicExaltation.class)); cards.add(new SetCardInfo("Angelic Exaltation", 2, Rarity.UNCOMMON, mage.cards.a.AngelicExaltation.class));
cards.add(new SetCardInfo("Archway Angel", 3, Rarity.UNCOMMON, mage.cards.a.ArchwayAngel.class)); cards.add(new SetCardInfo("Archway Angel", 3, Rarity.UNCOMMON, mage.cards.a.ArchwayAngel.class));
cards.add(new SetCardInfo("Arrester's Admonition", 31, Rarity.COMMON, mage.cards.a.ArrestersAdmonition.class)); cards.add(new SetCardInfo("Arrester's Admonition", 31, Rarity.COMMON, mage.cards.a.ArrestersAdmonition.class));
cards.add(new SetCardInfo("Awaken the Erstwhile", 61, Rarity.RARE, mage.cards.a.AwakenTheErstwhile.class));
cards.add(new SetCardInfo("Azorius Guildgate", 243, Rarity.COMMON, mage.cards.a.AzoriusGuildgate.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Azorius Guildgate", 243, Rarity.COMMON, mage.cards.a.AzoriusGuildgate.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Azorius Guildgate", 244, Rarity.COMMON, mage.cards.a.AzoriusGuildgate.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Azorius Guildgate", 244, Rarity.COMMON, mage.cards.a.AzoriusGuildgate.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Azorius Locket", 231, Rarity.COMMON, mage.cards.a.AzoriusLocket.class)); cards.add(new SetCardInfo("Azorius Locket", 231, Rarity.COMMON, mage.cards.a.AzoriusLocket.class));