Fix item count on star tower shop goods

This commit is contained in:
Melledy
2025-12-05 19:25:20 -08:00
parent 426e5bce63
commit 5182e94db7
2 changed files with 23 additions and 13 deletions

View File

@@ -7,28 +7,24 @@ import lombok.Getter;
@Entity(useDiscriminator = false) @Entity(useDiscriminator = false)
public class StarTowerShopGoods { public class StarTowerShopGoods {
private int type; private int type;
private int goodsId; private int idx; // This is actually the shop goods id
private int goodsId; // Item id
private int price; private int price;
private int discount; private int discount;
private int count;
private int charPos; private int charPos;
private boolean sold; private boolean sold;
public StarTowerShopGoods(int type, int goodsId, int price) { public StarTowerShopGoods(int type, int idx, int goodsId, int price) {
this.type = type; this.type = type;
this.idx = idx;
this.goodsId = goodsId; this.goodsId = goodsId;
this.price = price; this.price = price;
this.count = 1;
} }
public void markAsSold() { public void markAsSold() {
this.sold = true; this.sold = true;
} }
public void setCount(int count) {
this.count = count;
}
public void setCharPos(int charPos) { public void setCharPos(int charPos) {
this.charPos = charPos; this.charPos = charPos;
} }
@@ -49,6 +45,14 @@ public class StarTowerShopGoods {
return this.price; return this.price;
} }
public int getCount() {
if (this.getType() == 2) {
return this.getIdx() == 8 ? 15 : 5;
}
return 1;
}
public int getCharId(StarTowerGame game) { public int getCharId(StarTowerGame game) {
if (this.getCharPos() == 0) { if (this.getCharPos() == 0) {
return 0; return 0;

View File

@@ -44,12 +44,14 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
int minPotentials = Math.max(total / 2, 2); int minPotentials = Math.max(total / 2, 2);
int maxPotentials = Math.max(total - 1, minPotentials); int maxPotentials = Math.max(total - 1, minPotentials);
int potentials = Utils.randomRange(minPotentials, maxPotentials); int potentials = Utils.randomRange(minPotentials, maxPotentials);
int subNotes = total - potentials; int subNotes = total - potentials;
boolean hasCoins = this.getGame().getResCount(GameConstants.TOWER_COIN_ITEM_ID) >= 500;
// Add goods // Add goods
for (int i = 0; i < potentials; i++) { for (int i = 0; i < potentials; i++) {
// Create potential selector shop item // Create potential selector shop item
var goods = new StarTowerShopGoods(1, 102, 200); var goods = new StarTowerShopGoods(1, 1, 102, 200);
// Add character specific potentials // Add character specific potentials
if (Utils.generateRandomDouble() < .2) { if (Utils.generateRandomDouble() < .2) {
@@ -62,11 +64,15 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
for (int i = 0; i < subNotes; i++) { for (int i = 0; i < subNotes; i++) {
// Randomize sub note // Randomize sub note
int id = Utils.randomElement(this.getGame().getSubNoteDropList()); int id = Utils.randomElement(this.getGame().getSubNoteDropList());
int count = Utils.randomRange(3, 10);
// Create sub note shop item // Create sub note shop item
var goods = new StarTowerShopGoods(2, id, 15 * count); StarTowerShopGoods goods = null;
goods.setCount(count);
if (hasCoins && Utils.randomChance(.25)) {
goods = new StarTowerShopGoods(2, 8, id, 400);
} else {
goods = new StarTowerShopGoods(2, 3, id, 90);
}
// Add to goods map // Add to goods map
this.addGoods(goods); this.addGoods(goods);
@@ -219,9 +225,9 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
var goods = entry.getValue(); var goods = entry.getValue();
var info = HawkerGoods.newInstance() var info = HawkerGoods.newInstance()
.setIdx(1)
.setSid(sid) .setSid(sid)
.setType(goods.getType()) .setType(goods.getType())
.setIdx(goods.getIdx())
.setGoodsId(goods.getGoodsId()) .setGoodsId(goods.getGoodsId())
.setPrice(goods.getDisplayPrice()) .setPrice(goods.getDisplayPrice())
.setTag(1); .setTag(1);