mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
* Spellskite - Fixed a bug that wrong log message was written if target was chnaged from a player to spellskite.
This commit is contained in:
parent
334f919ef9
commit
63c6aa226a
2 changed files with 48 additions and 16 deletions
|
|
@ -95,7 +95,7 @@ class SpellskiteEffect extends OneShotEffect {
|
|||
if (stackObject != null && sourceObject != null) {
|
||||
Targets targets = new Targets();
|
||||
Ability sourceAbility;
|
||||
MageObject oldTarget = null;
|
||||
String oldTargetName = null;
|
||||
if (stackObject instanceof Spell) {
|
||||
Spell spell = (Spell) stackObject;
|
||||
sourceAbility = spell.getSpellAbility();
|
||||
|
|
@ -114,7 +114,7 @@ class SpellskiteEffect extends OneShotEffect {
|
|||
if (targets.size() == 1 && targets.get(0).getTargets().size() == 1) {
|
||||
Target target = targets.get(0);
|
||||
if (target.canTarget(stackObject.getControllerId(), source.getSourceId(), sourceAbility, game)) {
|
||||
oldTarget = game.getObject(targets.getFirstTarget());
|
||||
oldTargetName = getTargetName(targets.getFirstTarget(), game);
|
||||
target.clearChosen();
|
||||
// The source is still the spell on the stack
|
||||
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
|
||||
|
|
@ -125,14 +125,7 @@ class SpellskiteEffect extends OneShotEffect {
|
|||
do {
|
||||
for (Target target : targets) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
MageObject object = game.getObject(targetId);
|
||||
String name;
|
||||
if (object == null) {
|
||||
Player targetPlayer = game.getPlayer(targetId);
|
||||
name = targetPlayer.getLogName();
|
||||
} else {
|
||||
name = object.getLogName();
|
||||
}
|
||||
String name = getTargetName(targets.getFirstTarget(), game);
|
||||
if (!targetId.equals(source.getSourceId()) && target.getTargets().contains(source.getSourceId())) {
|
||||
// you can't change this target to Spellskite because Spellskite is already another targetId of that target.
|
||||
twoTimesTarget = true;
|
||||
|
|
@ -142,7 +135,7 @@ class SpellskiteEffect extends OneShotEffect {
|
|||
validTargets = true;
|
||||
if (name != null
|
||||
&& controller.chooseUse(Outcome.Neutral, "Change target from " + name + " to " + sourceObject.getLogName() + "?", source, game)) {
|
||||
oldTarget = game.getObject(targetId);
|
||||
oldTargetName = getTargetName(targetId, game);
|
||||
target.remove(targetId);
|
||||
// The source is still the spell on the stack
|
||||
target.addTarget(source.getSourceId(), stackObject.getStackAbility(), game);
|
||||
|
|
@ -150,17 +143,17 @@ class SpellskiteEffect extends OneShotEffect {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (oldTarget != null) {
|
||||
if (oldTargetName != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (oldTarget == null) {
|
||||
if (oldTargetName == null) {
|
||||
game.informPlayer(controller, "You have to select at least one target to change to spellskite!");
|
||||
}
|
||||
} while (validTargets && oldTarget == null);
|
||||
} while (validTargets && oldTargetName == null);
|
||||
}
|
||||
if (oldTarget != null) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": Changed target of " + stackObject.getLogName() + " from " + oldTarget.getLogName() + " to " + sourceObject.getLogName());
|
||||
if (oldTargetName != null) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": Changed target of " + stackObject.getLogName() + " from " + oldTargetName + " to " + sourceObject.getLogName());
|
||||
} else {
|
||||
if (twoTimesTarget) {
|
||||
game.informPlayers(sourceObject.getLogName() + ": Target not changed to " + sourceObject.getLogName() + " because its not valid to target it twice for " + stackObject.getLogName());
|
||||
|
|
@ -178,4 +171,15 @@ class SpellskiteEffect extends OneShotEffect {
|
|||
return new SpellskiteEffect(this);
|
||||
}
|
||||
|
||||
private String getTargetName(UUID objectId, Game game) {
|
||||
MageObject object = game.getObject(objectId);
|
||||
if (object != null) {
|
||||
return object.getLogName();
|
||||
}
|
||||
Player player = game.getPlayer(objectId);
|
||||
if (player != null) {
|
||||
return player.getLogName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,4 +197,32 @@ public class SpellskiteTest extends CardTestPlayerBase {
|
|||
assertLife(playerB, 20);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* My opponent cast Lightning Bolt, targeting me. I redirected it to my
|
||||
* Spellskite. The log window said Spellskite was an invalid target (though
|
||||
* it should be valid). Spellskite still appeared to be targeted and took
|
||||
* the damage, so just a log issue I guess.
|
||||
*/
|
||||
@Test
|
||||
public void testRedirectBolt() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
||||
addCard(Zone.HAND, playerA, "Lightning Bolt");
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Spellskite", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Lightning Bolt", playerB);
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerB, "{UP}: Change a target of target spell or ability to {this}.", "Lightning Bolt");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Lightning Bolt", 1);
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue