mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Introduction of "wild duels" in quest
This commit is contained in:
@@ -10,7 +10,8 @@ public enum QuestEventDifficulty {
|
||||
EASY ("easy", 1. ),
|
||||
MEDIUM("medium", 1.5),
|
||||
HARD ("hard", 2. ),
|
||||
EXPERT("very hard", 3. );
|
||||
EXPERT("very hard", 3. ),
|
||||
WILD("wild", 2. );
|
||||
|
||||
private final String inFile;
|
||||
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> 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> wildOrder = Arrays.asList(QuestEventDifficulty.WILD);
|
||||
|
||||
private List<QuestEventDifficulty> getOrderForDifficulty(QuestEventDifficulty d) {
|
||||
final List<QuestEventDifficulty> difficultyOrder;
|
||||
@@ -83,6 +84,9 @@ public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
||||
case EXPERT:
|
||||
difficultyOrder = expertOrder;
|
||||
break;
|
||||
case WILD:
|
||||
difficultyOrder = wildOrder;
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("unhandled difficulty: " + d);
|
||||
}
|
||||
@@ -203,6 +207,7 @@ public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
||||
}
|
||||
}
|
||||
|
||||
addDuel(duelOpponents, QuestEventDifficulty.WILD, 1);
|
||||
addRandomDuel(duelOpponents, randomDuelDifficulty);
|
||||
|
||||
return duelOpponents;
|
||||
@@ -222,6 +227,7 @@ public class QuestEventDuelManager implements QuestEventDuelManagerInterface {
|
||||
sortedDuels.put(QuestEventDifficulty.MEDIUM, new ArrayList<>());
|
||||
sortedDuels.put(QuestEventDifficulty.HARD, new ArrayList<>());
|
||||
sortedDuels.put(QuestEventDifficulty.EXPERT, new ArrayList<>());
|
||||
sortedDuels.put(QuestEventDifficulty.WILD, new ArrayList<>());
|
||||
|
||||
for (final QuestEventDuel qd : allDuels) {
|
||||
sortedDuels.add(qd.getDifficulty(), qd);
|
||||
|
||||
@@ -3,23 +3,73 @@ package forge.quest.io;
|
||||
import forge.ImageKeys;
|
||||
import forge.deck.io.DeckSerializer;
|
||||
import forge.deck.io.DeckStorage;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.quest.QuestEvent;
|
||||
import forge.quest.QuestEventDifficulty;
|
||||
import forge.quest.QuestEventDuel;
|
||||
import forge.util.FileSection;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.TextUtil;
|
||||
import forge.util.storage.StorageReaderFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
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) {
|
||||
super(deckDir0, QuestEvent.FN_GET_NAME);
|
||||
// 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
|
||||
protected QuestEventDuel read(File file) {
|
||||
@@ -28,14 +78,23 @@ public class QuestDuelReader extends StorageReaderFolder<QuestEventDuel> {
|
||||
|
||||
// Common properties
|
||||
FileSection sectionMeta = FileSection.parse(contents.get("metadata"), "=");
|
||||
qc.setTitle(sectionMeta.get("Title"));
|
||||
qc.setName(sectionMeta.get("Name")); // Challenges have unique titles
|
||||
qc.setDifficulty(QuestEventDifficulty.fromString(sectionMeta.get("Difficulty")));
|
||||
qc.setDescription(sectionMeta.get("Description", "").replace("\\n", "\n"));
|
||||
qc.setCardReward(sectionMeta.get("Card Reward"));
|
||||
qc.setIconImageKey(ImageKeys.ICON_PREFIX + sectionMeta.get("Icon"));
|
||||
if (sectionMeta.contains("Profile")) {
|
||||
qc.setProfile(sectionMeta.get("Profile"));
|
||||
|
||||
boolean difficultySpecified = !StringUtils.isEmpty(sectionMeta.get("Difficulty"));
|
||||
if(difficultySpecified) {
|
||||
qc.setTitle(sectionMeta.get("Title"));
|
||||
qc.setDifficulty(QuestEventDifficulty.fromString(sectionMeta.get("Difficulty")));
|
||||
qc.setDescription(sectionMeta.get("Description", "").replace("\\n", "\n"));
|
||||
qc.setCardReward(sectionMeta.get("Card Reward"));
|
||||
qc.setIconImageKey(ImageKeys.ICON_PREFIX + sectionMeta.get("Icon"));
|
||||
if (sectionMeta.contains("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
|
||||
|
||||
Reference in New Issue
Block a user