mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
spjspj - Add option of adding in Tokens from the init.txt file
token:Human:MerfolkWizardToken:1 token:Human:GermToken:1 are examples
This commit is contained in:
parent
f73c30812e
commit
94ea9b8ebd
1 changed files with 13 additions and 0 deletions
|
@ -9,12 +9,14 @@ import mage.players.Player;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import mage.abilities.effects.common.CreateTokenEffect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author nantuko
|
* @author nantuko
|
||||||
|
@ -85,6 +87,8 @@ public final class SystemUtil {
|
||||||
gameZone = Zone.GRAVEYARD;
|
gameZone = Zone.GRAVEYARD;
|
||||||
} else if ("library".equalsIgnoreCase(zone)) {
|
} else if ("library".equalsIgnoreCase(zone)) {
|
||||||
gameZone = Zone.LIBRARY;
|
gameZone = Zone.LIBRARY;
|
||||||
|
} else if ("token".equalsIgnoreCase(zone)) {
|
||||||
|
gameZone = Zone.BATTLEFIELD;
|
||||||
} else {
|
} else {
|
||||||
continue; // go parse next line
|
continue; // go parse next line
|
||||||
}
|
}
|
||||||
|
@ -94,6 +98,15 @@ public final class SystemUtil {
|
||||||
|
|
||||||
List<CardInfo> cards = CardRepository.instance.findCards(cardName);
|
List<CardInfo> cards = CardRepository.instance.findCards(cardName);
|
||||||
if (cards.isEmpty()) {
|
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);
|
logger.warn("Couldn't find a card: " + cardName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue