mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge branch 'khmldabranch' into 'master'
KHM deck generation See merge request core-developers/forge!4469
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,18 +2,31 @@ package forge.gamemodes.limited;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.card.MagicColor;
|
||||||
import forge.deck.DeckFormat;
|
import forge.deck.DeckFormat;
|
||||||
import forge.deck.io.Archetype;
|
import forge.deck.io.Archetype;
|
||||||
import forge.game.GameFormat;
|
import forge.game.GameFormat;
|
||||||
import forge.item.PaperCard;
|
import forge.item.PaperCard;
|
||||||
|
import forge.model.FModel;
|
||||||
|
import forge.util.MyRandom;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
public class ArchetypeDeckBuilder extends CardThemedDeckBuilder{
|
public class ArchetypeDeckBuilder extends CardThemedDeckBuilder{
|
||||||
|
|
||||||
private Archetype archetype;
|
private Archetype archetype;
|
||||||
|
private boolean needsSnowLands = false;
|
||||||
|
|
||||||
public ArchetypeDeckBuilder(Archetype archetype0, PaperCard keyCard0, final List<PaperCard> dList, GameFormat format, boolean isForAI){
|
public ArchetypeDeckBuilder(Archetype archetype0, PaperCard keyCard0, final List<PaperCard> dList, GameFormat format, boolean isForAI){
|
||||||
super(keyCard0,null, dList, format, isForAI, DeckFormat.Constructed);
|
super(keyCard0,null, dList, format, isForAI, DeckFormat.Constructed);
|
||||||
archetype = archetype0;
|
archetype = archetype0;
|
||||||
|
for(Pair<String, Double> pair : archetype.getCardProbabilities()){
|
||||||
|
for(int i=0;i<5;++i){
|
||||||
|
if (pair.getLeft().equals(MagicColor.Constant.SNOW_LANDS.get(i)) && pair.getRight() > 0.04) {
|
||||||
|
needsSnowLands=true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +38,25 @@ public class ArchetypeDeckBuilder extends CardThemedDeckBuilder{
|
|||||||
return archetype.getName() + " Generated Deck";
|
return archetype.getName() + " Generated Deck";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get basic land.
|
||||||
|
*
|
||||||
|
* @param basicLand
|
||||||
|
* the set to take basic lands from (pass 'null' for random).
|
||||||
|
* @return card
|
||||||
|
*/
|
||||||
|
protected PaperCard getBasicLand(final int basicLand) {
|
||||||
|
if(needsSnowLands){
|
||||||
|
for(String landSet : setsWithBasicLands){
|
||||||
|
PaperCard land = FModel.getMagicDb().getCommonCards().getCard(MagicColor.Constant.SNOW_LANDS.get(basicLand), landSet);
|
||||||
|
if(land!=null){
|
||||||
|
return land;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getBasicLand(basicLand);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -704,24 +704,11 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
|||||||
System.out.printf("Basics[%s]: %d/%d = %f%% = %d cards%n", MagicColor.Constant.BASIC_LANDS.get(i), clrCnts[i], totalColor, 100*p, nLand + 1);
|
System.out.printf("Basics[%s]: %d/%d = %f%% = %d cards%n", MagicColor.Constant.BASIC_LANDS.get(i), clrCnts[i], totalColor, 100*p, nLand + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
PaperCard snowLand = null;
|
|
||||||
// if appropriate snow-covered lands are available, add them
|
|
||||||
for (final PaperCard cp : basicLands) {
|
|
||||||
if (cp.getName().equals(MagicColor.Constant.SNOW_LANDS.get(i))) {
|
|
||||||
snowLand = cp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < nLand; j++) {
|
for (int j = 0; j < nLand; j++) {
|
||||||
if(snowLand!=null){
|
|
||||||
deckList.add(snowLand);
|
|
||||||
}else {
|
|
||||||
deckList.add(getBasicLand(i));
|
deckList.add(getBasicLand(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// A common problem at this point is that p in the above loop was exactly 1/2,
|
// A common problem at this point is that p in the above loop was exactly 1/2,
|
||||||
// and nLand rounded up for both colors, so that one too many lands was added.
|
// and nLand rounded up for both colors, so that one too many lands was added.
|
||||||
@@ -740,7 +727,7 @@ public class CardThemedDeckBuilder extends DeckGeneratorBase {
|
|||||||
* the set to take basic lands from (pass 'null' for random).
|
* the set to take basic lands from (pass 'null' for random).
|
||||||
* @return card
|
* @return card
|
||||||
*/
|
*/
|
||||||
private PaperCard getBasicLand(final int basicLand) {
|
protected PaperCard getBasicLand(final int basicLand) {
|
||||||
String set;
|
String set;
|
||||||
if (setsWithBasicLands.size() > 1) {
|
if (setsWithBasicLands.size() > 1) {
|
||||||
set = setsWithBasicLands.get(MyRandom.getRandom().nextInt(setsWithBasicLands.size() - 1));
|
set = setsWithBasicLands.get(MyRandom.getRandom().nextInt(setsWithBasicLands.size() - 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user