Commit d877d7ee authored by Melledy's avatar Melledy
Browse files

Remove player from challenge if they are leaving the scene

parent cb15a5de
...@@ -23,7 +23,8 @@ public class DungeonChallenge { ...@@ -23,7 +23,8 @@ public class DungeonChallenge {
private int challengeIndex; private int challengeIndex;
private int challengeId; private int challengeId;
private boolean isSuccess; private boolean success;
private boolean progress;
private int score; private int score;
private int objective = 0; private int objective = 0;
...@@ -60,11 +61,15 @@ public class DungeonChallenge { ...@@ -60,11 +61,15 @@ public class DungeonChallenge {
} }
public boolean isSuccess() { public boolean isSuccess() {
return isSuccess; return success;
} }
public void setSuccess(boolean isSuccess) { public void setSuccess(boolean isSuccess) {
this.isSuccess = isSuccess; this.success = isSuccess;
}
public boolean inProgress() {
return progress;
} }
public int getScore() { public int getScore() {
...@@ -72,10 +77,12 @@ public class DungeonChallenge { ...@@ -72,10 +77,12 @@ public class DungeonChallenge {
} }
public void start() { public void start() {
this.progress = true;
getScene().broadcastPacket(new PacketDungeonChallengeBeginNotify(this)); getScene().broadcastPacket(new PacketDungeonChallengeBeginNotify(this));
} }
public void finish() { public void finish() {
this.progress = false;
getScene().broadcastPacket(new PacketDungeonChallengeFinishNotify(this)); getScene().broadcastPacket(new PacketDungeonChallengeFinishNotify(this));
if (this.isSuccess()) { if (this.isSuccess()) {
......
...@@ -25,6 +25,7 @@ import emu.grasscutter.scripts.data.SceneBlock; ...@@ -25,6 +25,7 @@ import emu.grasscutter.scripts.data.SceneBlock;
import emu.grasscutter.scripts.data.SceneGadget; import emu.grasscutter.scripts.data.SceneGadget;
import emu.grasscutter.scripts.data.SceneGroup; import emu.grasscutter.scripts.data.SceneGroup;
import emu.grasscutter.scripts.data.ScriptArgs; import emu.grasscutter.scripts.data.ScriptArgs;
import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify; import emu.grasscutter.server.packet.send.PacketLifeStateChangeNotify;
import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify; import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
...@@ -212,6 +213,11 @@ public class Scene { ...@@ -212,6 +213,11 @@ public class Scene {
} }
public synchronized void removePlayer(Player player) { public synchronized void removePlayer(Player player) {
// Remove from challenge if leaving
if (this.getChallenge() != null && this.getChallenge().inProgress()) {
player.sendPacket(new PacketDungeonChallengeFinishNotify(this.getChallenge()));
}
// Remove player from scene // Remove player from scene
getPlayers().remove(player); getPlayers().remove(player);
player.setScene(null); player.setScene(null);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment