mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-07-05 14:10:42 -04:00
V10 compatibility with 0.7.0-alpha1 release
This commit is contained in:
parent
107aec3244
commit
e23893b6ca
12 changed files with 125 additions and 126 deletions
|
@ -3,12 +3,13 @@
|
|||
* @extends {TokenDocument}
|
||||
*/
|
||||
export class SimpleTokenDocument extends TokenDocument {
|
||||
|
||||
/** @inheritdoc */
|
||||
getBarAttribute(barName, {alternative}={}) {
|
||||
const data = super.getBarAttribute(barName, {alternative});
|
||||
const attr = alternative || this.data[barName]?.attribute;
|
||||
const attr = alternative || this[barName]?.attribute;
|
||||
if ( !data || !attr || !this.actor ) return data;
|
||||
const current = foundry.utils.getProperty(this.actor.data.data, attr);
|
||||
const current = foundry.utils.getProperty(this.actor.system, attr);
|
||||
if ( current?.dtype === "Resource" ) data.min = parseInt(current.min || 0);
|
||||
data.editable = true;
|
||||
return data;
|
||||
|
@ -23,7 +24,7 @@ export class SimpleTokenDocument extends TokenDocument {
|
|||
foundry.utils.mergeObject(data, model);
|
||||
}
|
||||
for ( const actor of game.actors ) {
|
||||
if ( actor.isTemplate ) foundry.utils.mergeObject(data, actor.toObject().data);
|
||||
if ( actor.isTemplate ) foundry.utils.mergeObject(data, actor.toObject());
|
||||
}
|
||||
return super.getTrackedAttributes(data);
|
||||
}
|
||||
|
@ -42,8 +43,7 @@ export class SimpleToken extends Token {
|
|||
if ( "min" in data ) {
|
||||
// Copy the data to avoid mutating what the caller gave us.
|
||||
data = {...data};
|
||||
// Shift the value and max by the min to ensure that the bar's percentage is drawn accurately if this resource has
|
||||
// a non-zero min.
|
||||
// Shift the value and max by the min to draw the bar percentage accurately for a non-zero min
|
||||
data.value -= data.min;
|
||||
data.max -= data.min;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue