Skip to content

Commit

Permalink
[#2495] Allow prepareData methods to be called on module actors
Browse files Browse the repository at this point in the history
  • Loading branch information
arbron committed Oct 25, 2023
1 parent 827dcd0 commit 58d565c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
15 changes: 2 additions & 13 deletions module/data/actor/group.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,8 @@ export default class GroupActor extends SystemDataModel.mixin(CurrencyTemplate)
/* Data Preparation */
/* -------------------------------------------- */

/**
* Prepare base data for group actors.
* @internal
*/
_prepareBaseData() {
/** @inheritdoc */
prepareBaseData() {
this.members.clear();
for ( const id of this._source.members ) {
const a = game.actors.get(id);
Expand All @@ -74,14 +71,6 @@ export default class GroupActor extends SystemDataModel.mixin(CurrencyTemplate)
}
}

/**
* Prepare derived data for group actors.
* @internal
*/
_prepareDerivedData() {
// No preparation needed at this time
}

/* -------------------------------------------- */
/* Methods */
/* -------------------------------------------- */
Expand Down
20 changes: 6 additions & 14 deletions module/documents/actor/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ export default class Actor5e extends Actor {

/** @inheritDoc */
prepareData() {
// Do not attempt to prepare non-system types.
if ( !game.template.Actor.types.includes(this.type) ) return;
if ( !game.template.Actor.types.includes(this.type) ) return super.prepareData();
this._classes = undefined;
this._preparationWarnings = [];
super.prepareData();
Expand All @@ -103,13 +102,9 @@ export default class Actor5e extends Actor {

/** @inheritDoc */
prepareBaseData() {

// Delegate preparation to type-subclass
if ( this.type === "group" ) { // Eventually other types will also support this
return this.system._prepareBaseData();
}

this._prepareBaseArmorClass();
if ( !game.template.Actor.types.includes(this.type) ) return;
if ( this.type !== "group" ) this._prepareBaseArmorClass();
else if ( game.release.generation < 11 ) this.system.prepareBaseData();

// Type-specific preparation
switch ( this.type ) {
Expand Down Expand Up @@ -137,11 +132,8 @@ export default class Actor5e extends Actor {

/** @inheritDoc */
prepareDerivedData() {

// Delegate preparation to type-subclass
if ( this.type === "group" ) { // Eventually other types will also support this
return this.system._prepareDerivedData();
}
if ( !game.template.Actor.types.includes(this.type) ) return;
if ( this.type === "group" ) return;

const flags = this.flags.dnd5e || {};
this.labels = {};
Expand Down

0 comments on commit 58d565c

Please sign in to comment.