Skip to content

Commit

Permalink
fix(item): migrating items should consider not resetting durability a…
Browse files Browse the repository at this point in the history
…nd other important values
  • Loading branch information
seiyria committed Mar 29, 2023
1 parent 2567c24 commit f56a643
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/services/item-creator.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Injectable } from '@angular/core';
import { isNumber } from 'lodash';
import { v4 as uuidv4 } from 'uuid';

import { IGameItem } from '../../interfaces';
Expand Down Expand Up @@ -47,15 +48,15 @@ export class ItemCreatorService {
}

// we only want to migrate stats if it's not food. otherwise we want the correct stats
if(!baseItem.foodDuration) {
if(!isNumber(baseItem.foodDuration)) {
baseItem.stats = oldItem.stats;
}

if(oldItem.durability) {
if(isNumber(oldItem.durability)) {
baseItem.durability = oldItem.durability;
}

if(oldItem.foodDuration) {
if(isNumber(oldItem.foodDuration)) {
baseItem.foodDuration = oldItem.foodDuration;
}

Expand Down

0 comments on commit f56a643

Please sign in to comment.