1289: Fixed issue with item value being taken from another item #1309
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The goal of this change was to fix a problem described in #1289 - skills in the Character sheet had different values when the sheet was in a
locked
vsunlocked
state. That was happening for specialised skills named "Any", for example, "Pilot (Any)" or "Art/Craft (Any)".Root cause
This problem is caused by the fact that we don't fully support skills with non-unique names.
Skills as items are stored in
this.system.skills
object, and there are two keys used to identify them:skillName
id
And they live next to each other in the same object,
this.system.skills
.In some cases,
skillName
is used to obtain a skill, in some cases it'sid
.As a result, if two skills with the same name exist, their
rawValue
will be displayed correctly, whilevalue
will be taken from thethis.system.skills
byskillName
, thus picking the last object that was saved with that non-unique key name, causing the problem.Types of Changes
I feel
id
is a new thing and I don't know if using only this property (which would be best) won't break old systems...So I added a method which, for a given item, should either store it using
id
or, ifid
does not exists, asskillName
.It's also used for obtaining the item the same way.
Tests Done
Screenshots