Skip to content

Commit

Permalink
Mythras v3.6 update with fix for enc application to combat styles and…
Browse files Browse the repository at this point in the history
… professional skills
  • Loading branch information
DigitalPagan committed Feb 28, 2024
1 parent da2fb03 commit 713395f
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 16 deletions.
5 changes: 5 additions & 0 deletions Mythras/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to the Mythras sheet will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## 3.6
### Fixed
- Combat Styles did not default to applying Encumbrance penalties
- Professional Skills and Combat Style did not proper evaluate which encumbrance penalties should apply when STR or DEX was part of the base score.

## 3.5
### Fixed
- [Various reapeating fields can not be added to the macro bar #77](https://github.com/DigitalPagan/Mythras-Roll20-Sheet/issues/77)
Expand Down
10 changes: 6 additions & 4 deletions Mythras/Mythras.min.html

Large diffs are not rendered by default.

63 changes: 57 additions & 6 deletions Mythras/pre-minified/Mythras.html
Original file line number Diff line number Diff line change
Expand Up @@ -2713,7 +2713,7 @@ <h2><span data-i18n="conditions">Conditions</span> <button type="roll" class="sh
<button type="roll" title="%{$ID_improve}" name="roll_improve" value="@{roll_display}&{template:improvement} {{name=@{name}}} {{character=@{character_name}}} {{roll=[[1d100+@{int}]]}} {{improvement=[[1d4+1]]}} {{skill=[[@{total}]]}}" data-i18n="improve">Improve</button>
</div>
<textarea class="sheet-skill-notes" title="@{$ID_notes}" name="attr_notes" value=""></textarea>
<input type="hidden" name="attr_encumbered" value="0">
<input type="hidden" name="attr_encumbered" value="1">
</div>
<div class="sheet-compact">
<button type="roll" title="%{$ID_combatstyle}" name="roll_combatstyle" value="@{roll_display}&{template:skill} {{character=@{character_name}}} {{combatstyle=1}} {{weapon_buttons=@{weapon_buttons}}} {{character_id=@{character_id}}} {{name=@{name}}} {{roll=[[1d100]]}} {{fatigue_skills=[[@{fatigue_skills}]]}} {{encumbered=[[@{encumbered}]]}} {{encumbrance_skills=[[@{encumbrance_skills}]]}} {{original=@{total}}} {{difficulty=[[@{difficulty}]]}} {{augmentation=[[@{augmentation}]]}} {{penalty=[[@{penalty}]]}} {{very_easy=[[((@{total}+@{augmentation})*2)+@{penalty}]]}} {{very_easy_crit=[[ceil(((@{total}*2)+@{penalty})/10)]]}} {{very_easy_fumble=[[((@{total}*2)+@{penalty})]]}} {{easy=[[ceil((@{total}+@{augmentation})*1.5)+@{penalty}]]}} {{easy_crit=[[ceil(((@{total}*1.5)+@{penalty})/10)]]}} {{easy_fumble=[[ceil((@{total}*1.5)+@{penalty})]]}} {{standard=[[@{total}+@{augmentation}+@{penalty}]]}} {{standard_crit=[[ceil((@{total}+@{penalty})/10)]]}} {{standard_fumble=[[(@{total}+@{penalty})]]}} {{hard=[[ceil((@{total}+@{augmentation})*.67)+@{penalty}]]}} {{hard_crit=[[ceil(((@{total}*.67)+@{penalty})/10)]]}} {{hard_fumble=[[ceil((@{total}*.67)+@{penalty})]]}} {{formidable=[[ceil((@{total}+@{augmentation})*.5)+@{penalty}]]}} {{formidable_crit=[[ceil(((@{total}*.5)+@{penalty})/10)]]}} {{formidable_fumble=[[ceil((@{total}*.5)+@{penalty})]]}} {{herculean=[[ceil((@{total}+@{augmentation})*@{herculean_mod})+@{penalty}]]}} {{herculean_crit=[[ceil(((@{total}*@{herculean_mod})+@{penalty})/10)]]}} {{herculean_fumble=[[ceil((@{total}*@{herculean_mod})+@{penalty})]]}} {{notes=@{notes}}}"><span class="sheet-bold" name="attr_name"></span> <span name="attr_total"></span>%</button>
Expand Down Expand Up @@ -8517,8 +8517,8 @@ <h3 data-i18n="weapons">Weapons</h3>
function calcProSkill(skillId, v, sourceAttribute) {
let newAttrs = {};
/* If a str or dex skill then it is affected by encumbrance */
if (v['${skillId}_char1'] === '@{str}' || v['${skillId}_char1'] === '@{dex}' ||
v['${skillId}_char2'] === '@{str}' || v['${skillId}_char2'] === '@{dex}') {
if (v[`${skillId}_char1`] === '@{str}' || v[`${skillId}_char1`] === '@{dex}' ||
v[`${skillId}_char2`] === '@{str}' || v[`${skillId}_char2`] === '@{dex}') {
newAttrs[`${skillId}_encumbered`] = 1;
} else {
newAttrs[`${skillId}_encumbered`] = 0;
Expand Down Expand Up @@ -11251,6 +11251,51 @@ <h3 data-i18n="weapons">Weapons</h3>
});
});
}

