Search in sources :

Example 21 with CardInfo

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));
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) CardInfo(mage.cards.repository.CardInfo) TurnMod(mage.game.turn.TurnMod) UUID(java.util.UUID) MomirEmblem(mage.game.command.emblems.MomirEmblem) InfoEffect(mage.abilities.effects.common.InfoEffect)

Example 22 with CardInfo

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;
}
Also used : CardInfo(mage.cards.repository.CardInfo) ExpansionInfo(mage.cards.repository.ExpansionInfo) BigCard(mage.client.cards.BigCard) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 23 with CardInfo

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;
}
Also used : CardInfo(mage.cards.repository.CardInfo) ExpansionInfo(mage.cards.repository.ExpansionInfo) BigCard(mage.client.cards.BigCard) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Example 24 with CardInfo

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));
}
Also used : CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card) Test(org.junit.Test)

Example 25 with CardInfo

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);
    }
}
Also used : Matcher(java.util.regex.Matcher) Zone(mage.constants.Zone) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card) PermanentCard(mage.game.permanent.PermanentCard) PermanentCard(mage.game.permanent.PermanentCard)

Aggregations

CardInfo (mage.cards.repository.CardInfo)67 Card (mage.cards.Card)25 CardCriteria (mage.cards.repository.CardCriteria)14 DeckCardInfo (mage.cards.decks.DeckCardInfo)13 PermanentCard (mage.game.permanent.PermanentCard)10 Matcher (java.util.regex.Matcher)8 Test (org.junit.Test)8 CardView (mage.view.CardView)7 ArrayList (java.util.ArrayList)6 BigCard (mage.client.cards.BigCard)6 Player (mage.players.Player)5 java.util (java.util)3 List (java.util.List)3 Ability (mage.abilities.Ability)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 InfoEffect (mage.abilities.effects.common.InfoEffect)3 ExpansionInfo (mage.cards.repository.ExpansionInfo)3 Rarity (mage.constants.Rarity)3 PermanentImpl (mage.game.permanent.PermanentImpl)3 SimpleCardView (mage.view.SimpleCardView)3