added damagePlayerOrPlaneswalker method to Game to make some things easier, fixed some more cards

This commit is contained in:
Evan Kranzler 2018-04-20 09:59:03 -04:00
parent 687d3bdc97
commit e6bb4f4b83
6 changed files with 41 additions and 25 deletions

View file

@ -50,7 +50,7 @@ import mage.target.targetpointer.FixedTarget;
public class Hellrider extends CardImpl {
public Hellrider(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{R}");
this.subtype.add(SubType.DEVIL);
this.power = new MageInt(3);
@ -95,7 +95,7 @@ class HellriderTriggeredAbility extends TriggeredAbilityImpl {
public boolean checkTrigger(GameEvent event, Game game) {
Permanent source = game.getPermanent(event.getSourceId());
if (source != null && source.getControllerId().equals(controllerId)) {
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(event.getSourceId(), game);
UUID defendingPlayerId = game.getCombat().getDefenderId(event.getSourceId());
this.getEffects().get(0).setTargetPointer(new FixedTarget(defendingPlayerId));
return true;
}
@ -104,6 +104,6 @@ class HellriderTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "Whenever a creature you control attacks, {this} deals 1 damage to defending player.";
return "Whenever a creature you control attacks, {this} deals 1 damage to the player or planeswalker its attacking.";
}
}

View file

@ -40,7 +40,6 @@ import mage.constants.SubType;
import mage.constants.Outcome;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
/**
@ -58,7 +57,6 @@ public class MageSlayer extends CardImpl {
// Equip {3}
this.addAbility(new EquipAbility(Outcome.Benefit, new GenericManaCost(3), new TargetControlledCreaturePermanent()));
}
public MageSlayer(final MageSlayer card) {
@ -75,7 +73,7 @@ class MageSlayerEffect extends OneShotEffect {
public MageSlayerEffect() {
super(Outcome.Damage);
staticText = "it deals damage equal to its power to defending player";
staticText = "it deals damage equal to the player or planeswalker its attacking";
}
public MageSlayerEffect(final MageSlayerEffect effect) {
@ -92,13 +90,11 @@ class MageSlayerEffect extends OneShotEffect {
Permanent equipment = game.getPermanent(source.getSourceId());
if (equipment != null && equipment.getAttachedTo() != null) {
int power = game.getPermanent(equipment.getAttachedTo()).getPower().getValue();
UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(equipment.getAttachedTo(), game);
if (power > 0 && defendingPlayerId != null) {
Player defendingPlayer = game.getPlayer(defendingPlayerId);
UUID defenderId = game.getCombat().getDefenderId(equipment.getAttachedTo());
if (power > 0 && defenderId != null) {
UUID sourceId = (UUID) this.getValue("sourceId");
if (sourceId != null && defendingPlayer != null) {
defendingPlayer.damage(power, source.getSourceId(), game, false, true);
if (sourceId != null) {
game.damagePlayerOrPlaneswalker(defenderId, power, source.getSourceId(), game, false, true);
}
}
return true;

View file

@ -40,8 +40,8 @@ import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetPlayerOrPlaneswalker;
/**
*
@ -50,14 +50,13 @@ import mage.target.common.TargetControlledCreaturePermanent;
public class RiteOfConsumption extends CardImpl {
public RiteOfConsumption(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// As an additional cost to cast Rite of Consumption, sacrifice a creature.
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,new FilterControlledCreaturePermanent("a creature"), false)));
this.getSpellAbility().addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature"), false)));
// Rite of Consumption deals damage equal to the sacrificed creature's power to target player. You gain life equal to the damage dealt this way.
this.getSpellAbility().addEffect(new RiteOfConsumptionEffect());
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addTarget(new TargetPlayerOrPlaneswalker());
}
public RiteOfConsumption(final RiteOfConsumption card) {
@ -74,7 +73,7 @@ class RiteOfConsumptionEffect extends OneShotEffect {
public RiteOfConsumptionEffect() {
super(Outcome.Benefit);
this.staticText = "{this} deals damage equal to the sacrificed creature's power to target player. You gain life equal to the damage dealt this way";
this.staticText = "{this} deals damage equal to the sacrificed creature's power to target player or planeswalker. You gain life equal to the damage dealt this way";
}
public RiteOfConsumptionEffect(final RiteOfConsumptionEffect effect) {
@ -88,14 +87,13 @@ class RiteOfConsumptionEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (targetPlayer != null && controller != null) {
if (controller != null) {
Permanent sacrificedCreature = null;
for (Cost cost :source.getCosts()) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
SacrificeTargetCost sacCost = (SacrificeTargetCost) cost;
for(Permanent permanent : sacCost.getPermanents()) {
for (Permanent permanent : sacCost.getPermanents()) {
sacrificedCreature = permanent;
break;
}
@ -104,7 +102,7 @@ class RiteOfConsumptionEffect extends OneShotEffect {
if (sacrificedCreature != null) {
int damage = sacrificedCreature.getPower().getValue();
if (damage > 0) {
int damageDealt = targetPlayer.damage(damage, source.getSourceId(), game, false, true);
int damageDealt = game.damagePlayerOrPlaneswalker(source.getFirstTarget(), damage, source.getSourceId(), game, false, true);
if (damageDealt > 0) {
controller.gainLife(damage, game, source);
}

View file

@ -49,9 +49,9 @@ import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.TargetPlayer;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.common.TargetPlayerOrPlaneswalker;
/**
*
@ -92,7 +92,7 @@ public class WanderingMage extends CardImpl {
ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new PreventDamageToTargetEffect(Duration.EndOfTurn, 2), new ManaCostsImpl("{B}"));
ability.addCost(new WanderingMageCost());
ability.addTarget(new TargetPlayer());
ability.addTarget(new TargetPlayerOrPlaneswalker());
Target target = new TargetControlledCreaturePermanent();
target.setNotTarget(true);
ability.addTarget(target);

View file

@ -471,4 +471,8 @@ public interface Game extends MageItem, Serializable {
UUID getMonarchId();
void setMonarchId(Ability source, UUID monarchId);
int damagePlayerOrPlaneswalker(UUID playerOrWalker, int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable);
int damagePlayerOrPlaneswalker(UUID playerOrWalker, int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List<UUID> appliedEffects);
}

View file

@ -3159,4 +3159,22 @@ public abstract class GameImpl implements Game, Serializable {
fireEvent(new GameEvent(GameEvent.EventType.BECOMES_MONARCH, monarchId, source == null ? null : source.getSourceId(), monarchId));
}
}
@Override
public int damagePlayerOrPlaneswalker(UUID playerOrWalker, int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable) {
return damagePlayerOrPlaneswalker(playerOrWalker, damage, sourceId, game, combatDamage, preventable, null);
}
@Override
public int damagePlayerOrPlaneswalker(UUID playerOrWalker, int damage, UUID sourceId, Game game, boolean combatDamage, boolean preventable, List<UUID> appliedEffects) {
Player player = getPlayer(playerOrWalker);
if (player != null) {
return player.damage(damage, sourceId, game, combatDamage, preventable, appliedEffects);
}
Permanent permanent = getPermanent(playerOrWalker);
if (permanent != null) {
return permanent.damage(damage, sourceId, game, combatDamage, preventable, appliedEffects);
}
return 0;
}
}