Skip to content

Commit

Permalink
[#1910] [#1911] Address class-subclass and identifier discrepancies a…
Browse files Browse the repository at this point in the history
…nd Actor#getRollData item mutation.
  • Loading branch information
Fyorl committed Oct 31, 2022
1 parent c807a8b commit 6eb6c17
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion module/documents/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default class Actor5e extends Actor {

data.classes = {};
for ( const [identifier, cls] of Object.entries(this.classes) ) {
data.classes[identifier] = cls.system;
data.classes[identifier] = foundry.utils.deepClone(cls.system);
if ( cls.subclass ) data.classes[identifier].subclass = cls.subclass.system;
}
return data;
Expand Down
4 changes: 2 additions & 2 deletions module/documents/item.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default class Item5e extends Item {
get class() {
if ( !this.isEmbedded || (this.type !== "subclass") ) return null;
const cid = this.system.classIdentifier;
return this._classLink ??= this.parent.items.find(i => (i.type === "class") && (i.system.identifier === cid));
return this._classLink ??= this.parent.items.find(i => (i.type === "class") && (i.identifier === cid));
}

/* -------------------------------------------- */
Expand All @@ -159,7 +159,7 @@ export default class Item5e extends Item {
get subclass() {
if ( !this.isEmbedded || (this.type !== "class") ) return null;
const items = this.parent.items;
const cid = this.system.identifier;
const cid = this.identifier;
return this._classLink ??= items.find(i => (i.type === "subclass") && (i.system.classIdentifier === cid));
}

Expand Down
5 changes: 3 additions & 2 deletions templates/items/class.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@
<div class="form-group">
<label>{{ localize "DND5E.Identifier" }}</label>
<div class="form-fields">
<input type="text" name="system.identifier" value="{{system.identifier}}">
<input type="text" name="system.identifier" value="{{system.identifier}}"
placeholder="{{item.identifier}}">
</div>
<p class="hint">
{{{localize "DND5E.ClassIdentifierHint" identifier=system.identifier}}}
{{{localize "DND5E.ClassIdentifierHint" identifier=item.identifier}}}
</p>
</div>

Expand Down
2 changes: 1 addition & 1 deletion templates/items/subclass.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<div class="form-group">
<label>{{localize "DND5E.Identifier"}}</label>
<div class="form-fields">
<input type="text" name="system.identifier" value="{{system.identifier}}">
<input type="text" name="system.identifier" value="{{system.identifier}}" placeholder="{{item.identifier}}">
</div>
</div>

Expand Down

0 comments on commit 6eb6c17

Please sign in to comment.