fixed Oath of Mages not dealing damage from the correct source

This commit is contained in:
Evan Kranzler 2020-01-08 16:36:28 -05:00
parent f4e2e6fdf1
commit 35b4bc6103

View file

@ -1,4 +1,3 @@
package mage.cards.o;
import mage.MageObject;
@ -29,12 +28,14 @@ public final class OathOfMages extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}");
// At the beginning of each player's upkeep, that player chooses target player who has more life than they do and is their opponent. The first player may have Oath of Mages deal 1 damage to the second player.
Ability ability = new BeginningOfUpkeepTriggeredAbility(new OathOfMagesEffect(), TargetController.ANY, false);
Ability ability = new BeginningOfUpkeepTriggeredAbility(
new OathOfMagesEffect(), TargetController.ANY, false
);
ability.setTargetAdjuster(OathOfMagesAdjuster.instance);
this.addAbility(ability);
}
public OathOfMages(final OathOfMages card) {
private OathOfMages(final OathOfMages card) {
super(card);
}
@ -49,22 +50,24 @@ enum OathOfMagesAdjuster implements TargetAdjuster {
private static final FilterPlayer filter = new FilterPlayer();
static {
filter.add(new OathOfMagesPredicate());
filter.add(OathOfMagesPredicate.instance);
}
@Override
public void adjustTargets(Ability ability, Game game) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
if (activePlayer != null) {
ability.getTargets().clear();
TargetPlayer target = new TargetPlayer(1, 1, false, filter);
target.setTargetController(activePlayer.getId());
ability.getTargets().add(target);
if (activePlayer == null) {
return;
}
ability.getTargets().clear();
TargetPlayer target = new TargetPlayer(1, 1, false, filter);
target.setTargetController(activePlayer.getId());
ability.getTargets().add(target);
}
}
class OathOfMagesPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Player>> {
enum OathOfMagesPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Player>> {
instance;
@Override
public boolean apply(ObjectSourcePlayer<Player> input, Game game) {
@ -89,12 +92,13 @@ class OathOfMagesPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePl
class OathOfMagesEffect extends OneShotEffect {
public OathOfMagesEffect() {
OathOfMagesEffect() {
super(Outcome.Damage);
staticText = "that player chooses target player who has more life than they do and is their opponent. The first player may have Oath of Mages deal 1 damage to the second player";
staticText = "that player chooses target player who has more life than they do and is their opponent. " +
"The first player may have {this} deal 1 damage to the second player";
}
public OathOfMagesEffect(OathOfMagesEffect effect) {
private OathOfMagesEffect(OathOfMagesEffect effect) {
super(effect);
}
@ -107,7 +111,7 @@ class OathOfMagesEffect extends OneShotEffect {
return false;
}
if (firstPlayer.chooseUse(outcome, "Deal one damage to " + secondPlayer.getLogName() + "?", source, game)) {
secondPlayer.damage(1, source.getId(), game, false, true);
secondPlayer.damage(1, source.getSourceId(), game, false, true);
}
return true;
}