Search in sources :

Example 11 with CardInfo

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

the class CardsViewUtil method convertSimple.

public static CardsView convertSimple(SimpleCardsView view, Map<String, Card> loadedCards) {
    CardsView cards = new CardsView();
    for (SimpleCardView simple : view.values()) {
        String key = simple.getExpansionSetCode() + '_' + simple.getCardNumber();
        Card card = loadedCards.get(key);
        if (card == null) {
            CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
            card = cardInfo != null ? cardInfo.getMockCard() : null;
            loadedCards.put(key, card);
        }
        if (card != null) {
            cards.put(simple.getId(), new CardView(card, simple));
        }
    }
    return cards;
}
Also used : CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card)

Example 12 with CardInfo

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

the class NaturalOrderCardNumberComparator method compare.

@Override
public int compare(Object o1, Object o2) {
    CardInfo cardInfo1 = (CardInfo) o1;
    CardInfo cardInfo2 = (CardInfo) o2;
    return super.compare(cardInfo1.getCardNumber(), cardInfo2.getCardNumber());
}
Also used : CardInfo(mage.cards.repository.CardInfo)

Example 13 with CardInfo

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

the class ChatManagerImpl method performUserCommand.

private boolean performUserCommand(User user, String message, UUID chatId, boolean doError) {
    String command = message.substring(1).trim().toUpperCase(Locale.ENGLISH);
    if (doError) {
        message += new StringBuilder("<br/>Invalid User Command '" + message + "'.").append(COMMANDS_LIST).toString();
        message += "<br/>Type <font color=green>\\w " + user.getName() + " profanity 0 (or 1 or 2)</font> to use/not use the profanity filter";
        chatSessions.get(chatId).broadcastInfoToUser(user, message);
        return true;
    }
    if (command.startsWith("H ") || command.startsWith("HISTORY ")) {
        message += "<br/>" + managerFactory.userManager().getUserHistory(message.substring(command.startsWith("H ") ? 3 : 9));
        chatSessions.get(chatId).broadcastInfoToUser(user, message);
        return true;
    }
    if (command.equals("ME")) {
        message += "<br/>" + managerFactory.userManager().getUserHistory(user.getName());
        chatSessions.get(chatId).broadcastInfoToUser(user, message);
        return true;
    }
    if (command.startsWith("GAME")) {
        message += "<br/>";
        ChatSession session = chatSessions.get(chatId);
        if (session != null && session.getInfo() != null) {
            String gameId = session.getInfo();
            if (gameId.startsWith("Game ")) {
                UUID id = java.util.UUID.fromString(gameId.substring(5));
                for (Entry<UUID, GameController> entry : managerFactory.gameManager().getGameController().entrySet()) {
                    if (entry.getKey().equals(id)) {
                        GameController controller = entry.getValue();
                        if (controller != null) {
                            message += controller.getGameStateDebugMessage();
                            chatSessions.get(chatId).broadcastInfoToUser(user, message);
                        }
                    }
                }
            }
        }
        return true;
    }
    if (command.startsWith("FIX")) {
        message += "<br/>";
        ChatSession session = chatSessions.get(chatId);
        if (session != null && session.getInfo() != null) {
            String gameId = session.getInfo();
            if (gameId.startsWith("Game ")) {
                UUID id = java.util.UUID.fromString(gameId.substring(5));
                for (Entry<UUID, GameController> entry : managerFactory.gameManager().getGameController().entrySet()) {
                    if (entry.getKey().equals(id)) {
                        GameController controller = entry.getValue();
                        if (controller != null) {
                            message += controller.attemptToFixGame(user);
                            chatSessions.get(chatId).broadcastInfoToUser(user, message);
                        }
                    }
                }
            }
        }
        return true;
    }
    if (command.equals("PINGS")) {
        message += "<br/>";
        ChatSession session = chatSessions.get(chatId);
        if (session != null && session.getInfo() != null) {
            String gameId = session.getInfo();
            if (gameId.startsWith("Game ")) {
                UUID id = java.util.UUID.fromString(gameId.substring(5));
                for (Entry<UUID, GameController> entry : managerFactory.gameManager().getGameController().entrySet()) {
                    if (entry.getKey().equals(id)) {
                        GameController controller = entry.getValue();
                        if (controller != null) {
                            message += controller.getPingsInfo();
                            chatSessions.get(chatId).broadcastInfoToUser(user, message);
                        }
                    }
                }
            }
        }
        return true;
    }
    if (command.startsWith("CARD ")) {
        Matcher matchPattern = getCardTextPattern.matcher(message.toLowerCase(Locale.ENGLISH));
        if (matchPattern.find()) {
            String cardName = matchPattern.group(1);
            CardInfo cardInfo = CardRepository.instance.findPreferredCoreExpansionCard(cardName, true);
            if (cardInfo != null) {
                cardInfo.getRules();
                message = "<font color=orange>" + cardInfo.getName() + "</font>: Cost:" + cardInfo.getManaCosts(CardInfo.ManaCostSide.ALL).toString() + ",  Types:" + cardInfo.getTypes().toString() + ", ";
                for (String rule : cardInfo.getRules()) {
                    message = message + rule;
                }
            } else {
                message = "Couldn't find: " + cardName;
            }
        }
        chatSessions.get(chatId).broadcastInfoToUser(user, message);
        return true;
    }
    if (command.startsWith("W ") || command.startsWith("WHISPER ")) {
        String rest = message.substring(command.startsWith("W ") ? 3 : 9);
        int first = rest.indexOf(' ');
        if (first > 1) {
            String userToName = rest.substring(0, first);
            rest = rest.substring(first + 1).trim();
            Optional<User> userTo = managerFactory.userManager().getUserByName(userToName);
            if (userTo.isPresent()) {
                if (!chatSessions.get(chatId).broadcastWhisperToUser(user, userTo.get(), rest)) {
                    message += new StringBuilder("<br/>User ").append(userToName).append(" not found").toString();
                    chatSessions.get(chatId).broadcastInfoToUser(user, message);
                }
            } else {
                message += new StringBuilder("<br/>User ").append(userToName).append(" not found").toString();
                chatSessions.get(chatId).broadcastInfoToUser(user, message);
            }
            return true;
        }
    }
    if (command.equals("L") || command.equals("LIST")) {
        message += COMMANDS_LIST;
        message += "<br/>Type <font color=green>\\w " + user.getName() + " profanity 0 (or 1 or 2)</font> to use/not use the profanity filter";
        chatSessions.get(chatId).broadcastInfoToUser(user, message);
        return true;
    }
    return false;
}
Also used : Matcher(java.util.regex.Matcher) GameController(mage.server.game.GameController) CardInfo(mage.cards.repository.CardInfo)

