From e54ea3b13eab9c6ca558cc3bc50496ec1eeebc16 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Tue, 20 Oct 2026 21:10:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E5=95=86=E5=BA=97?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=9A=84=E9=83=A8=E5=88=86=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pnpm-lock.yaml | 36 ++++++++++++++++++++++++++++++++++ src/data/plugin/shop/state.ts | 6 +++--- src/data/plugin/shop/system.ts | 7 +++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index db9d869..bf52c8f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -668,12 +668,48 @@ importers: src: dependencies: + '@motajs/animate': + specifier: workspace:* + version: link:../packages/animate + '@motajs/anon-tokyo': + specifier: workspace:* + version: link:../packages/anon-tokyo + '@motajs/audio': + specifier: workspace:* + version: link:../packages/audio + '@motajs/common': + specifier: workspace:* + version: link:../packages/common + '@motajs/loader': + specifier: workspace:* + version: link:../packages/loader + '@motajs/render': + specifier: workspace:* + version: link:../packages/render + '@motajs/render-vue': + specifier: workspace:* + version: link:../packages/render-vue + '@motajs/system': + specifier: workspace:* + version: link:../packages/system + '@user/client-base': + specifier: workspace:* + version: link:../packages-user/client-base + '@user/client-modules': + specifier: workspace:* + version: link:../packages-user/client-modules + '@user/data-base': + specifier: workspace:* + version: link:../packages-user/data-base '@user/data-common': specifier: workspace:* version: link:../packages-user/data-common '@user/data-state': specifier: workspace:* version: link:../packages-user/data-state + '@user/data-system': + specifier: workspace:* + version: link:../packages-user/data-system packages: diff --git a/src/data/plugin/shop/state.ts b/src/data/plugin/shop/state.ts index 161d72e..013ca3c 100644 --- a/src/data/plugin/shop/state.ts +++ b/src/data/plugin/shop/state.ts @@ -77,9 +77,9 @@ export class ShopState implements IShopState { return { id: this.id, enabled: this.enabled, - items: this.items, - buyPrice: this.buyPrice, - sellPrice: this.sellPrice + items: new Map(this.items), + buyPrice: new Map(this.buyPrice), + sellPrice: new Map(this.sellPrice) }; } diff --git a/src/data/plugin/shop/system.ts b/src/data/plugin/shop/system.ts index 95ecc7d..b8a52b2 100644 --- a/src/data/plugin/shop/system.ts +++ b/src/data/plugin/shop/system.ts @@ -45,6 +45,9 @@ export class ShopSystem implements IShopSystem { @shouldReplay('Buying items should be replayed.') buyItem(item: number | string, count: number): ShopTradeResult { + if (count < 0) return this.sellItem(item, -count); + if (count === 0) return ShopTradeResult.Success; + if (!Number.isInteger(count)) return ShopTradeResult.Invalid; if (!this.current || !this.hero) { logger.warn(199); return ShopTradeResult.Invalid; @@ -76,7 +79,11 @@ export class ShopSystem implements IShopSystem { return ShopTradeResult.Success; } + @shouldReplay('Selling items should be replayed.') sellItem(item: number | string, count: number): ShopTradeResult { + if (count < 0) return this.buyItem(item, -count); + if (count === 0) return ShopTradeResult.Success; + if (!Number.isInteger(count)) return ShopTradeResult.Invalid; if (!this.current || !this.hero) { logger.warn(199); return ShopTradeResult.Invalid;