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