Example 14 with CardInfo

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

the class DominariaCollator method findSpecialCardsByRarity.

@Override
protected List<CardInfo> findSpecialCardsByRarity(Rarity rarity) {
    List<CardInfo> cardInfos = super.findSpecialCardsByRarity(rarity);
    cardInfos.addAll(CardRepository.instance.findCards(new CardCriteria().setCodes(this.code).rarities(rarity).supertypes(SuperType.LEGENDARY).types(CardType.CREATURE).maxCardNumber(maxCardNumberInBooster)));
    cardInfos.removeIf(cardInfo -> nonSpecialLegends.contains(cardInfo.getName()));
    return cardInfos;
}
Also used : CardCriteria(mage.cards.repository.CardCriteria) CardInfo(mage.cards.repository.CardInfo)

Example 15 with CardInfo

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

the class ModernHorizons2Collator method addSpecialCards.

@Override
protected void addSpecialCards(List<Card> booster, int number) {
    // number is here always 1
    Rarity rarity;
    int rarityKey = RandomUtil.nextInt(120);
    if (rarityKey < 4) {
        rarity = Rarity.MYTHIC;
    } else if (rarityKey < 40) {
        rarity = Rarity.RARE;
    } else {
        rarity = Rarity.UNCOMMON;
    }
    List<CardInfo> reprintCards = getSpecialCardsByRarity(rarity);
    addToBooster(booster, reprintCards);
}
Also used : Rarity(mage.constants.Rarity) CardInfo(mage.cards.repository.CardInfo)

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