mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-16 07:14:58 +01:00
Fix starlight/ember exchange stores
This commit is contained in:
@@ -2,8 +2,8 @@ package emu.lunarcore.data.excel;
|
|||||||
|
|
||||||
import emu.lunarcore.data.GameResource;
|
import emu.lunarcore.data.GameResource;
|
||||||
import emu.lunarcore.data.ResourceType;
|
import emu.lunarcore.data.ResourceType;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectAVLTreeMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -15,7 +15,7 @@ public class ShopExcel extends GameResource {
|
|||||||
private transient Int2ObjectMap<ShopGoodsExcel> goods;
|
private transient Int2ObjectMap<ShopGoodsExcel> goods;
|
||||||
|
|
||||||
public ShopExcel() {
|
public ShopExcel() {
|
||||||
this.goods = new Int2ObjectOpenHashMap<>();
|
this.goods = new Int2ObjectAVLTreeMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ public class ShopGoodsExcel extends GameResource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
// Skip if we dont have an item id associated with this goods excel
|
||||||
|
if (this.getItemID() == 0) return;
|
||||||
|
|
||||||
// Add to shop excel
|
// Add to shop excel
|
||||||
ShopExcel shop = GameData.getShopExcelMap().get(this.ShopID);
|
ShopExcel shop = GameData.getShopExcelMap().get(this.ShopID);
|
||||||
if (shop == null) return;
|
if (shop == null) return;
|
||||||
|
|||||||
@@ -26,18 +26,20 @@ public class ShopService extends BaseGameService {
|
|||||||
ShopGoodsExcel goods = shop.getGoods().get(goodsId);
|
ShopGoodsExcel goods = shop.getGoods().get(goodsId);
|
||||||
if (goods == null) return null;
|
if (goods == null) return null;
|
||||||
|
|
||||||
|
ItemExcel itemExcel = GameData.getItemExcelMap().get(goods.getItemID());
|
||||||
|
if (itemExcel == null) return null;
|
||||||
|
|
||||||
// Verify item params
|
// Verify item params
|
||||||
if (!player.getInventory().verifyItems(goods.getCostList(), count)) {
|
if (!player.getInventory().verifyItems(goods.getCostList(), count)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pay items
|
// Handle payment
|
||||||
player.getInventory().removeItemsByParams(goods.getCostList(), count);
|
player.getInventory().removeItemsByParams(goods.getCostList(), count);
|
||||||
|
|
||||||
// Buy items
|
// Buy items
|
||||||
List<GameItem> items = new ArrayList<>();
|
List<GameItem> items = new ArrayList<>();
|
||||||
|
|
||||||
ItemExcel itemExcel = GameData.getItemExcelMap().get(goods.getItemID());
|
|
||||||
if (!itemExcel.isEquippable()) {
|
if (!itemExcel.isEquippable()) {
|
||||||
GameItem item = new GameItem(itemExcel, goods.getItemCount() * count);
|
GameItem item = new GameItem(itemExcel, goods.getItemCount() * count);
|
||||||
items.add(item);
|
items.add(item);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class PacketGetShopListScRsp extends BasePacket {
|
|||||||
.setShopType(shopType);
|
.setShopType(shopType);
|
||||||
|
|
||||||
for (ShopExcel shopExcel : GameData.getShopExcelMap().values()) {
|
for (ShopExcel shopExcel : GameData.getShopExcelMap().values()) {
|
||||||
if (shopExcel.getShopType() != shopType) {
|
if (shopExcel.getShopType() != shopType || shopExcel.getGoods().size() == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user