mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:12:54 +08:00
Implement dungeon completion
This commit is contained in:
parent
aadbc05061
commit
916db0f408
@ -271,6 +271,20 @@ 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);
|
||||
}
|
||||
});
|
||||
|
||||
notifyEndDungeon(true);
|
||||
endDungeon(BaseDungeonResult.DungeonEndReason.COMPLETED);
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import dev.morphia.annotations.Entity;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -12,9 +15,14 @@ import lombok.val;
|
||||
/** Tracks progress the player made in the world, like obtained items, seen characters and more */
|
||||
@Entity
|
||||
public class PlayerProgress {
|
||||
|
||||
@Getter private Map<Integer, ItemEntry> itemHistory;
|
||||
|
||||
/*
|
||||
* A list of dungeon IDs which have been completed.
|
||||
* This only applies to one-time dungeons.
|
||||
*/
|
||||
@Getter private IntList completedDungeons;
|
||||
|
||||
// keep track of EXEC_ADD_QUEST_PROGRESS count, will be used in CONTENT_ADD_QUEST_PROGRESS
|
||||
// not sure where to put this, this should be saved to DB but not to individual quest, since
|
||||
// it will be hard to loop and compare
|
||||
@ -22,6 +30,7 @@ public class PlayerProgress {
|
||||
|
||||
public PlayerProgress() {
|
||||
this.questProgressCountMap = new Int2IntOpenHashMap();
|
||||
this.completedDungeons = new IntArrayList();
|
||||
this.itemHistory = new Int2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,17 @@ import emu.grasscutter.data.excels.QuestData;
|
||||
import emu.grasscutter.game.quest.GameQuest;
|
||||
import emu.grasscutter.game.quest.QuestValueContent;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@QuestValueContent(QUEST_CONTENT_FINISH_DUNGEON)
|
||||
public class ContentFinishDungeon extends BaseContent {
|
||||
|
||||
// params[0] dungeon ID, params[1] unknown
|
||||
|
||||
@Override
|
||||
public boolean execute(
|
||||
GameQuest quest, QuestData.QuestContentCondition condition, String paramStr, int... params) {
|
||||
return condition.getParam()[0] == params[0];
|
||||
var dungeonId = condition.getParam()[0];
|
||||
return quest.getOwner().getPlayerProgress()
|
||||
.getCompletedDungeons().contains(dungeonId);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user