2022-04-28 22:19:14 -07:00
|
|
|
package emu.grasscutter.game.dungeons;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import emu.grasscutter.data.GameData;
|
|
|
|
import emu.grasscutter.data.def.MonsterData;
|
|
|
|
import emu.grasscutter.game.entity.EntityMonster;
|
|
|
|
import emu.grasscutter.game.entity.GameEntity;
|
|
|
|
import emu.grasscutter.game.world.Scene;
|
|
|
|
import emu.grasscutter.net.proto.VisionTypeOuterClass.VisionType;
|
2022-04-29 00:00:23 -07:00
|
|
|
import emu.grasscutter.scripts.constants.EventType;
|
2022-04-28 22:19:14 -07:00
|
|
|
import emu.grasscutter.scripts.data.SceneGroup;
|
|
|
|
import emu.grasscutter.scripts.data.SceneMonster;
|
2022-04-29 00:49:05 -07:00
|
|
|
import emu.grasscutter.server.packet.send.PacketChallengeDataNotify;
|
2022-04-28 22:19:14 -07:00
|
|
|
import emu.grasscutter.server.packet.send.PacketDungeonChallengeBeginNotify;
|
|
|
|
import emu.grasscutter.server.packet.send.PacketDungeonChallengeFinishNotify;
|
|
|
|
import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
|
|
|
|
|
|
|
|
public class DungeonChallenge {
|
|
|
|
private final Scene scene;
|
|
|
|
private final SceneGroup group;
|
|
|
|
|
|
|
|
private int challengeIndex;
|
|
|
|
private int challengeId;
|
2022-04-29 03:24:36 -07:00
|
|
|
private boolean success;
|
|
|
|
private boolean progress;
|
2022-04-28 22:19:14 -07:00
|
|
|
|
|
|
|
private int score;
|
|
|
|
private int objective = 0;
|
|
|
|
|
|
|
|
public DungeonChallenge(Scene scene, SceneGroup group) {
|
|
|
|
this.scene = scene;
|
|
|
|
this.group = group;
|
|
|
|
|
|
|
|
objective += group.monsters.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Scene getScene() {
|
|
|
|
return scene;
|
|
|
|
}
|
|
|
|
|
|
|
|
public SceneGroup getGroup() {
|
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getChallengeIndex() {
|
|
|
|
return challengeIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setChallengeIndex(int challengeIndex) {
|
|
|
|
this.challengeIndex = challengeIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getChallengeId() {
|
|
|
|
return challengeId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setChallengeId(int challengeId) {
|
|
|
|
this.challengeId = challengeId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSuccess() {
|
2022-04-29 03:24:36 -07:00
|
|
|
return success;
|
2022-04-28 22:19:14 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setSuccess(boolean isSuccess) {
|
2022-04-29 03:24:36 -07:00
|
|
|
this.success = isSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean inProgress() {
|
|
|
|
return progress;
|
2022-04-28 22:19:14 -07:00
|
|
|
}
|
|
|
|
|
2022-04-29 00:49:05 -07:00
|
|
|
public int getScore() {
|
|
|
|
return score;
|
|
|
|
}
|
|
|
|
|
2022-04-28 22:19:14 -07:00
|
|
|
public void start() {
|
2022-04-29 03:24:36 -07:00
|
|
|
this.progress = true;
|
2022-04-28 22:19:14 -07:00
|
|
|
getScene().broadcastPacket(new PacketDungeonChallengeBeginNotify(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
public void finish() {
|
2022-04-29 03:24:36 -07:00
|
|
|
this.progress = false;
|
2022-04-28 22:19:14 -07:00
|
|
|
getScene().broadcastPacket(new PacketDungeonChallengeFinishNotify(this));
|
|
|
|
|
|
|
|
if (this.isSuccess()) {
|
2022-04-29 00:00:23 -07:00
|
|
|
this.getScene().getScriptManager().callEvent(EventType.EVENT_CHALLENGE_SUCCESS, null);
|
2022-04-28 22:19:14 -07:00
|
|
|
} else {
|
2022-04-29 00:00:23 -07:00
|
|
|
this.getScene().getScriptManager().callEvent(EventType.EVENT_CHALLENGE_FAIL, null);
|
2022-04-28 22:19:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onMonsterDie(EntityMonster entity) {
|
2022-04-29 00:49:05 -07:00
|
|
|
score = getScore() + 1;
|
|
|
|
|
|
|
|
getScene().broadcastPacket(new PacketChallengeDataNotify(this, 1, getScore()));
|
2022-04-28 22:19:14 -07:00
|
|
|
|
2022-04-29 00:49:05 -07:00
|
|
|
if (getScore() >= objective) {
|
2022-04-28 22:19:14 -07:00
|
|
|
this.setSuccess(true);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|