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

use better shop config structure

parent 3e0ccbbb
[ [
{ {
"shopId": 1004, "shopId": 1004,
"items": [
{
"goodsId": 1004202, "goodsId": 1004202,
"goodsItem": { "goodsItem": {
"Id": 202, "Id": 202,
...@@ -11,16 +13,23 @@ ...@@ -11,16 +13,23 @@
"beginTime": 1575129600, "beginTime": 1575129600,
"endTime": 2051193600, "endTime": 2051193600,
"minLevel": 1, "minLevel": 1,
"maxLevel": 99 "maxLevel": 99,
"costItemList": [
{
"Id": 223,
"Count": 100
}
]
}, },
{ {
"shopId": 1004,
"goodsId": 10048006, "goodsId": 10048006,
"goodsItem": { "goodsItem": {
"Id": 108006, "Id": 108006,
"Count": 20 "Count": 20
}, },
"scoin": 1, "scoin": 100,
"hcoin": 100,
"mcoin": 100,
"buyLimit": 50000, "buyLimit": 50000,
"beginTime": 1575129600, "beginTime": 1575129600,
"endTime": 2051193600, "endTime": 2051193600,
...@@ -28,7 +37,6 @@ ...@@ -28,7 +37,6 @@
"maxLevel": 99 "maxLevel": 99
}, },
{ {
"shopId": 1004,
"goodsId": 10048033, "goodsId": 10048033,
"goodsItem": { "goodsItem": {
"Id": 108033, "Id": 108033,
...@@ -40,47 +48,7 @@ ...@@ -40,47 +48,7 @@
"endTime": 2051193600, "endTime": 2051193600,
"minLevel": 1, "minLevel": 1,
"maxLevel": 99 "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; ...@@ -6,23 +6,22 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class ShopInfo { public class ShopInfo {
public int shopId = 1004; private int goodsId = 0;
public int goodsId = 0; private ItemParamData goodsItem;
public ItemParamData goodsItem; private int scoin = 0;
public int scoin = 0; private List<ItemParamData> costItemList;
public List<ItemParamData> costItemList; private int boughtNum = 0;
public int boughtNum = 0; private int buyLimit = 0;
public int buyLimit = 0; private int beginTime = 0;
public int beginTime = 0; private int endTime = 1924992000;
public int endTime = 1924992000; private int nextRefreshTime = 1924992000;
public int nextRefreshTime = 1924992000; private int minLevel = 0;
public int minLevel = 0; private int maxLevel = 61;
public int maxLevel = 61; private List<Integer> preGoodsIdList = new ArrayList<>();
public List<Integer> preGoodsIdList = new ArrayList<>(); private int mcoin = 0;
public int mcoin = 0; private int hcoin = 0;
public int hcoin = 0; private int disableType = 0;
public int disableType = 0; private int secondarySheetId = 0;
public int secondarySheetId = 0;
public int getHcoin() { public int getHcoin() {
return hcoin; return hcoin;
...@@ -64,14 +63,6 @@ public class ShopInfo { ...@@ -64,14 +63,6 @@ public class ShopInfo {
this.secondarySheetId = secondarySheetId; this.secondarySheetId = secondarySheetId;
} }
public int getShopId() {
return shopId;
}
public void setShopId(int shopId) {
this.shopId = shopId;
}
public int getGoodsId() { public int getGoodsId() {
return goodsId; return goodsId;
} }
......
...@@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap; ...@@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import java.io.FileReader; import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -29,13 +28,10 @@ public class ShopManager { ...@@ -29,13 +28,10 @@ public class ShopManager {
public synchronized void load() { public synchronized void load() {
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Shop.json")) { try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Shop.json")) {
getShopData().clear(); 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) { if(banners.size() > 0) {
for (ShopInfo shopInfo : banners) { for (ShopTable shopTable : banners) {
if (!getShopData().containsKey(shopInfo.getShopId())) getShopData().put(shopTable.getShopId(), shopTable.getItems());
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()));
} }
Grasscutter.getLogger().info("Shop data successfully loaded."); Grasscutter.getLogger().info("Shop data successfully loaded.");
} else { } 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