Reverted some changes, related to #6187, see comments from d20a20fb6a

This commit is contained in:
Oleg Agafonov 2020-01-16 08:22:23 +04:00
parent 180c7dfff6
commit ec2ea7f070
6 changed files with 74 additions and 59 deletions

View file

@ -70,7 +70,7 @@ class AvengerEnDalEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source));
if (permanent != null) {
Player player = game.getPlayer(permanent.getControllerId());
if (player != null) {

View file

@ -59,7 +59,7 @@ class BeastWithinEffect extends OneShotEffect {
// If the permanent is an illegal target when Beast Within tries to resolve, the spell wont resolve and none
// of its effects will happen. The permanents controller wont get a Beast token.
// (2011-06-01)
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); // must use LKI
if (permanent != null) {
new BeastToken().putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());
}

View file

@ -58,8 +58,9 @@ class CrumbleEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
// If the target artifact becomes illegal before resolution, the player does not gain any life. (2004-10-04)
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
// If the target artifact becomes illegal before resolution, the player does not gain any life.
// (2004-10-04)
Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); // must use LKI
if (permanent != null) {
int cost = permanent.getConvertedManaCost();
Player player = game.getPlayer(permanent.getControllerId());

View file

@ -44,6 +44,7 @@ public final class FaerieArtisans extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever a nontoken creature enters the battlefield under an opponent's control, create a token that's a copy of that creature except it's an artifact in addition to its other types. Then exile all other tokens created with Faerie Artisans.
Ability ability = new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new FaerieArtisansEffect(), filterNontoken, false, SetTargetPointer.PERMANENT,
"Whenever a nontoken creature enters the battlefield under an opponent's control, create a token that's a copy of that creature except it's an artifact in addition to its other types. Then exile all other tokens created with {this}.");

View file

@ -74,7 +74,7 @@ class IncongruityEffect extends OneShotEffect {
// If the target creature is an illegal target by the time Incongruity tries to resolve, the spell doesnt resolve.
// No player creates a Frog Lizard token.
// (2019-01-25)
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));
Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); // must use LKI
if (permanent != null) {
FrogLizardToken token = new FrogLizardToken();
token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId());

View file

