mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-18 07:14:49 +01:00
Implement monolith shop discounts and improvements
This commit is contained in:
@@ -458,14 +458,18 @@ public class StarTowerGame {
|
|||||||
* Creates a potential selector for a random character
|
* Creates a potential selector for a random character
|
||||||
*/
|
*/
|
||||||
public StarTowerBaseCase createPotentialSelector() {
|
public StarTowerBaseCase createPotentialSelector() {
|
||||||
int charId = this.getRandomCharId();
|
return this.createPotentialSelector(0);
|
||||||
return this.createPotentialSelector(charId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a potential selector for the specified character
|
* Creates a potential selector for the specified character
|
||||||
*/
|
*/
|
||||||
public StarTowerBaseCase createPotentialSelector(int charId) {
|
public StarTowerBaseCase createPotentialSelector(int charId) {
|
||||||
|
// Check character id
|
||||||
|
if (charId <= 0) {
|
||||||
|
charId = this.getRandomCharId();
|
||||||
|
}
|
||||||
|
|
||||||
// Get character potentials
|
// Get character potentials
|
||||||
var data = GameData.getCharPotentialDataTable().get(charId);
|
var data = GameData.getCharPotentialDataTable().get(charId);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -498,14 +502,10 @@ public class StarTowerGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get random potential id
|
// Get random potential id
|
||||||
int index = ThreadLocalRandom.current().nextInt(0, potentials.size());
|
int potentialId = Utils.randomElement(potentials, true);
|
||||||
int potentialId = potentials.getInt(index);
|
|
||||||
|
|
||||||
// Add to selector
|
// Add to selector
|
||||||
selector.add(potentialId);
|
selector.add(potentialId);
|
||||||
|
|
||||||
// Remove potential id from the selector
|
|
||||||
potentials.removeInt(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
|
|||||||
@@ -10,18 +10,29 @@ public class StarTowerShopGoods {
|
|||||||
private int goodsId;
|
private int goodsId;
|
||||||
private int price;
|
private int price;
|
||||||
private int discount;
|
private int discount;
|
||||||
|
private int count;
|
||||||
|
private int charPos;
|
||||||
private boolean sold;
|
private boolean sold;
|
||||||
|
|
||||||
public StarTowerShopGoods(int type, int goodsId, int price) {
|
public StarTowerShopGoods(int type, int goodsId, int price) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
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) {
|
||||||
|
this.charPos = charPos;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasDiscount() {
|
public boolean hasDiscount() {
|
||||||
return this.getDiscount() > 0;
|
return this.getDiscount() > 0;
|
||||||
}
|
}
|
||||||
@@ -37,4 +48,13 @@ public class StarTowerShopGoods {
|
|||||||
public int getDisplayPrice() {
|
public int getDisplayPrice() {
|
||||||
return this.price;
|
return this.price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCharId(StarTowerGame game) {
|
||||||
|
if (this.getCharPos() == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index = this.getCharPos() - 1;
|
||||||
|
return game.getCharIds().getInt(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import emu.nebula.GameConstants;
|
import emu.nebula.GameConstants;
|
||||||
|
import emu.nebula.game.player.PlayerChangeInfo;
|
||||||
import emu.nebula.game.tower.StarTowerShopGoods;
|
import emu.nebula.game.tower.StarTowerShopGoods;
|
||||||
import emu.nebula.proto.PublicStarTower.HawkerCaseData;
|
import emu.nebula.proto.PublicStarTower.HawkerCaseData;
|
||||||
import emu.nebula.proto.PublicStarTower.HawkerGoods;
|
import emu.nebula.proto.PublicStarTower.HawkerGoods;
|
||||||
@@ -37,9 +38,38 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
// Clear goods
|
// Clear goods
|
||||||
this.getGoods().clear();
|
this.getGoods().clear();
|
||||||
|
|
||||||
|
// Caclulate amount of potentials/sub notes to sell
|
||||||
|
int total = getModifiers().getShopGoodsCount();
|
||||||
|
|
||||||
|
int minPotentials = Math.max(total / 2, 2);
|
||||||
|
int maxPotentials = Math.max(total - 1, minPotentials);
|
||||||
|
int potentials = Utils.randomRange(minPotentials, maxPotentials);
|
||||||
|
int subNotes = total - potentials;
|
||||||
|
|
||||||
// Add goods
|
// Add goods
|
||||||
for (int i = 0; i < getModifiers().getShopGoodsCount(); i++) {
|
for (int i = 0; i < potentials; i++) {
|
||||||
this.addGoods(new StarTowerShopGoods(1, 1, 200));
|
// Create potential selector shop item
|
||||||
|
var goods = new StarTowerShopGoods(1, 102, 200);
|
||||||
|
|
||||||
|
// Add character specific potentials
|
||||||
|
if (Utils.generateRandomDouble() < .2) {
|
||||||
|
goods.setCharPos(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add to goods map
|
||||||
|
this.addGoods(goods);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < subNotes; i++) {
|
||||||
|
// Randomize sub note
|
||||||
|
int id = Utils.randomElement(this.getGame().getSubNoteDropList());
|
||||||
|
int count = Utils.randomRange(3, 10);
|
||||||
|
|
||||||
|
// Create sub note shop item
|
||||||
|
var goods = new StarTowerShopGoods(2, id, 15 * count);
|
||||||
|
goods.setCount(count);
|
||||||
|
|
||||||
|
// Add to goods map
|
||||||
|
this.addGoods(goods);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply discounts based on star tower talents
|
// Apply discounts based on star tower talents
|
||||||
@@ -121,6 +151,9 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
// Create new goods
|
// Create new goods
|
||||||
this.initGoods();
|
this.initGoods();
|
||||||
|
|
||||||
|
// Consume reroll count
|
||||||
|
this.getGame().getModifiers().consumeShopReroll();
|
||||||
|
|
||||||
// Set in proto
|
// Set in proto
|
||||||
rsp.getMutableSelectResp()
|
rsp.getMutableSelectResp()
|
||||||
.setHawkerCase(this.toHawkerCaseProto());
|
.setHawkerCase(this.toHawkerCaseProto());
|
||||||
@@ -130,9 +163,6 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
|
|
||||||
// Set change info
|
// Set change info
|
||||||
rsp.setChange(change.toProto());
|
rsp.setChange(change.toProto());
|
||||||
|
|
||||||
// Consume reroll count
|
|
||||||
this.getGame().getModifiers().consumeShopReroll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buy(int sid, StarTowerInteractResp rsp) {
|
private void buy(int sid, StarTowerInteractResp rsp) {
|
||||||
@@ -153,11 +183,21 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
// Mark goods as sold
|
// Mark goods as sold
|
||||||
goods.markAsSold();
|
goods.markAsSold();
|
||||||
|
|
||||||
// Add case
|
// Create change info
|
||||||
this.getGame().addCase(rsp.getMutableCases(), this.getGame().createPotentialSelector());
|
var change = new PlayerChangeInfo();
|
||||||
|
|
||||||
|
// Add goods
|
||||||
|
if (goods.getType() == 1) {
|
||||||
|
// Potential selector
|
||||||
|
int charId = goods.getCharId(this.getGame());
|
||||||
|
this.getGame().addCase(rsp.getMutableCases(), this.getGame().createPotentialSelector(charId));
|
||||||
|
} else {
|
||||||
|
// Sub notes
|
||||||
|
this.getGame().addItem(goods.getGoodsId(), goods.getCount(), change);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove coins
|
// Remove coins
|
||||||
var change = this.getGame().addItem(GameConstants.STAR_TOWER_COIN_ITEM_ID, -price);
|
this.getGame().addItem(GameConstants.STAR_TOWER_COIN_ITEM_ID, -price, change);
|
||||||
|
|
||||||
// Set change info
|
// Set change info
|
||||||
rsp.setChange(change.toProto());
|
rsp.setChange(change.toProto());
|
||||||
@@ -179,10 +219,10 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
var goods = entry.getValue();
|
var goods = entry.getValue();
|
||||||
|
|
||||||
var info = HawkerGoods.newInstance()
|
var info = HawkerGoods.newInstance()
|
||||||
.setIdx(goods.getGoodsId())
|
.setIdx(1)
|
||||||
.setSid(sid)
|
.setSid(sid)
|
||||||
.setType(goods.getType())
|
.setType(goods.getType())
|
||||||
.setGoodsId(102) // ?
|
.setGoodsId(goods.getGoodsId())
|
||||||
.setPrice(goods.getDisplayPrice())
|
.setPrice(goods.getDisplayPrice())
|
||||||
.setTag(1);
|
.setTag(1);
|
||||||
|
|
||||||
@@ -190,6 +230,10 @@ public class StarTowerHawkerCase extends StarTowerBaseCase {
|
|||||||
info.setDiscount(goods.getPrice());
|
info.setDiscount(goods.getPrice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (goods.getCharPos() > 0) {
|
||||||
|
info.setCharPos(goods.getCharPos());
|
||||||
|
}
|
||||||
|
|
||||||
hawker.addList(info);
|
hawker.addList(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user