mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-16 22:34:41 +01:00
Rework how quest/achievement conditions are handled
This commit is contained in:
@@ -2,29 +2,62 @@ package emu.nebula.game.achievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import emu.nebula.GameConstants;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.resources.AchievementDef;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import lombok.Getter;
|
||||
|
||||
// Because achievements in the data files do not have params, we will hardcode them here
|
||||
public class AchievementHelper {
|
||||
// Achievement cache
|
||||
// Cache
|
||||
private static IntSet isTotalAchievementSet = new IntOpenHashSet();
|
||||
|
||||
@Getter
|
||||
private static Int2ObjectMap<List<AchievementDef>> cache = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
public static List<AchievementDef> getAchievementsByCondition(AchievementCondition condition) {
|
||||
return cache.get(condition.getValue());
|
||||
public static List<AchievementDef> getAchievementsByCondition(int condition) {
|
||||
return cache.get(condition);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
public static boolean isTotalAchievement(int condition) {
|
||||
return isTotalAchievementSet.contains(condition);
|
||||
}
|
||||
|
||||
// Fix params
|
||||
|
||||
public static void fixParams() {
|
||||
addParam(78, -1, 2);
|
||||
addParam(79, -1, 4);
|
||||
addParam(498, -1, 1);
|
||||
public static void init() {
|
||||
// Cache total achievements
|
||||
for (var condition : AchievementCondition.values()) {
|
||||
if (condition.name().endsWith("Total")) {
|
||||
isTotalAchievementSet.add(condition.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
isTotalAchievementSet.add(AchievementCondition.ItemsAdd.getValue());
|
||||
isTotalAchievementSet.add(AchievementCondition.ItemsDeplete.getValue());
|
||||
|
||||
// Fix params
|
||||
fixParams();
|
||||
}
|
||||
|
||||
private static void fixParams() {
|
||||
// Monolith
|
||||
addParam(78, 0, 2);
|
||||
addParam(79, 0, 4);
|
||||
addParam(498, 0, 1);
|
||||
|
||||
// Money
|
||||
addParam(25, GameConstants.GOLD_ITEM_ID, 0);
|
||||
addParam(26, GameConstants.GOLD_ITEM_ID, 0);
|
||||
addParam(27, GameConstants.GOLD_ITEM_ID, 0);
|
||||
addParam(28, GameConstants.GOLD_ITEM_ID, 0);
|
||||
addParam(29, GameConstants.GOLD_ITEM_ID, 0);
|
||||
}
|
||||
|
||||
private static void addParam(int achievementId, int param1, int param2) {
|
||||
|
||||
Reference in New Issue
Block a user