/**
* Make the changes needs to get a character sheet updated from 3.4+ to 3.6
*/
function upgradeCharacter3Dot6() {
console.log("Upgrading character to 3.6");

getSectionIDs("repeating_professionalskill", function(proSkillIds) {
getSectionIDs("repeating_combatstyle", function(combatStyleIds) {
let proSkillGetAttrs = [];
proSkillIds.forEach(id => {
proSkillGetAttrs.push(`repeating_professionalskill_${id}_char1`, `repeating_professionalskill_${id}_char2`);
});

let combatStyleGetAttrs = [];
combatStyleIds.forEach(id => {
combatStyleGetAttrs.push(`repeating_combatstyle_${id}_char1`, `repeating_combatstyle_${id}_char2`);
});

getAttrs(proSkillGetAttrs.concat(combatStyleGetAttrs), function(v) {
let newAttrs = {"version": '3.6'};

proSkillIds.forEach(id => {
if (v[`repeating_professionalskill_${id}_char1`] === '@{str}' || v[`repeating_professionalskill_${id}_char1`] === '@{dex}' ||
v[`repeating_professionalskill_${id}_char2`] === '@{str}' || v[`repeating_professionalskill_${id}_char2`] === '@{dex}') {
newAttrs[`repeating_professionalskill_${id}_encumbered`] = 1;
} else {
newAttrs[`repeating_professionalskill_${id}_encumbered`] = 0;
}
});

combatStyleIds.forEach(id => {
if (v[`repeating_combatstyle_${id}_char1`] === '@{str}' || v[`repeating_combatstyle_${id}_char1`] === '@{dex}' ||
v[`repeating_combatstyle_${id}_char2`] === '@{str}' || v[`repeating_combatstyle_${id}_char2`] === '@{dex}') {
newAttrs[`repeating_combatstyle_${id}_encumbered`] = 1;
} else {
newAttrs[`repeating_combatstyle_${id}_encumbered`] = 0;
}
});

setAttrs(newAttrs);
});
});
});
}
const shipConditionTable = {
"ship_shape": {
"speed": "-",
Expand Down Expand Up @@ -11858,7 +11903,7 @@ <h3 data-i18n="weapons">Weapons</h3>
* @param version the sheet version already parse to a float or 0 if not a valid float
*/
function versioning(sheet_type, version) {
const latestVersion = '3.4';
const latestVersion = '3.6';
if (!sheet_type) {
sheet_type = "pc";
}
Expand Down Expand Up @@ -11891,8 +11936,14 @@ <h3 data-i18n="weapons">Weapons</h3>
upgradeCharacter3Dot4();
}
versioning(sheet_type, '3.4');
} else if (version <= 3.4) { /* TODO change this when we next introduce a version that requires updating */
setAttrs({"version": "3.4"});
} else if (version < 3.6) { /* TODO change this when we next introduce a version that requires updating */
if (sheet_type === 'character' || sheet_type === 'pc' || sheet_type === 'creature' || sheet_type === 'spirit') {
console.log("running character 3.6 update");
upgradeCharacter3Dot6();
}
versioning(sheet_type, '3.6');
} else {
setattr({"version": 3.6})
}
}

