Search in sources :

Example 26 with Deck

use of mage.cards.decks.Deck in project mage by magefree.

the class DeckUtil method construct.

public static Deck construct(DeckView view) {
    Deck deck = new Deck();
    for (SimpleCardView cardView : view.getCards().values()) {
        CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
        Card card = cardInfo != null ? cardInfo.getMockCard() : null;
        if (card != null) {
            deck.getCards().add(card);
        } else {
            log.fatal("(Deck constructing) Couldn't find card: set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
        }
    }
    for (SimpleCardView cardView : view.getSideboard().values()) {
        CardInfo cardInfo = CardRepository.instance.findCard(cardView.getExpansionSetCode(), cardView.getCardNumber());
        Card card = cardInfo != null ? cardInfo.getMockCard() : null;
        if (card != null) {
            deck.getSideboard().add(card);
        } else {
            log.fatal("(Deck constructing) Couldn't find card: set=" + cardView.getExpansionSetCode() + ", cid=" + Integer.valueOf(cardView.getCardNumber()));
        }
    }
    return deck;
}
Also used : SimpleCardView(mage.view.SimpleCardView) Deck(mage.cards.decks.Deck) CardInfo(mage.cards.repository.CardInfo) Card(mage.cards.Card)

Example 27 with Deck

use of mage.cards.decks.Deck in project mage by magefree.

the class GameController method cheat.

public void cheat(UUID userId, UUID playerId, DeckCardLists deckList) {
    try {
        Deck deck = Deck.load(deckList, false, false);
        game.loadCards(deck.getCards(), playerId);
        for (Card card : deck.getCards()) {
            card.putOntoBattlefield(game, Zone.OUTSIDE, null, playerId);
        }
    } catch (GameException ex) {
        logger.warn(ex.getMessage());
    }
    addCardsForTesting(game, playerId);
    updateGame();
}
Also used : Deck(mage.cards.decks.Deck) Card(mage.cards.Card)

Aggregations

Deck (mage.cards.decks.Deck)27 Card (mage.cards.Card)11 Player (mage.players.Player)7 Ability (mage.abilities.Ability)5 Test (org.junit.Test)5 java.util (java.util)4 CompanionAbility (mage.abilities.keyword.CompanionAbility)4 Constructed (mage.cards.decks.Constructed)4 DeckValidatorErrorType (mage.cards.decks.DeckValidatorErrorType)4 CardType (mage.constants.CardType)4 FilterMana (mage.filter.FilterMana)4 Game (mage.game.Game)4 TwoPlayerDuel (mage.game.TwoPlayerDuel)4 UUID (java.util.UUID)3 CanBeYourCommanderAbility (mage.abilities.common.CanBeYourCommanderAbility)3 PartnerAbility (mage.abilities.keyword.PartnerAbility)3 PartnerWithAbility (mage.abilities.keyword.PartnerWithAbility)3 ExpansionSet (mage.cards.ExpansionSet)3 Sets (mage.cards.Sets)3 DeckCardLists (mage.cards.decks.DeckCardLists)3