Merge pull request #8397 from weirddan455/tyrant

[AFC] Implemented Death Tyrant
This commit is contained in:
Daniel Bomar 2021-10-22 14:06:30 -05:00 committed by GitHub
commit ad0d802ed2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 152 additions and 2 deletions

View file

@ -0,0 +1,104 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.ReturnSourceFromGraveyardToBattlefieldEffect;
import mage.constants.SubType;
import mage.abilities.keyword.MenaceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.ZombieToken;
/**
*
* @author weirddan455
*/
public final class DeathTyrant extends CardImpl {
public DeathTyrant(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}");
this.subtype.add(SubType.BEHOLDER);
this.subtype.add(SubType.SKELETON);
this.power = new MageInt(4);
this.toughness = new MageInt(6);
// Menace
this.addAbility(new MenaceAbility());
// Negative Energy Cone Whenever an attacking creature you control or a blocking creature an opponent controls dies, create a 2/2 black Zombie creature token.
this.addAbility(new DeathTyrantTriggeredAbility().withFlavorWord("Negative Energy Cone"));
// {5}{B}: Return Death Tyrant from your graveyard to the battlefield tapped.
this.addAbility(new SimpleActivatedAbility(
Zone.GRAVEYARD, new ReturnSourceFromGraveyardToBattlefieldEffect(true),
new ManaCostsImpl<>("{5}{B}")
));
}
private DeathTyrant(final DeathTyrant card) {
super(card);
}
@Override
public DeathTyrant copy() {
return new DeathTyrant(this);
}
}
class DeathTyrantTriggeredAbility extends TriggeredAbilityImpl {
public DeathTyrantTriggeredAbility() {
super(Zone.ALL, new CreateTokenEffect(new ZombieToken()));
}
private DeathTyrantTriggeredAbility(final DeathTyrantTriggeredAbility ability) {
super(ability);
}
@Override
public DeathTyrantTriggeredAbility copy() {
return new DeathTyrantTriggeredAbility(this);
}
@Override
public boolean checkEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ZONE_CHANGE;
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.isDiesEvent()) {
Permanent permanent = game.getPermanentOrLKIBattlefield(zEvent.getTargetId());
if (permanent != null && permanent.isCreature(game)) {
if (permanent.isControlledBy(controllerId) && permanent.isAttacking()) {
return true;
}
return game.getOpponents(controllerId).contains(permanent.getControllerId()) && permanent.getBlocking() > 0;
}
}
return false;
}
@Override
public boolean isInUseableZone(Game game, MageObject source, GameEvent event) {
return TriggeredAbilityImpl.isInUseableZoneDiesTrigger(this, event, game);
}
@Override
public String getTriggerPhrase() {
return "Whenever an attacking creature you control or a blocking creature an opponent controls dies, ";
}
}

View file

@ -79,6 +79,7 @@ public final class ForgottenRealmsCommander extends ExpansionSet {
cards.add(new SetCardInfo("Dark-Dweller Oracle", 119, Rarity.RARE, mage.cards.d.DarkDwellerOracle.class));
cards.add(new SetCardInfo("Darkwater Catacombs", 232, Rarity.RARE, mage.cards.d.DarkwaterCatacombs.class));
cards.add(new SetCardInfo("Dead Man's Chest", 97, Rarity.RARE, mage.cards.d.DeadMansChest.class));
cards.add(new SetCardInfo("Death Tyrant", 23, Rarity.RARE, mage.cards.d.DeathTyrant.class));
cards.add(new SetCardInfo("Decree of Savagery", 156, Rarity.RARE, mage.cards.d.DecreeOfSavagery.class));
cards.add(new SetCardInfo("Demanding Dragon", 120, Rarity.RARE, mage.cards.d.DemandingDragon.class));
cards.add(new SetCardInfo("Desert", 233, Rarity.UNCOMMON, mage.cards.d.Desert.class));

View file

@ -0,0 +1,45 @@
package org.mage.test.cards.single.afc;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
public class DeathTyrantTest extends CardTestPlayerBase {
@Test
public void attackerDies() {
addCard(Zone.BATTLEFIELD, playerA, "Death Tyrant", 1);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears", 1);
addCard(Zone.BATTLEFIELD, playerB, "Hill Giant", 1);
attack(1, playerA, "Grizzly Bears");
block(1, playerB, "Hill Giant", "Grizzly Bears");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerA, "Grizzly Bears", 1);
assertPermanentCount(playerA, "Zombie", 1);
assertPermanentCount(playerA, "Death Tyrant", 1);
assertPermanentCount(playerB, "Hill Giant", 1);
}
@Test
public void blockerDies() {
addCard(Zone.BATTLEFIELD, playerA, "Death Tyrant", 1);
addCard(Zone.BATTLEFIELD, playerA, "Hill Giant", 1);
addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears", 1);
attack(1, playerA, "Hill Giant");
block(1, playerB, "Grizzly Bears", "Hill Giant");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertGraveyardCount(playerB, "Grizzly Bears", 1);
assertPermanentCount(playerA, "Zombie", 1);
assertPermanentCount(playerA, "Death Tyrant", 1);
assertPermanentCount(playerA, "Hill Giant", 1);
}
}

View file

@ -382,8 +382,8 @@ public final class ZonesHandler {
} else if (event.getTarget() != null) {
card.setFaceDown(info.faceDown, game);
Permanent target = event.getTarget();
success = game.getPlayer(target.getControllerId()).removeFromBattlefield(target, source, game)
&& target.removeFromZone(game, fromZone, source);
success = target.removeFromZone(game, fromZone, source)
&& game.getPlayer(target.getControllerId()).removeFromBattlefield(target, source, game);
} else {
card.setFaceDown(info.faceDown, game);
success = card.removeFromZone(game, fromZone, source);