mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-20 01:29:54 +02:00
Implement achievements properly
This commit is contained in:
@@ -55,7 +55,7 @@ public class GameQuest {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean trigger(QuestCondType condition, int progress, int param) {
|
||||
public boolean trigger(QuestCondition condition, int progress, int param) {
|
||||
// Sanity check
|
||||
if (this.isComplete()) {
|
||||
return false;
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum QuestCondType {
|
||||
public enum QuestCondition {
|
||||
BattleTotal (3),
|
||||
BattlesTotalWithPartner (4),
|
||||
CharacterAcquireQuantityRarityAndAdvancement (6),
|
||||
@@ -126,19 +126,19 @@ public enum QuestCondType {
|
||||
|
||||
@Getter
|
||||
private final int value;
|
||||
private final static Int2ObjectMap<QuestCondType> map = new Int2ObjectOpenHashMap<>();
|
||||
private final static Int2ObjectMap<QuestCondition> map = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static {
|
||||
for (QuestCondType type : QuestCondType.values()) {
|
||||
for (QuestCondition type : QuestCondition.values()) {
|
||||
map.put(type.getValue(), type);
|
||||
}
|
||||
}
|
||||
|
||||
private QuestCondType(int value) {
|
||||
private QuestCondition(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static QuestCondType getByValue(int value) {
|
||||
public static QuestCondition getByValue(int value) {
|
||||
return map.get(value);
|
||||
}
|
||||
}
|
||||
@@ -11,19 +11,20 @@ public class QuestHelper {
|
||||
@Getter
|
||||
private static final Int2ObjectMap<QuestParams> battlePassQuestParams = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
// Put params here
|
||||
static {
|
||||
battlePassQuestParams.put(1001, new QuestParams(QuestCondType.LoginTotal, 1));
|
||||
battlePassQuestParams.put(1002, new QuestParams(QuestCondType.EnergyDeplete, 160));
|
||||
battlePassQuestParams.put(1003, new QuestParams(QuestCondType.BattleTotal, 6));
|
||||
battlePassQuestParams.put(1004, new QuestParams(QuestCondType.QuestWithSpecificType, 5, QuestType.Daily));
|
||||
battlePassQuestParams.put(2001, new QuestParams(QuestCondType.TowerEnterFloor, 1));
|
||||
battlePassQuestParams.put(2002, new QuestParams(QuestCondType.WeekBoosClearSpecificDifficultyAndTotal, 3));
|
||||
battlePassQuestParams.put(2003, new QuestParams(QuestCondType.BattleTotal, 20));
|
||||
battlePassQuestParams.put(2004, new QuestParams(QuestCondType.LoginTotal, 5));
|
||||
battlePassQuestParams.put(2005, new QuestParams(QuestCondType.AgentFinishTotal, 3));
|
||||
battlePassQuestParams.put(2006, new QuestParams(QuestCondType.ItemsDeplete, 100000, 1));
|
||||
battlePassQuestParams.put(2007, new QuestParams(QuestCondType.GiftGiveTotal, 5));
|
||||
battlePassQuestParams.put(2008, new QuestParams(QuestCondType.EnergyDeplete, 1200));
|
||||
battlePassQuestParams.put(1001, new QuestParams(QuestCondition.LoginTotal, 1));
|
||||
battlePassQuestParams.put(1002, new QuestParams(QuestCondition.EnergyDeplete, 160));
|
||||
battlePassQuestParams.put(1003, new QuestParams(QuestCondition.BattleTotal, 6));
|
||||
battlePassQuestParams.put(1004, new QuestParams(QuestCondition.QuestWithSpecificType, 5, QuestType.Daily));
|
||||
battlePassQuestParams.put(2001, new QuestParams(QuestCondition.TowerEnterFloor, 1));
|
||||
battlePassQuestParams.put(2002, new QuestParams(QuestCondition.WeekBoosClearSpecificDifficultyAndTotal, 3));
|
||||
battlePassQuestParams.put(2003, new QuestParams(QuestCondition.BattleTotal, 20));
|
||||
battlePassQuestParams.put(2004, new QuestParams(QuestCondition.LoginTotal, 5));
|
||||
battlePassQuestParams.put(2005, new QuestParams(QuestCondition.AgentFinishTotal, 3));
|
||||
battlePassQuestParams.put(2006, new QuestParams(QuestCondition.ItemsDeplete, 100000, 1));
|
||||
battlePassQuestParams.put(2007, new QuestParams(QuestCondition.GiftGiveTotal, 5));
|
||||
battlePassQuestParams.put(2008, new QuestParams(QuestCondition.EnergyDeplete, 1200));
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -40,7 +41,7 @@ public class QuestHelper {
|
||||
this(cond, new int[] {param});
|
||||
}
|
||||
|
||||
public QuestParams(QuestCondType cond, int... params) {
|
||||
public QuestParams(QuestCondition cond, int... params) {
|
||||
this(cond.getValue(), params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
this.save();
|
||||
}
|
||||
|
||||
public synchronized void trigger(QuestCondType condition, int progress, int param) {
|
||||
public synchronized void trigger(QuestCondition condition, int progress, int param) {
|
||||
for (var quest : getQuests().values()) {
|
||||
// Try to trigger quest
|
||||
boolean result = quest.trigger(condition, progress, param);
|
||||
@@ -194,7 +194,7 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
}
|
||||
|
||||
// Trigger quest
|
||||
this.getPlayer().triggerQuest(QuestCondType.QuestWithSpecificType, claimList.size(), QuestType.Daily);
|
||||
this.getPlayer().triggerQuest(QuestCondition.QuestWithSpecificType, claimList.size(), QuestType.Daily);
|
||||
|
||||
// Success
|
||||
return change.setSuccess(true);
|
||||
@@ -305,7 +305,7 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
Nebula.getGameDatabase().update(this, this.getUid(), "hasDailyReward", this.hasDailyReward);
|
||||
|
||||
// Trigger quest
|
||||
this.getPlayer().triggerQuest(QuestCondType.DailyShopReceiveShopTotal, 1);
|
||||
this.getPlayer().triggerQuest(QuestCondition.DailyShopReceiveShopTotal, 1);
|
||||
|
||||
// Success
|
||||
return change.setSuccess(true);
|
||||
|
||||
Reference in New Issue
Block a user