forked from External/mage
Face down changes: * GUI: added visible face down type and real card name for controller/owner (opponent can see it after game ends); * GUI: added day/night button to view real card for controller/owner (opponent can see it after game ends); * game: fixed that faced-down card can render symbols, abilities and other hidden data from a real card; * images: added image support for normal faced-down cards; * images: added image support for morph and megamorph faced-down cards; * images: added image support for foretell faced-down cards; Other changes: * images: fixed missing tokens from DDD set; * images: no more client restart to apply newly downloaded images or render settings; * images: improved backface image quality (use main menu -> symbols to download it);
68 lines
2.5 KiB
Java
68 lines
2.5 KiB
Java
package mage.client.util;
|
|
|
|
import mage.cards.Card;
|
|
import mage.cards.repository.CardInfo;
|
|
import mage.cards.repository.CardRepository;
|
|
import mage.view.*;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* @author BetaSteward_at_googlemail.com, JayDi85
|
|
*/
|
|
public final class CardsViewUtil {
|
|
|
|
public static CardsView convertSimple(SimpleCardsView view) {
|
|
CardsView cards = new CardsView();
|
|
|
|
for (SimpleCardView simple : view.values()) {
|
|
CardInfo cardInfo = CardRepository.instance.findCard(simple.getExpansionSetCode(), simple.getCardNumber());
|
|
Card card = cardInfo != null ? cardInfo.createMockCard() : null;
|
|
if (card != null) {
|
|
cards.put(simple.getId(), new CardView(card, simple));
|
|
}
|
|
}
|
|
|
|
return cards;
|
|
}
|
|
|
|
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.createMockCard() : null;
|
|
loadedCards.put(key, card);
|
|
}
|
|
if (card != null) {
|
|
cards.put(simple.getId(), new CardView(card, simple));
|
|
}
|
|
}
|
|
|
|
return cards;
|
|
}
|
|
|
|
public static CardsView convertCommandObject(List<CommandObjectView> view) {
|
|
CardsView cards = new CardsView();
|
|
for (CommandObjectView commandObject : view) {
|
|
CardView cardView;
|
|
if (commandObject instanceof EmblemView) {
|
|
cardView = new CardView((EmblemView) commandObject);
|
|
} else if (commandObject instanceof DungeonView) {
|
|
cardView = new CardView((DungeonView) commandObject);
|
|
} else if (commandObject instanceof PlaneView) {
|
|
cardView = new CardView((PlaneView) commandObject);
|
|
} else if (commandObject instanceof CommanderView) {
|
|
cardView = (CommanderView) commandObject;
|
|
} else {
|
|
throw new IllegalStateException("ERROR, unsupported commander object type: " + commandObject.getClass().getSimpleName());
|
|
}
|
|
cards.put(commandObject.getId(), cardView);
|
|
}
|
|
return cards;
|
|
}
|
|
}
|