@ -1,10 +1,5 @@
package org.mage.test.player;
import java.io.Serializable;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import mage.MageItem;
import mage.MageObject;
import mage.MageObjectReference;
@ -61,6 +56,14 @@ import mage.util.CardUtil;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Ignore;
import java.io.Serializable;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static org.mage.test.serverside.base.impl.CardTestPlayerAPIImpl.*;
/**
@ -1288,7 +1291,7 @@ public class TestPlayer implements Player {
UUID defenderId = null;
boolean mustAttackByAction = false;
boolean madeAttackByAction = false;
for (Iterator<org.mage.test.player.PlayerAction> it = actions.iterator(); it.hasNext();) {
for (Iterator<org.mage.test.player.PlayerAction> it = actions.iterator(); it.hasNext(); ) {
PlayerAction action = it.next();
if (action.getTurnNum() == game.getTurnNum() && action.getAction().startsWith("attack:")) {
mustAttackByAction = true;
@ -1453,21 +1456,28 @@ public class TestPlayer implements Player {
}
private String getInfo(MageObject o) {
return o != null ? o.getClass().getSimpleName() + ": " + o.getName() : "null";
return "Object: " + (o != null ? o.getClass().getSimpleName() + ": " + o.getName() : "null");
}
private String getInfo(Ability o) {
return o != null ? o.getClass().getSimpleName() + ": " + o.getRule() : "null";
private String getInfo(Ability o, Game game) {
if (o != null) {
MageObject object = o.getSourceObject(game);
return "Ability: " + (object == null ? "" : object.getName() + " - " + o.getClass().getSimpleName() + ": " + o.getRule());
}
return "Ability: null";
}
private String getInfo(Target o) {
return o != null ? o.getClass().getSimpleName() + ": " + o.getMessage() : "null";
return "Target: " + (o != null ? o.getClass().getSimpleName() + ": " + o.getMessage() : "null");
}
private void chooseStrictModeFailed(String choiceType, Game game, String reason) {
if (strictChooseMode) {
Assert.fail("Missing " + choiceType + " def for turn " + game.getTurnNum() + ", " + this.getName() + ", "
+ game.getStep().getType().name() + ": " + reason);
Assert.fail("Missing " + choiceType + " def for"
+ " turn " + game.getTurnNum()
+ ", step " + game.getStep().getType().name()
+ ", " + this.getName()
+ "\n" + reason);
}
}
@ -1493,7 +1503,7 @@ public class TestPlayer implements Player {
return null;
}
this.chooseStrictModeFailed("mode", game, getInfo(source));
this.chooseStrictModeFailed("mode", game, getInfo(source, game));
return computerPlayer.chooseMode(modes, source, game);
}
@ -2025,7 +2035,7 @@ public class TestPlayer implements Player {
Assert.fail(message);
}
this.chooseStrictModeFailed("target", game, getInfo(source) + "; " + getInfo(target));
this.chooseStrictModeFailed("target", game,getInfo(source, game) + "\n" + getInfo(target));
return computerPlayer.chooseTarget(outcome, target, source, game);
}
@ -2054,7 +2064,7 @@ public class TestPlayer implements Player {
//Assert.fail("Wrong target");
}
this.chooseStrictModeFailed("target", game, getInfo(source) + "; " + getInfo(target));
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "; " + getInfo(target));
return computerPlayer.chooseTarget(outcome, cards, target, source, game);
}
@ -2071,7 +2081,9 @@ public class TestPlayer implements Player {
//Assert.fail("Wrong choice");
}
this.chooseStrictModeFailed("choice", game, abilities.stream().map(this::getInfo).collect(Collectors.joining("; ")));
this.chooseStrictModeFailed("choice", game,
"Triggered list (total " + abilities.size() + "):\n"
+ abilities.stream().map(a -> getInfo(a, game)).collect(Collectors.joining("\n")));
return computerPlayer.chooseTriggeredAbility(abilities, game);
}
@ -2098,8 +2110,9 @@ public class TestPlayer implements Player {
//Assert.fail("Wrong choice");
}
this.chooseStrictModeFailed("choice", game, getInfo(source) + "; " + message + ": "
+ (trueText != null ? trueText : "Yes") + " - " + (falseText != null ? falseText : "No"));
this.chooseStrictModeFailed("choice", game, getInfo(source, game)
+ "\nMessage: " + message
+ "\nChoices: " + (trueText != null ? trueText : "Yes") + " - " + (falseText != null ? falseText : "No"));
return computerPlayer.chooseUse(outcome, message, secondMessage, trueText, falseText, source, game);
}
@ -2115,7 +2128,7 @@ public class TestPlayer implements Player {
}
}
this.chooseStrictModeFailed("choice", game, getInfo(ability) + "; " + message);
this.chooseStrictModeFailed("choice", game, getInfo(ability, game) + "; " + message);
return computerPlayer.announceXMana(min, max, multiplier, message, game, ability);
}
@ -2129,7 +2142,7 @@ public class TestPlayer implements Player {
}
}
this.chooseStrictModeFailed("choice", game, getInfo(ability) + "; " + message);
this.chooseStrictModeFailed("choice", game, getInfo(ability, game) + "; " + message);
return computerPlayer.announceXCost(min, max, message, game, ability, null);
}
@ -3341,7 +3354,7 @@ public class TestPlayer implements Player {
}
}
this.chooseStrictModeFailed("target", game, getInfo(source) + "; " + getInfo(target));
this.chooseStrictModeFailed("target", game, getInfo(source, game) + "; " + getInfo(target));
return computerPlayer.chooseTargetAmount(outcome, target, source, game);
}