mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:32:53 +08:00
Mark dungeons as completed and trigger the event
the event & completion were moved to the same location
This commit is contained in:
parent
62f7fa639a
commit
1786169782
@ -273,17 +273,8 @@ public final class DungeonManager {
|
||||
public void finishDungeon() {
|
||||
// Mark the dungeon has completed for the players.
|
||||
var dungeonId = this.getDungeonData().getId();
|
||||
this.getScene().getPlayers().forEach(player -> {
|
||||
var dungeons = player.getPlayerProgress().getCompletedDungeons();
|
||||
if (!dungeons.contains(dungeonId)) {
|
||||
dungeons.add(dungeonId);
|
||||
Grasscutter.getLogger().debug("Dungeon {} has been marked completed for {}.",
|
||||
dungeonId, player.getUid());
|
||||
} else {
|
||||
Grasscutter.getLogger().trace("Player {} already has dungeon {} completed.",
|
||||
player.getUid(), dungeonId);
|
||||
}
|
||||
});
|
||||
this.getScene().getPlayers().forEach(player -> player
|
||||
.getPlayerProgress().markDungeonAsComplete(dungeonId));
|
||||
|
||||
notifyEndDungeon(true);
|
||||
endDungeon(BaseDungeonResult.DungeonEndReason.COMPLETED);
|
||||
@ -294,13 +285,11 @@ public final class DungeonManager {
|
||||
.getPlayers()
|
||||
.forEach(
|
||||
p -> {
|
||||
// Quest trigger
|
||||
p.getQuestManager()
|
||||
.queueEvent(
|
||||
successfully
|
||||
? QuestContent.QUEST_CONTENT_FINISH_DUNGEON
|
||||
: QuestContent.QUEST_CONTENT_FAIL_DUNGEON,
|
||||
dungeonData.getId());
|
||||
// Trigger the fail event if needed.
|
||||
if (!successfully) {
|
||||
p.getQuestManager().queueEvent(
|
||||
QuestContent.QUEST_CONTENT_FAIL_DUNGEON, dungeonData.getId());
|
||||
}
|
||||
|
||||
// Battle pass trigger
|
||||
if (dungeonData.getType().isCountsToBattlepass() && successfully) {
|
||||
|
@ -255,7 +255,7 @@ public class Player {
|
||||
this.unlockedSceneAreas = new HashMap<>();
|
||||
this.unlockedScenePoints = new HashMap<>();
|
||||
this.chatEmojiIdList = new ArrayList<>();
|
||||
this.playerProgress = new PlayerProgress();
|
||||
this.playerProgress = new PlayerProgress(this);
|
||||
this.activeQuestTimers = new HashSet<>();
|
||||
|
||||
this.attackResults = new LinkedBlockingQueue<>();
|
||||
|
@ -1,6 +1,9 @@
|
||||
package emu.grasscutter.game.player;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.quest.enums.QuestContent;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import java.util.Map;
|
||||
@ -14,6 +17,8 @@ import lombok.val;
|
||||
/** Tracks progress the player made in the world, like obtained items, seen characters and more */
|
||||
@Entity
|
||||
public class PlayerProgress {
|
||||
@Getter @Transient private final Player player;
|
||||
|
||||
@Getter private Map<Integer, ItemEntry> itemHistory;
|
||||
|
||||
/*
|
||||
@ -27,12 +32,35 @@ public class PlayerProgress {
|
||||
// it will be hard to loop and compare
|
||||
private Map<Integer, Integer> questProgressCountMap;
|
||||
|
||||
public PlayerProgress() {
|
||||
public PlayerProgress(Player player) {
|
||||
this.player = player;
|
||||
|
||||
this.questProgressCountMap = new Int2IntOpenHashMap();
|
||||
this.completedDungeons = new IntArrayList();
|
||||
this.itemHistory = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a dungeon as completed.
|
||||
* Triggers the quest event.
|
||||
*
|
||||
* @param dungeonId The dungeon which was completed.
|
||||
*/
|
||||
public void markDungeonAsComplete(int dungeonId) {
|
||||
if (this.getCompletedDungeons().contains(dungeonId))
|
||||
return;
|
||||
|
||||
// Mark the dungeon as completed.
|
||||
this.getCompletedDungeons().add(dungeonId);
|
||||
// Trigger the completion event.
|
||||
this.getPlayer().getQuestManager().queueEvent(
|
||||
QuestContent.QUEST_CONTENT_FINISH_DUNGEON, dungeonId
|
||||
);
|
||||
|
||||
Grasscutter.getLogger().debug("Dungeon {} has been marked complete for {}.",
|
||||
dungeonId, this.getPlayer().getUid());
|
||||
}
|
||||
|
||||
public boolean hasPlayerObtainedItemHistorically(int itemId) {
|
||||
return itemHistory.containsKey(itemId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user