商店加入version,当版本不一致时刷新商店内容
This commit is contained in:
parent
c323a9e255
commit
88c39187a0
@ -11,7 +11,7 @@ export default async function (call: ApiCall<ReqBuy, ResBuy>) {
|
|||||||
|
|
||||||
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
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];
|
let shopItem = shopData.shopItems[index];
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
|
|
||||||
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
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);
|
call.succ(shopData);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { ApiCall } from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import { PlayerFun } from '../../public/player';
|
import {PlayerFun} from '../../public/player';
|
||||||
import { ShopFun } from '../../public/shop';
|
import {ShopFun} from '../../public/shop';
|
||||||
import { ReqRefresh, ResRefresh } from "../../shared/protocols/shop/PtlRefresh";
|
import {ReqRefresh, ResRefresh} from "../../shared/protocols/shop/PtlRefresh";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
||||||
let shopId = call.req.shopId;
|
let shopId = call.req.shopId;
|
||||||
@ -9,7 +9,7 @@ export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
|||||||
|
|
||||||
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
|
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);
|
if (!shopData) return call.error(globalThis.lng.shop_1);
|
||||||
|
|
||||||
@ -46,6 +46,6 @@ export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
|
|||||||
|
|
||||||
await ShopFun.changeShopData(uid, shopId, change);
|
await ShopFun.changeShopData(uid, shopId, change);
|
||||||
|
|
||||||
let { buyNum, shopItems, ...ops } = change;
|
let {buyNum, shopItems, ...ops} = change;
|
||||||
call.succ({buyNum: buyNum, shopItems: shopItems, ...ops});
|
call.succ({buyNum: buyNum, shopItems: shopItems, ...ops});
|
||||||
}
|
}
|
@ -1213,6 +1213,7 @@ type gc_shop = k_v<{
|
|||||||
'npcImg': number
|
'npcImg': number
|
||||||
/** 商店看板娘说话 */
|
/** 商店看板娘说话 */
|
||||||
'npcText': string
|
'npcText': string
|
||||||
|
'version': string | number
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
type gc_shopcom = k_v<{
|
type gc_shopcom = k_v<{
|
||||||
|
@ -4,4 +4,5 @@ import {ResOpen} from '../shared/protocols/shop/PtlOpen';
|
|||||||
export type CollectionShop = ResOpen & {
|
export type CollectionShop = ResOpen & {
|
||||||
uid: string; // 玩家uid
|
uid: string; // 玩家uid
|
||||||
shopId: string; // 商店id
|
shopId: string; // 商店id
|
||||||
|
version: string | number;
|
||||||
};
|
};
|
@ -94,7 +94,7 @@ export class ShopFun {
|
|||||||
)).value
|
)).value
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getShopData(uid: string, shopId: string) {
|
static async getShopData(uid: string, shopId: string, lv: number) {
|
||||||
let where = {
|
let where = {
|
||||||
uid: uid,
|
uid: uid,
|
||||||
shopId: shopId
|
shopId: shopId
|
||||||
@ -114,6 +114,10 @@ export class ShopFun {
|
|||||||
await this.changeShopData(uid, shopId, {useFreeRefreshNum: 0, lastFreeRefreshTime: G.time});
|
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
|
return shopData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user