Fix DR and defense values
All checks were successful
Release Creation / build (release) Successful in 1m7s
All checks were successful
Release Creation / build (release) Successful in 1m7s
This commit is contained in:
@@ -95,6 +95,9 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
case "main":
|
||||
context.armorDR = this.actor.getArmorDR()
|
||||
context.damageReduction = this.actor.computeDamageReduction()
|
||||
context.damageReductionShield = this.actor.getShieldDR()
|
||||
break
|
||||
case "skills":
|
||||
context.tab = context.tabs.skills
|
||||
|
||||
@@ -79,7 +79,48 @@ export default class LethalFantasyActor extends Actor {
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
async prepareRoll(rollType, rollKey, rollDice ) {
|
||||
computeDamageReduction() {
|
||||
let naturalDR = Number(this.system.biodata.naturalDR) || 0
|
||||
let magicDR = Number(this.system.biodata.magicDR) || 0
|
||||
let armorDR = this.getArmorDR()
|
||||
return naturalDR + magicDR + armorDR
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
getShieldDR() {
|
||||
let dr = 0
|
||||
for (let item of this.items) {
|
||||
if (item.type === "shield" && item.system.equipped) {
|
||||
dr += Number(item.system.damageReduction)
|
||||
}
|
||||
}
|
||||
return dr
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
getArmorDR() {
|
||||
let dr = 0
|
||||
for (let item of this.items) {
|
||||
if (item.type === "armor" && item.system.equipped) {
|
||||
dr += Number(item.system.damageReduction)
|
||||
}
|
||||
}
|
||||
return dr
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
getArmorDefenseValue() {
|
||||
let defenseValue = 0
|
||||
for (let item of this.items) {
|
||||
if (item.type === "armor" && item.system.equipped) {
|
||||
defenseValue += Number(item.system.defense)
|
||||
}
|
||||
}
|
||||
return defenseValue
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
async prepareRoll(rollType, rollKey, rollDice) {
|
||||
console.log("Preparing roll", rollType, rollKey, rollDice)
|
||||
let rollTarget
|
||||
switch (rollType) {
|
||||
@@ -89,7 +130,7 @@ export default class LethalFantasyActor extends Actor {
|
||||
formula: foundry.utils.duplicate(this.system.granted[rollKey]),
|
||||
rollKey: rollKey
|
||||
}
|
||||
if ( rollTarget.formula === "" || rollTarget.formula === undefined) {
|
||||
if (rollTarget.formula === "" || rollTarget.formula === undefined) {
|
||||
rollTarget.formula = 0
|
||||
}
|
||||
break;
|
||||
@@ -126,60 +167,61 @@ export default class LethalFantasyActor extends Actor {
|
||||
rollTarget.rollKey = rollKey
|
||||
break
|
||||
case "shield-roll": {
|
||||
rollTarget = this.items.find((i) => i.type === "shield" && i.id === rollKey)
|
||||
let shieldSkill = this.items.find((i) => i.type === "skill" && i.name.toLowerCase() === rollTarget.name.toLowerCase())
|
||||
rollTarget.skill = shieldSkill
|
||||
rollTarget.rollKey = rollKey
|
||||
}
|
||||
rollTarget = this.items.find((i) => i.type === "shield" && i.id === rollKey)
|
||||
let shieldSkill = this.items.find((i) => i.type === "skill" && i.name.toLowerCase() === rollTarget.name.toLowerCase())
|
||||
rollTarget.skill = shieldSkill
|
||||
rollTarget.rollKey = rollKey
|
||||
}
|
||||
break;
|
||||
case "weapon-damage-small":
|
||||
case "weapon-damage-medium":
|
||||
case "weapon-attack":
|
||||
case "weapon-defense": {
|
||||
let weapon = this.items.find((i) => i.type === "weapon" && i.id === rollKey)
|
||||
let skill
|
||||
let skills = this.items.filter((i) => i.type === "skill" && i.name.toLowerCase() === weapon.name.toLowerCase())
|
||||
let weapon = this.items.find((i) => i.type === "weapon" && i.id === rollKey)
|
||||
let skill
|
||||
let skills = this.items.filter((i) => i.type === "skill" && i.name.toLowerCase() === weapon.name.toLowerCase())
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 1.0)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.name.toLowerCase().replace(" skill", "") === weapon.name.toLowerCase())
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 1.0)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.name.toLowerCase().replace(" skill", "") === weapon.name.toLowerCase())
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass === weapon.system.weaponClass)
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 1.0)
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.5)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass === weapon.system.weaponClass)
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass.includes(SYSTEM.WEAPON_CATEGORIES[weapon.system.weaponClass]))
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.5)
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.25)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass.includes(SYSTEM.WEAPON_CATEGORIES[weapon.system.weaponClass]))
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.25)
|
||||
} else {
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!weapon || !skill) {
|
||||
console.error("Weapon or skill not found", weapon, skill)
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
rollTarget = skill
|
||||
rollTarget.weapon = weapon
|
||||
rollTarget.weaponSkillModifier = skill.weaponSkillModifier
|
||||
rollTarget.rollKey = rollKey
|
||||
rollTarget.combat = foundry.utils.duplicate(this.system.combat)
|
||||
if ( rollType === "weapon-damage-small" || rollType === "weapon-damage-medium") {
|
||||
rollTarget.grantedDice = this.system.granted.damageDice
|
||||
}
|
||||
if ( rollType === "weapon-attack") {
|
||||
rollTarget.grantedDice = this.system.granted.attackDice
|
||||
}
|
||||
if ( rollType === "weapon-defense") {
|
||||
rollTarget.grantedDice = this.system.granted.defenseDice
|
||||
}
|
||||
}
|
||||
if (!weapon || !skill) {
|
||||
console.error("Weapon or skill not found", weapon, skill)
|
||||
ui.notifications.warn(game.i18n.localize("LETHALFANTASY.Notifications.skillNotFound"))
|
||||
return
|
||||
}
|
||||
rollTarget = skill
|
||||
rollTarget.weapon = weapon
|
||||
rollTarget.weaponSkillModifier = skill.weaponSkillModifier
|
||||
rollTarget.rollKey = rollKey
|
||||
rollTarget.combat = foundry.utils.duplicate(this.system.combat)
|
||||
if (rollType === "weapon-damage-small" || rollType === "weapon-damage-medium") {
|
||||
rollTarget.grantedDice = this.system.granted.damageDice
|
||||
}
|
||||
if (rollType === "weapon-attack") {
|
||||
rollTarget.grantedDice = this.system.granted.attackDice
|
||||
}
|
||||
if (rollType === "weapon-defense") {
|
||||
rollTarget.armorDefense = this.getArmorDefenseValue()
|
||||
rollTarget.grantedDice = this.system.granted.defenseDice
|
||||
}
|
||||
}
|
||||
break
|
||||
default:
|
||||
ui.notifications.error(game.i18n.localize("LETHALFANTASY.Notifications.rollTypeNotFound") + String(rollType))
|
||||
|
||||
@@ -134,6 +134,7 @@ export default class LethalFantasyRoll extends Roll {
|
||||
let beyondSkill = false
|
||||
let hasStaticModifier = false
|
||||
let hasExplode = true
|
||||
let actor = game.actors.get(options.actorId)
|
||||
|
||||
if (options.rollType === "challenge" || options.rollType === "save") {
|
||||
options.rollName = game.i18n.localize(`LETHALFANTASY.Label.${options.rollTarget.rollKey}`)
|
||||
@@ -209,7 +210,7 @@ export default class LethalFantasyRoll extends Roll {
|
||||
options.rollTarget.charModifier = options.rollTarget.combat.rangedAttackModifier
|
||||
}
|
||||
} else {
|
||||
options.rollTarget.value = options.rollTarget.combat.defenseModifier + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.defenseBonus
|
||||
options.rollTarget.value = options.rollTarget.combat.defenseModifier + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.defenseBonus + options.rollTarget.armorDefense
|
||||
options.rollTarget.charModifier = options.rollTarget.combat.defenseModifier
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ export default class LethalFantasyCharacter extends foundry.abstract.TypeDataMod
|
||||
magicUser: new fields.BooleanField({ initial: false }),
|
||||
clericUser: new fields.BooleanField({ initial: false }),
|
||||
hpPerLevel: new fields.StringField({ required: true, nullable: false, initial: "" }),
|
||||
naturalDR: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
magicDR: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
|
||||
})
|
||||
|
||||
schema.modifiers = new fields.SchemaField({
|
||||
|
||||
@@ -6,9 +6,10 @@ export default class LethalFantasyShield extends foundry.abstract.TypeDataModel
|
||||
const requiredInteger = { required: true, nullable: false, integer: true }
|
||||
|
||||
schema.description = new fields.HTMLField({ required: true, textSearch: true })
|
||||
schema.defense = new fields.StringField({required: true, initial: "d4", choices: SYSTEM.SHIELD_DEFENSE_DICE})
|
||||
schema.defense = new fields.StringField({ required: true, initial: "d4", choices: SYSTEM.SHIELD_DEFENSE_DICE })
|
||||
schema.movementreduction = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
schema.hascover = new fields.BooleanField({ required: true, initial: false })
|
||||
schema.damageReduction = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
|
||||
|
||||
schema.standing = new fields.SchemaField({
|
||||
min: new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }),
|
||||
|
||||
Reference in New Issue
Block a user