diff --git a/BESM4eExtras/BESM4eExtras.css b/BESM4eExtras/BESM4eExtras.css
index db17d51dcd..7d852f3ce9 100644
--- a/BESM4eExtras/BESM4eExtras.css
+++ b/BESM4eExtras/BESM4eExtras.css
@@ -876,8 +876,9 @@ span.sheet-targeted-inactive{
line-height: 16px;
border: 1px solid;
}
-
+/*
.repcontrol[data-groupname="repeating_skill"] > .repcontrol_add,
+*/
input[class="templateradio"],
input[name="attr_damagetypeenable"],
input[name="attr_rollable"],
diff --git a/BESM4eExtras/BESM4eExtras.html b/BESM4eExtras/BESM4eExtras.html
index b270008820..6b651b3445 100644
--- a/BESM4eExtras/BESM4eExtras.html
+++ b/BESM4eExtras/BESM4eExtras.html
@@ -30,7 +30,7 @@
Sheet Options
+
@@ -8900,8 +8965,9 @@
function getSkillCost(debug, timer, value, name){
const json = JSON.parse(global_templates_skills_json);
const skills = json.template;
+ const capName = capital(name);
const skill = _.find(skills, s => {
- const result = s.name == name ? true : false;
+ const result = s.name === capName ? true : false;
return result;
});
const game_genre = parseInt(value.static_options_selection_gamegenre) || 0;
@@ -13563,7 +13629,7 @@
setDamageLevelByDamageTaken(debug, timer, value, setObj, 'fatigue');
}
- function getStatStateArray(debug, timer, value, sourceAttr, setObj, type, source = '') {
+ function getStatStateArray(debug, timer, value, setObj, type, source = '') {
const stats = type.major == 1 ? major_stats_array : allaspects_stats_array;
const skill = source.length > 0 ? `${source}_` : '';
let result = [];
@@ -13611,7 +13677,7 @@
}
function getStatRollBase(debug, timer, value, sourceAttr, setObj, type, source = '') {
- const statStates = getStatStateArray(debug, timer, value, sourceAttr, setObj, type, source);
+ const statStates = getStatStateArray(debug, timer, value, setObj, type, source);
const statValues = getStatValuesArray(value, type);
const denominator = getStateDenominator(statStates);
const base = getActivatedStatsBase(debug, timer, statStates, statValues, denominator);
@@ -13755,7 +13821,7 @@
const groupcost = parseInt(value[`static_skillgroup_${groupID}_groupcost`]) || 0;
setObj[`static_skillgroup_${groupID}_groupcost`] = groupcost + cost;
}
-
+ /*
function createSkill(debug, timer, value, skillmap, rowID, setObj){
const json = JSON.parse(global_templates_skills_json);
const skills = json.template;
@@ -13799,6 +13865,69 @@
value.skillIDs = value.skillIDs.push(skillID.toLowerCase());
setObj.skillmanagement = 0;
}
+ */
+ function setSkill(debug, timer, eventInfo, value, rowID, setObj) {
+ const json = JSON.parse(global_templates_skills_json);
+ const skills = json.template;
+ const temp = {};
+ clog(debug, timer, '', temp, 'setSkill()');
+ temp.level = parseInt(value[`repeating_skill_${rowID}_level`]) || 0;
+ if (temp.level !== 0) {
+ writeValues(debug, timer, value, `repeating_skill_${rowID}_name`, eventInfo.previousValue, setObj);
+ return;
+ }
+ if (eventInfo.newValue === undefined) {
+ temp.clear_skill_attributes = ['skillspecilizations','majorstats','minorstats','stat','skillrollvalue'];
+ _.each(temp.clear_skill_attributes, (a,i) => {
+ writeValues(debug, timer, value, `repeating_skill_${rowID}_${a}`, '', setObj);
+ });
+ return;
+ }
+ temp.name = capital(eventInfo.newValue);
+ temp.group = getGroupID(value, 'skill');
+ temp.skill =
+ _.find(skills, s => {
+ if (s.name === temp.name) return true;
+ });
+ temp.game_genre = parseInt(value.static_options_selection_gamegenre) || 0;
+ temp.cost = temp.skill.cost[temp.game_genre];
+ temp.statarray = temp.skill.statallaspect.concat(temp.skill.statmajor);
+ temp.type = getStatType(value);
+ _.each(temp.statarray,stat=>{
+ writeValues(debug, timer, value, `repeating_skill_${rowID}_${stat}state`, 1 , setObj);
+ });
+ temp.disabledStats = _.chain(all_stats_array)
+ .map(s => {
+ if(temp.statarray.indexOf(s) === -1) return s;
+ })
+ .compact().value();
+ _.each(temp.disabledStats, s => {
+ writeValues(debug, timer, value, `repeating_skill_${rowID}_${s}state`, 0 , setObj);
+ });
+ temp.stats = temp.type.major==1 ? temp.skill.statmajor: temp.skill.statallaspect;
+ temp.sum = _.chain(temp.stats)
+ .map(stat=>{
+ return parseInt(value[`stat_total_${stat}`]) || 0;
+ })
+ .reduce((memo,stat)=>{
+ return memo + stat;
+ })
+ .value();
+ temp.base = Math.round(temp.sum / temp.stats.length);
+ temp.roll = `&{template:besmDefault} {{rolls=1}} {{skillroll=1}} ` +
+ `{{title=Skill Roll}} {{character_name=@{charactername}}} ` +
+ `{{pronoun=@{pronoun}}} {{skill=${temp.name}}} {{level=0}} ` +
+ `{{base=${temp.base}}} {{total=[[ [[?{Roll is|Normal, 2d6|` +
+ `Minor Edge, 3d6kh2|Minor Obstacle, 3d6kl2|Major Edge, 4d6kh2|` +
+ `Major Obstacle, 4d6kl2}]] + [[${temp.base}]] ]]}} {{roll=$[[0]]}}`;
+ temp.skill_attributes = ['group','skillspecilizations','majorstats','minorstats','stat','skillrollvalue'];
+ temp.skill_attributes_values = [temp.group, temp.skill.specializations, temp.type.major, temp.type.minor, getSkillStatsDisplay(temp.stats), temp.roll];
+ _.each(temp.skill_attributes, (a,i) => {
+ writeValues(debug, timer, value, `repeating_skill_${rowID}_${a}`, temp.skill_attributes_values[i], setObj);
+ });
+ value.skillIDs = value.skillIDs.push(rowID);
+ setObj.skillmanagement = 0;
+ }
function buildSkillTemplateValuesArray(skilltemplateIDs){
if (skilltemplateIDs !== undefined) {
@@ -14285,6 +14414,9 @@
setSkillCostByRankChange(debug, timer, skillIDs, value, rowID, setObj);
setSkillRoll(debug, timer, value, source, rowID, sourceAttr, level, setObj, type);
break;
+ case 'name':
+ setSkill(debug, timer, eventInfo, value, rowID, setObj);
+ break;
case 'specializations':
setSkillCostBySpecilizationChange(debug, timer, skillIDs, eventInfo, value, sectionName, rowID, setObj);
break;