mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Improve random potential selector generator
This commit is contained in:
@@ -21,6 +21,10 @@ public class PotentialDef extends BaseDef {
|
|||||||
public int getId() {
|
public int getId() {
|
||||||
return Id;
|
return Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isRare() {
|
||||||
|
return this.BranchType != 3;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxLevel() {
|
public int getMaxLevel() {
|
||||||
// Check if regular potential
|
// Check if regular potential
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public class StarTowerGame {
|
|||||||
private int[] discIds;
|
private int[] discIds;
|
||||||
|
|
||||||
private int pendingPotentialCases = 0;
|
private int pendingPotentialCases = 0;
|
||||||
|
private int pendingRarePotentialCases = 0;
|
||||||
private boolean completed;
|
private boolean completed;
|
||||||
|
|
||||||
// Bag
|
// Bag
|
||||||
@@ -89,9 +90,10 @@ public class StarTowerGame {
|
|||||||
// Modifiers
|
// Modifiers
|
||||||
private StarTowerModifiers modifiers;
|
private StarTowerModifiers modifiers;
|
||||||
|
|
||||||
// Cached build
|
// Cached info
|
||||||
private transient StarTowerBuild build;
|
private transient StarTowerBuild build;
|
||||||
private transient ItemParamMap newInfos;
|
private transient ItemParamMap newInfos;
|
||||||
|
private transient ItemParamMap rarePotentialCount;
|
||||||
|
|
||||||
@Deprecated // Morphia only
|
@Deprecated // Morphia only
|
||||||
public StarTowerGame() {
|
public StarTowerGame() {
|
||||||
@@ -173,6 +175,9 @@ public class StarTowerGame {
|
|||||||
this.charIds = charList.toIntArray();
|
this.charIds = charList.toIntArray();
|
||||||
this.discIds = discList.toIntArray();
|
this.discIds = discList.toIntArray();
|
||||||
|
|
||||||
|
// Temp data to cache for rare potential count
|
||||||
|
this.rarePotentialCount = new ItemParamMap();
|
||||||
|
|
||||||
// Finish setting up droppable sub note skills
|
// Finish setting up droppable sub note skills
|
||||||
for (int id : GameConstants.TOWER_COMMON_SUB_NOTE_SKILLS) {
|
for (int id : GameConstants.TOWER_COMMON_SUB_NOTE_SKILLS) {
|
||||||
this.subNoteDropList.add(id);
|
this.subNoteDropList.add(id);
|
||||||
@@ -206,6 +211,10 @@ public class StarTowerGame {
|
|||||||
return this.getData().getDifficulty();
|
return this.getData().getDifficulty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRarePotentialCount(int charId) {
|
||||||
|
return this.getRarePotentialCount().get(charId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the team element, if the team has 2+ or more elements, then returns null
|
* Gets the team element, if the team has 2+ or more elements, then returns null
|
||||||
*/
|
*/
|
||||||
@@ -424,6 +433,11 @@ public class StarTowerGame {
|
|||||||
// Add potential
|
// Add potential
|
||||||
this.getPotentials().put(id, nextLevel);
|
this.getPotentials().put(id, nextLevel);
|
||||||
|
|
||||||
|
// Add to rare potential count
|
||||||
|
if (potentialData.isRare()) {
|
||||||
|
this.getRarePotentialCount().add(potentialData.getCharId(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Add to change info
|
// Add to change info
|
||||||
var info = PotentialInfo.newInstance()
|
var info = PotentialInfo.newInstance()
|
||||||
.setTid(id)
|
.setTid(id)
|
||||||
@@ -491,14 +505,34 @@ public class StarTowerGame {
|
|||||||
* Adds random potential selector cases for the client
|
* Adds random potential selector cases for the client
|
||||||
*/
|
*/
|
||||||
public void addPotentialSelectors(int amount) {
|
public void addPotentialSelectors(int amount) {
|
||||||
|
if (amount <= 0) return;
|
||||||
this.pendingPotentialCases += amount;
|
this.pendingPotentialCases += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addRarePotentialSelectors(int amount) {
|
||||||
|
if (amount <= 0) return;
|
||||||
|
this.pendingRarePotentialCases += amount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a potential selectors for the client if there are any potential selectors avaliable.
|
* Creates a potential selectors for the client if there are any potential selectors avaliable.
|
||||||
* If there are none, then create the door case so the player can exit
|
* If there are none, then create the door case so the player can exit
|
||||||
*/
|
*/
|
||||||
public List<StarTowerBaseCase> handlePendingPotentialSelectors() {
|
public List<StarTowerBaseCase> handlePendingPotentialSelectors() {
|
||||||
|
// Create rare potential selectors if any characters can recieve a rare potential
|
||||||
|
if (this.pendingRarePotentialCases > 0) {
|
||||||
|
this.pendingRarePotentialCases--;
|
||||||
|
|
||||||
|
// Create a rare selector, if no selector can be created, then create a regular one instead
|
||||||
|
var selector = this.createRarePotentialSelector();
|
||||||
|
|
||||||
|
if (selector != null) {
|
||||||
|
return List.of(selector);
|
||||||
|
} else {
|
||||||
|
this.pendingPotentialCases += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create potential selectors if any are avaliable
|
// Create potential selectors if any are avaliable
|
||||||
if (this.pendingPotentialCases > 0) {
|
if (this.pendingPotentialCases > 0) {
|
||||||
this.pendingPotentialCases--;
|
this.pendingPotentialCases--;
|
||||||
@@ -553,12 +587,17 @@ public class StarTowerGame {
|
|||||||
/**
|
/**
|
||||||
* Creates a potential selector for the specified character
|
* Creates a potential selector for the specified character
|
||||||
*/
|
*/
|
||||||
public StarTowerPotentialCase createPotentialSelector(int charId, boolean rareOnly) {
|
public StarTowerPotentialCase createPotentialSelector(int charId, boolean rare) {
|
||||||
// Check character id
|
// Check character id
|
||||||
if (charId <= 0) {
|
if (charId <= 0) {
|
||||||
charId = this.getRandomCharId();
|
charId = this.getRandomCharId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure character can't have more than 2 rare potentials
|
||||||
|
if (rare && this.getRarePotentialCount(charId) >= 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// Get character potentials
|
// Get character potentials
|
||||||
var data = GameData.getCharPotentialDataTable().get(charId);
|
var data = GameData.getCharPotentialDataTable().get(charId);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -572,20 +611,20 @@ public class StarTowerGame {
|
|||||||
boolean isMainCharacter = this.getCharIds()[0] == charId;
|
boolean isMainCharacter = this.getCharIds()[0] == charId;
|
||||||
|
|
||||||
if (isMainCharacter) {
|
if (isMainCharacter) {
|
||||||
list.addElements(0, data.getMasterSpecificPotentialIds());
|
if (rare) {
|
||||||
|
list.addElements(0, data.getMasterSpecificPotentialIds());
|
||||||
if (!rareOnly) {
|
} else {
|
||||||
list.addElements(0, data.getMasterNormalPotentialIds());
|
list.addElements(0, data.getMasterNormalPotentialIds());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list.addElements(0, data.getAssistSpecificPotentialIds());
|
if (rare) {
|
||||||
|
list.addElements(0, data.getAssistSpecificPotentialIds());
|
||||||
if (!rareOnly) {
|
} else {
|
||||||
list.addElements(0, data.getAssistNormalPotentialIds());
|
list.addElements(0, data.getAssistNormalPotentialIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rareOnly) {
|
if (!rare) {
|
||||||
list.addElements(0, data.getCommonPotentialIds());
|
list.addElements(0, data.getCommonPotentialIds());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -648,13 +687,44 @@ public class StarTowerGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Creator potential selector case
|
// Creator potential selector case
|
||||||
if (rareOnly) {
|
if (rare) {
|
||||||
return new StarTowerSelectSpecialPotentialCase(this, charId, selector);
|
return new StarTowerSelectSpecialPotentialCase(this, charId, selector);
|
||||||
} else {
|
} else {
|
||||||
return new StarTowerPotentialCase(this, charId, selector);
|
return new StarTowerPotentialCase(this, charId, selector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getRandomCharIdForRarePotential() {
|
||||||
|
// Create list of avaliable characters
|
||||||
|
IntList list = new IntArrayList();
|
||||||
|
|
||||||
|
for (int id : this.getCharIds()) {
|
||||||
|
int rareCount = this.getRarePotentialCount().get(id);
|
||||||
|
if (rareCount < 2) {
|
||||||
|
list.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sanity check
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Utils.randomElement(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a random rare potential selector
|
||||||
|
*/
|
||||||
|
public StarTowerPotentialCase createRarePotentialSelector() {
|
||||||
|
// Get random character from list
|
||||||
|
int charId = this.getRandomCharIdForRarePotential();
|
||||||
|
if (charId == 0) return null;
|
||||||
|
|
||||||
|
// Create rare selector
|
||||||
|
return this.createPotentialSelector(charId, true);
|
||||||
|
}
|
||||||
|
|
||||||
public StarTowerPotentialCase createStrengthenSelector() {
|
public StarTowerPotentialCase createStrengthenSelector() {
|
||||||
// Random potentials list
|
// Random potentials list
|
||||||
var potentials = new IntArrayList();
|
var potentials = new IntArrayList();
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ public class StarTowerModifiers {
|
|||||||
|
|
||||||
// Bonus potential max level (Ocean of Souls)
|
// Bonus potential max level (Ocean of Souls)
|
||||||
if (this.hasGrowthNode(30301)) {
|
if (this.hasGrowthNode(30301)) {
|
||||||
this.bonusMaxPotentialLevel = 6;
|
this.bonusMaxPotentialLevel = 3; // 6 total
|
||||||
} else if (this.hasGrowthNode(20601)) {
|
} else if (this.hasGrowthNode(20601)) {
|
||||||
this.bonusMaxPotentialLevel = 4;
|
this.bonusMaxPotentialLevel = 1; // 4 total
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shop extra goods (Monolith Premium)
|
// Shop extra goods (Monolith Premium)
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ public class StarTowerBattleCase extends StarTowerBaseCase {
|
|||||||
return CaseType.Battle;
|
return CaseType.Battle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RoomType getRoomType() {
|
||||||
|
return this.getRoom().getType();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRegister() {
|
public void onRegister() {
|
||||||
// Get relevant floor exp data
|
// Get relevant floor exp data
|
||||||
@@ -70,7 +74,28 @@ public class StarTowerBattleCase extends StarTowerBaseCase {
|
|||||||
if (proto.hasVictory()) {
|
if (proto.hasVictory()) {
|
||||||
// Level up
|
// Level up
|
||||||
this.getGame().addExp(this.expReward);
|
this.getGame().addExp(this.expReward);
|
||||||
this.getGame().addPotentialSelectors(this.getGame().levelUp());
|
int picks = this.getGame().levelUp();
|
||||||
|
|
||||||
|
// Handle potential picks
|
||||||
|
if (picks > 0) {
|
||||||
|
// Check special cases
|
||||||
|
if (this.getGame().getFloorCount() == 1) {
|
||||||
|
// First floor potential selector is always special
|
||||||
|
this.getGame().addRarePotentialSelectors(1);
|
||||||
|
picks--;
|
||||||
|
} else if (this.getRoomType() == RoomType.BossRoom || this.getRoomType() == RoomType.FinalBossRoom) {
|
||||||
|
// First selector after a boss fight is also rare
|
||||||
|
this.getGame().addRarePotentialSelectors(1);
|
||||||
|
picks--;
|
||||||
|
} else if (Utils.randomChance(0.125D)) {
|
||||||
|
// Random 1/8th chance for a rare potential
|
||||||
|
this.getGame().addRarePotentialSelectors(1);
|
||||||
|
picks--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add remaining picks
|
||||||
|
this.getGame().addPotentialSelectors(picks);
|
||||||
|
|
||||||
// Add clear time
|
// Add clear time
|
||||||
this.getGame().addBattleTime(proto.getVictory().getTime());
|
this.getGame().addBattleTime(proto.getVictory().getTime());
|
||||||
|
|||||||
@@ -297,7 +297,8 @@ public class StarTowerNpcEventCase extends StarTowerBaseCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addRarePotentialSelector(StarTowerInteractResp rsp) {
|
private void addRarePotentialSelector(StarTowerInteractResp rsp) {
|
||||||
this.addRarePotentialSelector(rsp, 0);
|
int charId = this.getGame().getRandomCharIdForRarePotential();
|
||||||
|
this.addRarePotentialSelector(rsp, charId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRarePotentialSelector(StarTowerInteractResp rsp, int charId) {
|
private void addRarePotentialSelector(StarTowerInteractResp rsp, int charId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user