mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-13 04:45:02 +01:00
feat(startower): leveling up
This commit is contained in:
@@ -113,6 +113,8 @@ public class GameData {
|
|||||||
@Getter private static DataTable<StarTowerDef> StarTowerDataTable = new DataTable<>();
|
@Getter private static DataTable<StarTowerDef> StarTowerDataTable = new DataTable<>();
|
||||||
@Getter private static DataTable<StarTowerStageDef> StarTowerStageDataTable = new DataTable<>();
|
@Getter private static DataTable<StarTowerStageDef> StarTowerStageDataTable = new DataTable<>();
|
||||||
@Getter private static DataTable<StarTowerGrowthNodeDef> StarTowerGrowthNodeDataTable = new DataTable<>();
|
@Getter private static DataTable<StarTowerGrowthNodeDef> StarTowerGrowthNodeDataTable = new DataTable<>();
|
||||||
|
@Getter private static DataTable<StarTowerFloorExpDef> StarTowerFloorExpDataTable = new DataTable<>();
|
||||||
|
@Getter private static DataTable<StarTowerTeamExpDef> StarTowerTeamExpDataTable = new DataTable<>();
|
||||||
@Getter private static DataTable<PotentialDef> PotentialDataTable = new DataTable<>();
|
@Getter private static DataTable<PotentialDef> PotentialDataTable = new DataTable<>();
|
||||||
@Getter private static DataTable<SubNoteSkillPromoteGroupDef> SubNoteSkillPromoteGroupDataTable = new DataTable<>();
|
@Getter private static DataTable<SubNoteSkillPromoteGroupDef> SubNoteSkillPromoteGroupDataTable = new DataTable<>();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package emu.nebula.data.resources;
|
||||||
|
|
||||||
|
import emu.nebula.data.BaseDef;
|
||||||
|
import emu.nebula.data.ResourceType;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ResourceType(name = "StarTowerFloorExp.json")
|
||||||
|
public class StarTowerFloorExpDef extends BaseDef {
|
||||||
|
private int Id;
|
||||||
|
private int StarTowerId;
|
||||||
|
private int Stage;
|
||||||
|
private int NormalExp;
|
||||||
|
private int EliteExp;
|
||||||
|
private int BossExp;
|
||||||
|
private int FinalBossExp;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return StarTowerId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package emu.nebula.data.resources;
|
||||||
|
|
||||||
|
import emu.nebula.data.BaseDef;
|
||||||
|
import emu.nebula.data.ResourceType;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@ResourceType(name = "StarTowerTeamExp.json")
|
||||||
|
public class StarTowerTeamExpDef extends BaseDef {
|
||||||
|
private int Id;
|
||||||
|
private int GroupId;
|
||||||
|
private int Level;
|
||||||
|
private int NeedExp;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return Id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
|
|
||||||
import emu.nebula.GameConstants;
|
import emu.nebula.GameConstants;
|
||||||
|
import emu.nebula.Nebula;
|
||||||
import emu.nebula.data.GameData;
|
import emu.nebula.data.GameData;
|
||||||
import emu.nebula.data.resources.PotentialDef;
|
import emu.nebula.data.resources.PotentialDef;
|
||||||
import emu.nebula.data.resources.StarTowerDef;
|
import emu.nebula.data.resources.StarTowerDef;
|
||||||
@@ -55,6 +56,7 @@ public class StarTowerGame {
|
|||||||
private int buildId;
|
private int buildId;
|
||||||
private int teamLevel;
|
private int teamLevel;
|
||||||
private int teamExp;
|
private int teamExp;
|
||||||
|
private int nextLevelExp;
|
||||||
private int charHp;
|
private int charHp;
|
||||||
private int battleTime;
|
private int battleTime;
|
||||||
private int battleCount;
|
private int battleCount;
|
||||||
@@ -103,6 +105,8 @@ public class StarTowerGame {
|
|||||||
this.formationId = req.getFormationId();
|
this.formationId = req.getFormationId();
|
||||||
this.buildId = Snowflake.newUid();
|
this.buildId = Snowflake.newUid();
|
||||||
this.teamLevel = 1;
|
this.teamLevel = 1;
|
||||||
|
this.teamExp = 0;
|
||||||
|
this.nextLevelExp = GameData.getStarTowerTeamExpDataTable().get(2).getNeedExp();
|
||||||
this.stageNum = 1;
|
this.stageNum = 1;
|
||||||
this.stageFloor = 1;
|
this.stageFloor = 1;
|
||||||
this.floor = 1;
|
this.floor = 1;
|
||||||
@@ -223,6 +227,37 @@ public class StarTowerGame {
|
|||||||
|
|
||||||
return gold;
|
return gold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int levelUp(int exp, int picks) {
|
||||||
|
if (this.teamExp + exp >= this.nextLevelExp) {
|
||||||
|
// Level up
|
||||||
|
this.teamLevel++;
|
||||||
|
|
||||||
|
// Add 1 to pending potential picks
|
||||||
|
picks++;
|
||||||
|
|
||||||
|
// Handle excess exp
|
||||||
|
if (this.teamExp + exp - this.nextLevelExp > 0) {
|
||||||
|
int excessExp = this.teamExp + exp - this.nextLevelExp;
|
||||||
|
return levelUp(excessExp, picks);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next level
|
||||||
|
this.nextLevelExp = GameData.getStarTowerTeamExpDataTable().get(this.teamLevel + 1).getNeedExp();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Update current team exp
|
||||||
|
this.teamExp += exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return picks
|
||||||
|
return picks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int levelUp(int exp) {
|
||||||
|
int potentialPicks = 0;
|
||||||
|
return this.levelUp(exp, potentialPicks);
|
||||||
|
}
|
||||||
|
|
||||||
// Cases
|
// Cases
|
||||||
|
|
||||||
@@ -443,8 +478,34 @@ public class StarTowerGame {
|
|||||||
|
|
||||||
// Handle victory/defeat
|
// Handle victory/defeat
|
||||||
if (proto.hasVictory()) {
|
if (proto.hasVictory()) {
|
||||||
// Add team level
|
// Handle leveling up
|
||||||
this.teamLevel++;
|
|
||||||
|
// Get relevant floor exp data
|
||||||
|
var floorExpData = GameData.getStarTowerFloorExpDataTable().get(this.getId());
|
||||||
|
int expReward = 0;
|
||||||
|
|
||||||
|
// Determine appropriate exp reward
|
||||||
|
switch (this.getRoomType()) {
|
||||||
|
// Regular battle room
|
||||||
|
case 0:
|
||||||
|
expReward = floorExpData.getNormalExp();
|
||||||
|
break;
|
||||||
|
// Elite battle room
|
||||||
|
case 1:
|
||||||
|
expReward = floorExpData.getEliteExp();
|
||||||
|
break;
|
||||||
|
// Non-final boss room
|
||||||
|
case 2:
|
||||||
|
expReward = floorExpData.getBossExp();
|
||||||
|
break;
|
||||||
|
// Final room
|
||||||
|
case 3:
|
||||||
|
expReward = floorExpData.getFinalBossExp();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level up
|
||||||
|
this.pendingPotentialCases += this.levelUp(expReward);
|
||||||
|
|
||||||
// Add clear time
|
// Add clear time
|
||||||
this.battleTime += proto.getVictory().getTime();
|
this.battleTime += proto.getVictory().getTime();
|
||||||
@@ -460,9 +521,6 @@ public class StarTowerGame {
|
|||||||
|
|
||||||
this.addItem(GameConstants.STAR_TOWER_GOLD_ITEM_ID, money, change);
|
this.addItem(GameConstants.STAR_TOWER_GOLD_ITEM_ID, money, change);
|
||||||
|
|
||||||
// Add potential selectors
|
|
||||||
this.pendingPotentialCases += 1;
|
|
||||||
|
|
||||||
// Handle pending potential selectors
|
// Handle pending potential selectors
|
||||||
if (this.pendingPotentialCases > 0) {
|
if (this.pendingPotentialCases > 0) {
|
||||||
// Create potential selector
|
// Create potential selector
|
||||||
@@ -471,6 +529,18 @@ public class StarTowerGame {
|
|||||||
|
|
||||||
this.pendingPotentialCases--;
|
this.pendingPotentialCases--;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Add door case here
|
||||||
|
var doorCase = this.addCase(new StarTowerCase(CaseType.OpenDoor));
|
||||||
|
doorCase.setFloorId(this.getStageFloor() + 1);
|
||||||
|
|
||||||
|
var nextStage = this.getNextStageData();
|
||||||
|
if (nextStage != null) {
|
||||||
|
doorCase.setRoomType(nextStage.getRoomType());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.addCase(rsp.getMutableCases(), doorCase);
|
||||||
|
}
|
||||||
|
|
||||||
// Add sub note skills
|
// Add sub note skills
|
||||||
var battleCase = this.getCase(CaseType.Battle);
|
var battleCase = this.getCase(CaseType.Battle);
|
||||||
|
|||||||
Reference in New Issue
Block a user