From 94ea9b8ebd5584954c4caee6fd9e0a144998a4c2 Mon Sep 17 00:00:00 2001 From: spjspj Date: Sun, 23 Apr 2017 02:51:49 +1000 Subject: [PATCH] spjspj - Add option of adding in Tokens from the init.txt file token:Human:MerfolkWizardToken:1 token:Human:GermToken:1 are examples --- .../src/main/java/mage/server/util/SystemUtil.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Mage.Server/src/main/java/mage/server/util/SystemUtil.java b/Mage.Server/src/main/java/mage/server/util/SystemUtil.java index a43a73f348..5a6880480a 100644 --- a/Mage.Server/src/main/java/mage/server/util/SystemUtil.java +++ b/Mage.Server/src/main/java/mage/server/util/SystemUtil.java @@ -9,12 +9,14 @@ import mage.players.Player; import mage.util.RandomUtil; import java.io.File; +import java.lang.reflect.Constructor; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; +import mage.abilities.effects.common.CreateTokenEffect; /** * @author nantuko @@ -85,6 +87,8 @@ public final class SystemUtil { gameZone = Zone.GRAVEYARD; } else if ("library".equalsIgnoreCase(zone)) { gameZone = Zone.LIBRARY; + } else if ("token".equalsIgnoreCase(zone)) { + gameZone = Zone.BATTLEFIELD; } else { continue; // go parse next line } @@ -94,6 +98,15 @@ public final class SystemUtil { List cards = CardRepository.instance.findCards(cardName); if (cards.isEmpty()) { + if ("token".equalsIgnoreCase(zone)) { + // eg: token:Human:HippoToken:1 + Class c = Class.forName("mage.game.permanent.token." + cardName); + Constructor cons = c.getConstructor(); + Object token = cons.newInstance(); + if (token != null && token instanceof mage.game.permanent.token.Token) { + ((mage.game.permanent.token.Token) token).putOntoBattlefield(amount, game, null, player.getId(), false, false); + } + } logger.warn("Couldn't find a card: " + cardName); continue; }