updated Bonfire of the Damned, added a new method for getting a player or planeswalker's controller

This commit is contained in:
Evan Kranzler 2018-04-19 16:01:44 -04:00
parent 9fe08dd438
commit 1e27d7222a
3 changed files with 24 additions and 9 deletions

View file

@ -50,8 +50,7 @@ import mage.target.TargetPlayer;
public class BonfireOfTheDamned extends CardImpl { public class BonfireOfTheDamned extends CardImpl {
public BonfireOfTheDamned(UUID ownerId, CardSetInfo setInfo) { public BonfireOfTheDamned(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{X}{R}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{R}");
// Bonfire of the Damned deals X damage to target player and each creature he or she controls. // Bonfire of the Damned deals X damage to target player and each creature he or she controls.
this.getSpellAbility().addEffect(new BonfireOfTheDamnedEffect()); this.getSpellAbility().addEffect(new BonfireOfTheDamnedEffect());
@ -77,7 +76,7 @@ class BonfireOfTheDamnedEffect extends OneShotEffect {
public BonfireOfTheDamnedEffect() { public BonfireOfTheDamnedEffect() {
super(Outcome.Damage); super(Outcome.Damage);
staticText = "{this} deals X damage to target player and each creature he or she controls"; staticText = "{this} deals X damage to target player or planeswalker and each creature that player or that planeswalkers controller controls";
} }
public BonfireOfTheDamnedEffect(final BonfireOfTheDamnedEffect effect) { public BonfireOfTheDamnedEffect(final BonfireOfTheDamnedEffect effect) {
@ -86,12 +85,12 @@ class BonfireOfTheDamnedEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getFirstTarget()); Player player = game.getPlayerOrPlaneswalkerController(source.getFirstTarget());
if (player != null) { if (player != null) {
int damage = source.getManaCostsToPay().getX(); int damage = source.getManaCostsToPay().getX();
if (damage > 0) { if (damage > 0) {
player.damage(damage, source.getSourceId(), game, false, true); player.damage(damage, source.getSourceId(), game, false, true);
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) { for (Permanent perm : game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
perm.damage(damage, source.getSourceId(), game, false, true); perm.damage(damage, source.getSourceId(), game, false, true);
} }
} }

View file

@ -132,6 +132,8 @@ public interface Game extends MageItem, Serializable {
Player getPlayer(UUID playerId); Player getPlayer(UUID playerId);
Player getPlayerOrPlaneswalkerController(UUID playerId);
Players getPlayers(); Players getPlayers();
PlayerList getPlayerList(); PlayerList getPlayerList();

View file

@ -306,6 +306,20 @@ public abstract class GameImpl implements Game, Serializable {
return state.getPlayer(playerId); return state.getPlayer(playerId);
} }
@Override
public Player getPlayerOrPlaneswalkerController(UUID playerId) {
Player player = getPlayer(playerId);
if (player != null) {
return player;
}
Permanent permanent = getPermanent(playerId);
if (permanent == null) {
return null;
}
player = getPlayer(permanent.getControllerId());
return player;
}
@Override @Override
public MageObject getObject(UUID objectId) { public MageObject getObject(UUID objectId) {
if (objectId == null) { if (objectId == null) {
@ -1565,14 +1579,14 @@ public abstract class GameImpl implements Game, Serializable {
} }
state.addCommandObject(newPlane); state.addCommandObject(newPlane);
informPlayers("You have planeswalked to " + newPlane.getLogName()); informPlayers("You have planeswalked to " + newPlane.getLogName());
// Fire off the planeswalked event // Fire off the planeswalked event
GameEvent event = new GameEvent(GameEvent.EventType.PLANESWALK, newPlane.getId(), null, newPlane.getId(), 0, true); GameEvent event = new GameEvent(GameEvent.EventType.PLANESWALK, newPlane.getId(), null, newPlane.getId(), 0, true);
if (!replaceEvent(event)) { if (!replaceEvent(event)) {
GameEvent ge = new GameEvent(GameEvent.EventType.PLANESWALKED, newPlane.getId(), null, newPlane.getId(), 0, true); GameEvent ge = new GameEvent(GameEvent.EventType.PLANESWALKED, newPlane.getId(), null, newPlane.getId(), 0, true);
fireEvent(ge); fireEvent(ge);
} }
return true; return true;
} }