use of mage.cards.repository.CardInfo in project mage by magefree.
the class MomirDuel method init.
@Override
protected void init(UUID choosingPlayerId) {
Ability ability = new SimpleStaticAbility(Zone.COMMAND, new InfoEffect("Vanguard effects"));
for (UUID playerId : state.getPlayerList(startingPlayerId)) {
Player player = getPlayer(playerId);
if (player != null) {
CardInfo cardInfo = CardRepository.instance.findCard("Momir Vig, Simic Visionary");
addEmblem(new MomirEmblem(), cardInfo.getCard(), playerId);
}
}
getState().addAbility(ability, null);
super.init(choosingPlayerId);
state.getTurnMods().add(new TurnMod(startingPlayerId, PhaseStep.DRAW));
}
use of mage.cards.repository.CardInfo in project mage by magefree.
the class TestGameType method createFaceDownCard.
private CardView createFaceDownCard(Game game, UUID controllerId, String code, String cardNumber, boolean isMorphed, boolean isManifested, boolean tapped) {
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(), new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
Card newCard = CardImpl.createCard(cardInfo.getClassName(), testSet);
Set<Card> cardsList = new HashSet<>();
cardsList.add(newCard);
game.loadCards(cardsList, controllerId);
Card permCard = CardUtil.getDefaultCardSideForBattlefield(game, newCard);
PermanentCard perm = new PermanentCard(permCard, controllerId, game);
perm.setFaceDown(true, game);
perm.setMorphed(isMorphed);
perm.setManifested(isManifested);
perm.removeSummoningSickness();
perm.setTapped(tapped);
if (perm.isTransformable()) {
perm.setTransformed(true);
}
PermanentView cardView = new PermanentView(perm, permCard, controllerId, game);
// must false for face down
cardView.setInViewerOnly(false);
return cardView;
}
use of mage.cards.repository.CardInfo in project mage by magefree.
the class TestGameType method createPermanentCard.
private PermanentView createPermanentCard(Game game, UUID controllerId, String code, String cardNumber, int power, int toughness, int damage, boolean tapped, boolean transform, List<Ability> extraAbilities) {
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(), new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
Card newCard = CardImpl.createCard(cardInfo.getClassName(), testSet);
Set<Card> cardsList = new HashSet<>();
cardsList.add(newCard);
game.loadCards(cardsList, controllerId);
Card permCard = CardUtil.getDefaultCardSideForBattlefield(game, newCard);
if (extraAbilities != null) {
extraAbilities.forEach(ability -> permCard.addAbility(ability));
}
PermanentCard perm = new PermanentCard(permCard, controllerId, game);
if (transform) {
// need direct transform call to keep other side info (original)
TransformAbility.transformPermanent(perm, permCard.getSecondCardFace(), game, null);
}
if (damage > 0)
perm.damage(damage, controllerId, null, game);
if (power > 0)
perm.getPower().setValue(power);
if (toughness > 0)
perm.getToughness().setValue(toughness);
perm.removeSummoningSickness();
perm.setTapped(tapped);
PermanentView cardView = new PermanentView(perm, permCard, controllerId, game);
return cardView;
}
use of mage.cards.repository.CardInfo in project mage by magefree.
the class Plus2MaceTest method test_NameProcessingByRegExp.
@Test
public void test_NameProcessingByRegExp() {
// + character can't processing by regexp, so it must be quoted replaced in code by Pattern.quote(mageObject.getName())
String cardName = "+2 Mace";
CardInfo cardinfo = CardRepository.instance.findCard(cardName);
Assert.assertNotNull(cardName + " must exists", cardinfo);
Card card = cardinfo.getCard();
String cardText = GameLog.replaceNameByColoredName(card, card.getSpellAbility().toString(), null);
Assert.assertTrue("card text must contain card name", cardText.contains(cardName));
}
use of mage.cards.repository.CardInfo in project mage by magefree.
the class MageTestBase method parseLine.
private void parseLine(String line) {
if (parserState == ParserState.EXPECTED) {
// just remember for future use
expectedResults.add(line);
return;
}
Matcher m = pattern.matcher(line);
if (m.matches()) {
String zone = m.group(1);
String nickname = m.group(2);
if (nickname.equals("ComputerA") || nickname.equals("ComputerB")) {
List<Card> cards = null;
List<PermanentCard> perms = null;
Zone gameZone;
if ("hand".equalsIgnoreCase(zone)) {
gameZone = Zone.HAND;
cards = nickname.equals("ComputerA") ? handCardsA : handCardsB;
} else if ("battlefield".equalsIgnoreCase(zone)) {
gameZone = Zone.BATTLEFIELD;
perms = nickname.equals("ComputerA") ? battlefieldCardsA : battlefieldCardsB;
} else if ("graveyard".equalsIgnoreCase(zone)) {
gameZone = Zone.GRAVEYARD;
cards = nickname.equals("ComputerA") ? graveyardCardsA : graveyardCardsB;
} else if ("library".equalsIgnoreCase(zone)) {
gameZone = Zone.LIBRARY;
cards = nickname.equals("ComputerA") ? libraryCardsA : libraryCardsB;
} else if ("player".equalsIgnoreCase(zone)) {
String command = m.group(3);
if ("life".equals(command)) {
if (nickname.equals("ComputerA")) {
commandsA.put(Zone.OUTSIDE, "life:" + m.group(4));
} else {
commandsB.put(Zone.OUTSIDE, "life:" + m.group(4));
}
}
return;
} else {
// go parse next line
return;
}
String cardName = m.group(3);
Integer amount = Integer.parseInt(m.group(4));
boolean tapped = m.group(5) != null && m.group(5).equals(":{tapped}");
if (cardName.equals("clear")) {
if (nickname.equals("ComputerA")) {
commandsA.put(gameZone, "clear");
} else {
commandsB.put(gameZone, "clear");
}
} else {
for (int i = 0; i < amount; i++) {
CardInfo cardInfo = CardRepository.instance.findCard(cardName);
Card newCard = cardInfo != null ? cardInfo.getCard() : null;
if (newCard != null) {
if (gameZone == Zone.BATTLEFIELD) {
Card permCard = CardUtil.getDefaultCardSideForBattlefield(currentGame, newCard);
PermanentCard p = new PermanentCard(permCard, null, currentGame);
p.setTapped(tapped);
perms.add(p);
} else {
cards.add(newCard);
}
} else {
logger.fatal("Couldn't find a card: " + cardName);
logger.fatal("line: " + line);
}
}
}
} else {
logger.warn("Unknown player: " + nickname);
}
} else {
logger.warn("Init string wasn't parsed: " + line);
}
}
Aggregations