Implement bonus potential level monolith talents

This commit is contained in:
Melledy
2025-12-05 02:12:29 -08:00
parent 880f0d1d7d
commit 6974631601
5 changed files with 118 additions and 41 deletions

View File

@@ -2,7 +2,6 @@ package emu.nebula.game.tower;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import dev.morphia.annotations.Entity;
@@ -558,7 +557,7 @@ public class StarTowerGame {
}
// Get up to 3 random potentials
IntList selector = new IntArrayList();
List<StarTowerPotentialInfo> selector = new ArrayList<>();
for (int i = 0; i < 3; i++) {
// Sanity check
@@ -567,10 +566,27 @@ public class StarTowerGame {
}
// Get random potential id
int potentialId = Utils.randomElement(potentials, true);
int id = Utils.randomElement(potentials, true);
int level = 1;
// Check for bonuses
if (this.getItemCount(id) > 0) {
// New potential
if (Utils.randomChance(this.getModifiers().getBonusPotentialChance())) {
level += this.getModifiers().getBonusPotentialLevel();
}
} else {
// Existing potential
if (Utils.randomChance(this.getModifiers().getBonusStrengthenChance())) {
level += 1;
}
}
// Create potential
var potential = new StarTowerPotentialInfo(id, level);
// Add to selector
selector.add(potentialId);
selector.add(potential);
}
// Sanity check
@@ -603,7 +619,7 @@ public class StarTowerGame {
}
// Get up to 3 random potentials
IntList selector = new IntArrayList();
List<StarTowerPotentialInfo> selector = new ArrayList<>();
for (int i = 0; i < 3; i++) {
// Sanity check
@@ -612,14 +628,19 @@ public class StarTowerGame {
}
// Get random potential id
int index = ThreadLocalRandom.current().nextInt(0, potentials.size());
int potentialId = potentials.getInt(index);
int id = Utils.randomElement(potentials, true);
int level = 1;
// Check bonus potential chance
if (Utils.randomChance(this.getModifiers().getBonusStrengthenChance())) {
level += 1;
}
// Create potential
var potential = new StarTowerPotentialInfo(id, level);
// Add to selector
selector.add(potentialId);
// Remove potential id from the selector
potentials.removeInt(index);
selector.add(potential);
}
// Sanity check

View File

