package mage.util; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.EntersBattlefieldEffect; import mage.abilities.keyword.PhasingAbility; import mage.cards.Card; import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import java.util.Map; import java.util.UUID; /** * Helper class for fuzzy testing *
* Support: * - [x] enable by command line; * - [x] phased out permanents must be hidden * - [ ] TODO: out of range players and permanents must be hidden * - [ ] TODO: leave/disconnected players must be hidden *
* How-to use: * - enable here or by command line * - run unit tests and research the fails * * @author JayDi85 */ public class FuzzyTestsUtil { /** * Phased out permanents must be hidden * Make sure other cards and effects do not see phased out permanents and ignore it *
* Use case: * - each permanent on battlefield will have copied phased out version with all abilities and effects *
* How-to use:
* - set true or run with -Dxmage.tests.addRandomPhasedOutPermanents=true
*/
public static boolean ADD_RANDOM_PHASED_OUT_PERMANENTS = false;
static {
String val = System.getProperty("xmage.tests.addRandomPhasedOutPermanents");
if (val != null) {
ADD_RANDOM_PHASED_OUT_PERMANENTS = Boolean.parseBoolean(val);
}
}
/**
* Create duplicated phased out permanent
*/
public static void addRandomPhasedOutPermanent(Permanent originalPermanent, Ability source, Game game) {
if (!ADD_RANDOM_PHASED_OUT_PERMANENTS) {
return;
}
Player samplePlayer = game.getPlayers().values().stream().findFirst().orElse(null);
if (samplePlayer == null || !samplePlayer.isTestMode()) {
return;
}
// copy permanent and put it to battlefield as phased out (diff sides also supported here)
// TODO: add phased out tests support (must not fail on it)
Card originalCardSide = game.getCard(originalPermanent.getId());
Card originalCardMain = originalCardSide.getMainCard();
if (!originalCardMain.hasAbility(PhasingAbility.getInstance(), game)) {
boolean canCreate = true;
Card doppelgangerCardMain = game.copyCard(originalCardMain, source, originalPermanent.getControllerId());
Map