mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Introduction of "wild duels" in quest
This commit is contained in:
@@ -10,7 +10,8 @@ public enum QuestEventDifficulty {
|
|||||||
EASY ("easy", 1. ),
|
EASY ("easy", 1. ),
|
||||||
MEDIUM("medium", 1.5),
|
MEDIUM("medium", 1.5),
|
||||||
HARD ("hard", 2. ),
|
HARD ("hard", 2. ),
|
||||||
EXPERT("very hard", 3. );
|
EXPERT("very hard", 3. ),
|
||||||
|
WILD("wild", 2. );
|
||||||
|
|
||||||
private final String inFile;
|
private final String inFile;
|
||||||
private final double multiplier;
|
private final double multiplier;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
|||||||
private static List<QuestEventDifficulty> mediumOrder = Arrays.asList(QuestEventDifficulty.MEDIUM, QuestEventDifficulty.HARD, QuestEventDifficulty.EASY, QuestEventDifficulty.EXPERT);
|
private static List<QuestEventDifficulty> mediumOrder = Arrays.asList(QuestEventDifficulty.MEDIUM, QuestEventDifficulty.HARD, QuestEventDifficulty.EASY, QuestEventDifficulty.EXPERT);
|
||||||
private static List<QuestEventDifficulty> hardOrder = Arrays.asList(QuestEventDifficulty.HARD, QuestEventDifficulty.MEDIUM, QuestEventDifficulty.EASY, QuestEventDifficulty.EXPERT);
|
private static List<QuestEventDifficulty> hardOrder = Arrays.asList(QuestEventDifficulty.HARD, QuestEventDifficulty.MEDIUM, QuestEventDifficulty.EASY, QuestEventDifficulty.EXPERT);
|
||||||
private static List<QuestEventDifficulty> expertOrder = Arrays.asList(QuestEventDifficulty.EXPERT, QuestEventDifficulty.HARD, QuestEventDifficulty.MEDIUM, QuestEventDifficulty.EASY);
|
private static List<QuestEventDifficulty> expertOrder = Arrays.asList(QuestEventDifficulty.EXPERT, QuestEventDifficulty.HARD, QuestEventDifficulty.MEDIUM, QuestEventDifficulty.EASY);
|
||||||
|
private static List<QuestEventDifficulty> wildOrder = Arrays.asList(QuestEventDifficulty.WILD);
|
||||||
|
|
||||||
private List<QuestEventDifficulty> getOrderForDifficulty(QuestEventDifficulty d) {
|
private List<QuestEventDifficulty> getOrderForDifficulty(QuestEventDifficulty d) {
|
||||||
final List<QuestEventDifficulty> difficultyOrder;
|
final List<QuestEventDifficulty> difficultyOrder;
|
||||||
@@ -83,6 +84,9 @@ public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
|||||||
case EXPERT:
|
case EXPERT:
|
||||||
difficultyOrder = expertOrder;
|
difficultyOrder = expertOrder;
|
||||||
break;
|
break;
|
||||||
|
case WILD:
|
||||||
|
difficultyOrder = wildOrder;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("unhandled difficulty: " + d);
|
throw new RuntimeException("unhandled difficulty: " + d);
|
||||||
}
|
}
|
||||||
@@ -203,6 +207,7 @@ public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDuel(duelOpponents, QuestEventDifficulty.WILD, 1);
|
||||||
addRandomDuel(duelOpponents, randomDuelDifficulty);
|
addRandomDuel(duelOpponents, randomDuelDifficulty);
|
||||||
|
|
||||||
return duelOpponents;
|
return duelOpponents;
|
||||||
@@ -222,6 +227,7 @@ public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
|||||||
sortedDuels.put(QuestEventDifficulty.MEDIUM, new ArrayList<>());
|
sortedDuels.put(QuestEventDifficulty.MEDIUM, new ArrayList<>());
|
||||||
sortedDuels.put(QuestEventDifficulty.HARD, new ArrayList<>());
|
sortedDuels.put(QuestEventDifficulty.HARD, new ArrayList<>());
|
||||||
sortedDuels.put(QuestEventDifficulty.EXPERT, new ArrayList<>());
|
sortedDuels.put(QuestEventDifficulty.EXPERT, new ArrayList<>());
|
||||||
|
sortedDuels.put(QuestEventDifficulty.WILD, new ArrayList<>());
|
||||||
|
|
||||||
for (final QuestEventDuel qd : allDuels) {
|
for (final QuestEventDuel qd : allDuels) {
|
||||||
sortedDuels.add(qd.getDifficulty(), qd);
|
sortedDuels.add(qd.getDifficulty(), qd);
|
||||||
|
|||||||
@@ -3,24 +3,74 @@ package forge.quest.io;
|
|||||||
import forge.ImageKeys;
|
import forge.ImageKeys;
|
||||||
import forge.deck.io.DeckSerializer;
|
import forge.deck.io.DeckSerializer;
|
||||||
import forge.deck.io.DeckStorage;
|
import forge.deck.io.DeckStorage;
|
||||||
|
import forge.properties.ForgeConstants;
|
||||||
import forge.quest.QuestEvent;
|
import forge.quest.QuestEvent;
|
||||||
import forge.quest.QuestEventDifficulty;
|
import forge.quest.QuestEventDifficulty;
|
||||||
import forge.quest.QuestEventDuel;
|
import forge.quest.QuestEventDuel;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
import forge.util.FileUtil;
|
import forge.util.FileUtil;
|
||||||
|
import forge.util.TextUtil;
|
||||||
import forge.util.storage.StorageReaderFolder;
|
import forge.util.storage.StorageReaderFolder;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public class QuestDuelReader extends StorageReaderFolder<QuestEventDuel> {
|
public class QuestDuelReader extends StorageReaderFolder<QuestEventDuel> {
|
||||||
|
|
||||||
|
private static final String WILD_DEFAULT_ICON_NAME = "Wild.jpg";
|
||||||
|
private static final String WILD_DIR_NAME = "wild";
|
||||||
|
|
||||||
public QuestDuelReader(File deckDir0) {
|
public QuestDuelReader(File deckDir0) {
|
||||||
super(deckDir0, QuestEvent.FN_GET_NAME);
|
super(deckDir0, QuestEvent.FN_GET_NAME);
|
||||||
// TODO Auto-generated constructor stub
|
// TODO Auto-generated constructor stub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, QuestEventDuel> readAll() {
|
||||||
|
|
||||||
|
List<File> dirList = new ArrayList<File>();
|
||||||
|
dirList.add(directory);
|
||||||
|
|
||||||
|
File directoryWild = new File(directory.getAbsolutePath() + ForgeConstants.PATH_SEPARATOR + WILD_DIR_NAME + ForgeConstants.PATH_SEPARATOR);
|
||||||
|
if(directoryWild.exists()) {
|
||||||
|
dirList.add(directoryWild);
|
||||||
|
}
|
||||||
|
|
||||||
|
final Map<String, QuestEventDuel> result = new TreeMap<>();
|
||||||
|
|
||||||
|
for(File currDir : dirList) {
|
||||||
|
final File[] files = currDir.listFiles(this.getFileFilter());
|
||||||
|
for (final File file : files) {
|
||||||
|
try {
|
||||||
|
final QuestEventDuel newDeck = this.read(file);
|
||||||
|
if (null == newDeck) {
|
||||||
|
final String msg = "An object stored in " + file.getPath() + " failed to load.\nPlease submit this as a bug with the mentioned file/directory attached.";
|
||||||
|
throw new RuntimeException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
String newKey = keySelector.apply(newDeck);
|
||||||
|
if (result.containsKey(newKey)) {
|
||||||
|
System.err.println("StorageReaderFolder: an object with key " + newKey + " is already present - skipping new entry");
|
||||||
|
} else {
|
||||||
|
result.put(newKey, newDeck);
|
||||||
|
}
|
||||||
|
} catch (final NoSuchElementException ex) {
|
||||||
|
final String message = TextUtil.concatWithSpace( file.getName(),"failed to load because ----", ex.getMessage());
|
||||||
|
objectsThatFailedToLoad.add(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected QuestEventDuel read(File file) {
|
protected QuestEventDuel read(File file) {
|
||||||
final Map<String, List<String>> contents = FileSection.parseSections(FileUtil.readFile(file));
|
final Map<String, List<String>> contents = FileSection.parseSections(FileUtil.readFile(file));
|
||||||
@@ -28,8 +78,11 @@ public class QuestDuelReader extends StorageReaderFolder<QuestEventDuel> {
|
|||||||
|
|
||||||
// Common properties
|
// Common properties
|
||||||
FileSection sectionMeta = FileSection.parse(contents.get("metadata"), "=");
|
FileSection sectionMeta = FileSection.parse(contents.get("metadata"), "=");
|
||||||
qc.setTitle(sectionMeta.get("Title"));
|
|
||||||
qc.setName(sectionMeta.get("Name")); // Challenges have unique titles
|
qc.setName(sectionMeta.get("Name")); // Challenges have unique titles
|
||||||
|
|
||||||
|
boolean difficultySpecified = !StringUtils.isEmpty(sectionMeta.get("Difficulty"));
|
||||||
|
if(difficultySpecified) {
|
||||||
|
qc.setTitle(sectionMeta.get("Title"));
|
||||||
qc.setDifficulty(QuestEventDifficulty.fromString(sectionMeta.get("Difficulty")));
|
qc.setDifficulty(QuestEventDifficulty.fromString(sectionMeta.get("Difficulty")));
|
||||||
qc.setDescription(sectionMeta.get("Description", "").replace("\\n", "\n"));
|
qc.setDescription(sectionMeta.get("Description", "").replace("\\n", "\n"));
|
||||||
qc.setCardReward(sectionMeta.get("Card Reward"));
|
qc.setCardReward(sectionMeta.get("Card Reward"));
|
||||||
@@ -37,6 +90,12 @@ public class QuestDuelReader extends StorageReaderFolder<QuestEventDuel> {
|
|||||||
if (sectionMeta.contains("Profile")) {
|
if (sectionMeta.contains("Profile")) {
|
||||||
qc.setProfile(sectionMeta.get("Profile"));
|
qc.setProfile(sectionMeta.get("Profile"));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qc.setDifficulty(QuestEventDifficulty.WILD);
|
||||||
|
qc.setTitle(sectionMeta.get("Title") != null ? sectionMeta.get("Title") : qc.getName());
|
||||||
|
qc.setDescription(sectionMeta.get("Description") != null ? sectionMeta.get("Description") : "Wild opponent");
|
||||||
|
qc.setIconImageKey(ImageKeys.ICON_PREFIX + (sectionMeta.get("Icon") != null ? sectionMeta.get("Icon") : WILD_DEFAULT_ICON_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
// Deck
|
// Deck
|
||||||
qc.setEventDeck(DeckSerializer.fromSections(contents));
|
qc.setEventDeck(DeckSerializer.fromSections(contents));
|
||||||
|
|||||||
Reference in New Issue
Block a user