on('change:strength_magicbonus',function(){ UpdateStrength(); }
UpdateStrength = function(){
getAttrs(["Strength_MagicBonus","Strength_RolledBaseValue","Strength_RaceBonus"],function(values){
setAttrs({ Strength: parseInt(values.Strength_MagicBonus)+parseInt(values.Strength_RolledBaseValue)+parseInt(values.Strength_RaceBonus)});
});
}
on('change:strength'function() { UpdateCarryingCapacity(); }
on('change:carryingcapacity',function(){ CheckEncumberancePenalties(); } This is a simplified version of my question to illustrate my point. When sheet worker scripts update values that other values depend on, is it better to "chain" them (writing multiple update functions that will update when their dependent values change as seen above) or have an update function that calculates all that are dependent on the updated value, and all values dependent on those values, etc, and post one update with setAttrs (as seen below). on('change:strength_magicbonus',function(){ UpdateStrength(); }
UpdateStrength = function(){
getAttrs(["Strength_MagicBonus","Strength_RolledBaseValue","Strength_RaceBonus","Weapon1_BaseDamage","Weapon1_MagicBonus", "Weapon1..."],function(values){
var strength = parseInt(values.Strength_MagicBonus)+parseInt(values.Strength_RolledBaseValue)+parseInt(values.Strength_RaceBonus);
setAttrs({ Strength: strength, CarryingCapacity: CalculateCaryingCapacity(strength), Weapon1_Damage: CalculateWeaponDamage(values.Weapon1_BaseDamage, values.Weapon1_MagicBonus, values.Weapon1..., Strength)};
});
} My concern is that allowing things to "chain" (example 1) makes things easier to code, by having so many dependent asynchronous calls may create significant lag in users seeing the results of updating stats. Creating monolithic functions that update everything make each individual update take longer and would be a nightmare to code effectively (updating strength_magicbonus and armor1_armortype would have a lot of overlap). So to lay out the question: "Is there an easy coding architecture that is light on system resources that handles updates to an initial value and all subsequent updates to values dependent on the initial value? If so, what is it?"