Shadowrun 5th Edition v4.15 (#6085)

* fix translation bug and white space in notes

* remove css duplicate variable

* save update Astral Init Dice function

* add back astral init

* fix edge toggle

* combine script files. Add additional unit tests

* convert unit test to QUnit. Break up pugs into tabs

* convert roll template pug, add fade/draain to chat template

* add margin above drain/fade selects

* break up scss into 7-1

* adjust css

* add user feedback

* remove obsolete css and add additiona user feedback

* move npc sheet

* reduce button highlighting change

* fix bug in with the Primary target

* refactor vehicle, add gear location

* move and fix npc sheet
This commit is contained in:
Cassie Levett
2020-04-06 14:03:28 -07:00
committed by GitHub
parent 63de2c3f53
commit 5932178ce8
81 changed files with 4357 additions and 3524 deletions
@@ -1,5 +1,4 @@
const processingFunctions = {
convertIntegerNegative: number => number > 0 ? -Math.abs(number) : number,
convertIntegersNegatives: numbers => {
@@ -34,150 +33,4 @@ const processingFunctions = {
setAttributes: (update, silent) => silent && typeof update === 'object' ? setAttrs(update, {silent:true}) : typeof update === 'object' ? setAttrs(update) : console.error(`${update} is not an object`),
sliceAttr: attribute => attribute.slice(2, -1),
sumIntegers: numbers => numbers.reduce((a,b) => a + b, 0),
shadowrun: {
addRepRow: (repRowID, attributeList) => {
let weaponAttributeWithRepeatingRow = []
attributeList.forEach(weaponAttribute => weaponAttributeWithRepeatingRow.push(`${repRowID}_${weaponAttribute}`))
return weaponAttributeWithRepeatingRow
},
attributeFactory: attrs => {
attrs = processingFunctions.shadowrun.findFlagInKeys(attrs) ? processingFunctions.shadowrun.processTempFlags(attrs) : attrs
attrs = processingFunctions.parseIntegers(attrs)
attrs = processingFunctions.shadowrun.calculateBonuses(attrs)
attrs.total = processingFunctions.sumIntegers(Object.values(attrs))
attrs.base = attrs.total - attrs.bonus
return attrs
},
conditionFactory: attrs => {
attrs.attribute = processingFunctions.shadowrun.determineConditionAttribute(attrs)
attrs.base = processingFunctions.shadowrun.determineConditionBase(attrs.sheet_type, attrs.flag_drone)
attrs.modifier = attrs[processingFunctions.shadowrun.findModifierInKeys(attrs)]
Object.keys(attrs).forEach(key => !['attribute', 'base', 'modifier'].includes(key) ? delete attrs[key] : false)
attrs = processingFunctions.parseIntegers(attrs)
return attrs
},
contructRepeatingWeaponAttributes: (repRowID, type) => {
const attributeList = processingFunctions.shadowrun.determineWeaponAttributesByType(type)
const constructedWeaponAttributes = processingFunctions.shadowrun.addRepRow(repRowID, attributeList)
return constructedWeaponAttributes
},
buildDisplay: (base, bonus) => bonus === 0 ? base : `${base} (${base + bonus})`,
calculateBonuses: attrs => {
attrs.bonus = 0
for (let [key, value] of Object.entries(attrs)) {
if (key.includes('modifier') || key.includes('temp')) {
attrs.bonus += value
delete attrs[key]
}
}
return attrs
},
calculateConditionTracks: conditionInts => Math.ceil(conditionInts.attribute/2) + conditionInts.base + conditionInts.modifier,
calculateLimitTotal: attrs => Math.ceil((attrs[0] + attrs[1] + (attrs[2] * 2))/3),
calculateRunSpeed: (agility, modifier) => (agility * 4) + modifier,
calculateWalkSpeed:(agility, modifier) => (agility * 2) + modifier,
calculateWounds: attrs => {
const divisor = attrs.low_pain_tolerance === 2 ? attrs.low_pain_tolerance : 3;
const highPain = attrs.high_pain_tolerance >= 1 ? attrs.high_pain_tolerance : 0;
let sum = 0;
["stun", "physical"].forEach(attr => {
const damageCompensator = attrs[`damage_compensators_${attr}`] || 0
let dividend = Math.max(attrs[`${attr}`] - (highPain + damageCompensator), 0)
sum -= Math.floor(dividend / divisor) || 0
})
return sum
},
convertSkillSelectToHiddenSkill: skillName => {
let skill = skillName.toLowerCase()
skill = skill.includes('group') ? skill.slice(0, -6) : skill
skill = skill.includes(" ") ? skill.replace(/ /g,"") : skill
return skill
},
determineConditionBase: (type, drone) => drone && drone === 'drone' ? 6 : type === 'vehicle' ? 12 : 8,
determineConditionAttribute: attrs => attrs.willpower ? attrs.willpower : attrs.body ? attrs.body : attrs.device_rating ? attrs.device_rating : 0,
determineWeaponAttributesByType: weaponType => weaponType === 'range' ? sheetAttributes.rangeAttributes : sheetAttributes.meleeAttributes,
findFlagInKeys: attrs => Object.keys(attrs).find(key => key.includes('_flag')),
findModifierInKeys: attrs => Object.keys(attrs).find(key => key.includes('_modifier')),
processTempFlags: attrs => {
try {
const tempFlag = processingFunctions.shadowrun.findFlagInKeys(attrs)
const attrName = tempFlag.split('_temp_flag')[0]
attrs[`${tempFlag}`] === 'on' ? false : delete attrs[`${attrName}_temp`];
delete attrs[`${tempFlag}`];
return attrs
} catch (error) {
console.error(error)
}
},
resetRepeatingFieldsPrimaries: (repeatingSection, repRowID) => {
getSectionIDs(repeatingSection, ids => {
let attributesWithIDs = [];
let update = {};
ids.forEach(id => attributesWithIDs.push(`${repeatingSection}_${id}_primary`))
attributesWithIDs.forEach(attribute => !attribute.includes(repRowID) ? update[attribute] = 0 : false)
setAttrs(update);
})
},
shotsFired: (shots, trigger) => shots > 0 && trigger.includes('remove') ? shots -= 1 : trigger.includes('add') ? shots += 1 : shots,
updateLimitTotal: attrs => {
attrs.essence ? Math.ceil(attrs.essence) || 0 : false;
return processingFunctions.shadowrun.calculateLimitTotal(Object.values(attrs))
},
resetPrimaryArmor: () => {
const resetPrimary = new PrimaryArmor()
let update = {}
for (let [key, value] of Object.entries(resetPrimary)) {
update[key] = value
}
return update
},
resetPrimaryWeapon: type => {
const resetPrimary = type === 'range' ? new PrimaryRangeWeapon(type) : new PrimaryMeleeWeapon(type)
let update = {}
for (let [key, value] of Object.entries(resetPrimary)) {
update[key] = value
}
return update
},
updatePrimaryArmor: attrs => {
let update = {}
for (let [key, value] of Object.entries(attrs)) {
const repRowID = processingFunctions.getReprowid(key)
if (key.includes('name')) {
update['armor_name'] = attrs[`${repRowID}_name`]
} else if (key.includes('rating')) {
update['armor_rating'] = value
} else if (key.includes('dicepool_modifier')) {
update['soak_modifier'] = value
} else {
const type = key.split('_')[3]
update[`${type}_modifier`] = value
}
}
return update
},
updatePrimaryWeapons: attrs => {
let update = {}
for (let [key, value] of Object.entries(attrs)) {
const type = processingFunctions.findRepeatingField(key)
const weaponAttribute = processingFunctions.getReprowAttribute(key)
const primaryAttributeName = key.includes('weapon') ? `primary_${type}_weapon` : `primary_${type}_weapon_${weaponAttribute}`
update[primaryAttributeName] = value
if (key.includes('ammo')) {
update[`${primaryAttributeName}_max`] = value
}
}
return update
}
}
}
//for Mocha Unit Texting
//module.exports = processingFunctions;