add logging to settings change

This commit is contained in:
Chris Schmalz
2023-09-26 23:59:38 -07:00
parent f1bc32973f
commit 12be73275e
+107 -46
View File
@@ -9,7 +9,12 @@ export const registerSettings = function () {
config: true,
onChange: value => {
//log the change
console.log("newArmorandCombat set to " + value)
console.log("firstEdition set to " + value)
//get list of actors
let actorList = game.actors;
let actorName = '';
let maxStart = null;
let maxEnd = null;
//if setting is now true
if (value) {
//loop through all actors and update their maximum stress
@@ -19,8 +24,16 @@ export const registerSettings = function () {
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
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
@@ -32,8 +45,16 @@ export const registerSettings = function () {
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
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);
}
});
}
@@ -124,57 +145,97 @@ export const registerSettings = function () {
onChange: value => {
//log the change
console.log("useCalm set to " + value);
//get list of actors
let actorList = game.actors;
let actorName = '';
let minStart = null;
let valueStart = null;
let maxStart = null;
let labelStart = '';
let minEnd = null;
let valueEnd = null;
let maxEnd = null;
let labelEnd = '';
//if setting is now true
if (value) {
//loop through all actors and update their stress values
//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 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));
//convert stress to calm
actor.system.other.stress.value = Math.round(85-(actor.system.other.stress.value*3));
//set stress label to Calm
actor.system.other.stress.label = 'Calm';
}
});
actorList.forEach(function(actor){
//loop through each result
if (actor.type === 'character') {
//set character name
actorName = actor.name;
//set current values
minStart = actor.system.other.stress.min;
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));
//convert stress to calm
actor.system.other.stress.value = Math.round(85-(actor.system.other.stress.value*3));
//set stress label to Calm
actor.system.other.stress.label = 'Calm';
//set final values
minEnd = actor.system.other.stress.min;
valueEnd = actor.system.other.stress.value;
maxEnd = actor.system.other.stress.max;
labelEnd = actor.system.other.stress.label;
//log change
console.log(actorName + " stress.min changed from " + minStart + " to " + minEnd);
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);
}
});
//if value is now false
} else {
//loop through all actors and update their stress values
//get list of actors
let actorList = game.actors;
//loop through each actor
actorList.forEach(function(actor){
//loop through each result
if (actor.type === 'character') {
//convert maximum calm to min stress
actor.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;}
} else {
//set max stress to 999
actor.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;}
}
//convert calm to stress
actor.system.other.stress.value = Math.round((85-actor.system.other.stress.value)/3);
//set stress label to Stress
actor.system.other.stress.label = 'Stress';
actorList.forEach(function(actor){
//loop through each result
if (actor.type === 'character') {
//set character name
actorName = actor.name;
//set current values
minStart = actor.system.other.stress.min;
valueStart = actor.system.other.stress.value;
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 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;}
} else {
//set max stress to 999
actor.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;}
}
});
//convert calm to stress
actor.system.other.stress.value = Math.round((85-actor.system.other.stress.value)/3);
//set stress label to Stress
actor.system.other.stress.label = 'Stress';
//set final values
minEnd = actor.system.other.stress.min;
valueEnd = actor.system.other.stress.value;
maxEnd = actor.system.other.stress.max;
labelEnd = actor.system.other.stress.label;
//log change
console.log(actorName + " stress.min changed from " + minStart + " to " + minEnd);
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);
}
});
}
}
});