@@ -29,12 +29,17 @@ public class StarTowerModifiers {
private boolean shopDiscountTier2;
private boolean shopDiscountTier3;
// Bonus potential levels
private double bonusStrengthenChance = 0;
private double bonusPotentialChance = 0;
private int bonusPotentialLevel = 0;
public StarTowerModifiers(StarTowerGame game) {
this.game = game;
// Strengthen machines
this.enableEndStrengthen = this.hasGrowthNode(10601) && game.getDifficulty() >= 2;
this.enableShopStrengthen = this.hasGrowthNode(20301) && game.getDifficulty() >= 4;
this.enableEndStrengthen = game.getDifficulty() >= 2 && this.hasGrowthNode(10601);
this.enableShopStrengthen = game.getDifficulty() >= 4 && this.hasGrowthNode(20301);
this.freeStrengthen = this.hasGrowthNode(10801);
@@ -45,14 +50,14 @@ public class StarTowerModifiers {
this.strengthenDiscount += 30;
}
// Bonus max level
// Bonus potential max level (Ocean of Souls)
if (this.hasGrowthNode(30301)) {
this.bonusMaxPotentialLevel = 6;
} else if (this.hasGrowthNode(20601)) {
this.bonusMaxPotentialLevel = 4;
}
// Shop
// Shop (Monolith Premium)
if (this.hasGrowthNode(20702)) {
this.shopGoodsCount = 8;
} else if (this.hasGrowthNode(20402)) {
@@ -74,9 +79,34 @@ public class StarTowerModifiers {
this.shopRerollPrice = 100;
}
this.shopDiscountTier1 = this.hasGrowthNode(20202) && game.getDifficulty() >= 3;
this.shopDiscountTier2 = this.hasGrowthNode(20502) && game.getDifficulty() >= 4;
this.shopDiscountTier3 = this.hasGrowthNode(20802) && game.getDifficulty() >= 5;
// Shop discount (Member Discount)
this.shopDiscountTier1 = game.getDifficulty() >= 3 && this.hasGrowthNode(20202);
this.shopDiscountTier2 = game.getDifficulty() >= 4 && this.hasGrowthNode(20502);
this.shopDiscountTier3 = game.getDifficulty() >= 5 && this.hasGrowthNode(20802);
// Bonus potential levels (Potential Boost)
if (game.getDifficulty() >= 7 && this.hasGrowthNode(30802)) {
this.bonusStrengthenChance = 0.3;
} else if (game.getDifficulty() >= 6 && this.hasGrowthNode(30502)) {
this.bonusStrengthenChance = 0.2;
} else if (game.getDifficulty() >= 6 && this.hasGrowthNode(30202)) {
this.bonusStrengthenChance = 0.1;
}
// Bonus potential levels (Butterflies Inside)
if (game.getDifficulty() >= 7 && this.hasGrowthNode(30901)) {
this.bonusPotentialChance = 0.3;
this.bonusMaxPotentialLevel = 2;
} else if (game.getDifficulty() >= 7 && this.hasGrowthNode(30801)) {
this.bonusPotentialChance = 0.2;
this.bonusMaxPotentialLevel = 1;
} else if (game.getDifficulty() >= 6 && this.hasGrowthNode(30201)) {
this.bonusPotentialChance = 0.1;
this.bonusMaxPotentialLevel = 1;
} else if (game.getDifficulty() >= 5 && this.hasGrowthNode(20801)) {
this.bonusPotentialChance = 0.05;
this.bonusMaxPotentialLevel = 1;
}
}
public boolean hasGrowthNode(int nodeId) {

View File

@@ -0,0 +1,26 @@
package emu.nebula.game.tower;
import emu.nebula.proto.PublicStarTower.PotentialInfo;
import lombok.Getter;
@Getter
public class StarTowerPotentialInfo {
private int id;
private int level;
public StarTowerPotentialInfo(int id, int level) {
this.id = id;
this.level = level;
}
// Proto
public PotentialInfo toProto() {
var proto = PotentialInfo.newInstance()
.setTid(this.getId())
.setLevel(this.getLevel());
return proto;
}
}

View File

@@ -1,20 +1,22 @@
package emu.nebula.game.tower.cases;
import emu.nebula.proto.PublicStarTower.PotentialInfo;
import java.util.List;
import emu.nebula.game.tower.StarTowerPotentialInfo;
import emu.nebula.proto.PublicStarTower.StarTowerRoomCase;
import emu.nebula.proto.StarTowerInteract.StarTowerInteractReq;
import emu.nebula.proto.StarTowerInteract.StarTowerInteractResp;
import it.unimi.dsi.fastutil.ints.IntList;
import lombok.Getter;
@Getter
public class StarTowerPotentialCase extends StarTowerBaseCase {
private int teamLevel;
private IntList potentialIds;
private List<StarTowerPotentialInfo> potentials;
public StarTowerPotentialCase(int teamLevel, IntList potentialIds) {
public StarTowerPotentialCase(int teamLevel, List<StarTowerPotentialInfo> potentials) {
this.teamLevel = teamLevel;
this.potentialIds = potentialIds;
this.potentials = potentials;
}
@Override
@@ -22,29 +24,26 @@ public class StarTowerPotentialCase extends StarTowerBaseCase {
return CaseType.PotentialSelect;
}
public int selectId(int index) {
if (this.getPotentialIds() == null) {
return 0;
public StarTowerPotentialInfo selectId(int index) {
if (index < 0 || index >= this.getPotentials().size()) {
return null;
}
if (index < 0 || index >= this.getPotentialIds().size()) {
return 0;
}
return this.getPotentialIds().getInt(index);
return this.getPotentials().get(index);
}
@Override
public StarTowerInteractResp interact(StarTowerInteractReq req, StarTowerInteractResp rsp) {
// Get selected potential
var index = req.getMutableSelectReq().getIndex();
int id = this.selectId(index);
if (id <= 0) {
var potential = this.selectId(index);
if (potential == null) {
return rsp;
}
// Add item
var change = this.getGame().addItem(id, 1);
// Add potential
var change = this.getGame().addItem(potential.getId(), potential.getLevel());
// Set change
rsp.setChange(change.toProto());
@@ -56,6 +55,7 @@ public class StarTowerPotentialCase extends StarTowerBaseCase {
this.getGame().addCase(rsp.getMutableCases(), towerCase);
}
// Complete
return rsp;
}
@@ -66,12 +66,8 @@ public class StarTowerPotentialCase extends StarTowerBaseCase {
var select = proto.getMutableSelectPotentialCase()
.setTeamLevel(this.getTeamLevel());
for (int id : this.getPotentialIds()) {
var info = PotentialInfo.newInstance()
.setTid(id)
.setLevel(1);
select.addInfos(info);
for (var potential : this.getPotentials()) {
select.addInfos(potential.toProto());
}
}
}

View File

@@ -175,6 +175,10 @@ public class Utils {
}
public static boolean randomChance(double chance) {
if (chance <= 0) {
return false;
}
return ThreadLocalRandom.current().nextDouble() < chance;
}