Changes to ensure LDA archetype decks are used in gauntlets rather than the old card-based ones. Ensured correct longpress function for generated decks in cardview on android.

This commit is contained in:
austinio7116
2018-06-07 20:32:15 +01:00
committed by maustin
parent 85ad236693
commit f34dc83907
5 changed files with 21 additions and 55 deletions

View File

@@ -10,6 +10,7 @@ import com.badlogic.gdx.math.Rectangle;
import forge.Forge;
import forge.Graphics;
import forge.assets.FSkinImage;
import forge.deck.ArchetypeDeckGenerator;
import forge.deck.CardThemedDeckGenerator;
import forge.deck.CommanderDeckGenerator;
import forge.deck.DeckProxy;
@@ -131,6 +132,8 @@ public class CardZoom extends FOverlay {
return CardView.getCardForUi(((CardThemedDeckGenerator)item).getPaperCard());
}else if (item instanceof CommanderDeckGenerator){
return CardView.getCardForUi(((CommanderDeckGenerator)item).getPaperCard());
}else if (item instanceof ArchetypeDeckGenerator){
return CardView.getCardForUi(((ArchetypeDeckGenerator)item).getPaperCard());
}else{
DeckProxy deck = ((DeckProxy)item);
return new CardView(-1, null, deck.getName(), null, deck.getImageKey(false));

View File

@@ -11,10 +11,7 @@ import forge.assets.ImageCache;
import forge.card.CardRenderer;
import forge.card.CardRenderer.CardStackPosition;
import forge.card.CardZoom;
import forge.deck.CardThemedDeckGenerator;
import forge.deck.CommanderDeckGenerator;
import forge.deck.DeckProxy;
import forge.deck.FDeckViewer;
import forge.deck.*;
import forge.item.InventoryItem;
import forge.item.PaperCard;
import forge.itemmanager.ColumnDef;
@@ -864,7 +861,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
public boolean longPress(float x, float y) {
ItemInfo item = getItemAtPoint(x + getLeft(), y + getTop());
if (item != null) {
if(item.getKey() instanceof CardThemedDeckGenerator || item.getKey() instanceof CommanderDeckGenerator){
if(item.getKey() instanceof CardThemedDeckGenerator || item.getKey() instanceof CommanderDeckGenerator
|| item.getKey() instanceof ArchetypeDeckGenerator){
FDeckViewer.show(((DeckProxy)item.getKey()).getDeck());
return true;
}

View File

@@ -72,48 +72,6 @@ public class DeckgenUtil {
}
}
/**
* Take two lists of cards with counts of each and combine the second into the first by adding a mean normalized fraction
* of the count in the second list to the first list.
* @param cards1
* @param cards2
*/
public static void combineDistances(List<Map.Entry<PaperCard,Integer>> cards1,List<Map.Entry<PaperCard,Integer>> cards2){
Float secondListWeighting=0.4f;
Integer maxDistance=0;
for (Map.Entry<PaperCard,Integer> pair1:cards1){
maxDistance=maxDistance+pair1.getValue();
}
maxDistance=maxDistance/cards1.size();
Integer maxDistance2=0;
for (Map.Entry<PaperCard,Integer> pair2:cards2){
maxDistance2=maxDistance2+pair2.getValue();
}
maxDistance2=maxDistance2/cards2.size();
for (Map.Entry<PaperCard,Integer> pair2:cards2){
boolean isCardPresent=false;
for (Map.Entry<PaperCard,Integer> pair1:cards1){
if (pair1.getKey().equals(pair2.getKey())){
pair1.setValue(pair1.getValue()+new Float((pair2.getValue()*secondListWeighting*maxDistance/maxDistance2)).intValue());
isCardPresent=true;
break;
}
}
if(!isCardPresent){
Map.Entry<PaperCard,Integer> newEntry=new AbstractMap.SimpleEntry<PaperCard, Integer>(pair2.getKey(),new Float((pair2.getValue()*0.4*maxDistance/maxDistance2)).intValue());
cards1.add(newEntry);
}
}
}
public static class CardDistanceComparator implements Comparator<Map.Entry<PaperCard,Integer>>
{
@Override
public int compare(Map.Entry<PaperCard,Integer> index1, Map.Entry<PaperCard,Integer> index2)
{
return index1.getValue().compareTo(index2.getValue());
}
}
public static Deck buildPlanarConquestDeck(PaperCard card, GameFormat format, DeckFormat deckFormat){
return buildPlanarConquestDeck(card, null, format, deckFormat, false);
@@ -241,11 +199,11 @@ public class DeckgenUtil {
if(deck.getMain().countAll()!=60){
System.out.println(deck.getMain().countAll());
System.out.println("Wrong card count "+deck.getMain().countAll());
deck=buildCardGenDeck(format,isForAI);
deck=buildLDACArchetypeDeck(format,isForAI);
}
if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES))>27){
System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES)));
deck=buildCardGenDeck(format,isForAI);
deck=buildLDACArchetypeDeck(format,isForAI);
}
while(deck.get(DeckSection.Sideboard).countAll()>15){
deck.get(DeckSection.Sideboard).remove(deck.get(DeckSection.Sideboard).get(0));
@@ -255,6 +213,13 @@ public class DeckgenUtil {
public static Deck buildLDACArchetypeDeck(GameFormat format, boolean isForAI){
List<Archetype> keys = new ArrayList<>(CardArchetypeLDAGenerator.ldaArchetypes.get(format.getName()));
Archetype randomKey = keys.get( MyRandom.getRandom().nextInt(keys.size()) );
return buildLDACArchetypeDeck(randomKey,format,isForAI);
}
/**
* Build a deck based on the chosen card.
*
@@ -319,11 +284,11 @@ public class DeckgenUtil {
if(deck.getMain().countAll()!=60){
System.out.println(deck.getMain().countAll());
System.out.println("Wrong card count "+deck.getMain().countAll());
deck=buildCardGenDeck(format,isForAI);
deck=buildLDACArchetypeDeck(format,isForAI);
}
if(deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES))>27){
System.out.println("Too many lands "+deck.getMain().countAll(Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES)));
deck=buildCardGenDeck(format,isForAI);
deck=buildLDACArchetypeDeck(format,isForAI);
}
while(deck.get(DeckSection.Sideboard).countAll()>15){
deck.get(DeckSection.Sideboard).remove(deck.get(DeckSection.Sideboard).get(0));

View File

@@ -101,9 +101,9 @@ public class RandomDeckGenerator extends DeckProxy implements Comparable<RandomD
}
return DeckgenUtil.buildColorDeck(colors, null, isAi);
case STANDARD_CARDGEN_DECK:
return DeckgenUtil.buildCardGenDeck(FModel.getFormats().getStandard(),isAi);
return DeckgenUtil.buildLDACArchetypeDeck(FModel.getFormats().getStandard(),isAi);
case MODERN_CARDGEN_DECK:
return DeckgenUtil.buildCardGenDeck(FModel.getFormats().getModern(),isAi);
return DeckgenUtil.buildLDACArchetypeDeck(FModel.getFormats().getModern(),isAi);
case STANDARD_COLOR_DECK:
colors = new ArrayList<String>();
count = Aggregates.randomInt(1, 3);

View File

@@ -34,10 +34,10 @@ public class GauntletUtil {
deck = DeckgenUtil.getRandomColorDeck(FModel.getFormats().getStandard().getFilterPrinted(),true);
break;
case STANDARD_CARDGEN_DECK:
deck = DeckgenUtil.buildCardGenDeck(FModel.getFormats().getStandard(),true);
deck = DeckgenUtil.buildLDACArchetypeDeck(FModel.getFormats().getStandard(),true);
break;
case MODERN_CARDGEN_DECK:
deck = DeckgenUtil.buildCardGenDeck(FModel.getFormats().getModern(),true);
deck = DeckgenUtil.buildLDACArchetypeDeck(FModel.getFormats().getModern(),true);
break;
case MODERN_COLOR_DECK:
deck = DeckgenUtil.getRandomColorDeck(FModel.getFormats().getModern().getFilterPrinted(),true);