mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-13 12:54:36 +01:00
Clear current player level ids when settling
This commit is contained in:
@@ -13,7 +13,6 @@ import lombok.Getter;
|
||||
public class InfinityTowerManager extends PlayerManager {
|
||||
private InfinityTowerLevelDef levelData;
|
||||
private int levelId;
|
||||
|
||||
private long buildId;
|
||||
|
||||
public InfinityTowerManager(Player player) {
|
||||
@@ -79,6 +78,10 @@ public class InfinityTowerManager extends PlayerManager {
|
||||
// Trigger achievement
|
||||
this.getPlayer().trigger(AchievementCondition.InfinityTowerClearSpecificFloor, 10, this.getLevelId(), 0);
|
||||
|
||||
// Clear instance
|
||||
this.levelId = 0;
|
||||
this.buildId = 0;
|
||||
|
||||
// Success
|
||||
return change.setSuccess(true);
|
||||
}
|
||||
|
||||
@@ -70,6 +70,10 @@ public class InstanceManager extends PlayerManager {
|
||||
// Set extra data
|
||||
change.setExtraData(settleData);
|
||||
|
||||
// Clear instance
|
||||
this.curInstanceId = 0;
|
||||
this.rewardType = 0;
|
||||
|
||||
// Success
|
||||
return change.setSuccess(true);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,9 @@ public class StoryManager extends PlayerManager implements GameDatabaseObject {
|
||||
// Note: Story options are seperate from regular story ids to save database space, since most stories do not have options
|
||||
private Map<Integer, StoryOptionLog> options;
|
||||
|
||||
// Current story
|
||||
private transient int storyId;
|
||||
|
||||
@Deprecated // Morphia only
|
||||
public StoryManager() {
|
||||
|
||||
@@ -53,6 +56,10 @@ public class StoryManager extends PlayerManager implements GameDatabaseObject {
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void apply(int idx) {
|
||||
this.storyId = idx;
|
||||
}
|
||||
|
||||
public boolean hasNew() {
|
||||
if (this.getCompletedStories().size() < GameData.getStoryDataTable().size()) {
|
||||
return true;
|
||||
@@ -111,6 +118,9 @@ public class StoryManager extends PlayerManager implements GameDatabaseObject {
|
||||
Nebula.getGameDatabase().addToSet(this, this.getPlayerUid(), "evidences", id);
|
||||
}
|
||||
|
||||
// Clear current story
|
||||
this.storyId = 0;
|
||||
|
||||
// Complete
|
||||
return change;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,13 @@ public class HandlerInfinityTowerSettleReq extends NetHandler {
|
||||
// Parse request
|
||||
var req = InfinityTowerSettleReq.parseFrom(message);
|
||||
|
||||
// Settle
|
||||
// Get manager and save current level/build
|
||||
var manager = session.getPlayer().getInfinityTowerManager();
|
||||
|
||||
int level = manager.getLevelId();
|
||||
long build = manager.getBuildId();
|
||||
|
||||
// Settle
|
||||
var change = manager.settle(req.getValue());
|
||||
|
||||
if (change == null) {
|
||||
@@ -25,10 +30,10 @@ public class HandlerInfinityTowerSettleReq extends NetHandler {
|
||||
}
|
||||
|
||||
// Get next level
|
||||
int nextLevel = manager.getLevelId() + 1;
|
||||
int nextLevel = level + 1;
|
||||
|
||||
// Try to apply for next level
|
||||
if (!manager.apply(nextLevel, -1)) {
|
||||
if (!manager.apply(nextLevel, build)) {
|
||||
nextLevel = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.StoryApply.StoryApplyReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@@ -10,6 +11,13 @@ public class HandlerStoryApplyReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = StoryApplyReq.parseFrom(message);
|
||||
|
||||
// Apply for story
|
||||
session.getPlayer().getStoryManager().apply(req.getIdx());
|
||||
|
||||
// Encode response
|
||||
return session.encodeMsg(NetMsgId.story_apply_succeed_ack);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user