From 88c39187a0e2af0eca1128f60e53be20f333aae3 Mon Sep 17 00:00:00 2001 From: dy Date: Mon, 25 Dec 2023 13:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=BA=97=E5=8A=A0=E5=85=A5version?= =?UTF-8?q?=EF=BC=8C=E5=BD=93=E7=89=88=E6=9C=AC=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E6=97=B6=E5=88=B7=E6=96=B0=E5=95=86=E5=BA=97=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/shop/ApiBuy.ts | 2 +- src/api_s2c/shop/ApiOpen.ts | 2 +- src/api_s2c/shop/ApiRefresh.ts | 12 ++++++------ src/jsonType.ts | 1 + src/module/collection_shop.ts | 1 + src/public/shop.ts | 6 +++++- 6 files changed, 15 insertions(+), 9 deletions(-) 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 }