[GURPS] Added radio button to set how "mod" values are applied to sub-attributes

This commit is contained in:
sdJasper
2017-03-08 00:01:41 -05:00
parent 9ad1835dbc
commit d5219a8f6c
3 changed files with 332 additions and 260 deletions
+2
View File
@@ -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
+15 -16
View File
@@ -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); }
+315 -244
View File
@@ -557,8 +557,9 @@
<div class="sheet-table">
<div class="sheet-header">
<div class="sheet-cell sheet-col0">Stats</div>
<div class="sheet-cell sheet-col2">Value</div>
<div class="sheet-cell sheet-col1">Pts</div>
<div class="sheet-cell sheet-col1">Value</div>
<div class="sheet-cell sheet-col2">Mod</div>
<div class="sheet-cell sheet-col3">Pts</div>
</div> <!-- .sheet-header -->
<div class="sheet-row sheet-row-hit-points">
<div class="sheet-cell sheet-col0 sheet-label">
@@ -575,6 +576,9 @@
<input type="number" name="attr_hit_points_max" value="10" readonly="readonly" />
</div>
<div class="sheet-cell sheet-col2">
<input type="number" name="attr_hit_points_mod" value="0" step="1" />
</div>
<div class="sheet-cell sheet-col3">
<input type="number" name="attr_hit_points_points" value="0" step="2" />
</div>
</div> <!-- .sheet-row -->
@@ -666,6 +670,9 @@
<input type="number" name="attr_fatigue_points_max" value="10" readonly="readonly" />
</div>
<div class="sheet-cell sheet-col2">
<input type="number" name="attr_fatigue_points_mod" value="0" step="1" />
</div>
<div class="sheet-cell sheet-col3">
<input type="number" name="attr_fatigue_points_points" value="0" step="3" />
</div>
</div> <!-- .sheet-row -->
@@ -738,7 +745,8 @@
<div class="sheet-cell sheet-col1">
<input type="number" name="attr_energy_points_max" />
</div>
<div class="sheet-cell sheet-col2">
<div class="sheet-cell sheet-col2"></div>
<div class="sheet-cell sheet-col3">
<input type="number" name="attr_energy_points_points" value="0" step="3" />
</div>
</div> <!-- .sheet-row -->
@@ -762,7 +770,8 @@
<div class="sheet-cell sheet-col1">
<input type="number" name="attr_user_pool1_max" />
</div>
<div class="sheet-cell sheet-col2">
<div class="sheet-cell sheet-col2"></div>
<div class="sheet-cell sheet-col3">
<input type="number" name="attr_user_pool1_points" value=0 />
</div>
</div> <!-- .sheet-row -->
@@ -781,7 +790,8 @@
<div class="sheet-cell sheet-col1">
<input type="number" name="attr_user_pool2_max" />
</div>
<div class="sheet-cell sheet-col2">
<div class="sheet-cell sheet-col2"></div>
<div class="sheet-cell sheet-col3">
<input type="number" name="attr_user_pool2_points" value=0 />
</div>
</div> <!-- .sheet-row -->
@@ -2239,58 +2249,70 @@
</div>
</div>
<div>
<hr />
<div class="sheet-options">
<div class="sheet-box">
<input type="radio" name="attr_modifier" value="0" checked="true" />
<span class="sheet-popup">No Modifier Prompt</span>
<span class="sheet-tooltip">
Rolls will be made immediately with no prompt.
</span>
<br /><input type="radio" name="attr_modifier" value="?{Modifier|0}" />
<span class="sheet-popup">Single Modifier Prompt</span>
<span class="sheet-tooltip">
Ask for a bonus or penalty to be added to dice rolls.
<br />
This will not affect damage rolls.
</span>
<br />
<input type="radio" name="attr_modifier" value="?{Modifier|0} + ?{Shock|0} + ?{Reeling or Staggered|0} + ?{Off-Hand|0} + ?{Familiarity|0}" />
<span class="sheet-popup">Extended Modifier Prompts</span>
<span class="sheet-tooltip">
Instead of a single modifier, rolls will ask for a series of modifiers,<br />
to remind you about potential bonuses/penalties.
<br />
This will not affect damage rolls.
</span>
</div>
<div class="sheet-box">
<input type="radio" name="attr_roll" value="@{character_name} rolls" checked="true" />
<span class="sheet-popup">Public Rolls</span>
<span class="sheet-tooltip">
All players will be able to see<br />
your skill level, roll and results.
</span>
<br />
<input type="radio" name="attr_roll" value="/w gm --l @{character_name} rolls" />
<span class="sheet-popup">Private Skill Levels</span>
<span class="sheet-tooltip">
Only the GM will be able to see<br />
your skill level, but all players<br />
will see the result.
<br />
This will not affect damage rolls.
</span>
<br />
<input type="radio" name="attr_roll" value="/w gm @{character_name} rolls" />
<span class="sheet-popup">Private Rolls</span>
<span class="sheet-tooltip">
Only the GM will see your skill<br />
level and the result.
<br />
This will not affect damage rolls.
</span>
</div>
<hr />
<input type="radio" name="attr_modifier" value="0" checked="true" />
<span class="sheet-popup">No Modifier Prompt</span>
<span class="sheet-tooltip">
Rolls will be made immediately with no prompt.
</span>
<br /><input type="radio" name="attr_modifier" value="?{Modifier|0}" />
<span class="sheet-popup">Single Modifier Prompt</span>
<span class="sheet-tooltip">
Ask for a bonus or penalty to be added to dice rolls.
<div class="sheet-box">
<input type="radio" name="attr_mod_cascade" value="all" checked="true" />
<span class="sheet-popup">Mods to attributes increase all derived stats (including HP, FP)</span>
<br />
This will not affect damage rolls.
</span>
<br />
<input type="radio" name="attr_modifier" value="?{Modifier|0} + ?{Shock|0} + ?{Reeling or Staggered|0} + ?{Off-Hand|0} + ?{Familiarity|0}" />
<span class="sheet-popup">Extended Modifier Prompts</span>
<span class="sheet-tooltip">
Instead of a single modifier, rolls will ask for a series of modifiers,<br />
to remind you about potential bonuses/penalties.
<input type="radio" name="attr_mod_cascade" value="some" />
<span class="sheet-popup">Mods to attributes increase most derived stats (not HP, FP)</span>
<br />
This will not affect damage rolls.
</span>
<br />
<br />
<input type="radio" name="attr_roll" value="@{character_name} rolls" checked="true" />
<span class="sheet-popup">Public Rolls</span>
<span class="sheet-tooltip">
All players will be able to see<br />
your skill level, roll and results.
</span>
<br />
<input type="radio" name="attr_roll" value="/w gm --l @{character_name} rolls" />
<span class="sheet-popup">Private Skill Levels</span>
<span class="sheet-tooltip">
Only the GM will be able to see<br />
your skill level, but all players<br />
will see the result.
<br />
This will not affect damage rolls.
</span>
<br />
<input type="radio" name="attr_roll" value="/w gm @{character_name} rolls" />
<span class="sheet-popup">Private Rolls</span>
<span class="sheet-tooltip">
Only the GM will see your skill<br />
level and the result.
<br />
This will not affect damage rolls.
</span>
<input type="radio" name="attr_mod_cascade" value="none" />
<span class="sheet-popup">Mods to attributes do not increase derived stats</span>
</div>
<br />
</div>
@@ -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 });
});
});