char sheet now refreshes when settings change
This commit is contained in:
+77
-57
@@ -15,48 +15,57 @@ export const registerSettings = function () {
|
||||
let actorName = '';
|
||||
let maxStart = null;
|
||||
let maxEnd = null;
|
||||
//if setting is now true
|
||||
if (value) {
|
||||
//loop through all actors and update their maximum stress
|
||||
//get list of actors
|
||||
let actorList = game.actors;
|
||||
//loop through each actor
|
||||
actorList.forEach(function(actor){
|
||||
//loop through each result
|
||||
if (actor.type === 'character') {
|
||||
//set character name
|
||||
actorName = actor.name;
|
||||
//set current values
|
||||
maxStart = actor.system.other.stress.max;
|
||||
//set max stress to 20
|
||||
actor.system.other.stress.max = 20;
|
||||
//set final values
|
||||
maxEnd = actor.system.other.stress.max;
|
||||
//log change
|
||||
console.log(actorName + " stress.max changed from " + maxStart + " to " + maxEnd);
|
||||
}
|
||||
});
|
||||
//if value is now false
|
||||
} else {
|
||||
//loop through all actors and update their maximum stress
|
||||
//get list of actors
|
||||
let actorList = game.actors;
|
||||
//loop through each actor
|
||||
actorList.forEach(function(actor){
|
||||
//loop through each result
|
||||
if (actor.type === 'character') {
|
||||
//set character name
|
||||
actorName = actor.name;
|
||||
//set current values
|
||||
maxStart = actor.system.other.stress.max;
|
||||
//set max stress to 999
|
||||
actor.system.other.stress.max = 999;
|
||||
//set final values
|
||||
maxEnd = actor.system.other.stress.max;
|
||||
//log change
|
||||
console.log(actorName + " stress.max changed from " + maxStart + " to " + maxEnd);
|
||||
}
|
||||
});
|
||||
//only make changes if calm is false
|
||||
if (game.settings.get('mosh','useCalm') === false) {
|
||||
//if setting is now true
|
||||
if (value) {
|
||||
//loop through all actors and update their maximum stress
|
||||
//get list of actors
|
||||
let actorList = game.actors;
|
||||
//loop through each actor
|
||||
actorList.forEach(function(actor){
|
||||
//loop through each result
|
||||
if (actor.type === 'character') {
|
||||
//set character name
|
||||
actorName = actor.name;
|
||||
//set current values
|
||||
maxStart = actor.system.other.stress.max;
|
||||
//set max stress to 20
|
||||
actor.update({'system.other.stress.max': 20});
|
||||
//set final values
|
||||
actorList = game.actors;
|
||||
maxEnd = actor.system.other.stress.max;
|
||||
//log change
|
||||
console.log(actorName + " stress.max changed from " + maxStart + " to " + maxEnd);
|
||||
//rerender this sheet
|
||||
actor.render();
|
||||
}
|
||||
});
|
||||
//if value is now false
|
||||
} else {
|
||||
//loop through all actors and update their maximum stress
|
||||
//get list of actors
|
||||
let actorList = game.actors;
|
||||
//loop through each actor
|
||||
actorList.forEach(function(actor){
|
||||
//loop through each result
|
||||
if (actor.type === 'character') {
|
||||
//set character name
|
||||
actorName = actor.name;
|
||||
//set current values
|
||||
maxStart = actor.system.other.stress.max;
|
||||
//set max stress to 999
|
||||
actor.update({'system.other.stress.min': 999});
|
||||
//set final values
|
||||
actorList = game.actors;
|
||||
maxEnd = actor.system.other.stress.max;
|
||||
//log change
|
||||
console.log(actorName + " stress.max changed from " + maxStart + " to " + maxEnd);
|
||||
//rerender this sheet
|
||||
actor.render();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -169,15 +178,16 @@ export const registerSettings = function () {
|
||||
valueStart = actor.system.other.stress.value;
|
||||
maxStart = actor.system.other.stress.max;
|
||||
labelStart = actor.system.other.stress.label;
|
||||
//set min stress to 0
|
||||
actor.system.other.stress.min = 0;
|
||||
//convert min stress to max calm
|
||||
actor.system.other.stress.max = Math.round(85-(actor.system.other.stress.min*3));
|
||||
actor.update({'system.other.stress.max': Math.round(85-(actor.system.other.stress.min*3))});
|
||||
//set min stress to 0
|
||||
actor.update({'system.other.stress.min': 0});
|
||||
//convert stress to calm
|
||||
actor.system.other.stress.value = Math.round(85-(actor.system.other.stress.value*3));
|
||||
actor.update({'system.other.stress.value': Math.round(85-(actor.system.other.stress.value*3))});
|
||||
//set stress label to Calm
|
||||
actor.system.other.stress.label = 'Calm';
|
||||
actor.update({'system.other.stress.label': 'Calm'});
|
||||
//set final values
|
||||
actorList = game.actors;
|
||||
minEnd = actor.system.other.stress.min;
|
||||
valueEnd = actor.system.other.stress.value;
|
||||
maxEnd = actor.system.other.stress.max;
|
||||
@@ -187,6 +197,8 @@ export const registerSettings = function () {
|
||||
console.log(actorName + " stress.value changed from " + valueStart + " to " + valueEnd);
|
||||
console.log(actorName + " stress.max changed from " + maxStart + " to " + maxEnd);
|
||||
console.log(actorName + " stress.label changed from " + labelStart + " to " + labelEnd);
|
||||
//rerender this sheet
|
||||
actor.render();
|
||||
}
|
||||
});
|
||||
//if value is now false
|
||||
@@ -203,26 +215,32 @@ export const registerSettings = function () {
|
||||
maxStart = actor.system.other.stress.max;
|
||||
labelStart = actor.system.other.stress.label;
|
||||
//convert maximum calm to min stress
|
||||
actor.system.other.stress.min = Math.round((85-actor.system.other.stress.max)/3);
|
||||
//set min stress to 20 if > 20
|
||||
if (Math.round((85-actor.system.other.stress.max)/3) > 20) {
|
||||
actor.update({'system.other.stress.min': 20});
|
||||
//set min stress to 2 if < 2
|
||||
} else if (Math.round((85-actor.system.other.stress.max)/3) < 2) {
|
||||
actor.update({'system.other.stress.min': 2});
|
||||
//regular value
|
||||
} else {
|
||||
actor.update({'system.other.stress.min': Math.round((85-actor.system.other.stress.max)/3)});
|
||||
}
|
||||
//set max stress based on current system setting
|
||||
if (game.settings.get('mosh','firstEdition')) {
|
||||
//set max stress to 20
|
||||
actor.system.other.stress.max = 20;
|
||||
//set min stress to 20 if > 20
|
||||
if (actor.system.other.stress.min > 20) {actor.system.other.stress.min = 20;}
|
||||
//set min stress to 2 if < 2
|
||||
if (actor.system.other.stress.min < 2) {actor.system.other.stress.min = 2;}
|
||||
actor.update({'system.other.stress.max': 20});
|
||||
} else {
|
||||
//set max stress to 999
|
||||
actor.system.other.stress.max = 999;
|
||||
actor.update({'system.other.stress.max': 999});
|
||||
//set min stress to 2 if < 2
|
||||
if (actor.system.other.stress.min < 2) {actor.system.other.stress.min = 2;}
|
||||
if (actor.system.other.stress.min < 2) {actor.update({'system.other.stress.min': 2});}
|
||||
}
|
||||
//convert calm to stress
|
||||
actor.system.other.stress.value = Math.round((85-actor.system.other.stress.value)/3);
|
||||
actor.update({'system.other.stress.value': Math.round((85-actor.system.other.stress.value)/3)});
|
||||
//set stress label to Stress
|
||||
actor.system.other.stress.label = 'Stress';
|
||||
actor.update({'system.other.stress.label': 'Stress'});
|
||||
//set final values
|
||||
actorList = game.actors;
|
||||
minEnd = actor.system.other.stress.min;
|
||||
valueEnd = actor.system.other.stress.value;
|
||||
maxEnd = actor.system.other.stress.max;
|
||||
@@ -232,6 +250,8 @@ export const registerSettings = function () {
|
||||
console.log(actorName + " stress.value changed from " + valueStart + " to " + valueEnd);
|
||||
console.log(actorName + " stress.max changed from " + maxStart + " to " + maxEnd);
|
||||
console.log(actorName + " stress.label changed from " + labelStart + " to " + labelEnd);
|
||||
//rerender this sheet
|
||||
actor.render();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user