Enhance progression rolls, damage rolls and other fixes
Some checks failed
Release Creation / build (release) Failing after 56s

This commit is contained in:
2025-06-12 20:53:54 +02:00
parent 17be9df64b
commit c08a8c38e9
35 changed files with 1630 additions and 282 deletions

View File

@ -84,7 +84,7 @@ export default class CthulhuEternalRoll extends Roll {
return this.options.isNudgedRoll
}
get wpCost() {
get wpCost() {
return this.options.wpCost
}
@ -146,43 +146,48 @@ export default class CthulhuEternalRoll extends Roll {
options.rollItem.enableStorage = true
options.isNudge = false
break
case "damage":
case "damage": {
let isLethal = false
options.isNudge = false
if (options.rollItem.system.lethality > 0) {
let lethalityRoll = new Roll("1d100")
await lethalityRoll.evaluate()
isLethal = (lethalityRoll.total <= options.rollItem.system.lethality)
let flavor = `${options.rollItem.name} - <strong>Lethality Roll</strong> : ${lethalityRoll.total} <= ${options.rollItem.system.lethality} => ${isLethal}`
if ( isLethal) {
flavor += `<br>The target is lethally wounded => HP = 0`
let lethalScore = (options?.previousResultType === "successCritical") ? options.rollItem.system.lethality * 2 : options.rollItem.system.lethality
isLethal = (lethalityRoll.total <= lethalScore)
let flavor = `${options.rollItem.name} - <strong> ${game.i18n.localize("CTHULHUETERNAL.Label.lethalityRoll")} </strong> : ${lethalityRoll.total} <= ${lethalScore} => ${isLethal}`
if (isLethal) {
flavor += `<br> ${game.i18n.localize("CTHULHUETERNAL.Label.lethalityWounded")} => HP = 0`
} else {
let wounds = Math.floor(lethalityRoll.total/10) + (lethalityRoll.total % 10)
flavor += `<br>The target is not lethally wounded => HP loss = ${wounds}`
let wounds = Math.floor(lethalityRoll.total / 10) + (lethalityRoll.total % 10)
flavor += `<br> ${game.i18n.localize("CTHULHUETERNAL.Label.lethalityNotWounded")} => HP loss = ${wounds}`
}
await lethalityRoll.toMessage({
flavor:flavor
flavor: flavor
});
return
}
let formula = options.rollItem.system.damage
if ( options.rollItem.system.weaponType === "melee" || options.rollItem.system.weaponType === "unarmed") {
if (options.rollItem.system.weaponType === "melee" || options.rollItem.system.weaponType === "unarmed") {
formula += ` + ${options.rollItem.damageBonus}`
}
if (options?.previousResultType === "successCritical") {
formula = `( ${formula} ) * 2`
}
let damageRoll = new Roll(formula)
await damageRoll.evaluate()
await damageRoll.toMessage({
flavor: `${options.rollItem.name} - Damage Roll`
flavor: `${options.rollItem.name} - ${game.i18n.localize("CTHULHUETERNAL.Label.damageRoll")}`
});
}
return
case "weapon":
case "weapon": {
let era = game.settings.get("fvtt-cthulhu-eternal", "settings-era")
if (era !== options.rollItem.system.settings) {
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.WrongEra"))
console.log("WP Wrong Era", era, options.rollItem.system.weaponType)
return
}
if (!SYSTEM.WEAPON_SKILL_MAPPING[era] || !SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType]) {
if (!SYSTEM.WEAPON_SKILL_MAPPING[era]?.[options.rollItem.system.weaponType]) {
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.NoWeaponType"))
console.log("WP Not found", era, options.rollItem.system.weaponType)
return
@ -190,7 +195,7 @@ export default class CthulhuEternalRoll extends Roll {
options.weapon = options.rollItem
if (options.rollItem.system.hasDirectSkill) {
let skillName = options.rollItem.name
options.rollItem = {type: "skill", name: skillName, system: {base: 0, bonus: options.weapon.system.directSkillValue} }
options.rollItem = { type: "skill", name: skillName, system: { base: 0, bonus: options.weapon.system.directSkillValue } }
options.initialScore = options.weapon.system.directSkillValue
} else {
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
@ -203,6 +208,7 @@ export default class CthulhuEternalRoll extends Roll {
options.initialScore = options.rollItem.system.computeScore()
console.log("WEAPON", skillName, era, options.rollItem)
}
}
break
default:
options.initialScore = 50
@ -343,6 +349,20 @@ export default class CthulhuEternalRoll extends Roll {
resultType = "failureCritical"
}
}
// As per the rules, a roll of 100 is always a failure, even if the target is above 100
if (this.total === 100) {
resultType = "failureCritical"
}
// A roll of 1 is always a critical success, even if the target is 1
if (this.total === 1) {
resultType = "successCritical"
}
if (rollData.targetScore <= 0) {
resultType = "failure"
if (this.total === 1) {
resultType = "success"
}
}
this.options.resultType = resultType
if (this.options.isNudgedRoll) {
@ -354,6 +374,7 @@ export default class CthulhuEternalRoll extends Roll {
this.options.isFailure = resultType === "failure" || resultType === "failureCritical"
this.options.isCritical = resultType === "successCritical" || resultType === "failureCritical"
}
rollData.resultType = resultType
this.options.isLowWP = rollData.isLowWP
this.options.isZeroWP = rollData.isZeroWP
this.options.isExhausted = rollData.isExhausted
@ -377,6 +398,8 @@ export default class CthulhuEternalRoll extends Roll {
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleCharacteristic")}`
case "san":
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleSAN")}`
case "resource":
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleResource")}`
default:
return game.i18n.localize("CTHULHUETERNAL.Label.titleStandard")
}
@ -462,6 +485,33 @@ export default class CthulhuEternalRoll extends Roll {
},
{ rollMode: rollMode },
)
console.log("Roll to message", this.options, this.options.rollData, this.options.rollItem)
let rollData = this.options.rollData || this.options
let rollItem = this.options.rollItem
if (rollData.resultType.includes("failure") && rollItem.type === "skill") {
// Is the skill able to progress
if (rollItem.system.diceEvolved && !rollItem.system.rollFailed) {
// If the skill is not adversary, we can evolve it
if (!rollItem.system.isAdversary) {
rollItem.system.rollFailed = true
// Get the actor and update the skill
const actor = game.actors.get(rollData.actorId)
await actor.updateEmbeddedDocuments("Item", [{
_id: rollItem._id,
"system.rollFailed": true
}])
// Create a chat message to inform the user
const flavor = `${rollItem.name} - ${game.i18n.localize("CTHULHUETERNAL.Label.skillFailed")}`
await ChatMessage.create({
user: game.user.id,
content: `<div class="cthulhu-eternal-roll"><p>${flavor}</p></div>`,
speaker: ChatMessage.getSpeaker({ actor: rollData.actor }),
}, { rollMode: rollData.rollMode, create: true })
}
}
}
}
}