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);
}
}
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);
}
}
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());
}
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();
}
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();
}
}
Aggregations