Expand Down
12 changes: 9 additions & 3 deletions Mythras/templates/sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function upgradeGeneric3Dot1() {
* @param version the sheet version already parse to a float or 0 if not a valid float
*/
function versioning(sheet_type, version) {
const latestVersion = '3.5';
const latestVersion = '3.6';
if (!sheet_type) {
sheet_type = "pc";
}
Expand Down Expand Up @@ -386,8 +386,14 @@ function versioning(sheet_type, version) {
upgradeCharacter3Dot4();
}
versioning(sheet_type, '3.4');
} else if (version <= 3.5) { /* TODO change this when we next introduce a version that requires updating */
setAttrs({"version": "3.5"});
} else if (version < 3.6) { /* TODO change this when we next introduce a version that requires updating */
if (sheet_type === 'character' || sheet_type === 'pc' || sheet_type === 'creature' || sheet_type === 'spirit') {
console.log("running character 3.6 update");
upgradeCharacter3Dot6();
}
versioning(sheet_type, '3.6');
} else {
setattr({"version": 3.6})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@
<button type="roll" title="%{$ID_improve}" name="roll_improve" value="{{'@{roll_display}&{template:improvement} {{name=@{name}}} {{character=@{character_name}}} {{roll=[[1d100+@{int}]]}} {{improvement=[[1d4+1]]}} {{skill=[[@{total}]]}}'}}" data-i18n="improve">Improve</button>
</div>
<textarea class="sheet-skill-notes" title="@{$ID_notes}" name="attr_notes" value=""></textarea>
<input type="hidden" name="attr_encumbered" value="0">
<input type="hidden" name="attr_encumbered" value="1">
</div>
<div class="sheet-compact">
<button type="roll" title="%{$ID_combatstyle}" name="roll_combatstyle" value="{{'@{roll_display}&{template:skill} {{character=@{character_name}}} {{combatstyle=1}} {{weapon_buttons=@{weapon_buttons}}} {{character_id=@{character_id}}} {{name=@{name}}} {{roll=[[1d100]]}} {{fatigue_skills=[[@{fatigue_skills}]]}} {{encumbered=[[@{encumbered}]]}} {{encumbrance_skills=[[@{encumbrance_skills}]]}} {{original=@{total}}} {{difficulty=[[@{difficulty}]]}} {{augmentation=[[@{augmentation}]]}} {{penalty=[[@{penalty}]]}} {{very_easy=[[((@{total}+@{augmentation})*2)+@{penalty}]]}} {{very_easy_crit=[[ceil(((@{total}*2)+@{penalty})/10)]]}} {{very_easy_fumble=[[((@{total}*2)+@{penalty})]]}} {{easy=[[ceil((@{total}+@{augmentation})*1.5)+@{penalty}]]}} {{easy_crit=[[ceil(((@{total}*1.5)+@{penalty})/10)]]}} {{easy_fumble=[[ceil((@{total}*1.5)+@{penalty})]]}} {{standard=[[@{total}+@{augmentation}+@{penalty}]]}} {{standard_crit=[[ceil((@{total}+@{penalty})/10)]]}} {{standard_fumble=[[(@{total}+@{penalty})]]}} {{hard=[[ceil((@{total}+@{augmentation})*.67)+@{penalty}]]}} {{hard_crit=[[ceil(((@{total}*.67)+@{penalty})/10)]]}} {{hard_fumble=[[ceil((@{total}*.67)+@{penalty})]]}} {{formidable=[[ceil((@{total}+@{augmentation})*.5)+@{penalty}]]}} {{formidable_crit=[[ceil(((@{total}*.5)+@{penalty})/10)]]}} {{formidable_fumble=[[ceil((@{total}*.5)+@{penalty})]]}} {{herculean=[[ceil((@{total}+@{augmentation})*@{herculean_mod})+@{penalty}]]}} {{herculean_crit=[[ceil(((@{total}*@{herculean_mod})+@{penalty})/10)]]}} {{herculean_fumble=[[ceil((@{total}*@{herculean_mod})+@{penalty})]]}} {{notes=@{notes}}}'}}"><span class="sheet-bold" name="attr_name"></span> <span name="attr_total"></span>%</button>
Expand Down
4 changes: 2 additions & 2 deletions Mythras/templates/sheet_types/character/character_skills.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ function parseBaseChar(charOption, v) {
function calcProSkill(skillId, v, sourceAttribute) {
let newAttrs = {};
/* If a str or dex skill then it is affected by encumbrance */
if (v['${skillId}_char1'] === '@{str}' || v['${skillId}_char1'] === '@{dex}' ||
v['${skillId}_char2'] === '@{str}' || v['${skillId}_char2'] === '@{dex}') {
if (v[`${skillId}_char1`] === '@{str}' || v[`${skillId}_char1`] === '@{dex}' ||
v[`${skillId}_char2`] === '@{str}' || v[`${skillId}_char2`] === '@{dex}') {
newAttrs[`${skillId}_encumbered`] = 1;
} else {
newAttrs[`${skillId}_encumbered`] = 0;
Expand Down
45 changes: 45 additions & 0 deletions Mythras/templates/sheet_types/character/character_versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,51 @@ function upgradeCharacter3Dot4() {
console.log("Upgrading weapon_buttons to " + weaponButtons);
newAttrs['weapon_buttons'] = weaponButtons;
console.log("newAttrs = " + newAttrs);
setAttrs(newAttrs);
});
});
});
}

