mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 09:09:54 +02:00
Fix return to ascension
This commit is contained in:
@@ -249,6 +249,10 @@ public class StarTowerGame {
|
|||||||
return Utils.randomElement(this.getCharIds());
|
return Utils.randomElement(this.getCharIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setHp(int hp) {
|
||||||
|
this.charHp = hp;
|
||||||
|
}
|
||||||
|
|
||||||
public StarTowerStageDef getStageData(int stageNum, int stageFloor) {
|
public StarTowerStageDef getStageData(int stageNum, int stageFloor) {
|
||||||
var stageId = (this.getId() * 10000) + (stageNum * 100) + stageFloor;
|
var stageId = (this.getId() * 10000) + (stageNum * 100) + stageFloor;
|
||||||
return GameData.getStarTowerStageDataTable().get(stageId);
|
return GameData.getStarTowerStageDataTable().get(stageId);
|
||||||
@@ -792,7 +796,13 @@ public class StarTowerGame {
|
|||||||
|
|
||||||
// Handle interaction with tower case
|
// Handle interaction with tower case
|
||||||
if (towerCase != null) {
|
if (towerCase != null) {
|
||||||
|
// Interact with case
|
||||||
rsp = towerCase.interact(req, rsp);
|
rsp = towerCase.interact(req, rsp);
|
||||||
|
|
||||||
|
// Remove case
|
||||||
|
if (towerCase.removeAfterInteract()) {
|
||||||
|
this.getRoom().getCases().remove(req.getId());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
rsp.getMutableNilResp();
|
rsp.getMutableNilResp();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ public abstract class StarTowerBaseCase {
|
|||||||
|
|
||||||
public abstract CaseType getType();
|
public abstract CaseType getType();
|
||||||
|
|
||||||
|
public boolean removeAfterInteract() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void register(StarTowerBaseRoom room) {
|
public void register(StarTowerBaseRoom room) {
|
||||||
this.game = room.getGame();
|
this.game = room.getGame();
|
||||||
this.id = room.getNextCaseId();
|
this.id = room.getNextCaseId();
|
||||||
|
|||||||
@@ -30,6 +30,11 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
return CaseType.Hawker;
|
return CaseType.Hawker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAfterInteract() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegister() {
|
public void onRegister() {
|
||||||
this.initGoods();
|
this.initGoods();
|
||||||
@@ -251,6 +256,10 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
info.setCharPos(goods.getCharPos());
|
info.setCharPos(goods.getCharPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (goods.isSold()) {
|
||||||
|
hawker.addPurchase(sid);
|
||||||
|
}
|
||||||
|
|
||||||
hawker.addList(info);
|
hawker.addList(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,13 @@ public class StarTowerNpcRecoveryHPCase extends StarTowerBaseCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StarTowerInteractResp interact(StarTowerInteractReq req, StarTowerInteractResp rsp) {
|
public StarTowerInteractResp interact(StarTowerInteractReq req, StarTowerInteractResp rsp) {
|
||||||
|
// Get hp
|
||||||
|
int hp = req.getRecoveryHPReq().getHp();
|
||||||
|
|
||||||
|
// Sync with game
|
||||||
|
this.getGame().setHp(hp);
|
||||||
|
|
||||||
|
// Complete
|
||||||
return rsp;
|
return rsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ public class StarTowerStrengthenMachineCase extends StarTowerBaseCase {
|
|||||||
private int discount;
|
private int discount;
|
||||||
private int times;
|
private int times;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAfterInteract() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegister() {
|
public void onRegister() {
|
||||||
// Set strengthen price
|
// Set strengthen price
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ public class StarTowerSyncHPCase extends StarTowerBaseCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StarTowerInteractResp interact(StarTowerInteractReq req, StarTowerInteractResp rsp) {
|
public StarTowerInteractResp interact(StarTowerInteractReq req, StarTowerInteractResp rsp) {
|
||||||
|
// Get hp
|
||||||
|
int hp = req.getRecoveryHPReq().getHp();
|
||||||
|
|
||||||
|
// Sync with game
|
||||||
|
this.getGame().setHp(hp);
|
||||||
|
|
||||||
|
// Complete
|
||||||
return rsp;
|
return rsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package emu.nebula.server.handlers;
|
||||||
|
|
||||||
|
import emu.nebula.net.NetHandler;
|
||||||
|
import emu.nebula.net.NetMsgId;
|
||||||
|
import emu.nebula.net.HandlerId;
|
||||||
|
import emu.nebula.net.GameSession;
|
||||||
|
|
||||||
|
@HandlerId(NetMsgId.star_tower_info_req)
|
||||||
|
public class HandlerStarTowerInfoReq extends NetHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||||
|
// Get star tower game
|
||||||
|
var game = session.getPlayer().getStarTowerManager().getGame();
|
||||||
|
|
||||||
|
if (game == null) {
|
||||||
|
return session.encodeMsg(NetMsgId.star_tower_info_failed_ack);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode and send
|
||||||
|
return session.encodeMsg(NetMsgId.star_tower_info_succeed_ack, game.toProto());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user