mirror of
https://github.com/RoY7x/worldbuilding.git
synced 2025-07-14 10:22:00 -04:00
10: Add attribute groups base implementation
- Added support for attribute groups - Added rollable buttons to formula attributes - Added additional i18n translation strings
This commit is contained in:
parent
c515f8d5b7
commit
f69e3841ff
13 changed files with 827 additions and 151 deletions
|
@ -25,6 +25,7 @@ export class SimpleActor extends Actor {
|
|||
delete data.attributes;
|
||||
delete data.attr;
|
||||
delete data.abil;
|
||||
delete data.groups;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
@ -44,7 +45,18 @@ export class SimpleActor extends Actor {
|
|||
// Add shortened version of the attributes.
|
||||
if ( !!shorthand ) {
|
||||
if ( !(k in data) ) {
|
||||
data[k] = v.value;
|
||||
// Non-grouped attributes.
|
||||
if ( v.dtype ) {
|
||||
data[k] = v.value;
|
||||
}
|
||||
// Grouped attributes.
|
||||
else {
|
||||
data[k] = {};
|
||||
for ( let [attrKey, attrValue] of Object.entries(v) ) {
|
||||
data[k][attrKey] = attrValue.value;
|
||||
if ( attrValue.dtype == "Formula" ) formulaAttributes.push(`${k}.${attrKey}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -110,15 +122,43 @@ export class SimpleActor extends Actor {
|
|||
// Evaluate formula attributes after all other attributes have been handled,
|
||||
// including items.
|
||||
for ( let k of formulaAttributes ) {
|
||||
// Grouped attributes are included as `group.attr`, so we need to split
|
||||
// them into new keys.
|
||||
let attr = null;
|
||||
if ( k.includes('.') ) {
|
||||
let attrKey = k.split('.');
|
||||
k = attrKey[0];
|
||||
attr = attrKey[1];
|
||||
}
|
||||
// Non-grouped attributes.
|
||||
if ( data.attributes[k].value ) {
|
||||
data.attributes[k].value = this._replaceData(data.attributes[k].value, data, {missing: "0"});
|
||||
// TODO: Replace with:
|
||||
// data.attributes[k].value = Roll.replaceFormulaData(data.attributes[k].value, data, {missing: "0"});
|
||||
}
|
||||
// Grouped attributes.
|
||||
else {
|
||||
if ( attr ) {
|
||||
data.attributes[k][attr].value = this._replaceData(data.attributes[k][attr].value, data, {missing: "0"});
|
||||
}
|
||||
}
|
||||
|
||||
// Duplicate values to shorthand.
|
||||
if ( !!shorthand ) {
|
||||
data[k] = data.attributes[k].value;
|
||||
// Non-grouped attributes.
|
||||
if ( data.attributes[k].value ) {
|
||||
data[k] = data.attributes[k].value;
|
||||
}
|
||||
// Grouped attributes.
|
||||
else {
|
||||
if ( attr ) {
|
||||
// Initialize a group key in case it doesn't exist.
|
||||
if ( !data[k] ) {
|
||||
data[k] = {};
|
||||
}
|
||||
data[k][attr] = data.attributes[k][attr].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue