forked from External/mage
[Client]Load cards from db only once during a game.
Display library with effects like "fetchland" are faster
This commit is contained in:
parent
16eee07a74
commit
0d88b4055b
3 changed files with 36 additions and 10 deletions
|
|
@ -29,6 +29,7 @@
|
|||
package mage.client.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
|
|
@ -53,6 +54,26 @@ public class CardsViewUtil {
|
|||
|
||||
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.getMockCard() : null;
|
||||
loadedCards.put(key, card);
|
||||
}
|
||||
if (card != null) {
|
||||
cards.put(simple.getId(), new CardView(card, simple.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
return cards;
|
||||
}
|
||||
|
||||
public static CardsView convertCommandObject(List<CommandObjectView> view) {
|
||||
CardsView cards = new CardsView();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue