Skip to content

Commit

Permalink
Better dex handling
Browse files Browse the repository at this point in the history
  • Loading branch information
jbblanchet committed May 20, 2024
1 parent 4c47f89 commit 4245028
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 73 deletions.
16 changes: 8 additions & 8 deletions src/shapes/aerial.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FORM_AERIAL, SIZE_MEDIUM, SIZE_HUGE, SIZE_LARGE } from "./constants"
import { getDexAttackModifier } from "./utils"
import { getAthleticsModifier, getDexAttackModifier } from "./utils"

const baseAerialForms = [{
id: 'Bat',
Expand Down Expand Up @@ -31,7 +31,7 @@ const baseAerialForms = [{
diceDamage: 11.5,
}]

function scaleAerialForm (baseForm, level, attackModifier, athleticsModifer) {
function scaleAerialForm (baseForm, level) {
const form = {
type: FORM_AERIAL,
size: SIZE_MEDIUM,
Expand All @@ -41,8 +41,8 @@ function scaleAerialForm (baseForm, level, attackModifier, athleticsModifer) {
lowLight: true,
...(baseForm.senses || {}),
},
attackModifier: getDexAttackModifier(attackModifier, 16),
athletics: athleticsModifer,
attackModifier: getDexAttackModifier(level, 16),
athletics: getAthleticsModifier(level, 0),
damageBonus: 5,
reach: 5,
...baseForm,
Expand All @@ -55,7 +55,7 @@ function scaleAerialForm (baseForm, level, attackModifier, athleticsModifer) {
form.reach = 10
form.armorClass = 21 + level
form.tempHitPoints = 15
form.attackModifier = getDexAttackModifier(attackModifier, 21)
form.attackModifier = getDexAttackModifier(level, 21)
form.damageBonus = 4
form.diceDamage *= 2
if (form.agileDiceDamage) {
Expand All @@ -66,14 +66,14 @@ function scaleAerialForm (baseForm, level, attackModifier, athleticsModifer) {
form.size = SIZE_LARGE
form.fly += 10
form.tempHitPoints = 10
form.attackModifier = getDexAttackModifier(attackModifier, 18)
form.attackModifier = getDexAttackModifier(level, 18)
form.damageBonus = 8
break;
}

return form
}

export default function scaleAerialForms (level, attackModifier, athleticsModifer) {
return baseAerialForms.map(form => scaleAerialForm(form, level, attackModifier, athleticsModifer))
export default function scaleAerialForms (level) {
return baseAerialForms.map(form => scaleAerialForm(form, level))
}
14 changes: 7 additions & 7 deletions src/shapes/animal.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const baseAnimalForms = [{
diceDamage: 8.5,
}]

function scaleAnimalForm (baseForm, level, attackModifier, athleticsModifer) {
function scaleAnimalForm (baseForm, level) {
const form = {
type: FORM_ANIMAL,
armorClass: 16 + level,
Expand All @@ -56,8 +56,8 @@ function scaleAnimalForm (baseForm, level, attackModifier, athleticsModifer) {
lowLight: true,
impreciseScent: 30
},
athletics: getAthleticsModifier(athleticsModifer, 9),
attackModifier: getAttackModifier(attackModifier, 9),
athletics: getAthleticsModifier(level, 9),
attackModifier: getAttackModifier(level, 9),
damageBonus: 1,
reach: 5,
...baseForm,
Expand All @@ -69,18 +69,18 @@ function scaleAnimalForm (baseForm, level, attackModifier, athleticsModifer) {
form.reach = 15
form.tempHitPoints = 20
form.armorClass = 18 + level
form.attackModifier = getAttackModifier(attackModifier, 18)
form.attackModifier = getAttackModifier(level, 18)
form.damageBonus = 7
form.diceDamage *= 2
if (form.agileDiceDamage) {
form.agileDiceDamage *= 2
}
form.athletics = getAthleticsModifier(athleticsModifer, 20)
form.athletics = getAthleticsModifier(level, 20)
}

return form
}

export default function scaleAnimalForms (level, attackModifier, athleticsModifer) {
return baseAnimalForms.map(form => scaleAnimalForm(form, level, attackModifier, athleticsModifer))
export default function scaleAnimalForms (level) {
return baseAnimalForms.map(form => scaleAnimalForm(form, level))
}
18 changes: 9 additions & 9 deletions src/shapes/dinosaur.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const baseDinosaurForms = [{
criticalDamage: 6.5,
}]

function scaleDinosaurForm (baseForm, level, attackModifier, athleticsModifer) {
function scaleDinosaurForm (baseForm, level) {
const form = {
type: FORM_DINOSAUR,
armorClass: 18 + level,
Expand All @@ -45,8 +45,8 @@ function scaleDinosaurForm (baseForm, level, attackModifier, athleticsModifer) {
lowLight: true,
impreciseScent: 30
},
athletics: getAthleticsModifier(athleticsModifer, 18),
attackModifier: getAttackModifier(attackModifier, 16),
athletics: getAthleticsModifier(level, 18),
attackModifier: getAttackModifier(level, 16),
damageBonus: 9,
reach: 5,
...baseForm
Expand All @@ -58,10 +58,10 @@ function scaleDinosaurForm (baseForm, level, attackModifier, athleticsModifer) {
form.reach = form.Reach >= 15 ? 25 : 20
form.tempHitPoints = 25
form.armorClass = 21 + level
form.attackModifier = getAttackModifier(attackModifier, 25)
form.attackModifier = getAttackModifier(level, 25)
form.damageBonus = 15
form.diceDamage *= 2
form.athletics = getAthleticsModifier(athleticsModifer, 25)
form.athletics = getAthleticsModifier(level, 25)
if (form.agileDiceDamage) {
form.agileDiceDamage *= 2
}
Expand All @@ -70,10 +70,10 @@ function scaleDinosaurForm (baseForm, level, attackModifier, athleticsModifer) {
form.size = SIZE_HUGE
form.reach = form.Reach >= 15 ? 20 : 15
form.tempHitPoints = 20
form.attackModifier = getAttackModifier(attackModifier, 18)
form.attackModifier = getAttackModifier(level, 18)
form.damageBonus = 6
form.diceDamage *= 2
form.athletics = getAthleticsModifier(athleticsModifer, 21)
form.athletics = getAthleticsModifier(level, 21)
if (form.agileDiceDamage) {
form.agileDiceDamage *= 2
}
Expand All @@ -82,6 +82,6 @@ function scaleDinosaurForm (baseForm, level, attackModifier, athleticsModifer) {
return form
}

export default function scaleDinosaurForms (level, attackModifier, athleticsModifer) {
return baseDinosaurForms.map(form => scaleDinosaurForm(form, level, attackModifier, athleticsModifer))
export default function scaleDinosaurForms (level) {
return baseDinosaurForms.map(form => scaleDinosaurForm(form, level))
}
10 changes: 5 additions & 5 deletions src/shapes/dragon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FORM_DRAGON, SIZE_LARGE, SIZE_HUGE } from "./constants"
import { getAttackModifier, getAthleticsModifier } from "./utils"

export default function scaleDragonForm (level, attackModifier, athleticsModifer) {
export default function scaleDragonForm (level) {
const form = {
id: 'Dragon',
type: FORM_DRAGON,
Expand All @@ -15,8 +15,8 @@ export default function scaleDragonForm (level, attackModifier, athleticsModifer
lowLight: true,
impreciseScent: 60
},
athletics: getAthleticsModifier(athleticsModifer, 23),
attackModifier: getAttackModifier(attackModifier, 22),
athletics: getAthleticsModifier(level, 23),
attackModifier: getAttackModifier(level, 22),
damageBonus: 6,
diceDamage: 20,
agileDiceDamage: 16.5,
Expand All @@ -29,9 +29,9 @@ export default function scaleDragonForm (level, attackModifier, athleticsModifer
form.reach = 10
form.tempHitPoints = 15
form.armorClass = 21 + level
form.attackModifier = getAttackModifier(attackModifier, 28)
form.attackModifier = getAttackModifier(level, 28)
form.damageBonus = 12
form.athletics = getAttackModifier(attackModifier, 28)
form.athletics = getAttackModifier(level, 28)
}

return form
Expand Down
39 changes: 4 additions & 35 deletions src/shapes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,11 @@ import scaleAnimalForms from "./animal"
import scaleAerialForms from "./aerial"
import scaleDragonForm from "./dragon"

function getBaseAttackModifiers (level) {
const proficiency = 4
let strength = 4
let rune = 2

if (level >= 15) {
strength++
}

if (level >= 16) {
rune++
}

return level + proficiency + strength + rune
}

function getBaseAthleticsModifiers (level) {
const proficiency = 2
let strength = 4

if (level >= 15) {
strength++
}

return level + proficiency + strength
}


export default function listForms (level) {
const attackModifier = getBaseAttackModifiers(level)
const athleticsModifier = getBaseAthleticsModifiers(level)

return [
...scaleAnimalForms(level, attackModifier, athleticsModifier),
...scaleAerialForms(level, attackModifier, athleticsModifier),
...scaleDinosaurForms(level, attackModifier, athleticsModifier),
scaleDragonForm(level, attackModifier, athleticsModifier),
...scaleAnimalForms(level),
...scaleAerialForms(level),
...scaleDinosaurForms(level),
scaleDragonForm(level),
]
}
64 changes: 55 additions & 9 deletions src/shapes/utils.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,63 @@
export function getAttackModifier (attackModifier, base) {
if (attackModifier > base) {
export function getAttackModifier (level, formValue) {
const attackModifier = getBaseAttackModifiers(level)
if (attackModifier > formValue) {
return attackModifier + 2
}
return base
return formValue
}

export function getDexAttackModifier (attackModifier, base) {
if (attackModifier - 1 > base) {
return attackModifier + 1
export function getDexAttackModifier (level, formValue) {
const attackModifier = getBaseDexAttackModifiers(level)
if (attackModifier > formValue) {
return attackModifier + 2
}
return base
return formValue
}

export function getAthleticsModifier (level, formValue) {
const modifier = getBaseAthleticsModifiers(level)
return modifier > formValue ? modifier : formValue
}

export function getAthleticsModifier (modifier, base) {
return modifier > base ? modifier : base
function getBaseAttackModifiers (level) {
const proficiency = 4
let strength = 4
let rune = 2

if (level >= 15) {
strength++
}

if (level >= 16) {
rune++
}

return level + proficiency + strength + rune
}

function getBaseDexAttackModifiers (level) {
const proficiency = 4
let dexterity = 4
let rune = 2

if (level >= 20) {
dexterity++
}

if (level >= 16) {
rune++
}

return level + proficiency + dexterity + rune
}

function getBaseAthleticsModifiers (level) {
const proficiency = 2
let strength = 4

if (level >= 15) {
strength++
}

return level + proficiency + strength
}

0 comments on commit 4245028

Please sign in to comment.