diff --git a/Mythras/CHANGELOG.md b/Mythras/CHANGELOG.md index f112ab26f77..388a3265d95 100644 --- a/Mythras/CHANGELOG.md +++ b/Mythras/CHANGELOG.md @@ -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 diff --git a/Mythras/Mythras.min.html b/Mythras/Mythras.min.html index fec6a485c87..8f95dc04b40 100644 --- a/Mythras/Mythras.min.html +++ b/Mythras/Mythras.min.html @@ -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}`;} @@ -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');});}); - - - - +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');});}); \ No newline at end of file diff --git a/Mythras/pre-minified/Mythras.html b/Mythras/pre-minified/Mythras.html index 7c4372c0225..8fa46442533 100644 --- a/Mythras/pre-minified/Mythras.html +++ b/Mythras/pre-minified/Mythras.html @@ -8703,7 +8703,7 @@

Weapons

}); /* 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]; @@ -8734,17 +8734,28 @@

Weapons

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]; diff --git a/Mythras/templates/sheet_types/character/character_weapons.js b/Mythras/templates/sheet_types/character/character_weapons.js index 45279649009..2e3a599d061 100644 --- a/Mythras/templates/sheet_types/character/character_weapons.js +++ b/Mythras/templates/sheet_types/character/character_weapons.js @@ -1,6 +1,6 @@ /* 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]; @@ -31,17 +31,28 @@ on("change:repeating_meleeweapon change:repeating_rangedweapon change:_reporder: 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];