fix: 调整商店插件的部分实现

This commit is contained in:
AncTe committed 2026-10-20 21:10:45 +08:00
1 parent e6f4346924
commit e54ea3b13e
3 files changed
+46 -3

No files matched your search

+3 -3
View File
@@ -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)
};
}
+7
View File
@@ -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;