/**
* Make the changes needs to get a character sheet updated from 3.4+ to 3.6
*/
function upgradeCharacter3Dot6() {
console.log("Upgrading character to 3.6");

getSectionIDs("repeating_professionalskill", function(proSkillIds) {
getSectionIDs("repeating_combatstyle", function(combatStyleIds) {
let proSkillGetAttrs = [];
proSkillIds.forEach(id => {
proSkillGetAttrs.push(`repeating_professionalskill_${id}_char1`, `repeating_professionalskill_${id}_char2`);
});

let combatStyleGetAttrs = [];
combatStyleIds.forEach(id => {
combatStyleGetAttrs.push(`repeating_combatstyle_${id}_char1`, `repeating_combatstyle_${id}_char2`);
});

getAttrs(proSkillGetAttrs.concat(combatStyleGetAttrs), function(v) {
let newAttrs = {"version": '3.6'};

proSkillIds.forEach(id => {
if (v[`repeating_professionalskill_${id}_char1`] === '@{str}' || v[`repeating_professionalskill_${id}_char1`] === '@{dex}' ||
v[`repeating_professionalskill_${id}_char2`] === '@{str}' || v[`repeating_professionalskill_${id}_char2`] === '@{dex}') {
newAttrs[`repeating_professionalskill_${id}_encumbered`] = 1;
} else {
newAttrs[`repeating_professionalskill_${id}_encumbered`] = 0;
}
});

combatStyleIds.forEach(id => {
if (v[`repeating_combatstyle_${id}_char1`] === '@{str}' || v[`repeating_combatstyle_${id}_char1`] === '@{dex}' ||
v[`repeating_combatstyle_${id}_char2`] === '@{str}' || v[`repeating_combatstyle_${id}_char2`] === '@{dex}') {
newAttrs[`repeating_combatstyle_${id}_encumbered`] = 1;
} else {
newAttrs[`repeating_combatstyle_${id}_encumbered`] = 0;
}
});

setAttrs(newAttrs);
});
});
Expand Down

0 comments on commit 713395f

Please sign in to comment.