Search in sources :

Example 56 with CardInfo

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

the class VirtualCardInfo method init.

public void init(String cardName, BigCard bigCard, UUID gameId) {
    CardInfo cardInfo = CardRepository.instance.findCards(cardName).stream().findFirst().orElse(null);
    if (cardInfo == null) {
        clear();
        return;
    }
    this.init(new CardView(cardInfo.getCard()), bigCard, gameId);
}
Also used : CardView(mage.view.CardView) CardInfo(mage.cards.repository.CardInfo)

Example 57 with CardInfo

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

the class MomirGame 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 58 with CardInfo

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

the class MageBook method getCards.

private List<CardInfo> getCards(int page, String set) {
    CardCriteria criteria = new CardCriteria();
    criteria.setCodes(set);
    List<CardInfo> cards = CardRepository.instance.findCards(criteria);
    cards.sort(new NaturalOrderCardNumberComparator());
    int start = page * conf.CARDS_PER_PAGE;
    int end = page * conf.CARDS_PER_PAGE + conf.CARDS_PER_PAGE;
    if (end > cards.size()) {
        end = cards.size();
    }
    if (cards.size() > end) {
        pageRight.setVisible(true);
    }
    return cards.subList(start, end);
}
Also used : NaturalOrderCardNumberComparator(mage.client.util.NaturalOrderCardNumberComparator) CardCriteria(mage.cards.repository.CardCriteria) CardInfo(mage.cards.repository.CardInfo)

Example 59 with CardInfo

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

the class MageBook method loadCards.

private List<Object> loadCards() {
    CardCriteria criteria = new CardCriteria();
    criteria.setCodes(currentSet);
    List<CardInfo> cards = CardRepository.instance.findCards(criteria);
    cards.sort(new NaturalOrderCardNumberComparator());
    List<Object> res = new ArrayList<>();
    cards.forEach(card -> res.add(new CardView(card.getMockCard())));
    return res;
}
Also used : NaturalOrderCardNumberComparator(mage.client.util.NaturalOrderCardNumberComparator) CardCriteria(mage.cards.repository.CardCriteria) ArrayList(java.util.ArrayList) CardInfo(mage.cards.repository.CardInfo)

Example 60 with CardInfo

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

the class UpdateDeckTask method setCardNumberToCardsList.

private void setCardNumberToCardsList(Event event, Set<Card> cards) {
    CardView cardView = (CardView) event.getSource();
    int numberToSet = event.getNumber();
    int cardsFound = 0;
    java.util.List<Card> toDelete = new ArrayList<>();
    for (Card card : cards) {
        if (card.getName().equals(cardView.getName()) && Objects.equals(card.getCardNumber(), cardView.getCardNumber()) && card.getExpansionSetCode().equals(cardView.getExpansionSetCode())) {
            cardsFound++;
            if (cardsFound > numberToSet) {
                toDelete.add(card);
            }
        }
    }
    if (toDelete.isEmpty()) {
        // add cards
        CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
        for (int i = cardsFound; i < numberToSet; i++) {
            cards.add(cardInfo.getMockCard());
        }
    } else {
        // remove cards
        for (Card card : toDelete) {
            cards.remove(card);
        }
    }
    hidePopup();
    refreshDeck();
}
Also used : java.util(java.util) SimpleCardView(mage.view.SimpleCardView) CardView(mage.view.CardView) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card) BigCard(mage.client.cards.BigCard)

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