mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
Merge branch 'traxisfix' into 'master'
Deck Generator Improvements See merge request core-developers/forge!452
This commit is contained in:
@@ -63,6 +63,8 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
protected static final boolean logToConsole = false;
|
||||
protected static final boolean logColorsToConsole = false;
|
||||
|
||||
protected Map<Integer,Integer> targetCMCs;
|
||||
|
||||
|
||||
public CardThemedDeckBuilder(IDeckGenPool pool, DeckFormat format){
|
||||
super(pool,format);
|
||||
@@ -169,6 +171,8 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
// as filters and iterate over _source_ collection each time. So even if
|
||||
// aiPlayable has changed, there is no need to create a new iterable.
|
||||
|
||||
generateTargetCMCs();
|
||||
|
||||
// 2. Add keycards
|
||||
|
||||
addKeyCards();
|
||||
@@ -299,6 +303,29 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
|
||||
}
|
||||
|
||||
protected void generateTargetCMCs(){
|
||||
targetCMCs = new HashMap<>();
|
||||
targetCMCs.put(1,Math.round((MyRandom.getRandom().nextInt(4)+2)*targetSize/60));//2
|
||||
targetCMCs.put(2,Math.round((MyRandom.getRandom().nextInt(5)+5)*targetSize/60));//6
|
||||
targetCMCs.put(3,Math.round((MyRandom.getRandom().nextInt(5)+6)*targetSize/60));//7
|
||||
targetCMCs.put(4,Math.round((MyRandom.getRandom().nextInt(3)+3)*targetSize/60));//4
|
||||
targetCMCs.put(5,Math.round((MyRandom.getRandom().nextInt(3)+3)*targetSize/60));//3
|
||||
targetCMCs.put(6,Math.round((MyRandom.getRandom().nextInt(3)+1)*targetSize/60));//2
|
||||
|
||||
while(sumMapValues(targetCMCs) < numSpellsNeeded){
|
||||
int randomKey = MyRandom.getRandom().nextInt(6)+1;
|
||||
targetCMCs.put(randomKey,targetCMCs.get(randomKey) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private int sumMapValues(Map<Integer, Integer> integerMap){
|
||||
int sum = 0;
|
||||
for (float f : integerMap.values()) {
|
||||
sum += f;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
protected void addKeyCards(){
|
||||
// Add the first keycard if not land
|
||||
if(!keyCard.getRules().getMainPart().getType().isLand()) {
|
||||
@@ -528,7 +555,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
if (secondKeyCard != null) {
|
||||
possibleList.removeAll(StaticData.instance().getCommonCards().getAllCards(secondKeyCard.getName()));
|
||||
}
|
||||
Iterator<PaperCard> iRandomPool=possibleList.iterator();
|
||||
Iterator<PaperCard> iRandomPool = CardRanker.rankCardsInDeck(possibleList.subList(0, targetSize <= possibleList.size() ? targetSize : possibleList.size())).iterator();
|
||||
while (deckList.size() < targetSize) {
|
||||
if (logToConsole) {
|
||||
System.out.println("WARNING: Fixing deck size, currently " + deckList.size() + " cards.");
|
||||
@@ -762,14 +789,9 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
possibleList.removeAll(StaticData.instance().getCommonCards().getAllCards(secondKeyCard.getName()));
|
||||
}
|
||||
Collections.shuffle(possibleList);
|
||||
Iterator<PaperCard> iRandomPool=possibleList.iterator();
|
||||
for(int i=0;i<num;++i){
|
||||
PaperCard randomCard=iRandomPool.next();
|
||||
deckList.add(randomCard);
|
||||
if(logToConsole) {
|
||||
System.out.println("Random Card[" + i + "]:" + randomCard.getName() + " (" + randomCard.getRules().getManaCost() + ")");
|
||||
}
|
||||
}
|
||||
addManaCurveCards(CardRanker.rankCardsInDeck(possibleList.subList(0, targetSize*3 <= possibleList.size() ? targetSize*3 : possibleList.size())),
|
||||
num, "Random Card");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -820,13 +842,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
||||
aiPlayables.removeAll(keyCardList);
|
||||
rankedColorList.removeAll(keyCardList);
|
||||
}*/
|
||||
final Map<Integer,Integer> targetCMCs = new HashMap<>();
|
||||
targetCMCs.put(1,Math.round((MyRandom.getRandom().nextInt(4)+2)*targetSize/60));//2
|
||||
targetCMCs.put(2,Math.round((MyRandom.getRandom().nextInt(5)+5)*targetSize/60));//6
|
||||
targetCMCs.put(3,Math.round((MyRandom.getRandom().nextInt(5)+6)*targetSize/60));//7
|
||||
targetCMCs.put(4,Math.round((MyRandom.getRandom().nextInt(3)+3)*targetSize/60));//4
|
||||
targetCMCs.put(5,Math.round((MyRandom.getRandom().nextInt(3)+3)*targetSize/60));//3
|
||||
targetCMCs.put(6,Math.round((MyRandom.getRandom().nextInt(3)+1)*targetSize/60));//2
|
||||
|
||||
|
||||
|
||||
final Map<Integer, Integer> creatureCosts = new HashMap<Integer, Integer>();
|
||||
|
||||
Reference in New Issue
Block a user