mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
Improve convertByXitaxMethod
This commit is contained in:
@@ -247,6 +247,36 @@ public class StaticData {
|
||||
return card;
|
||||
}
|
||||
|
||||
public PaperCard getCardFromLatestorEarliest(PaperCard card) {
|
||||
|
||||
PaperCard c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.Latest, card.getArtIndex());
|
||||
|
||||
if (null != c && c.hasImage()) {
|
||||
return c;
|
||||
}
|
||||
|
||||
c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.Latest, -1);
|
||||
|
||||
if (null != c && c.hasImage()) {
|
||||
return c;
|
||||
}
|
||||
|
||||
c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.LatestCoreExp, -1);
|
||||
|
||||
if (null != c) {
|
||||
return c;
|
||||
}
|
||||
|
||||
c = this.getCommonCards().getCardFromEdition(card.getName(), null, CardDb.SetPreference.EarliestCoreExp, -1);
|
||||
|
||||
if (null != c) {
|
||||
return c;
|
||||
}
|
||||
|
||||
// I give up!
|
||||
return card;
|
||||
}
|
||||
|
||||
public boolean getFilteredHandsEnabled(){
|
||||
return filteredHandsEnabled;
|
||||
}
|
||||
|
||||
@@ -402,6 +402,16 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
||||
public PaperCard getCardFromEdition(final String cardName, final Date printedBefore, final SetPreference fromSet, int artIndex) {
|
||||
final CardRequest cr = CardRequest.fromString(cardName);
|
||||
List<PaperCard> cards = getAllCards(cr.cardName);
|
||||
if (printedBefore != null){
|
||||
cards = Lists.newArrayList(Iterables.filter(cards, new Predicate<PaperCard>() {
|
||||
@Override public boolean apply(PaperCard c) {
|
||||
CardEdition ed = editions.get(c.getEdition());
|
||||
return ed.getDate().before(printedBefore); }
|
||||
}));
|
||||
}
|
||||
|
||||
if (cards.size() == 0) // Don't bother continuing! No cards has been found!
|
||||
return null;
|
||||
boolean cardsListReadOnly = true;
|
||||
|
||||
if (StringUtils.isNotBlank(cr.edition)) {
|
||||
|
||||
@@ -252,7 +252,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
||||
}
|
||||
|
||||
private void convertByXitaxMethod() {
|
||||
Date dateWithAllCards = StaticData.instance().getEditions().getEarliestDateWithAllCards(getAllCardsInASinglePool());
|
||||
//Date dateWithAllCards = StaticData.instance().getEditions().getEarliestDateWithAllCards(getAllCardsInASinglePool());
|
||||
|
||||
for(Entry<DeckSection, CardPool> p : parts.entrySet()) {
|
||||
if( p.getKey() == DeckSection.Planes || p.getKey() == DeckSection.Schemes || p.getKey() == DeckSection.Avatar)
|
||||
@@ -264,12 +264,18 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
|
||||
PaperCard card = cp.getKey();
|
||||
int count = cp.getValue();
|
||||
|
||||
PaperCard replacementCard = StaticData.instance().getCardByEditionDate(card, dateWithAllCards);
|
||||
PaperCard replacementCard = StaticData.instance().getCardFromLatestorEarliest(card);
|
||||
|
||||
if (replacementCard.getArtIndex() == card.getArtIndex()) {
|
||||
newPool.add(card, count);
|
||||
if (card.hasImage())
|
||||
newPool.add(card, count);
|
||||
else
|
||||
newPool.add(replacementCard, count);
|
||||
} else {
|
||||
newPool.add(card.getName(), card.getEdition(), count); // this is to randomize art
|
||||
if (card.hasImage())
|
||||
newPool.add(card.getName(), card.getEdition(), count); // this is to randomize art
|
||||
else
|
||||
newPool.add(replacementCard, count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user