Manage DR and damage roll
This commit is contained in:
@@ -65,7 +65,7 @@ export default class LethalFantasyActor extends Actor {
|
||||
}
|
||||
}
|
||||
}
|
||||
goodSkill.weaponSkillModifier = maxValue * multiplier
|
||||
goodSkill.weaponSkillModifier = Math.ceil(maxValue * multiplier)
|
||||
return goodSkill
|
||||
}
|
||||
|
||||
@@ -119,6 +119,27 @@ export default class LethalFantasyActor extends Actor {
|
||||
return defenseValue
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
fuzzyNameSearchWeaponSkills(weaponName, weaponClass=null) {
|
||||
// Get all weapon skills without the " skill" suffix
|
||||
let skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass === weaponClass && i.system.category === "weapon")
|
||||
// Remove parenthesis in the weapon name for better matching
|
||||
weaponName = weaponName.replace(/\(.*?\)/g, "").trim()
|
||||
// Now search if we find all the words of the weapon name in the skill name
|
||||
skills = skills.filter((s) => {
|
||||
let skillName = s.name.toLowerCase().replace(" skill", "").trim()
|
||||
let wName = weaponName.toLowerCase().trim()
|
||||
let wWords = wName.split(" ")
|
||||
for (let w of wWords) {
|
||||
if (!skillName.includes(w)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
return skills
|
||||
}
|
||||
|
||||
/* *************************************************/
|
||||
async prepareRoll(rollType, rollKey, rollDice) {
|
||||
console.log("Preparing roll", rollType, rollKey, rollDice)
|
||||
@@ -179,19 +200,19 @@ export default class LethalFantasyActor extends Actor {
|
||||
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 skills = this.items.filter((i) => i.type === "skill" && i.system.category === "weapon" && 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())
|
||||
skills = this.fuzzyNameSearchWeaponSkills(weapon.name, weapon.system.weaponClass)
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 1.0)
|
||||
} 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.category === "weapon" && i.system.weaponClass === weapon.system.weaponClass)
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.5)
|
||||
} else {
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.weaponClass.includes(SYSTEM.WEAPON_CATEGORIES[weapon.system.weaponClass]))
|
||||
skills = this.items.filter((i) => i.type === "skill" && i.system.category === "weapon" && i.system.weaponClass.includes(SYSTEM.WEAPON_CATEGORIES[weapon.system.weaponClass]))
|
||||
if (skills.length > 0) {
|
||||
skill = this.getBestWeaponClassSkill(skills, rollType, 0.25)
|
||||
} else {
|
||||
|
||||
@@ -260,14 +260,17 @@ export default class LethalFantasyRoll extends Roll {
|
||||
|
||||
} else if (options.rollType.includes("weapon-damage")) {
|
||||
options.rollName = options.rollTarget.name
|
||||
options.isDamage = true
|
||||
hasModifier = true
|
||||
hasChangeDice = false
|
||||
let damageBonus = (options.rollTarget.weapon.system.applyStrengthDamageBonus) ? options.rollTarget.combat.damageModifier : 0
|
||||
options.rollTarget.value = damageBonus + options.rollTarget.weaponSkillModifier + options.rollTarget.weapon.system.bonuses.damageBonus
|
||||
options.rollTarget.charModifier = damageBonus
|
||||
if (options.rollType.includes("small")) {
|
||||
options.damageSmall = true
|
||||
dice = options.rollTarget.weapon.system.damage.damageS
|
||||
} else {
|
||||
options.damageMedium = true
|
||||
dice = options.rollTarget.weapon.system.damage.damageM
|
||||
}
|
||||
dice = dice.replace("E", "")
|
||||
@@ -474,6 +477,9 @@ export default class LethalFantasyRoll extends Roll {
|
||||
actorImage: options.actorImage,
|
||||
rollMode: rollContext.visibility,
|
||||
hasTarget: options.hasTarget,
|
||||
isDamage: options.isDamage,
|
||||
damageSmall: options.damageSmall,
|
||||
damageMedium: options.damageMedium,
|
||||
pointBlank,
|
||||
beyondSkill,
|
||||
letItFly,
|
||||
@@ -1123,6 +1129,16 @@ export default class LethalFantasyRoll extends Roll {
|
||||
* Generates the data required for rendering a roll chat card.
|
||||
*/
|
||||
async _getChatCardData(isPrivate) {
|
||||
// Générer la liste des combatants de la scène
|
||||
let combatants = []
|
||||
if (game?.combat?.combatants && this.rollData?.isDamage) {
|
||||
for (let c of game.combat.combatants) {
|
||||
if (c.actorId !== this.actorId) {
|
||||
combatants.push({ id: c.id, name: c.name })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const cardData = {
|
||||
css: [SYSTEM.id, "dice-roll"],
|
||||
data: this.data,
|
||||
@@ -1146,7 +1162,8 @@ export default class LethalFantasyRoll extends Roll {
|
||||
D30result: this.D30result,
|
||||
badResult: this.badResult,
|
||||
rollData: this.rollData,
|
||||
isPrivate: isPrivate
|
||||
isPrivate: isPrivate,
|
||||
combatants: combatants
|
||||
}
|
||||
cardData.cssClass = cardData.css.join(" ")
|
||||
cardData.tooltip = isPrivate ? "" : await this.getTooltip()
|
||||
|
||||
Reference in New Issue
Block a user