Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Dungeon Master and Nira, Hellkite Duelist #5995

Closed
wants to merge 9 commits into from
144 changes: 144 additions & 0 deletions Mage.Sets/src/mage/cards/d/DungeonMaster.java
@@ -0,0 +1,144 @@
package mage.cards.d;

import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility;
import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.CreateTokenTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.game.Game;
import mage.game.permanent.token.*;
import mage.game.turn.TurnMod;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetOpponent;

import java.util.Random;
import java.util.UUID;

/**
* @author jmharmon
*/

public final class DungeonMaster extends CardImpl {

public DungeonMaster(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{2}{W}{U}");

this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DUNGEON_MASTER);

Random rnd = new Random();
int number = 0;
number = rnd.nextInt(4)+2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use xmage's RandomUtil.nextInt(), not java


if (number == 2) {
this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(2));
}
else if (number == 3) {
this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(3));
}
else if (number == 4) {
this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(4));
}
else if (number == 5) {
this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(5));
}

// +1: Target opponent creates a 1/1 black Skeleton creature token with “When this creature dies, each opponent gains 2 life.”
LoyaltyAbility ability = new LoyaltyAbility(new CreateTokenTargetEffect(new SkeletonToken2()), 1);
Target target = new TargetOpponent();
ability.addTarget(target);
this.addAbility(ability);

// +1: Roll a d20. If you roll a 1, skip your next turn. If you roll a 12 or higher, draw a card.
LoyaltyAbility ability2 = new LoyaltyAbility(new DungeonMasterRollDieEffect(), 1);
this.addAbility(ability2);

// −6: You get an adventuring party. (Your party is a 3/3 red Fighter with first strike, a 1/1 white Cleric with lifelink, a 2/2 black Rogue with hexproof, and a 1/1 blue Wizard with flying.)
LoyaltyAbility ability3 = new LoyaltyAbility(new DungeonMasterAdventuringPartyEffect(), -6);
this.addAbility(ability3);
}

public DungeonMaster(final DungeonMaster card) {
super(card);
}

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

class DungeonMasterRollDieEffect extends OneShotEffect {

public DungeonMasterRollDieEffect() {
super(Outcome.DrawCard);
staticText = "Roll a d20. If you roll a 1, skip your next turn. If you roll a 12 or higher, draw a card";
}

public DungeonMasterRollDieEffect(final DungeonMasterRollDieEffect effect) {
super(effect);
}

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

@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = controller.rollDice(game, 20);
if (amount == 1) {
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), true));
}
else if (amount >= 12) {
controller.drawCards(1, game);
}
return true;
}
return false;
}
}

class DungeonMasterAdventuringPartyEffect extends OneShotEffect {

public DungeonMasterAdventuringPartyEffect() {
super(Outcome.PutCreatureInPlay);
this.staticText = "You get an adventuring party. (Your party is a 3/3 red Fighter with first strike, a 1/1 white Cleric with lifelink, a 2/2 black Rogue with hexproof, and a 1/1 blue Wizard with flying.)";
}

public DungeonMasterAdventuringPartyEffect(final DungeonMasterAdventuringPartyEffect effect) {
super(effect);
}

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

@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
CreateTokenEffect effect = new CreateTokenEffect(new FighterToken(), 1);
effect.apply(game, source);
CreateTokenEffect effect1 = new CreateTokenEffect(new ClericToken(), 1);
effect1.apply(game,source);
CreateTokenEffect effect2 = new CreateTokenEffect(new RogueToken(), 1);
effect2.apply(game, source);
CreateTokenEffect effect3 = new CreateTokenEffect(new WizardToken2(), 1);
effect3.apply(game, source);
return true;
}
return false;
}
}
100 changes: 100 additions & 0 deletions Mage.Sets/src/mage/cards/n/NiraHellkiteDuelist.java
@@ -0,0 +1,100 @@
package mage.cards.n;

import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlashAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;

import java.util.UUID;

/**
* @author jmharmon
*/

public final class NiraHellkiteDuelist extends CardImpl {

public NiraHellkiteDuelist(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}{U}{B}{R}{G}");

this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.DRAGON);

this.power = new MageInt(6);
this.toughness = new MageInt(6);

// Flash
this.addAbility(FlashAbility.getInstance());

// Flying, trample, haste
this.addAbility(FlyingAbility.getInstance());
this.addAbility(TrampleAbility.getInstance());
this.addAbility(HasteAbility.getInstance());

// When Nira, Hellkite Duelist enters the battlefield, the next time you would lose the game this turn, instead draw three cards and your life total becomes 5.
this.addAbility(new EntersBattlefieldAbility(new NiraHellkiteDuelistEffect(), false));
}

public NiraHellkiteDuelist(final NiraHellkiteDuelist card) {
super(card);
}

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

class NiraHellkiteDuelistEffect extends ReplacementEffectImpl {

public NiraHellkiteDuelistEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
staticText = "the next time you would lose the game this turn, instead draw three cards and your life total becomes 5";
}

