mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Adventure tweaks
Fixed rotating shop with too many cards spawning. Refactored Jumpstart pack selection to prevent selecting two copies of the same pack when other options are available.
This commit is contained in:
@@ -279,8 +279,6 @@ public class CardUtil {
|
|||||||
List<PaperCard> result = new ArrayList<>();
|
List<PaperCard> result = new ArrayList<>();
|
||||||
CardPredicate pre = new CardPredicate(data, true);
|
CardPredicate pre = new CardPredicate(data, true);
|
||||||
|
|
||||||
java.util.Map<String, String> tempMap = new HashMap<>();
|
|
||||||
|
|
||||||
for (final PaperCard item : cards)
|
for (final PaperCard item : cards)
|
||||||
{
|
{
|
||||||
if(pre.apply(item))
|
if(pre.apply(item))
|
||||||
@@ -338,8 +336,8 @@ public class CardUtil {
|
|||||||
return reward.getCount();
|
return reward.getCount();
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
static List<List<PaperCard>> packCandidates=null;
|
|
||||||
public static Deck generateDeck(GeneratedDeckData data, CardEdition starterEdition)
|
public static Deck generateDeck(GeneratedDeckData data, CardEdition starterEdition, boolean discourageDuplicates)
|
||||||
{
|
{
|
||||||
List<String> editionCodes = (starterEdition != null)?Arrays.asList(starterEdition.getCode(), starterEdition.getCode2()):Arrays.asList("JMP", "J22", "DMU","BRO");
|
List<String> editionCodes = (starterEdition != null)?Arrays.asList(starterEdition.getCode(), starterEdition.getCode2()):Arrays.asList("JMP", "J22", "DMU","BRO");
|
||||||
Deck deck= new Deck(data.name);
|
Deck deck= new Deck(data.name);
|
||||||
@@ -353,6 +351,10 @@ public class CardUtil {
|
|||||||
if(data.jumpstartPacks!=null)
|
if(data.jumpstartPacks!=null)
|
||||||
{
|
{
|
||||||
deck.getOrCreate(DeckSection.Main);
|
deck.getOrCreate(DeckSection.Main);
|
||||||
|
|
||||||
|
Map <String, List<PaperCard>> packCandidates=null;
|
||||||
|
List<String> usedPackNames=new ArrayList<String>();
|
||||||
|
|
||||||
for(int i=0;i<data.jumpstartPacks.length;i++)
|
for(int i=0;i<data.jumpstartPacks.length;i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -368,7 +370,7 @@ public class CardUtil {
|
|||||||
case MagicColor.GREEN: targetName = "Forest"; break;
|
case MagicColor.GREEN: targetName = "Forest"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
packCandidates=new ArrayList<>();
|
packCandidates=new HashMap<>();
|
||||||
for(SealedProduct.Template template : StaticData.instance().getSpecialBoosters())
|
for(SealedProduct.Template template : StaticData.instance().getSpecialBoosters())
|
||||||
{
|
{
|
||||||
if (!editionCodes.contains(template.getEdition().split("\\s",2)[0]))
|
if (!editionCodes.contains(template.getEdition().split("\\s",2)[0]))
|
||||||
@@ -377,9 +379,30 @@ public class CardUtil {
|
|||||||
if (packContents.size() < 20 | packContents.size() > 25)
|
if (packContents.size() < 20 | packContents.size() > 25)
|
||||||
continue;
|
continue;
|
||||||
if (packContents.stream().filter(x -> x.getName().equals(targetName)).count() >=3)
|
if (packContents.stream().filter(x -> x.getName().equals(targetName)).count() >=3)
|
||||||
packCandidates.add(packContents);
|
packCandidates.putIfAbsent(template.getEdition(), packContents);
|
||||||
}
|
}
|
||||||
deck.getOrCreate(DeckSection.Main).addAllFlat(packCandidates.get(Current.world().getRandom().nextInt(packCandidates.size())));
|
List<PaperCard> selectedPack;
|
||||||
|
if (discourageDuplicates) {
|
||||||
|
Map <String, List<PaperCard>> filteredPackCandidates= new HashMap<>();
|
||||||
|
for (java.util.Map.Entry<String, List<PaperCard>> entry: packCandidates.entrySet()){
|
||||||
|
if (!usedPackNames.contains(entry.getKey())){
|
||||||
|
filteredPackCandidates.put(entry.getKey(), entry.getValue()); //deep copy so that packCandidates can be used if filtered ends up being empty
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Only re-use a pack if all possibilities have already been chosen
|
||||||
|
if (filteredPackCandidates.size() == 0)
|
||||||
|
filteredPackCandidates = packCandidates;
|
||||||
|
Object[] keys = filteredPackCandidates.keySet().toArray();
|
||||||
|
|
||||||
|
String keyName = (String)keys[Current.world().getRandom().nextInt(keys.length)];
|
||||||
|
usedPackNames.add(keyName);
|
||||||
|
selectedPack = filteredPackCandidates.remove(keyName);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Object[] keys = packCandidates.keySet().toArray();
|
||||||
|
selectedPack = packCandidates.get((String)keys[Current.world().getRandom().nextInt(keys.length)]);
|
||||||
|
}
|
||||||
|
deck.getOrCreate(DeckSection.Main).addAllFlat(selectedPack);
|
||||||
}
|
}
|
||||||
return deck;
|
return deck;
|
||||||
}
|
}
|
||||||
@@ -592,10 +615,10 @@ public class CardUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme, boolean useGeneticAI) {
|
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme, boolean useGeneticAI) {
|
||||||
return getDeck(path, forAI, isFantasyMode, colors, isTheme, useGeneticAI, null);
|
return getDeck(path, forAI, isFantasyMode, colors, isTheme, useGeneticAI, null,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme, boolean useGeneticAI, CardEdition starterEdition)
|
public static Deck getDeck(String path, boolean forAI, boolean isFantasyMode, String colors, boolean isTheme, boolean useGeneticAI, CardEdition starterEdition, boolean discourageDuplicates)
|
||||||
{
|
{
|
||||||
if(path.endsWith(".dck"))
|
if(path.endsWith(".dck"))
|
||||||
return DeckSerializer.fromFile(new File(Config.instance().getFilePath(path)));
|
return DeckSerializer.fromFile(new File(Config.instance().getFilePath(path)));
|
||||||
@@ -608,8 +631,11 @@ public class CardUtil {
|
|||||||
Json json = new Json();
|
Json json = new Json();
|
||||||
FileHandle handle = Config.instance().getFile(path);
|
FileHandle handle = Config.instance().getFile(path);
|
||||||
if (handle.exists())
|
if (handle.exists())
|
||||||
return generateDeck(json.fromJson(GeneratedDeckData.class, handle), starterEdition);
|
return generateDeck(json.fromJson(GeneratedDeckData.class, handle), starterEdition, discourageDuplicates);
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ public class Config {
|
|||||||
{
|
{
|
||||||
if(ColorSet.fromNames(entry.key.toCharArray()).getColor()==color.getColor())
|
if(ColorSet.fromNames(entry.key.toCharArray()).getColor()==color.getColor())
|
||||||
{
|
{
|
||||||
return CardUtil.getDeck(entry.value, false, false, "", false, false, starterEdition);
|
return CardUtil.getDeck(entry.value, false, false, "", false, false, starterEdition, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case Chaos:
|
case Chaos:
|
||||||
|
|||||||
@@ -339,7 +339,7 @@
|
|||||||
"overlaySprite":"Overlay6Red",
|
"overlaySprite":"Overlay6Red",
|
||||||
"rewards": [
|
"rewards": [
|
||||||
{
|
{
|
||||||
"count":68,
|
"count":6,
|
||||||
"cardText": "haste|(first |double )strike | prowess|return .* to hand at end of turn|At the beginning of (your|the) end step, (sacrifice|return .* to (your|its owner).*hand)",
|
"cardText": "haste|(first |double )strike | prowess|return .* to hand at end of turn|At the beginning of (your|the) end step, (sacrifice|return .* to (your|its owner).*hand)",
|
||||||
"colors": ["red"]
|
"colors": ["red"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user