Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mythras v3.7 - Bugfix #13168

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Mythras/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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.7
### Fixed
- Deleting a weapon will now actually remove the row instead of just clearing the data

## 3.6
### Fixed
- Combat Styles did not default to applying Encumbrance penalties
Expand Down
12 changes: 4 additions & 8 deletions Mythras/Mythras.min.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@
if(v['social_defense_id'].toLowerCase()===skillId.toLowerCase()){newAttrs['social_defense_name']=v[`${skillId}_name`];newAttrs['social_defense_total']=v[`${skillId}_total`];newAttrs['social_defense_notes']=v[`${skillId}_notes`];}
return{...newAttrs,...newSpiritDamageAttrs,...newSocialDamageAttrs}}
on('change:repeating_passion:total change:repeating_passion:notes change:repeating_passion:name',function(event){if(event.sourceType==="sheetworker"){return;}
const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_passion_${id}_total`,`repeating_passion_${id}_notes`,`repeating_passion_${id}_name`,'social_defense_id'].concat(spiritDamageGetAttrs,socialDamageGetAttrs),function(v){setAttrs(calcPassion(`repeating_passion_${id}`,v));});});on('clicked:repeating_standardskill:augment clicked:repeating_combatstyle:augment clicked:repeating_professionalskill:augment clicked:repeating_affiliation:augment clicked:repeating_passion:augment clicked:repeating_dependency:augment clicked:repeating_peculiarity:augment',function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_total`],function(v){const skillValue=parseInt(v[`repeating_${type}_${id}_total`])||0;const augmentValue=Math.ceil(skillValue/5);setAttrs({augmentation:"@{set_augmentation}",set_augmentation:augmentValue});});});on('clicked:repeating_standardskill:set-social-offense clicked:repeating_professionalskill:set-social-offense clicked:repeating_passion:set-social-offense',function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_total`,`repeating_${type}_${id}_notes`].concat(socialDamageGetAttrs),function(v){const newAttrs={social_offense_id:`repeating_${type}_${id}`,social_offense_name:v[`repeating_${type}_${id}_name`],social_offense_total:v[`repeating_${type}_${id}_total`],social_offense_notes:v[`repeating_${type}_${id}_notes`],};setAttrs({...newAttrs,...calcSocialDamage({...v,...newAttrs})});});});on('clicked:repeating_standardskill:set-social-defense clicked:repeating_professionalskill:set-social-defense clicked:repeating_passion:set-social-defense',function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_total`,`repeating_${type}_${id}_notes`],function(v){const newAttrs={social_defense_id:`repeating_${type}_${id}`,social_defense_name:v[`repeating_${type}_${id}_name`],social_defense_total:v[`repeating_${type}_${id}_total`],social_defense_notes:v[`repeating_${type}_${id}_notes`]};setAttrs(newAttrs);});});on(`clicked:repeating_standardskill:set-spirit-combat clicked:repeating_professionalskill:set-spirit-combat clicked:repeating_passion:set-spirit-combat`,function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_total`,`repeating_${type}_${id}_notes`].concat(spiritDamageGetAttrs),function(v){const newAttrs={spirit_combat_skill_id:`repeating_${type}_${id}`,spirit_combat_skill_name:v[`repeating_${type}_${id}_name`],spirit_combat_skill_total:v[`repeating_${type}_${id}_total`],spirit_combat_skill_notes:v[`repeating_${type}_${id}_notes`]};setAttrs({...newAttrs,...calcSpiritDamage({...v,...newAttrs})});});});on(`change:repeating_dependency:total remove:repeating_dependency`,function(event){getSectionIDs("repeating_dependency",function(dependencyIds){let fetchAttrs=[];dependencyIds.forEach(id=>{fetchAttrs.push(`repeating_dependency_${id}_total`);});getAttrs(fetchAttrs.concat(tenacityGetAttrs),function(v){let newAttrs={tenacity_dependencies:0};dependencyIds.forEach(id=>{const depTotal=parseInt(v[`repeating_dependency_${id}_total`])||0;const depPenalty=Math.floor(depTotal/20);newAttrs['tenacity_dependencies']=newAttrs['tenacity_dependencies']-depPenalty;});setAttrs({...newAttrs,...calcTenacity({...v,...newAttrs})});});});});on("change:repeating_meleeweapon change:repeating_rangedweapon change:_reporder:meleeweapon change:_reporder:rangedweapon remove:repeating_meleeweapon remove:repeating_rangedweapon",function(event){if(event.sourceType==="sheetworker"){return;}
const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_passion_${id}_total`,`repeating_passion_${id}_notes`,`repeating_passion_${id}_name`,'social_defense_id'].concat(spiritDamageGetAttrs,socialDamageGetAttrs),function(v){setAttrs(calcPassion(`repeating_passion_${id}`,v));});});on('clicked:repeating_standardskill:augment clicked:repeating_combatstyle:augment clicked:repeating_professionalskill:augment clicked:repeating_affiliation:augment clicked:repeating_passion:augment clicked:repeating_dependency:augment clicked:repeating_peculiarity:augment',function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_total`],function(v){const skillValue=parseInt(v[`repeating_${type}_${id}_total`])||0;const augmentValue=Math.ceil(skillValue/5);setAttrs({augmentation:"@{set_augmentation}",set_augmentation:augmentValue});});});on('clicked:repeating_standardskill:set-social-offense clicked:repeating_professionalskill:set-social-offense clicked:repeating_passion:set-social-offense',function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_total`,`repeating_${type}_${id}_notes`].concat(socialDamageGetAttrs),function(v){const newAttrs={social_offense_id:`repeating_${type}_${id}`,social_offense_name:v[`repeating_${type}_${id}_name`],social_offense_total:v[`repeating_${type}_${id}_total`],social_offense_notes:v[`repeating_${type}_${id}_notes`],};setAttrs({...newAttrs,...calcSocialDamage({...v,...newAttrs})});});});on('clicked:repeating_standardskill:set-social-defense clicked:repeating_professionalskill:set-social-defense clicked:repeating_passion:set-social-defense',function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_total`,`repeating_${type}_${id}_notes`],function(v){const newAttrs={social_defense_id:`repeating_${type}_${id}`,social_defense_name:v[`repeating_${type}_${id}_name`],social_defense_total:v[`repeating_${type}_${id}_total`],social_defense_notes:v[`repeating_${type}_${id}_notes`]};setAttrs(newAttrs);});});on(`clicked:repeating_standardskill:set-spirit-combat clicked:repeating_professionalskill:set-spirit-combat clicked:repeating_passion:set-spirit-combat`,function(event){const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_total`,`repeating_${type}_${id}_notes`].concat(spiritDamageGetAttrs),function(v){const newAttrs={spirit_combat_skill_id:`repeating_${type}_${id}`,spirit_combat_skill_name:v[`repeating_${type}_${id}_name`],spirit_combat_skill_total:v[`repeating_${type}_${id}_total`],spirit_combat_skill_notes:v[`repeating_${type}_${id}_notes`]};setAttrs({...newAttrs,...calcSpiritDamage({...v,...newAttrs})});});});on(`change:repeating_dependency:total remove:repeating_dependency`,function(event){getSectionIDs("repeating_dependency",function(dependencyIds){let fetchAttrs=[];dependencyIds.forEach(id=>{fetchAttrs.push(`repeating_dependency_${id}_total`);});getAttrs(fetchAttrs.concat(tenacityGetAttrs),function(v){let newAttrs={tenacity_dependencies:0};dependencyIds.forEach(id=>{const depTotal=parseInt(v[`repeating_dependency_${id}_total`])||0;const depPenalty=Math.floor(depTotal/20);newAttrs['tenacity_dependencies']=newAttrs['tenacity_dependencies']-depPenalty;});setAttrs({...newAttrs,...calcTenacity({...v,...newAttrs})});});});});on("change:repeating_meleeweapon:favored change:repeating_rangedweapon:favored change:_reporder:meleeweapon change:_reporder:rangedweapon remove:repeating_meleeweapon remove:repeating_rangedweapon",function(event){if(event.sourceType==="sheetworker"){return;}
const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getSectionIDs("repeating_meleeweapon",function(meleeIds){getSectionIDs("repeating_rangedweapon",function(rangedIds){let meleeGetAttrs=[];meleeIds.forEach(id=>{meleeGetAttrs.push(`repeating_meleeweapon_${id}_name`,`repeating_meleeweapon_${id}_favored`);});let rangedGetAttrs=[];rangedIds.forEach(id=>{rangedGetAttrs.push(`repeating_rangedweapon_${id}_name`,`repeating_rangedweapon_${id}_favored`);});getAttrs(['character_id'].concat(rangedGetAttrs,meleeGetAttrs),function(v){let weaponButtons=""
meleeIds.forEach(id=>{if(v[`repeating_meleeweapon_${id}_favored`]==='1'){const name=v[`repeating_meleeweapon_${id}_name`];weaponButtons=weaponButtons+` [${name}](~${v['character_id']}|repeating_meleeweapon_${id}_roll)`;}});rangedIds.forEach(id=>{if(v[`repeating_rangedweapon_${id}_favored`]==='1'){const name=v[`repeating_rangedweapon_${id}_name`];weaponButtons=weaponButtons+` [${name}](~${v['character_id']}|repeating_rangedweapon_${id}_roll)`;}});let newAttrs={weapon_buttons:weaponButtons};if(id.startsWith("-")){newAttrs[`repeating_${type}_${id}_id`]=`repeating_${type}_${id}`;newAttrs[`repeating_${type}_${id}_rollval`]=`%{${v['character_id']}|repeating_${type}_${id}_roll}`;}
setAttrs(newAttrs);});});});});on('clicked:repeating_meleeweapon:roll clicked:repeating_rangedweapon:roll',(event)=>{const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_damage`,`repeating_${type}_${id}_damage_mod_toggle`,`repeating_${type}_${id}_size`,`repeating_${type}_${id}_reach`,`repeating_${type}_${id}_notes`,`repeating_${type}_${id}_force`,`repeating_${type}_${id}_range`,`repeating_${type}_${id}_impale_size`,'damage_mod','roll_display','character_name'],function(v){const roll_display=(v['roll_display']==='/w gm')?"/w gm ":"";const roll_name=v[`repeating_${type}_${id}_name`]||"";const character_name=v[`character_name`]||"";const damage=v[`repeating_${type}_${id}_damage`];let damage_mod=0;if(v[`repeating_${type}_${id}_damage_mod_toggle`]==='@{damage_mod}'){damage_mod=v['damage_mod'];}
meleeIds.forEach(id=>{if(v[`repeating_meleeweapon_${id}_favored`]==='1'){const name=v[`repeating_meleeweapon_${id}_name`];weaponButtons=weaponButtons+` [${name}](~${v['character_id']}|repeating_meleeweapon_${id}_roll)`;}});rangedIds.forEach(id=>{if(v[`repeating_rangedweapon_${id}_favored`]==='1'){const name=v[`repeating_rangedweapon_${id}_name`];weaponButtons=weaponButtons+` [${name}](~${v['character_id']}|repeating_rangedweapon_${id}_roll)`;}});setAttrs({weapon_buttons:weaponButtons});});});});});on("change:repeating_meleeweapon change:repeating_rangedweapon",function(event){if(event.sourceType==="sheetworker"){return;}
const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs(['character_id'],function(v){let newAttrs={};newAttrs[`repeating_${type}_${id}_id`]=`repeating_${type}_${id}`;newAttrs[`repeating_${type}_${id}_rollval`]=`%{${v['character_id']}|repeating_${type}_${id}_roll}`;setAttrs(newAttrs);});});on('clicked:repeating_meleeweapon:roll clicked:repeating_rangedweapon:roll',(event)=>{const type=event.sourceAttribute.split('_')[1];const id=event.sourceAttribute.split('_')[2];getAttrs([`repeating_${type}_${id}_name`,`repeating_${type}_${id}_damage`,`repeating_${type}_${id}_damage_mod_toggle`,`repeating_${type}_${id}_size`,`repeating_${type}_${id}_reach`,`repeating_${type}_${id}_notes`,`repeating_${type}_${id}_force`,`repeating_${type}_${id}_range`,`repeating_${type}_${id}_impale_size`,'damage_mod','roll_display','character_name'],function(v){const roll_display=(v['roll_display']==='/w gm')?"/w gm ":"";const roll_name=v[`repeating_${type}_${id}_name`]||"";const character_name=v[`character_name`]||"";const damage=v[`repeating_${type}_${id}_damage`];let damage_mod=0;if(v[`repeating_${type}_${id}_damage_mod_toggle`]==='@{damage_mod}'){damage_mod=v['damage_mod'];}
const size=v[`repeating_${type}_${id}_size`]||"";const reach=v[`repeating_${type}_${id}_reach`]||"";const force=v[`repeating_${type}_${id}_force`]||"";const range=v[`repeating_${type}_${id}_range`]||"";const impale_size=v[`repeating_${type}_${id}_impale_size`]||"";const notes=v[`repeating_${type}_${id}_notes`]||"";let roll_string=`${roll_display}&{template:weapon} \{\{name=${roll_name}\}\} \{\{character=${character_name}\}\} \{\{damage=[[${damage}+${damage_mod}]]\}\} \{\{notes=${notes}\}\}`;if(type==='meleeweapon'){roll_string=roll_string+` \{\{size=${size}\}\} \{\{reach=${reach}\}\}`;}else if(type==='rangedweapon'){roll_string=roll_string+` \{\{force=${force}\}\} \{\{range=${range}\}\} \{\{impale_size=${impale_size}\}\}`;}
startRoll(roll_string,(results)=>{finishRoll(results.rollId,{});});});});on(`change:repeating_tradition:skill1_id change:repeating_tradition:skill2_id`,function(event){if(event.sourceType==="sheetworker"){return{};}
const traditionId=event.sourceAttribute.split('_')[2];const traditionSkill=event.sourceAttribute.split('_')[3];const skillId=event.newValue;let newAttrs={};if(!event.newValue){newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_name`]='';newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_total`]='0';newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_notes`]='';}else if(skillId.startsWith("repeating_")){newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_name`]=`@{${skillId}_name}`;newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_total`]=`@{${skillId}_total}`;newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_notes`]=`@{${skillId}_notes}`;}else{newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_name`]=getTranslationByKey(skillId);newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_total`]=`@{${skillId}}`;newAttrs[`repeating_tradition_${traditionId}_${traditionSkill}_notes`]=`@{${skillId}_notes}`;}
Expand Down Expand Up @@ -400,8 +400,4 @@
versioning(sheet_type,'3.6');}else{setattr({"version":3.6})}}
const i18nVars=['ablation','area','casting_time','combine','condition','conditions','days','dose','doses','duration','effects','enhance',"focus",'fortune','hours','intensity','magnitude','months','none','precision','radius','range','rolls','rounds','service','services','shelf_life','spells','step','steps','swiftness','target','targets','term','terms','touch','turns','weeks','wonder','wonders','years'];function setTranslationAttrs(){let i18nAttrs={};i18nVars.forEach(i18nVar=>{i18nAttrs[`${i18nVar}_i18n`]=getTranslationByKey(i18nVar);});i18nAttrs['point_a_i18n']=getTranslationByKey('point-a');i18nAttrs['points_a_i18n']=getTranslationByKey('points-a');i18nAttrs['pow_u_i18n']=getTranslationByKey('pow-u');i18nAttrs['minutes_a_i18n']=getTranslationByKey('minutes-a');i18nAttrs['meters_a_i18n']=getTranslationByKey('meters-a');i18nAttrs['kilometers_a_i18n']=getTranslationByKey('kilometers-a');return i18nAttrs;}
on("sheet:opened",function(){getAttrs(['type','sheet_type','version','character_id'],function(v){const version=parseFloat(v['version'])||0;if(version<3.0){let sheet_type=(typeof v['type']==='undefined')?"pc":v['type'];versioning(sheet_type,version);}else{let sheet_type=(typeof v['sheet_type']==='undefined')?"pc":v['type'];versioning(sheet_type,version);}
let newAttrs=setTranslationAttrs();newAttrs['character_id']=v['character_id'];setAttrs(newAttrs);});});on('clicked:redo-v3-upgrade',function(event){console.log("redoing v3 upgrade");getAttrs(['type','version'],function(v){console.log("redoing v3 upgrade");let sheet_type=(typeof v['type']==='undefined')?"pc":v['type'];console.log("redoing v3 upgrade");versioning(sheet_type,'2.7');});});</script>




let newAttrs=setTranslationAttrs();newAttrs['character_id']=v['character_id'];setAttrs(newAttrs);});});on('clicked:redo-v3-upgrade',function(event){console.log("redoing v3 upgrade");getAttrs(['type','version'],function(v){console.log("redoing v3 upgrade");let sheet_type=(typeof v['type']==='undefined')?"pc":v['type'];console.log("redoing v3 upgrade");versioning(sheet_type,'2.7');});});</script>
25 changes: 18 additions & 7 deletions Mythras/pre-minified/Mythras.html
Original file line number Diff line number Diff line change
Expand Up @@ -8703,7 +8703,7 @@ <h3 data-i18n="weapons">Weapons</h3>
});
/* Weapons */
/* When a favored weapon is selected it is added to the weapons_buttons attr which is how we add it to combat rolls */
on("change:repeating_meleeweapon change:repeating_rangedweapon change:_reporder:meleeweapon change:_reporder:rangedweapon remove:repeating_meleeweapon remove:repeating_rangedweapon", function(event) {
on("change:repeating_meleeweapon:favored change:repeating_rangedweapon:favored change:_reporder:meleeweapon change:_reporder:rangedweapon remove:repeating_meleeweapon remove:repeating_rangedweapon", function(event) {
if (event.sourceType === "sheetworker") {return;}
const type = event.sourceAttribute.split('_')[1];
const id = event.sourceAttribute.split('_')[2];
Expand Down Expand Up @@ -8734,17 +8734,28 @@ <h3 data-i18n="weapons">Weapons</h3>
weaponButtons = weaponButtons + ` [${name}](~${v['character_id']}|repeating_rangedweapon_${id}_roll)`;
}
});
let newAttrs = {weapon_buttons: weaponButtons};
if (id.startsWith("-")) {
newAttrs[`repeating_${type}_${id}_id`] = `repeating_${type}_${id}`;
newAttrs[`repeating_${type}_${id}_rollval`] = `%{${v['character_id']}|repeating_${type}_${id}_roll}`;
}
setAttrs(newAttrs);
setAttrs({weapon_buttons: weaponButtons});
});
});
});
});

/* Set the id and rollval for weapons anytime they are updated. */
on("change:repeating_meleeweapon change:repeating_rangedweapon", function(event) {
if (event.sourceType === "sheetworker") {return;}
const type = event.sourceAttribute.split('_')[1];
const id = event.sourceAttribute.split('_')[2];

getAttrs(['character_id'], function(v) {
let newAttrs = {};

newAttrs[`repeating_${type}_${id}_id`] = `repeating_${type}_${id}`;
newAttrs[`repeating_${type}_${id}_rollval`] = `%{${v['character_id']}|repeating_${type}_${id}_roll}`;

setAttrs(newAttrs);
});
});

on('clicked:repeating_meleeweapon:roll clicked:repeating_rangedweapon:roll', (event) => {
const type = event.sourceAttribute.split('_')[1];
const id = event.sourceAttribute.split('_')[2];
Expand Down
Loading