diff --git a/GURPS/README.md b/GURPS/README.md index 9e690c6aa7..6a06e8ad70 100644 --- a/GURPS/README.md +++ b/GURPS/README.md @@ -4,6 +4,8 @@ Styling is inspired primarily by GCS, but also with some influence from the offi TODO + - Allow for free native language + - Add option for Language talent to reduce cost. - Add a damage calculator that: - Takes inputs for Damage Amount, Damage Type, and Location - Reduce amount by DR for location diff --git a/GURPS/gurps.css b/GURPS/gurps.css index 2d503ac7c7..e3ce9cdf36 100644 --- a/GURPS/gurps.css +++ b/GURPS/gurps.css @@ -226,13 +226,6 @@ input.sheet-tab:checked::before { -moz-box-shadow: inset 0px 0px 1px 0px rgba(98, 98, 94, 0.75); box-shadow: inset 0px 0px 1px 0px rgba(98, 98, 94, 0.75); } - { - border-radius: 2px; - - -webkit-box-shadow: inset 0px 0px 1px 0px rgba(98, 98, 94, 0.75); - -moz-box-shadow: inset 0px 0px 1px 0px rgba(98, 98, 94, 0.75); - box-shadow: inset 0px 0px 1px 0px rgba(98, 98, 94, 0.75); -} .sheet-row .sheet-textarea { text-align: center; @@ -465,17 +458,19 @@ input.sheet-module-roll:checked ~ .sheet-wrapper .sheet-module-off-roll, .sheet-attribute .sheet-row-willpower .sheet-col1 input { font-size: 16px; } .sheet-attribute .sheet-row-willpower .sheet-tooltip { font-size: 11px; } -.sheet-stats { width: 150; } +.sheet-stats { width: 180px; } .sheet-stats input { font-size: 13px;} -.sheet-stats .sheet-header .sheet-col0 { width: 70px; } -.sheet-stats .sheet-header .sheet-col1 { width: 35px; } -.sheet-stats .sheet-header .sheet-col2 { width: 45px; } +.sheet-stats .sheet-header .sheet-col0 { width: 72px; } +.sheet-stats .sheet-header .sheet-col1 { width: 41px; } +.sheet-stats .sheet-header .sheet-col2 { width: 30px; } +.sheet-stats .sheet-header .sheet-col3 { width: 37px; } .sheet-stats .sheet-row { font-size: 13px; height: 31px; } -.sheet-stats .sheet-row .sheet-col0 { width: 80px; } +.sheet-stats .sheet-row .sheet-col0 { width: 75px; } .sheet-stats .sheet-row .sheet-col0 input { text-align:left; } .sheet-stats .sheet-row .sheet-col1 { width: 35px; } .sheet-stats .sheet-row .sheet-col2 { width: 35px; } -.sheet-stats .sheet-row-current-points .sheet-col0 { width: 80px; } +.sheet-stats .sheet-row .sheet-col3 { width: 35px; } +.sheet-stats .sheet-row-current-points .sheet-col0 { width: 75px; } .sheet-stats .sheet-row-current-points .sheet-col1 { width: 35px; } .sheet-stats .sheet-tooltip table { text-align: left; font-size: 9px; } .sheet-stats .sheet-tooltip table .sheet-label { text-align: left; font-size: 9px; } @@ -484,8 +479,7 @@ input.sheet-module-roll:checked ~ .sheet-wrapper .sheet-module-off-roll, padding: 0.2em; } - -.sheet-miscelleneous { width: calc(100% - 180px - 150px - 100px - 1.6em); } +.sheet-miscelleneous { width: calc(100% - 180px - 180px - 100px - 1.6em); } .sheet-miscelleneous .sheet-header .sheet-col0 { width: calc(100% - 30px); text-align: center; @@ -505,7 +499,7 @@ input.sheet-module-roll:checked ~ .sheet-wrapper .sheet-module-off-roll, .sheet-points .sheet-row .sheet-col0 { width: 60px; } .sheet-points .sheet-row .sheet-col1 { width: 40px; } -.sheet-lift { width: calc(100% - 180px - 150px - 1.2em); } +.sheet-lift { width: calc(100% - 180px - 180px - 1.2em); } .sheet-lift .sheet-col0 { width: 180px; } .sheet-lift .sheet-col1 { width: calc(100% - 180px); text-align: center; } @@ -522,6 +516,11 @@ input.sheet-module-roll:checked ~ .sheet-wrapper .sheet-module-off-roll, .sheet-encumberance .sheet-row-load .sheet-cell { margin-top: 11px; } .sheet-encumberance .sheet-row-load input { font-size: 18px; font-weight: bold; } +.sheet-options .sheet-box { + margin: 10px; + padding: 2px; +} + /* -- TRAITS -- */ .sheet-language { width: calc(60% - 0.4em); } .sheet-language .sheet-col0 { width: calc(100% - 210px); } diff --git a/GURPS/gurps.html b/GURPS/gurps.html index 30f856a12f..4c4acd1a75 100644 --- a/GURPS/gurps.html +++ b/GURPS/gurps.html @@ -557,8 +557,9 @@
Stats
-
Value
-
Pts
+
Value
+
Mod
+
Pts
@@ -575,6 +576,9 @@
+ +
+
@@ -666,6 +670,9 @@
+ +
+
@@ -738,7 +745,8 @@
-
+
+
@@ -762,7 +770,8 @@
-
+
+
@@ -781,7 +790,8 @@
-
+
+
@@ -2239,58 +2249,70 @@ -
+
+ +
+
+ + No Modifier Prompt + + Rolls will be made immediately with no prompt. + +
+ Single Modifier Prompt + + Ask for a bonus or penalty to be added to dice rolls. +
+ This will not affect damage rolls. +
+
+ + Extended Modifier Prompts + + Instead of a single modifier, rolls will ask for a series of modifiers,
+ to remind you about potential bonuses/penalties. +
+ This will not affect damage rolls. +
+
+
+ + Public Rolls + + All players will be able to see
+ your skill level, roll and results. +
+
+ + Private Skill Levels + + Only the GM will be able to see
+ your skill level, but all players
+ will see the result. +
+ This will not affect damage rolls. +
+
+ + Private Rolls + + Only the GM will see your skill
+ level and the result. +
+ This will not affect damage rolls. +
+

- - No Modifier Prompt - - Rolls will be made immediately with no prompt. - -
- Single Modifier Prompt - - Ask for a bonus or penalty to be added to dice rolls. +
+ + Mods to attributes increase all derived stats (including HP, FP)
- This will not affect damage rolls. - -
- - Extended Modifier Prompts - - Instead of a single modifier, rolls will ask for a series of modifiers,
- to remind you about potential bonuses/penalties. + + Mods to attributes increase most derived stats (not HP, FP)
- This will not affect damage rolls. -
- -
-
- - - Public Rolls - - All players will be able to see
- your skill level, roll and results. -
-
- - Private Skill Levels - - Only the GM will be able to see
- your skill level, but all players
- will see the result. -
- This will not affect damage rolls. -
-
- - Private Rolls - - Only the GM will see your skill
- level and the result. -
- This will not affect damage rolls. -
+ + Mods to attributes do not increase derived stats +

@@ -2299,7 +2321,10 @@ var noop = function () {}; // do nothing. - var version = '1.3.1'; + var version = '1.3.2'; + + var modCascade = true; + var modCascadeAll = true; /* Due to the change from auto-calc fields to helper scrips, * I'm running a "on open" to set various fields. At some point @@ -2307,63 +2332,92 @@ */ on('sheet:opened', function() { console.log('********* Sheet Opened *********'); - getAttrs(["sheet_version"], function(v) { + getAttrs(['sheet_version', 'mod_cascade'], function(v) { if (!v.sheet_version || v.sheet_version != version) { // Set sheet version: setAttrs({ sheet_version: version }); // initalize any empty fields in repeating sections since the default values were removed. - loadRepeating("repeating_languages", "spoken", 0); - loadRepeating("repeating_languages", "written", 0); - loadRepeating("repeating_skills", "points", 1); - loadRepeating("repeating_cultures", "points", 1); - loadRepeating("repeating_techniques", "points", 1); - loadRepeating("repeating_spells", "points", 1); - sumRepeating("repeating_item", "weighttotal", function (v) { - setAttrs({ total_weight: (v * 100) / 100 }, {silent: false}, thenEncumbrance); - }); + loadRepeating('repeating_languages', 'spoken', 0); + loadRepeating('repeating_languages', 'written', 0); + loadRepeating('repeating_skills', 'points', 1); + loadRepeating('repeating_cultures', 'points', 1); + loadRepeating('repeating_techniques', 'points', 1); + loadRepeating('repeating_spells', 'points', 1); - // After DX and HT - var thenSpeedMoveDodge = _.after(2, function () { - updateBasicSpeed(function () { - // After Basic Speed... - updateBasicMove(thenCurrentMoveDodge); - updateDodge(thenCurrentMoveDodge); - }); - }); - - var thenEncumbrance = _.after(2, function () { - updateEncLevel(thenCurrentMoveDodge); - }); - - var thenCurrentMoveDodge = _.after(4, function () { - updateMoveDodge(); - }); - - // Update attributes, then secondary characteristics, and so on... - updateST(function () { - // After ST... - updateHP(thenCurrentMoveDodge); - updateLift(thenEncumbrance); - updateStrikingST(); - }); - updateDX(thenSpeedMoveDodge); - updateIQ(function () { - // After IQ... - updateWill(); - updatePer(function () { - // After Per... - updateSense(); - }); - }); - updateHT(function () { - updateFP(); - thenSpeedMoveDodge(); - }); + // initalize all calculated stats + resetAll(v.mod_cascade); } }); }); - + + on('change:mod_cascade', function (e) { + getAttrs(['mod_cascade'], function (v) { + resetAll(v.mod_cascade); + }) + }); + + function resetAll(mod_cascade) { + switch(mod_cascade) { + case 'all': + modCascade = true; + modCascadeAll = true; + break; + case 'some': + modCascade = true; + modCascadeAll = false; + break; + default: + modCascade = false; + modCascadeAll = false; + } + + // After move, dodge, encumbrance, HP, and FP + var thenCurrentMoveDodge = _.after(5, function () { + updateMoveDodge(); + }); + + // After DX and HT + var thenSpeedMoveDodge = _.after(2, function () { + updateBasicSpeed(function () { + // After Basic Speed... + updateBasicMove(thenCurrentMoveDodge); + updateDodge(thenCurrentMoveDodge); + }); + }); + + // After Lift and weight... + var thenEncumbrance = _.after(2, function () { + updateEncLevel(thenCurrentMoveDodge); + }); + + sumRepeating('repeating_item', 'weighttotal', function (v) { + setAttrs({ total_weight: (v * 100) / 100 }, {silent: false}, thenEncumbrance); + }); + + // Update attributes, then secondary characteristics, and so on... + updateST(function () { + // After ST... + updateHP(thenCurrentMoveDodge); + updateLift(thenEncumbrance); + updateStrikingST(); + }); + updateDX(thenSpeedMoveDodge); + updateIQ(function () { + // After IQ... + updateWill(); + updatePer(function () { + // After Per... + updateSense(); + }); + }); + updateHT(function () { + updateFP(thenCurrentMoveDodge); + thenSpeedMoveDodge(); + }); + + } + // Sum values, used in reduce function getSum(total, num) { return (+total || 0) + (+num || 0); @@ -2411,93 +2465,95 @@ } // Strength Change - on("change:strength_points change:strength_mod", function (e) { + on('change:strength_points change:strength_mod', function (e) { updateST(); }); // Update Strength function updateST(callback) { callback = callback || noop; console.log('********* updateST *********'); - getAttrs(["strength_points", "strength_mod"], function(v) { - var base = 10 + ((v.strength_points || 0) / 10 | 0); - var mod = v.strength_mod || 0; + getAttrs(['strength_points', 'strength_mod'], function(v) { + var base = 10 + ((+v.strength_points || 0) / 10 | 0); + var mod = +v.strength_mod || 0; setAttrs({ - strength_base: +base, - strength: +base + +mod + strength_base: base, + strength: base + mod }, {silent: false}, callback); }); } // Dexterity Change - on("change:dexterity_points change:dexterity_mod", function (e) { + on('change:dexterity_points change:dexterity_mod', function (e) { updateDX(); }); // Update Dexterity function updateDX(callback) { callback = callback || noop; console.log('********* updateDX *********'); - getAttrs(["dexterity_points", "dexterity_mod"], function(v) { - var base = 10 + ((v.dexterity_points || 0) / 20 | 0); - var mod = v.dexterity_mod || 0; + getAttrs(['dexterity_points', 'dexterity_mod'], function(v) { + var base = 10 + ((+v.dexterity_points || 0) / 20 | 0); + var mod = +v.dexterity_mod || 0; setAttrs({ - dexterity_base: +base, - dexterity: +base + +mod + dexterity_base: base, + dexterity: base + mod }, {silent: false}, callback); }); } // Intelligence - on("change:intelligence_points change:intelligence_mod", function (e) { + on('change:intelligence_points change:intelligence_mod', function (e) { updateIQ(); }); // Update Intelligence function updateIQ(callback) { callback = callback || noop; console.log('********* updateIQ *********'); - getAttrs(["intelligence_points", "intelligence_mod"], function(v) { - var base = 10 + ((v.intelligence_points || 0) / 20 | 0); - var mod = v.intelligence_mod || 0; + getAttrs(['intelligence_points', 'intelligence_mod'], function(v) { + var base = 10 + ((+v.intelligence_points || 0) / 20 | 0); + var mod = +v.intelligence_mod || 0; setAttrs({ - intelligence_base: +base, - intelligence: +base + +mod + intelligence_base: base, + intelligence: base + mod }, {silent: false}, callback); }); } // Health - on("change:health_points change:health_mod", function (e) { + on('change:health_points change:health_mod', function (e) { updateHT(); }); // Update Health function updateHT(callback) { callback = callback || noop; console.log('********* updateHT *********'); - getAttrs(["health_points", "health_mod"], function(v) { - var base = 10 + ((v.health_points || 0) / 10 | 0); - var mod = v.health_mod || 0; + getAttrs(['health_points', 'health_mod'], function(v) { + var base = 10 + ((+v.health_points || 0) / 10 | 0); + var mod = +v.health_mod || 0; setAttrs({ - health_base: +base, - health: +base + +mod + health_base: base, + health: base + mod }, {silent: false}, callback); }); } // HP - on("change:strength_base change:hit_points_points", function (e) { + on('change:strength change:hit_points_points change:hit_points_mod', function (e) { updateHP(); }); // Update HP function updateHP(callback) { console.log('********* updateHP *********'); callback = callback || noop; - getAttrs(["strength_base", "hit_points_points"], function(v) { - var base = v.strength_base + ((v.hit_points_points || 0) / 2 | 0); + getAttrs(['strength', 'strength_base', 'hit_points_points', 'hit_points_mod'], function(v) { + var base = (modCascadeAll ? +v.strength : +v.strength_base) + + ((+v.hit_points_points || 0) / 2 | 0); + var mod = +v.hit_points_mod; setAttrs({ - hit_points_max: +base + hit_points_max: base + mod }, {silent: false}, function () { - getAttrs(["hit_points"], function(v2) { + getAttrs(['hit_points'], function(v2) { if (v2.hit_points == null) { - setAttrs({ hit_points: +base }, {silent: false}, callback); + setAttrs({ hit_points: base }, {silent: false}, callback); } else { callback(); } @@ -2507,20 +2563,25 @@ } // FP - on("change:health_base change:fatigue_points_points", function (e) { + on('change:health change:fatigue_points_points change:fatigue_points_mod', function (e) { updateFP(); }); // Update FP - function updateFP() { + function updateFP(callback) { console.log('********* updateFP *********'); - getAttrs(["health_base", "fatigue_points_points"], function(v) { - var base = v.health_base + ((v.fatigue_points_points || 0) / 3 | 0); + callback = callback || noop; + getAttrs(['health', 'health_base', 'fatigue_points_points', 'fatigue_points_mod'], function(v) { + var base = (modCascadeAll ? +v.health : +v.health_base) + + ((+v.fatigue_points_points || 0) / 3 | 0); + var mod = +v.fatigue_points_mod; setAttrs({ - fatigue_points_max: +base + fatigue_points_max: base + mod }, {silent: false}, function () { - getAttrs(["fatigue_points"], function(v2) { + getAttrs(['fatigue_points'], function(v2) { if (v2.fatigue_points == null) { - setAttrs({ fatigue_points: +base }); + setAttrs({ fatigue_points: base }, {silent: false}, callback); + } else { + callback(); } }); }); @@ -2528,155 +2589,163 @@ } // Perception - on("change:intelligence_base change:perception_points change:perception_mod", function (e) { + on('change:intelligence change:perception_points change:perception_mod', function (e) { updatePer(); }); // Update Perception function updatePer(callback) { console.log('********* updatePer *********'); callback = callback || noop; - getAttrs(["intelligence_base", "perception_points", "perception_mod"], function(v) { - var base = v.intelligence_base + ((v.perception_points || 0) / 5 | 0); - var mod = v.perception_mod || 0; + getAttrs(['intelligence', 'intelligence_base', 'perception_points', 'perception_mod'], function(v) { + var base = (modCascade ? +v.intelligence : +v.intelligence_base) + + ((+v.perception_points || 0) / 5 | 0); + var mod = +v.perception_mod || 0; setAttrs({ - perception_base: +base, - perception: +base + +mod + perception_base: base, + perception: base + mod }, {silent: false}, callback); }); } // Vision, Hearing, Smell, Touch - on("change:perception_base change:vision_points change:vision_mod change:hearing_points change:hearing_mod change:taste_smell_points change:taste_smell_mod change:touch_points change:touch_mod", function (e) { + on('change:perception change:vision_points change:vision_mod change:hearing_points change:hearing_mod change:taste_smell_points change:taste_smell_mod change:touch_points change:touch_mod', function (e) { updateSense(); }); // Update Vision, Hearing, Smell, Touch function updateSense() { console.log('********* updateSense *********'); - getAttrs(["perception_base", "vision_points", "vision_mod", "hearing_points", "hearing_mod", "taste_smell_points", "taste_smell_mod", "touch_points", "touch_mod"], function(v) { - var visionBase = v.perception_base + ((v.vision_points || 0) / 2 | 0); - var visionMod = v.vision_mod || 0; - var hearingBase = v.perception_base + ((v.hearing_points || 0) / 2 | 0); - var hearingMod = v.hearing_mod || 0; - var tasteSmellBase = v.perception_base + ((v.taste_smell_points || 0) / 2 | 0); - var tasteSmellMod = v.taste_smell_mod || 0; - var touchBase = v.perception_base + ((v.touch_points || 0) / 2 | 0); - var touchMod = v.touch_mod || 0; + getAttrs(['perception', 'perception_base', 'vision_points', 'vision_mod', 'hearing_points', 'hearing_mod', 'taste_smell_points', 'taste_smell_mod', 'touch_points', 'touch_mod'], function(v) { + var base = (modCascade ? +v.perception : +v.perception_base); + var visionBase = base + ((+v.vision_points || 0) / 2 | 0); + var visionMod = +v.vision_mod || 0; + var hearingBase = base + ((+v.hearing_points || 0) / 2 | 0); + var hearingMod = +v.hearing_mod || 0; + var tasteSmellBase = base + ((+v.taste_smell_points || 0) / 2 | 0); + var tasteSmellMod = +v.taste_smell_mod || 0; + var touchBase = base + ((+v.touch_points || 0) / 2 | 0); + var touchMod = +v.touch_mod || 0; setAttrs({ - vision_base: +visionBase, - vision: +visionBase + +visionMod, - hearing_base: +hearingBase, - hearing: +hearingBase + +hearingMod, - taste_smell_base: +tasteSmellBase, - taste_smell: +tasteSmellBase + +tasteSmellMod, - touch_base: +touchBase, - touch: +touchBase + +touchMod + vision_base: visionBase, + vision: visionBase + visionMod, + hearing_base: hearingBase, + hearing: hearingBase + hearingMod, + taste_smell_base: tasteSmellBase, + taste_smell: tasteSmellBase + tasteSmellMod, + touch_base: touchBase, + touch: touchBase + touchMod }); }); } // Updage Willpower, Fear - on("change:intelligence_base change:willpower_points change:willpower_mod change:fear_check_points change:fear_check_mod", function (e) { + on('change:intelligence change:willpower_points change:willpower_mod change:fear_check_points change:fear_check_mod', function (e) { updateWill(); }); // Updage Willpower, Fear function updateWill() { console.log('********* updateWill *********'); - getAttrs(["intelligence_base", "willpower_points", "willpower_mod", "fear_check_points", "fear_check_mod"], function(v) { - var wBase = v.intelligence_base + ((v.willpower_points || 0) / 5 | 0); - var wMod = v.willpower_mod || 0; - var fBase = wBase + ((v.fear_check_points || 0) / 2 | 0); - var fMod = v.fear_check_mod || 0; + getAttrs(['intelligence', 'intelligence_base', 'willpower_points', 'willpower_mod', 'fear_check_points', 'fear_check_mod'], function(v) { + var wBase = (modCascade ? +v.intelligence : +v.intelligence_base) + + ((+v.willpower_points || 0) / 5 | 0); + var wMod = +v.willpower_mod || 0; + var fBase = wBase + (modCascade ? +wMod : 0) + + ((+v.fear_check_points || 0) / 2 | 0); + var fMod = +v.fear_check_mod || 0; setAttrs({ - willpower_base: +wBase, - willpower: +wBase + +wMod, - fear_check_base: +fBase, - fear_check: +fBase + +fMod + willpower_base: wBase, + willpower: wBase + wMod, + fear_check_base: fBase, + fear_check: fBase + fMod }); }); } // Speed - on("change:dexterity_base change:health_base change:basic_speed_points change:basic_speed_mod", function (e) { + on('change:dexterity change:health change:basic_speed_points change:basic_speed_mod', function (e) { updateBasicSpeed(); }); // Update Speed function updateBasicSpeed(callback) { console.log('********* updateBasicSpeed *********'); callback = callback || noop; - getAttrs(["dexterity_base", "health_base", "basic_speed_points", "basic_speed_mod"], function(v) { - var base = (v.dexterity_base + v.health_base) / 4 + (((v.basic_speed_points || 0) / 5 | 0) * 0.25); - var mod = v.basic_speed_mod || 0; + getAttrs(['dexterity', 'dexterity_base', 'health', 'health_base', 'basic_speed_points', 'basic_speed_mod'], function(v) { + var dx = (modCascade ? +v.dexterity : +v.dexterity_base); + var ht = (modCascade ? +v.health : +v.health_base); + var base = (dx + ht) / 4 + (((+v.basic_speed_points || 0) / 5 | 0) * 0.25); + var mod = +v.basic_speed_mod || 0; setAttrs({ - basic_speed_base: +base, - basic_speed: +base + +mod + basic_speed_base: base, + basic_speed: base + mod }, {silent: false}, callback); }); } // Move - on("change:basic_speed_base change:basic_move_points change:basic_move_mod", function (e) { + on('change:basic_speed change:basic_move_points change:basic_move_mod', function (e) { updateBasicMove(); }); // Update Move function updateBasicMove(callback) { console.log('********* updateBasicMove *********'); callback = callback || noop; - getAttrs(["basic_speed_base", "basic_move_points", "basic_move_mod"], function(v) { - var base = Math.floor(v.basic_speed_base) + ((v.basic_move_points || 0) / 5 | 0); - var mod = v.basic_move_mod || 0; + getAttrs(['basic_speed', 'basic_speed_base', 'basic_move_points', 'basic_move_mod'], function(v) { + var speed = (modCascade ? +v.basic_speed : +v.basic_speed_base); + var base = Math.floor(speed) + ((+v.basic_move_points || 0) / 5 | 0); + var mod = +v.basic_move_mod || 0; setAttrs({ - basic_move_base: +base, - basic_move: +base + +mod + basic_move_base: base, + basic_move: base + mod }, {silent: false}, callback); }); } // Dodge - on("change:basic_speed change:dodge_mod", function (e) { + on('change:basic_speed change:dodge_mod', function (e) { updateDodge(); }); // Update Dodge function updateDodge(callback) { console.log('********* updateDodge *********'); callback = callback || noop; - getAttrs(["basic_speed", "dodge_mod"], function(v) { - var base = Math.floor(v.basic_speed) + 3; - var mod = v.dodge_mod || 0; + getAttrs(['basic_speed', 'basic_speed_base', 'dodge_mod'], function(v) { + var speed = (modCascade ? +v.basic_speed : +v.basic_speed_base); + var base = Math.floor(speed) + 3; + var mod = +v.dodge_mod || 0; setAttrs({ - dodge_base: +base, - dodge: +base + +mod + dodge_base: base, + dodge: base + mod }, {silent: false}, callback); }); } // Encumbered/injured move and dodge - on("change:encumbrance_level change:dodge change:basic_move change:hit_points change:fatigue_points", function (e) { + on('change:encumbrance_level change:dodge change:basic_move change:hit_points change:fatigue_points', function (e) { updateMoveDodge(); }); // Update encumbered/injured move and dodge function updateMoveDodge() { console.log('***** UPDATE MOVE/DODGE *****'); - getAttrs(["encumbrance_level", "dodge", "basic_move", "hit_points", "hit_points_max", "fatigue_points", "fatigue_points_max", "strength_base", "strength_mod"], function(v) { - var dodge = v.dodge; - var move = v.basic_move; + getAttrs(['encumbrance_level', 'dodge', 'basic_move', 'hit_points', 'hit_points_max', 'fatigue_points', 'fatigue_points_max', 'strength_base', 'strength_mod'], function(v) { + var dodge = +v.dodge; + var move = +v.basic_move; var strength = +v.strength_base + +v.strength_mod; if (v.encumbrance_level === 5) { dodge = 0; move = 0; } else { - dodge = dodge - v.encumbrance_level; - move = Math.floor(v.basic_move * (1 - (0.2 * v.encumbrance_level))); + dodge = dodge - +v.encumbrance_level; + move = Math.floor(+v.basic_move * (1 - (0.2 * +v.encumbrance_level))); dodge = dodge < 0 ? 0 : dodge; move = move < 0 ? 0 : move; } - if (v.hit_points < v.hit_points_max / 3) { - dodge = Math.ceil(dodge/2); - move = Math.ceil(move/2); + if (+v.hit_points < +v.hit_points_max / 3) { + dodge = Math.ceil(dodge / 2); + move = Math.ceil(move / 2); } - if (v.fatigue_points < v.fatigue_points_max / 3 ) { - dodge = Math.ceil(dodge/2); - move = Math.ceil(move/2); - strength = Math.ceil(strength/2); + if (+v.fatigue_points < +v.fatigue_points_max / 3 ) { + dodge = Math.ceil(dodge / 2); + move = Math.ceil(move / 2); + strength = Math.ceil(strength / 2); } setAttrs({ current_move: move, @@ -2687,57 +2756,59 @@ } // Lifting ST - on("change:strength_base change:lift_st_points change:lift_st_mod", function (e) { + on('change:strength change:lift_st_points change:lift_st_mod', function (e) { updateLift(); }); // Update Lift function updateLift(callback) { console.log('********* updateLift *********'); callback = callback || noop; - getAttrs(["strength_base", "lift_st_points", "lift_st_mod"], function(v) { - var base = v.strength_base + ((v.lift_st_points || 0) / 3 | 0); - var modded = +base + +v.lift_st_mod; + getAttrs(['strength', 'strength_base', 'lift_st_points', 'lift_st_mod'], function(v) { + var base = (modCascade ? +v.strength : +v.strength_base) + + ((+v.lift_st_points || 0) / 3 | 0); + var modded = base + +v.lift_st_mod; var basicLift = (modded * modded) / 5; if (basicLift >= 10) { basicLift = Math.round(basicLift); } setAttrs({ - lift_st_base: +base, - lift_st: +modded, + lift_st_base: base, + lift_st: modded, basic_lift: basicLift }, {silent: false}, callback); }); } // Striking ST - on("change:strength_base change:striking_st_points change:striking_st_mod", function (e) { + on('change:strength change:striking_st_points change:striking_st_mod', function (e) { updateStrikingST(); }); // Update Striking function updateStrikingST() { console.log('********* updateStrikingST *********'); - getAttrs(["strength_base", "striking_st_points", "striking_st_mod"], function(v) { - var base = v.strength_base + ((v.striking_st_points || 0) / 5 | 0); - var mod = v.striking_st_mod; + getAttrs(['strength', 'strength_base', 'striking_st_points', 'striking_st_mod'], function(v) { + var base = (modCascade ? +v.strength : +v.strength_base) + + ((+v.striking_st_points || 0) / 5 | 0); + var mod = +v.striking_st_mod; setAttrs({ - striking_st_base: +base, - striking_st: +base + +mod + striking_st_base: base, + striking_st: base + mod }); }); } // Update the total cost of Languages - on("change:repeating_languages:spoken change:repeating_languages:written remove:repeating_languages", function (e) { + on('change:repeating_languages:spoken change:repeating_languages:written remove:repeating_languages', function (e) { var total = 0; var tally = _.after(2, function () { setAttrs({ languages_points: total }); }); - sumRepeating("repeating_languages", "spoken", function(v) { + sumRepeating('repeating_languages', 'spoken', function(v) { console.log('Spoken: ' + v); total += +v; tally(); }); - sumRepeating("repeating_languages", "written", function(v) { + sumRepeating('repeating_languages', 'written', function(v) { console.log('Written: ' + v); total += +v; tally(); @@ -2745,57 +2816,57 @@ }); // Update the total cost of Cultural Familiarities - on("change:repeating_cultures:points remove:repeating_cultures", function (e) { - sumRepeating("repeating_cultures", "points", function(v) { + on('change:repeating_cultures:points remove:repeating_cultures', function (e) { + sumRepeating('repeating_cultures', 'points', function(v) { setAttrs({ cf_points: v }); }); }); // Update the total cost of Advantages - on("change:repeating_traits:points remove:repeating_traits", function (e) { - sumRepeating("repeating_traits", "points", function(v) { + on('change:repeating_traits:points remove:repeating_traits', function (e) { + sumRepeating('repeating_traits', 'points', function(v) { setAttrs({ advantages_points: v }); }); }); // Update the total cost of Disadvantages - on("change:repeating_disadvantages:points remove:repeating_disadvantages", function (e) { - sumRepeating("repeating_disadvantages", "points", function(v) { + on('change:repeating_disadvantages:points remove:repeating_disadvantages', function (e) { + sumRepeating('repeating_disadvantages', 'points', function(v) { setAttrs({ disadvantages_points: v }); }); }); // Update the total cost of Racial Traits - on("change:repeating_racial:points remove:repeating_racial", function (e) { - sumRepeating("repeating_racial", "points", function(v) { + on('change:repeating_racial:points remove:repeating_racial', function (e) { + sumRepeating('repeating_racial', 'points', function(v) { setAttrs({ racial_points: v }); }); }); // Update the total cost of Skills - on("change:repeating_skills:points remove:repeating_skills", function (e) { - sumRepeating("repeating_skills", "points", function(v) { + on('change:repeating_skills:points remove:repeating_skills', function (e) { + sumRepeating('repeating_skills', 'points', function(v) { setAttrs({ skills_points: v }); }); }); // Update the total cost of Techniques - on("change:repeating_techniques:points remove:repeating_techniques", function (e) { - sumRepeating("repeating_techniques", "points", function(v) { + on('change:repeating_techniques:points remove:repeating_techniques', function (e) { + sumRepeating('repeating_techniques', 'points', function(v) { setAttrs({ techniques_points: v }); }); }); // Update the total cost of Spells - on("change:repeating_spells:points remove:repeating_spells", function (e) { - sumRepeating("repeating_spells", "points", function(v) { + on('change:repeating_spells:points remove:repeating_spells', function (e) { + sumRepeating('repeating_spells', 'points', function(v) { setAttrs({ spells_points: v }); }); }); // Update Summery - on("change:tl_pts change:appearance change:languages_points change:cf_points change:advantages_points change:disadvantages_points change:racial_points", function (e) { - getAttrs(["tl_pts", "appearance", "languages_points", "cf_points", "advantages_points", "disadvantages_points", "racial_points"], function(v) { + on('change:tl_pts change:appearance change:languages_points change:cf_points change:advantages_points change:disadvantages_points change:racial_points', function (e) { + getAttrs(['tl_pts', 'appearance', 'languages_points', 'cf_points', 'advantages_points', 'disadvantages_points', 'racial_points'], function(v) { var vals = Object.values(v); vals.push(0); setAttrs({ trait_points: vals.reduce(getSum) }); @@ -2803,8 +2874,8 @@ }); // Update the line total weight and cost - on("change:repeating_item:count change:repeating_item:cost change:repeating_item:carried change:repeating_item:weight", function (e) { - getAttrs(["repeating_item_count", "repeating_item_cost", "repeating_item_weight", "repeating_item_carried"], function (item) { + on('change:repeating_item:count change:repeating_item:cost change:repeating_item:carried change:repeating_item:weight', function (e) { + getAttrs(['repeating_item_count', 'repeating_item_cost', 'repeating_item_weight', 'repeating_item_carried'], function (item) { setAttrs({ repeating_item_weighttotal: Math.round(item.repeating_item_count * item.repeating_item_weight * item.repeating_item_carried * 100) / 100, repeating_item_costtotal: Math.round(item.repeating_item_count * item.repeating_item_cost * 100) / 100 @@ -2813,18 +2884,18 @@ }); // Update the total weight of all carried items. - on("change:repeating_item:weighttotal remove:repeating_item", function (e) { - sumRepeating("repeating_item", "weighttotal", function(v) { + on('change:repeating_item:weighttotal remove:repeating_item', function (e) { + sumRepeating('repeating_item', 'weighttotal', function(v) { setAttrs({ total_weight: (v * 100) / 100 }); }); }); // Get Encumbrance Level: - on("change:total_weight change:basic_lift", function (e) { + on('change:total_weight change:basic_lift', function (e) { updateEncLevel(); }); function updateEncLevel(callback) { - getAttrs(["basic_lift", "total_weight"], function(v) { + getAttrs(['basic_lift', 'total_weight'], function(v) { callback = callback || noop; var basicLift = +v.basic_lift; var encumbranceLevel = Math.floor(v.total_weight / basicLift); @@ -2847,8 +2918,8 @@ } // Update the total cost of all items. - on("change:repeating_item:costtotal remove:repeating_item", function (e) { - sumRepeating("repeating_item", "costtotal", function(v) { + on('change:repeating_item:costtotal remove:repeating_item', function (e) { + sumRepeating('repeating_item', 'costtotal', function(v) { setAttrs({ total_value: (v * 100) / 100 }); }); });