mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 19:28:01 +00:00
Merge pull request #440 from kevlahnota/master
refactor deckgen for adventure
This commit is contained in:
@@ -219,6 +219,16 @@ public class ConsoleCommandInterpreter {
|
|||||||
}
|
}
|
||||||
return "Enemy deck list dumped to stdout.";
|
return "Enemy deck list dumped to stdout.";
|
||||||
});
|
});
|
||||||
|
registerCommand(new String[]{"dumpEnemyColorIdentity"}, s -> {
|
||||||
|
for(EnemyData E : new Array.ArrayIterator<>(WorldData.getAllEnemies())){
|
||||||
|
Deck D = E.generateDeck(Current.player().isFantasyMode());
|
||||||
|
DeckProxy DP = new DeckProxy(D, "Constructed", GameType.Constructed, null);
|
||||||
|
ColorSet colorSet = DP.getColor();
|
||||||
|
System.out.printf("%s Colors: %s | Deck Colors: %s (%s)\n", E.name, E.colors, DP.getColorIdentity().toEnumSet().toString(), DP.getName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return "Enemy color Identity dumped to stdout.";
|
||||||
|
});
|
||||||
registerCommand(new String[]{"heal", "amount"}, s -> {
|
registerCommand(new String[]{"heal", "amount"}, s -> {
|
||||||
if(s.length<1) return "Command needs 1 parameter";
|
if(s.length<1) return "Command needs 1 parameter";
|
||||||
int N = 0;
|
int N = 0;
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
@@ -61,6 +59,7 @@ import forge.util.storage.IStorage;
|
|||||||
*/
|
*/
|
||||||
// TODO This class can be used for home menu constructed deck generation as well.
|
// TODO This class can be used for home menu constructed deck generation as well.
|
||||||
public class DeckgenUtil {
|
public class DeckgenUtil {
|
||||||
|
private static List<DeckProxy> advPrecons = Lists.newArrayList(), advThemes = Lists.newArrayList();
|
||||||
|
|
||||||
public static Deck buildCardGenDeck(GameFormat format, boolean isForAI){
|
public static Deck buildCardGenDeck(GameFormat format, boolean isForAI){
|
||||||
try {
|
try {
|
||||||
@@ -437,7 +436,14 @@ public class DeckgenUtil {
|
|||||||
/** @return {@link forge.deck.Deck} */
|
/** @return {@link forge.deck.Deck} */
|
||||||
public static Deck getRandomOrPreconOrThemeDeck(String colors, boolean forAi, boolean isTheme) {
|
public static Deck getRandomOrPreconOrThemeDeck(String colors, boolean forAi, boolean isTheme) {
|
||||||
final List<String> selection = new ArrayList<>();
|
final List<String> selection = new ArrayList<>();
|
||||||
List<DeckProxy> allDecks = new ArrayList<>();
|
Deck deck = null;
|
||||||
|
if (advPrecons.isEmpty()) {
|
||||||
|
advPrecons.addAll(DeckProxy.getAllPreconstructedDecks(QuestController.getPrecons()));
|
||||||
|
}
|
||||||
|
if (advThemes.isEmpty()) {
|
||||||
|
advThemes.addAll(DeckProxy.getAllThemeDecks());
|
||||||
|
advThemes.addAll(DeckProxy.getNonEasyQuestDuelDecks());
|
||||||
|
}
|
||||||
if (!colors.isEmpty()) {
|
if (!colors.isEmpty()) {
|
||||||
for (char c : colors.toLowerCase().toCharArray()) {
|
for (char c : colors.toLowerCase().toCharArray()) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@@ -449,61 +455,24 @@ public class DeckgenUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//limit selection to three
|
try {
|
||||||
if (!selection.isEmpty() && selection.size() < 4) {
|
if (!selection.isEmpty() && selection.size() < 4) {
|
||||||
//monocolor
|
Predicate<DeckProxy> pred = Predicates.and(deckProxy -> deckProxy.getMainSize() <= 60, deckProxy -> deckProxy.getColorIdentity().hasAllColors(ColorSet.fromNames(colors.toCharArray()).getColor()));
|
||||||
if (selection.size() == 1) {
|
if (isTheme)
|
||||||
if (isTheme) {
|
deck = Aggregates.random(Iterables.filter(advThemes, pred)).getDeck();
|
||||||
//duels and theme
|
else
|
||||||
allDecks = Stream.concat(DeckProxy.getAllThemeDecks().parallelStream()
|
deck = Aggregates.random(Iterables.filter(advPrecons, pred)).getDeck();
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60)
|
|
||||||
.filter(deckProxy -> deckProxy.getColor() != null && deckProxy.getColor().isMonoColor()
|
|
||||||
&& deckProxy.getColor().hasExactlyColor(ColorSet.fromNames(selection).getColor())),
|
|
||||||
DeckProxy.getNonEasyQuestDuelDecks().parallelStream()
|
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60)
|
|
||||||
.filter(deckProxy -> deckProxy.getColor() != null && deckProxy.getColor().isMonoColor()
|
|
||||||
&& deckProxy.getColor().hasExactlyColor(ColorSet.fromNames(selection).getColor())))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} else {
|
|
||||||
allDecks = DeckProxy.getAllPreconstructedDecks(QuestController.getPrecons()).parallelStream()
|
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60)
|
|
||||||
.filter(deckProxy -> deckProxy.getColor() != null && deckProxy.getColor().isMonoColor() && deckProxy.getColor().hasExactlyColor(ColorSet.fromNames(selection).getColor()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (isTheme) {
|
if (isTheme)
|
||||||
//duels and theme
|
deck = Aggregates.random(Iterables.filter(advThemes, deckProxy -> deckProxy.getMainSize() <= 60)).getDeck();
|
||||||
allDecks = Stream.concat(DeckProxy.getAllThemeDecks().parallelStream()
|
else
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60)
|
deck = Aggregates.random(Iterables.filter(advPrecons, deckProxy -> deckProxy.getMainSize() <= 60)).getDeck();
|
||||||
.filter(deckProxy -> deckProxy.getColor() != null && deckProxy.getColor().hasAllColors(ColorSet.fromNames(selection).getColor())),
|
|
||||||
DeckProxy.getNonEasyQuestDuelDecks().parallelStream()
|
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60)
|
|
||||||
.filter(deckProxy -> deckProxy.getColor() != null && deckProxy.getColor().hasAllColors(ColorSet.fromNames(selection).getColor())))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} else {
|
|
||||||
allDecks = DeckProxy.getAllPreconstructedDecks(QuestController.getPrecons()).parallelStream()
|
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60)
|
|
||||||
.filter(deckProxy -> deckProxy.getColor() != null && deckProxy.getColor().hasAllColors(ColorSet.fromNames(selection).getColor()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//no specific colors
|
|
||||||
if (isTheme) {
|
|
||||||
//duels and theme
|
|
||||||
allDecks = Stream.concat(DeckProxy.getAllThemeDecks().parallelStream()
|
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60),
|
|
||||||
DeckProxy.getNonEasyQuestDuelDecks().parallelStream()
|
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
} else {
|
|
||||||
allDecks = DeckProxy.getAllPreconstructedDecks(QuestController.getPrecons()).parallelStream()
|
|
||||||
.filter(deckProxy -> deckProxy.getMainSize() <= 60)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (!allDecks.isEmpty()) {
|
if (deck != null) {
|
||||||
return Aggregates.random(allDecks).getDeck();
|
return deck;
|
||||||
}
|
}
|
||||||
return DeckgenUtil.buildColorDeck(selection, null, forAi);
|
return DeckgenUtil.buildColorDeck(selection, null, forAi);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user