Search in sources :

Example 1 with CardInfo

use of mage.cards.repository.CardInfo in project mage by magefree.

the class ComputerPlayer method addBasicLands.

private static void addBasicLands(Deck deck, String landName, int number) {
    Set<String> landSets = TournamentUtil.getLandSetCodeForDeckSets(deck.getExpansionSetCodes());
    CardCriteria criteria = new CardCriteria();
    if (!landSets.isEmpty()) {
        criteria.setCodes(landSets.toArray(new String[landSets.size()]));
    }
    criteria.rarities(Rarity.LAND).name(landName);
    List<CardInfo> cards = CardRepository.instance.findCards(criteria);
    if (cards.isEmpty()) {
        criteria = new CardCriteria();
        criteria.rarities(Rarity.LAND).name(landName);
        criteria.setCodes("M15");
        cards = CardRepository.instance.findCards(criteria);
    }
    for (int i = 0; i < number; i++) {
        Card land = cards.get(RandomUtil.nextInt(cards.size())).getCard();
        deck.getCards().add(land);
    }
}
Also used : CardCriteria(mage.cards.repository.CardCriteria) CardInfo(mage.cards.repository.CardInfo) RateCard(mage.game.draft.RateCard) Card(mage.cards.Card) FilterCard(mage.filter.FilterCard)

Example 2 with CardInfo

use of mage.cards.repository.CardInfo in project mage by magefree.

the class DarkAscensionCollator method addDoubleFace.

@Override
protected void addDoubleFace(List<Card> booster) {
    Rarity rarity;
    for (int i = 0; i < numBoosterDoubleFaced; i++) {
        int rarityKey = RandomUtil.nextInt(121);
        if (rarityKey < 72) {
            rarity = Rarity.COMMON;
        } else if (rarityKey < 108) {
            rarity = Rarity.UNCOMMON;
        } else if (rarityKey < 117) {
            rarity = Rarity.RARE;
        } else {
            rarity = Rarity.MYTHIC;
        }
        List<CardInfo> doubleFacedCards = getSpecialCardsByRarity(rarity);
        addToBooster(booster, doubleFacedCards);
    }
}
Also used : Rarity(mage.constants.Rarity) CardInfo(mage.cards.repository.CardInfo)

Example 3 with CardInfo

use of mage.cards.repository.CardInfo in project mage by magefree.

the class TxtDeckImporterTest method testImportWithBlankLineAboveSideboard.

@Test
public void testImportWithBlankLineAboveSideboard() {
    TxtDeckImporter importer = new TxtDeckImporter(false);
    CardInfo card;
    DeckCardLists deck = new DeckCardLists();
    String[] cards = { "Plains", "Forest", "Island" };
    String[] sideboard = { "Swamp", "Mountain" };
    for (String c : cards) {
        card = CardRepository.instance.findPreferredCoreExpansionCard(c, true);
        assert card != null;
        deck.getCards().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getSetCode()));
    }
    for (String s : sideboard) {
        card = CardRepository.instance.findPreferredCoreExpansionCard(s, true);
        assert card != null;
        deck.getSideboard().add(new DeckCardInfo(card.getName(), card.getCardNumber(), card.getSetCode()));
    }
    Assert.assertEquals("Deck does not contain 3 cards, found " + deck.getCards().size(), 3, deck.getCards().size());
    Assert.assertEquals("Sideboard does not contain 2 cards, found " + deck.getSideboard().size(), 2, deck.getSideboard().size());
    DeckCardLists imported = importer.importDeck("JustLands.txt", false);
    Assert.assertEquals("Imported deck does not contain 3 cards, found " + imported.getCards().size(), 3, imported.getCards().size());
    Assert.assertEquals("Imported sideboard does not contain 2 cards, found " + imported.getSideboard().size(), 2, imported.getSideboard().size());
}
Also used : DeckCardLists(mage.cards.decks.DeckCardLists) DeckCardInfo(mage.cards.decks.DeckCardInfo) TxtDeckImporter(mage.cards.decks.importer.TxtDeckImporter) DeckCardInfo(mage.cards.decks.DeckCardInfo) CardInfo(mage.cards.repository.CardInfo) Test(org.junit.Test)

Example 4 with CardInfo

use of mage.cards.repository.CardInfo in project mage by magefree.

the class CommanderColorIdentityTest method getColorIdentityString.

private String getColorIdentityString(String cardName) {
    CardInfo cardInfo = CardRepository.instance.findCard(cardName);
    if (cardInfo == null) {
        throw new IllegalArgumentException("Couldn't find the card " + cardName + " in the DB.");
    }
    Card card = cardInfo.getCard();
    FilterMana filterMana = card.getColorIdentity();
    return filterMana.toString();
}
Also used : FilterMana(mage.filter.FilterMana) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card)

Example 5 with CardInfo

use of mage.cards.repository.CardInfo in project mage by magefree.

the class UpdateDeckTask method moveSelectorCardToDeck.

private void moveSelectorCardToDeck(Event event) {
    SimpleCardView cardView = (SimpleCardView) event.getSource();
    Card card = null;
    boolean gameMode = mode != DeckEditorMode.FREE_BUILDING;
    if (gameMode) {
        // game: use existing real cards
        for (Card sideCard : deck.getSideboard()) {
            if (sideCard.getId().equals(cardView.getId())) {
                card = sideCard;
                break;
            }
        }
    } else {
        // editor: create mock card
        CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
        card = cardInfo != null ? cardInfo.getMockCard() : null;
    }
    if (card != null) {
        deck.getCards().add(card);
        if (gameMode) {
            // game: move card from another board
            deck.getSideboard().remove(card);
            cardSelector.removeCard(card.getId());
            cardSelector.setCardCount(deck.getSideboard().size());
            cardSelector.refresh();
        }
        // card hint update
        if (cardInfoPane instanceof CardInfoPane) {
            ((CardInfoPane) cardInfoPane).setCard(new CardView(card), null);
        }
        hidePopup();
    }
}
Also used : SimpleCardView(mage.view.SimpleCardView) SimpleCardView(mage.view.SimpleCardView) CardView(mage.view.CardView) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card) BigCard(mage.client.cards.BigCard) CardInfoPane(mage.components.CardInfoPane)

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