public NiraHellkiteDuelistEffect(final NiraHellkiteDuelistEffect effect) {
super(effect);
}

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

@Override
public boolean apply(Game game, Ability source) {
return true;
}

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId());
if (player != null) {
player.drawCards(3, game);
player.setLife(5, game, source);
}
return true;
}

@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.LOSES;
}

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getPlayerId().equals(source.getControllerId())) {
return true;
}
return false;
}
}
2 changes: 2 additions & 0 deletions Mage.Sets/src/mage/sets/HeroesOfTheRealm.java
Expand Up @@ -20,5 +20,7 @@ private HeroesOfTheRealm() {
this.hasBasicLands = false;

cards.add(new SetCardInfo("Chandra, Gremlin Wrangler", 1, Rarity.MYTHIC, mage.cards.c.ChandraGremlinWrangler.class));
cards.add(new SetCardInfo("Dungeon Master", 2, Rarity.MYTHIC, mage.cards.d.DungeonMaster.class));
cards.add(new SetCardInfo("Nira, Hellkite Duelist", 3,Rarity.MYTHIC, mage.cards.n.NiraHellkiteDuelist.class));
}
}
2 changes: 2 additions & 0 deletions Mage/src/main/java/mage/constants/SubType.java
Expand Up @@ -139,6 +139,7 @@ public enum SubType {
// F
FAERIE("Faerie", SubTypeSet.CreatureType),
FERRET("Ferret", SubTypeSet.CreatureType),
FIGHTER("Fighter", SubTypeSet.CreatureType, true), // 2016 Heroes of the Realm
FISH("Fish", SubTypeSet.CreatureType),
FLAGBEARER("Flagbearer", SubTypeSet.CreatureType),
FOX("Fox", SubTypeSet.CreatureType),
Expand Down Expand Up @@ -392,6 +393,7 @@ public enum SubType {
DOMRI("Domri", SubTypeSet.PlaneswalkerType),
DOOKU("Dooku", SubTypeSet.PlaneswalkerType, true), // Star Wars
DOVIN("Dovin", SubTypeSet.PlaneswalkerType),
DUNGEON_MASTER("Dungeon Master", SubTypeSet.PlaneswalkerType, true), // 2016 Heroes of the Realm
ELSPETH("Elspeth", SubTypeSet.PlaneswalkerType),
ESTRID("Estrid", SubTypeSet.PlaneswalkerType),
FREYALISE("Freyalise", SubTypeSet.PlaneswalkerType),
Expand Down
31 changes: 31 additions & 0 deletions Mage/src/main/java/mage/game/permanent/token/ClericToken.java
@@ -0,0 +1,31 @@
package mage.game.permanent.token;

import mage.MageInt;
import mage.abilities.keyword.LifelinkAbility;
import mage.constants.CardType;
import mage.constants.SubType;

/**
* @author jmharmon
*/

public final class ClericToken extends TokenImpl {

public ClericToken() {
super("Cleric", "1/1 white Cleric creature token with lifelink");
cardType.add(CardType.CREATURE);
color.setWhite(true);
subtype.add(SubType.CLERIC);
power = new MageInt(1);
toughness = new MageInt(1);
addAbility(LifelinkAbility.getInstance());
}

public ClericToken(final ClericToken token) {
super(token);
}

public ClericToken copy() {
return new ClericToken(this);
}
}
31 changes: 31 additions & 0 deletions Mage/src/main/java/mage/game/permanent/token/FighterToken.java
@@ -0,0 +1,31 @@
package mage.game.permanent.token;

import mage.MageInt;
import mage.abilities.keyword.FirstStrikeAbility;
import mage.constants.CardType;
import mage.constants.SubType;

/**
* @author jmharmon
*/

public final class FighterToken extends TokenImpl {

public FighterToken(){
super("Fighter", "3/3 red Fighter creature token with first strike");
cardType.add(CardType.CREATURE);
color.setRed(true);
subtype.add(SubType.FIGHTER);
power = new MageInt(3);
toughness = new MageInt(3);
addAbility(FirstStrikeAbility.getInstance());
}

public FighterToken(final FighterToken token) {
super(token);
}

public FighterToken copy() {
return new FighterToken(this);
}
}
31 changes: 31 additions & 0 deletions Mage/src/main/java/mage/game/permanent/token/RogueToken.java
@@ -0,0 +1,31 @@
package mage.game.permanent.token;

import mage.MageInt;
import mage.abilities.keyword.HexproofAbility;
import mage.constants.CardType;
import mage.constants.SubType;

/**
* @author jmharmon
*/

public final class RogueToken extends TokenImpl {

public RogueToken() {
super("Rogue", "2/2 black Rogue creature token with hexproof");
cardType.add(CardType.CREATURE);
color.setBlack(true);
subtype.add(SubType.ROGUE);
power = new MageInt(2);
toughness = new MageInt(2);
addAbility(HexproofAbility.getInstance());
}

public RogueToken(final RogueToken token) {
super(token);
}

public RogueToken copy() {
return new RogueToken(this);
}
}