mirror of
https://github.com/motajs/template.git
synced 2026-10-24 16:40:17 +08:00
fix: 调整商店插件的部分实现
This commit is contained in:
parent
e6f4346924
commit
e54ea3b13e
@ -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:
|
||||
|
||||
|
||||
@ -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)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user