mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-13 04:45:02 +01:00
Handle monolith quick battle better
This commit is contained in:
@@ -159,7 +159,7 @@ public class StarTowerManager extends PlayerManager {
|
||||
return this.getBuilds().containsKey(id);
|
||||
}
|
||||
|
||||
public StarTowerGame apply(StarTowerApplyReq req) {
|
||||
public PlayerChangeInfo apply(StarTowerApplyReq req) {
|
||||
// Sanity checks
|
||||
var data = GameData.getStarTowerDataTable().get(req.getId());
|
||||
if (data == null) {
|
||||
@@ -177,6 +177,32 @@ public class StarTowerManager extends PlayerManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create change
|
||||
var change = new PlayerChangeInfo();
|
||||
|
||||
// Check if sweeping
|
||||
if (req.getSweep()) {
|
||||
// Make sure we have the proper growth node that enables sweeping
|
||||
if (!this.hasGrowthNode(10301)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if we have this tower completed
|
||||
boolean unlockInstances = Nebula.getConfig().getServerOptions().isUnlockInstances();
|
||||
if (!unlockInstances && !getPlayer().getProgress().getStarTowerLog().contains(data.getId())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check materials
|
||||
if (this.getPlayer().getInventory().hasItem(29, 1)) {
|
||||
this.getPlayer().getInventory().removeItem(29, 1, change);
|
||||
} else if (this.getPlayer().getInventory().hasItem(30, 1)) {
|
||||
this.getPlayer().getInventory().removeItem(30, 1, change);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Create game
|
||||
this.game = new StarTowerGame(this, data, formation, req);
|
||||
|
||||
@@ -184,7 +210,7 @@ public class StarTowerManager extends PlayerManager {
|
||||
this.getPlayer().triggerQuest(QuestCondType.TowerEnterFloor, 1);
|
||||
|
||||
// Success
|
||||
return this.game;
|
||||
return change.setExtraData(this.game);
|
||||
}
|
||||
|
||||
public StarTowerGame endGame() {
|
||||
|
||||
@@ -5,6 +5,7 @@ import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.StarTowerApply.StarTowerApplyReq;
|
||||
import emu.nebula.proto.StarTowerApply.StarTowerApplyResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.game.tower.StarTowerGame;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.star_tower_apply_req)
|
||||
@@ -16,18 +17,20 @@ public class HandlerStarTowerApplyReq extends NetHandler {
|
||||
var req = StarTowerApplyReq.parseFrom(message);
|
||||
|
||||
// Apply to create a star tower instance
|
||||
var instance = session.getPlayer().getStarTowerManager().apply(req);
|
||||
var change = session.getPlayer().getStarTowerManager().apply(req);
|
||||
|
||||
if (instance == null) {
|
||||
if (change == null) {
|
||||
return session.encodeMsg(NetMsgId.star_tower_apply_failed_ack);
|
||||
}
|
||||
|
||||
// Get star tower game from change info
|
||||
var game = (StarTowerGame) change.getExtraData();
|
||||
|
||||
// Create response
|
||||
var rsp = StarTowerApplyResp.newInstance()
|
||||
.setLastId(req.getId())
|
||||
.setInfo(instance.toProto());
|
||||
|
||||
rsp.getMutableChange();
|
||||
.setInfo(game.toProto())
|
||||
.setChange(change.toProto());
|
||||
|
||||
return session.encodeMsg(NetMsgId.star_tower_apply_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user