diff --git a/src/api_s2c/shop/ApiBuy.ts b/src/api_s2c/shop/ApiBuy.ts index ea47e0f..6ce5924 100644 --- a/src/api_s2c/shop/ApiBuy.ts +++ b/src/api_s2c/shop/ApiBuy.ts @@ -11,7 +11,7 @@ export default async function (call: ApiCall) { let uid = shopId != "2" ? call.uid : call.conn.gud.ghId - let shopData = await ShopFun.getShopData(uid, shopId); + let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv); let shopItem = shopData.shopItems[index]; diff --git a/src/api_s2c/shop/ApiOpen.ts b/src/api_s2c/shop/ApiOpen.ts index 809bb94..e78a366 100644 --- a/src/api_s2c/shop/ApiOpen.ts +++ b/src/api_s2c/shop/ApiOpen.ts @@ -17,7 +17,7 @@ export default async function (call: ApiCall) { let uid = shopId != "2" ? call.uid : call.conn.gud.ghId - let shopData = await ShopFun.getShopData(uid, shopId) + let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv) call.succ(shopData); } diff --git a/src/api_s2c/shop/ApiRefresh.ts b/src/api_s2c/shop/ApiRefresh.ts index b77029c..e095dcd 100644 --- a/src/api_s2c/shop/ApiRefresh.ts +++ b/src/api_s2c/shop/ApiRefresh.ts @@ -1,7 +1,7 @@ -import { ApiCall } from "tsrpc"; -import { PlayerFun } from '../../public/player'; -import { ShopFun } from '../../public/shop'; -import { ReqRefresh, ResRefresh } from "../../shared/protocols/shop/PtlRefresh"; +import {ApiCall} from "tsrpc"; +import {PlayerFun} from '../../public/player'; +import {ShopFun} from '../../public/shop'; +import {ReqRefresh, ResRefresh} from "../../shared/protocols/shop/PtlRefresh"; export default async function (call: ApiCall) { let shopId = call.req.shopId; @@ -9,7 +9,7 @@ export default async function (call: ApiCall) { let uid = shopId != "2" ? call.uid : call.conn.gud.ghId - let shopData = await ShopFun.getShopData(uid, shopId); + let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv); if (!shopData) return call.error(globalThis.lng.shop_1); @@ -46,6 +46,6 @@ export default async function (call: ApiCall) { await ShopFun.changeShopData(uid, shopId, change); - let { buyNum, shopItems, ...ops } = change; + let {buyNum, shopItems, ...ops} = change; call.succ({buyNum: buyNum, shopItems: shopItems, ...ops}); } \ No newline at end of file diff --git a/src/jsonType.ts b/src/jsonType.ts index aacb4a8..c953d75 100644 --- a/src/jsonType.ts +++ b/src/jsonType.ts @@ -1213,6 +1213,7 @@ type gc_shop = k_v<{ 'npcImg': number /** 商店看板娘说话 */ 'npcText': string + 'version': string | number }>; type gc_shopcom = k_v<{ diff --git a/src/module/collection_shop.ts b/src/module/collection_shop.ts index cf12500..657838b 100644 --- a/src/module/collection_shop.ts +++ b/src/module/collection_shop.ts @@ -4,4 +4,5 @@ import {ResOpen} from '../shared/protocols/shop/PtlOpen'; export type CollectionShop = ResOpen & { uid: string; // 玩家uid shopId: string; // 商店id + version: string | number; }; \ No newline at end of file diff --git a/src/public/shop.ts b/src/public/shop.ts index 9145f0f..a8c8e9e 100644 --- a/src/public/shop.ts +++ b/src/public/shop.ts @@ -94,7 +94,7 @@ export class ShopFun { )).value } - static async getShopData(uid: string, shopId: string) { + static async getShopData(uid: string, shopId: string, lv: number) { let where = { uid: uid, shopId: shopId @@ -114,6 +114,10 @@ export class ShopFun { await this.changeShopData(uid, shopId, {useFreeRefreshNum: 0, lastFreeRefreshTime: G.time}); } + if (shopConf.version && shopConf.version != shopData.version) { + await this.changeShopData(uid, shopId, {shopItems: this.getShopItems(shopId, lv)}) + } + return shopData }