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.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import dev.morphia.annotations.Entity; import dev.morphia.annotations.Entity;
@@ -558,7 +557,7 @@ public class StarTowerGame {
} }
// Get up to 3 random potentials // Get up to 3 random potentials
IntList selector = new IntArrayList(); List<StarTowerPotentialInfo> selector = new ArrayList<>();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
// Sanity check // Sanity check
@@ -567,10 +566,27 @@ public class StarTowerGame {
} }
// Get random potential id // 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 // Add to selector
selector.add(potentialId); selector.add(potential);
} }
// Sanity check // Sanity check
@@ -603,7 +619,7 @@ public class StarTowerGame {
} }
// Get up to 3 random potentials // Get up to 3 random potentials
IntList selector = new IntArrayList(); List<StarTowerPotentialInfo> selector = new ArrayList<>();
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
// Sanity check // Sanity check
@@ -612,14 +628,19 @@ public class StarTowerGame {
} }
// Get random potential id // Get random potential id
int index = ThreadLocalRandom.current().nextInt(0, potentials.size()); int id = Utils.randomElement(potentials, true);
int potentialId = potentials.getInt(index); 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 // Add to selector
selector.add(potentialId); selector.add(potential);
// Remove potential id from the selector
potentials.removeInt(index);
} }
// Sanity check // Sanity check

View File

@@ -29,12 +29,17 @@ public class StarTowerModifiers {
private boolean shopDiscountTier2; private boolean shopDiscountTier2;
private boolean shopDiscountTier3; private boolean shopDiscountTier3;
// Bonus potential levels
private double bonusStrengthenChance = 0;
private double bonusPotentialChance = 0;
private int bonusPotentialLevel = 0;
public StarTowerModifiers(StarTowerGame game) { public StarTowerModifiers(StarTowerGame game) {
this.game = game; this.game = game;
// Strengthen machines // Strengthen machines
this.enableEndStrengthen = this.hasGrowthNode(10601) && game.getDifficulty() >= 2; this.enableEndStrengthen = game.getDifficulty() >= 2 && this.hasGrowthNode(10601);
this.enableShopStrengthen = this.hasGrowthNode(20301) && game.getDifficulty() >= 4; this.enableShopStrengthen = game.getDifficulty() >= 4 && this.hasGrowthNode(20301);
this.freeStrengthen = this.hasGrowthNode(10801); this.freeStrengthen = this.hasGrowthNode(10801);
@@ -45,14 +50,14 @@ public class StarTowerModifiers {
this.strengthenDiscount += 30; this.strengthenDiscount += 30;
} }
// Bonus max level // Bonus potential max level (Ocean of Souls)
if (this.hasGrowthNode(30301)) { if (this.hasGrowthNode(30301)) {
this.bonusMaxPotentialLevel = 6; this.bonusMaxPotentialLevel = 6;
} else if (this.hasGrowthNode(20601)) { } else if (this.hasGrowthNode(20601)) {
this.bonusMaxPotentialLevel = 4; this.bonusMaxPotentialLevel = 4;
} }
// Shop // Shop (Monolith Premium)
if (this.hasGrowthNode(20702)) { if (this.hasGrowthNode(20702)) {
this.shopGoodsCount = 8; this.shopGoodsCount = 8;
} else if (this.hasGrowthNode(20402)) { } else if (this.hasGrowthNode(20402)) {
@@ -74,9 +79,34 @@ public class StarTowerModifiers {
this.shopRerollPrice = 100; this.shopRerollPrice = 100;
} }
this.shopDiscountTier1 = this.hasGrowthNode(20202) && game.getDifficulty() >= 3; // Shop discount (Member Discount)
this.shopDiscountTier2 = this.hasGrowthNode(20502) && game.getDifficulty() >= 4; this.shopDiscountTier1 = game.getDifficulty() >= 3 && this.hasGrowthNode(20202);
this.shopDiscountTier3 = this.hasGrowthNode(20802) && game.getDifficulty() >= 5; 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) { 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; 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.PublicStarTower.StarTowerRoomCase;
import emu.nebula.proto.StarTowerInteract.StarTowerInteractReq; import emu.nebula.proto.StarTowerInteract.StarTowerInteractReq;
import emu.nebula.proto.StarTowerInteract.StarTowerInteractResp; import emu.nebula.proto.StarTowerInteract.StarTowerInteractResp;
import it.unimi.dsi.fastutil.ints.IntList;
import lombok.Getter; import lombok.Getter;
@Getter @Getter
public class StarTowerPotentialCase extends StarTowerBaseCase { public class StarTowerPotentialCase extends StarTowerBaseCase {
private int teamLevel; 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.teamLevel = teamLevel;
this.potentialIds = potentialIds; this.potentials = potentials;
} }
@Override @Override
@@ -22,29 +24,26 @@ public class StarTowerPotentialCase extends StarTowerBaseCase {
return CaseType.PotentialSelect; return CaseType.PotentialSelect;
} }
public int selectId(int index) { public StarTowerPotentialInfo selectId(int index) {
if (this.getPotentialIds() == null) { if (index < 0 || index >= this.getPotentials().size()) {
return 0; return null;
} }
if (index < 0 || index >= this.getPotentialIds().size()) { return this.getPotentials().get(index);
return 0;
}
return this.getPotentialIds().getInt(index);
} }
@Override @Override
public StarTowerInteractResp interact(StarTowerInteractReq req, StarTowerInteractResp rsp) { public StarTowerInteractResp interact(StarTowerInteractReq req, StarTowerInteractResp rsp) {
// Get selected potential
var index = req.getMutableSelectReq().getIndex(); var index = req.getMutableSelectReq().getIndex();
int id = this.selectId(index); var potential = this.selectId(index);
if (id <= 0) { if (potential == null) {
return rsp; return rsp;
} }
// Add item // Add potential
var change = this.getGame().addItem(id, 1); var change = this.getGame().addItem(potential.getId(), potential.getLevel());
// Set change // Set change
rsp.setChange(change.toProto()); rsp.setChange(change.toProto());
@@ -56,6 +55,7 @@ public class StarTowerPotentialCase extends StarTowerBaseCase {
this.getGame().addCase(rsp.getMutableCases(), towerCase); this.getGame().addCase(rsp.getMutableCases(), towerCase);
} }
// Complete
return rsp; return rsp;
} }
@@ -66,12 +66,8 @@ public class StarTowerPotentialCase extends StarTowerBaseCase {
var select = proto.getMutableSelectPotentialCase() var select = proto.getMutableSelectPotentialCase()
.setTeamLevel(this.getTeamLevel()); .setTeamLevel(this.getTeamLevel());
for (int id : this.getPotentialIds()) { for (var potential : this.getPotentials()) {
var info = PotentialInfo.newInstance() select.addInfos(potential.toProto());
.setTid(id)
.setLevel(1);
select.addInfos(info);
} }
} }
} }

View File

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