Commit ee3a0c32 authored by Kengxxiao's avatar Kengxxiao Committed by Melledy
Browse files

use better shop config structure

parent 3e0ccbbb
[
{
"shopId": 1004,
"items": [
{
"goodsId": 1004202,
"goodsItem": {
"Id": 202,
......@@ -11,16 +13,23 @@
"beginTime": 1575129600,
"endTime": 2051193600,
"minLevel": 1,
"maxLevel": 99
"maxLevel": 99,
"costItemList": [
{
"Id": 223,
"Count": 100
}
]
},
{
"shopId": 1004,
"goodsId": 10048006,
"goodsItem": {
"Id": 108006,
"Count": 20
},
"scoin": 1,
"scoin": 100,
"hcoin": 100,
"mcoin": 100,
"buyLimit": 50000,
"beginTime": 1575129600,
"endTime": 2051193600,
......@@ -28,7 +37,6 @@
"maxLevel": 99
},
{
"shopId": 1004,
"goodsId": 10048033,
"goodsItem": {
"Id": 108033,
......@@ -40,47 +48,7 @@
"endTime": 2051193600,
"minLevel": 1,
"maxLevel": 99
},
{
"shopId": 1004,
"goodsId": 10040008,
"goodsItem": {
"Id": 220008,
"Count": 1
},
"scoin": 1,
"buyLimit": 1,
"beginTime": 1575129600,
"endTime": 2051193600,
"minLevel": 1,
"maxLevel": 99
},
{
"shopId": 1004,
"goodsId": 10044003,
"goodsItem": {
"Id": 104003,
"Count": 200
},
"scoin": 1,
"buyLimit": 50000,
"beginTime": 1575129600,
"endTime": 2051193600,
"minLevel": 1,
"maxLevel": 99
},
{
"shopId": 1004,
"goodsId": 10044013,
"goodsItem": {
"Id": 104013,
"Count": 200
},
"scoin": 1,
"buyLimit": 50000,
"beginTime": 1575129600,
"endTime": 2051193600,
"minLevel": 1,
"maxLevel": 99
}
]
}
]
\ No newline at end of file
......@@ -6,23 +6,22 @@ import java.util.ArrayList;
import java.util.List;
public class ShopInfo {
public int shopId = 1004;
public int goodsId = 0;
public ItemParamData goodsItem;
public int scoin = 0;
public List<ItemParamData> costItemList;
public int boughtNum = 0;
public int buyLimit = 0;
public int beginTime = 0;
public int endTime = 1924992000;
public int nextRefreshTime = 1924992000;
public int minLevel = 0;
public int maxLevel = 61;
public List<Integer> preGoodsIdList = new ArrayList<>();
public int mcoin = 0;
public int hcoin = 0;
public int disableType = 0;
public int secondarySheetId = 0;
private int goodsId = 0;
private ItemParamData goodsItem;
private int scoin = 0;
private List<ItemParamData> costItemList;
private int boughtNum = 0;
private int buyLimit = 0;
private int beginTime = 0;
private int endTime = 1924992000;
private int nextRefreshTime = 1924992000;
private int minLevel = 0;
private int maxLevel = 61;
private List<Integer> preGoodsIdList = new ArrayList<>();
private int mcoin = 0;
private int hcoin = 0;
private int disableType = 0;
private int secondarySheetId = 0;
public int getHcoin() {
return hcoin;
......@@ -64,14 +63,6 @@ public class ShopInfo {
this.secondarySheetId = secondarySheetId;
}
public int getShopId() {
return shopId;
}
public void setShopId(int shopId) {
this.shopId = shopId;
}
public int getGoodsId() {
return goodsId;
}
......
......@@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
......@@ -29,13 +28,10 @@ public class ShopManager {
public synchronized void load() {
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Shop.json")) {
getShopData().clear();
List<ShopInfo> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopInfo.class).getType());
List<ShopTable> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopTable.class).getType());
if(banners.size() > 0) {
for (ShopInfo shopInfo : banners) {
if (!getShopData().containsKey(shopInfo.getShopId()))
getShopData().put(shopInfo.getShopId(), new ArrayList<>());
getShopData().get(shopInfo.getShopId()).add(shopInfo);
Grasscutter.getLogger().info(String.format("Shop add: id [%d], data [%d*%d]", shopInfo.getShopId(), shopInfo.getGoodsItem().getId(), shopInfo.getGoodsItem().getCount()));
for (ShopTable shopTable : banners) {
getShopData().put(shopTable.getShopId(), shopTable.getItems());
}
Grasscutter.getLogger().info("Shop data successfully loaded.");
} else {
......
package emu.grasscutter.game.shop;
import java.util.ArrayList;
import java.util.List;
public class ShopTable {
private int shopId;
private List<ShopInfo> items = new ArrayList<>();
public int getShopId() {
return shopId;
}
public void setShopId(int shopId) {
this.shopId = shopId;
}
public List<ShopInfo> getItems() {
return items;
}
public void setItems(List<ShopInfo> items) {
this.items = items;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment