diff --git a/packages-user/data-base/src/hero/equipStore.ts b/packages-user/data-base/src/hero/equipStore.ts index 9a53a61..5a6d394 100644 --- a/packages-user/data-base/src/hero/equipStore.ts +++ b/packages-user/data-base/src/hero/equipStore.ts @@ -297,11 +297,15 @@ export class HeroEquipsStore implements IHeroEquipsStore { this.instanceMap.delete(uid); } } - const maxUid = maxBy(state.equipments, 'uid'); - if (!maxUid) { - logger.error(58); - return; + if (state.equipments.length === 0) { + this.nextUid = 0; + } else { + const maxUid = maxBy(state.equipments, 'uid'); + if (!maxUid) { + logger.error(58); + return; + } + this.nextUid = maxUid.uid + 1; } - this.nextUid = maxUid.uid + 1; } }