Skip to content

Commit

Permalink
Merge pull request #1309 from kwitczak/1289_fix
Browse files Browse the repository at this point in the history
1289: Fixed issue with item value being taken from another item
  • Loading branch information
snap01 authored Mar 16, 2023
2 parents f0daeb1 + 9530798 commit d88e38c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 2 additions & 6 deletions module/actors/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,8 @@ export class CoCActor extends Actor {
if (['character', 'npc', 'creature'].includes(this.type)) {
this.system.skills = {}
for (const i of this.items) {
if (i.type === 'skill') {
this.system.skills[`${i.system.skillName}`] = {
value: i.rawValue
}
this.system.skills[`${i.id}`] = { value: i.rawValue }
}
if (i.type !== 'skill') continue
this.system.skills[`${i.itemIdentifier}`] = { value: i.rawValue }
}

/**
Expand Down
12 changes: 10 additions & 2 deletions module/items/skill/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ export class CoC7Skill extends CoC7Item {
return []
}

/**
* Unique identifier should be used to store and obtain item to assess item uniqueness.
* For old items without id, fallback of skillName may still be used
* but if skill name is not unique it will cause problems.
*/
get itemIdentifier () {
return this.id || this.system.skillName
}

/**
* This is the value of the skill score unaffected by active effects
*/
Expand Down Expand Up @@ -116,8 +125,7 @@ export class CoC7Skill extends CoC7Item {
* This is the skill's value after active effects have been applied
*/
get value () {
const value = this.parent?.system.skills?.[`${this.system.skillName}`]
?.value
const value = this.parent?.system.skills?.[`${this.itemIdentifier}`]?.value
return value || this.rawValue
}

Expand Down

0 comments on commit d88e38c

Please sign in to comment.