Attempt to add HUD core
This commit is contained in:
@@ -142,7 +142,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
let combatants = []
|
||||
if (game?.combat?.combatants) {
|
||||
for (let c of game.combat.combatants) {
|
||||
if (c.actor.id !== actor.id) {
|
||||
if (c.actorid !== actor.id) {
|
||||
combatants.push({ id: c.id, name: c.name })
|
||||
}
|
||||
}
|
||||
@@ -210,8 +210,8 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
modifier += SYSTEM.WEAPON_VISIBILITY[rollData.visibilityChoice]?.modifier || 0
|
||||
modifier += SYSTEM.WEAPON_ATTACKER_STATE[rollData.attackerStateChoice]?.modifier || 0
|
||||
modifier += SYSTEM.WEAPON_TARGET_SIZE[rollData.targetSizeChoice]?.modifier || 0
|
||||
modifier += (rollData.aimingLastRound) ? 20 : 0
|
||||
modifier += (rollData.aimingWithSight) ? 20 : 0
|
||||
modifier += (rollData.aimingLastRoundFlag) ? 20 : 0
|
||||
modifier += (rollData.aimingWithSightFlag) ? 20 : 0
|
||||
return modifier
|
||||
}
|
||||
|
||||
@@ -298,9 +298,9 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
console.log("WP Not found", era, options.rollItem.system.weaponType)
|
||||
return
|
||||
}
|
||||
if (!target) {
|
||||
/*if (!target) {
|
||||
ui.notifications.warn(game.i18n.localize("CTHULHUETERNAL.Notifications.AttackNoTarget"))
|
||||
}
|
||||
}*/
|
||||
// Check if the weapon has enouth ammo in case of a firearm
|
||||
if (options.rollItem.system.isFireArm() && options.rollItem.system.ammo.value <= 0) {
|
||||
ui.notifications.warn(game.i18n.localize("CTHULHUETERNAL.Notifications.NoAmmo"))
|
||||
@@ -308,20 +308,9 @@ 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.initialScore = options.weapon.system.directSkillValue
|
||||
} else {
|
||||
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
|
||||
options.rollItem = actor.items.find(i => i.type === "skill" && i.name.toLowerCase() === skillName.toLowerCase())
|
||||
if (!options.rollItem) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.NoWeaponSkill"))
|
||||
return
|
||||
}
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
console.log("WEAPON", skillName, era, options.rollItem)
|
||||
}
|
||||
options.rollItem = CthulhuEternalUtils.getWeaponSkill(actor, options.rollItem, era)
|
||||
options.initialScore = options.rollItem.system.skillTotal
|
||||
console.log("WEAPON", era, options.rollItem)
|
||||
}
|
||||
break
|
||||
default:
|
||||
@@ -374,8 +363,8 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
visibilityChoice: "clear",
|
||||
attackerStateChoice: "normal",
|
||||
targetSizeChoice: "normal",
|
||||
aimingLastRound: false,
|
||||
aimingWithSight: false,
|
||||
aimingLastRoundFlag: false,
|
||||
aimingWithSightFlag: false,
|
||||
modifier,
|
||||
formula,
|
||||
targetName: target?.name,
|
||||
@@ -424,6 +413,14 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
options.multiplier = Number(event.target.value)
|
||||
this.updateResourceDialog(options)
|
||||
})
|
||||
$(".aimingLastRound").change(event => {
|
||||
options.aimingLastRoundFlag = event.target.checked
|
||||
this.updateResourceDialog(options)
|
||||
})
|
||||
$(".aimingWithSight").change(event => {
|
||||
options.aimingWithSightFlag = event.target.checked
|
||||
this.updateResourceDialog(options)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -526,6 +523,8 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
rollData.isFailure = this.options.isFailure
|
||||
rollData.isCritical = this.options.isCritical
|
||||
rollData.resultType = resultType
|
||||
rollData.rollResult = this.total
|
||||
rollData.total = this.total
|
||||
this.options.rollData = foundry.utils.duplicate(rollData)
|
||||
|
||||
// Keep track of the last defense roll for the actor
|
||||
@@ -553,7 +552,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
|
||||
compareRolls(attackRoll, defenseRoll) {
|
||||
if (!defenseRoll || defenseRoll.round !== game?.combat?.round) {
|
||||
ui.notifications.info(game.i18n.localize("CTHULHUETERNAL.Notifications.NoDefenseRoll"))
|
||||
// ui.notifications.info(game.i18n.localize("CTHULHUETERNAL.Notifications.NoDefenseRoll"))
|
||||
return
|
||||
}
|
||||
if (attackRoll.isFailure) {
|
||||
@@ -677,7 +676,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
* @returns {Promise} - A promise that resolves when the message is created.
|
||||
*/
|
||||
async toMessage(messageData = {}, { rollMode, create = true } = {}) {
|
||||
super.toMessage(
|
||||
let rollMsg = await super.toMessage(
|
||||
{
|
||||
isFailure: this.resultType === "failure",
|
||||
actingCharName: this.actorName,
|
||||
@@ -688,10 +687,11 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
},
|
||||
{ rollMode: rollMode },
|
||||
)
|
||||
|
||||
// Manage the skill evolution if the roll is a failure
|
||||
let rollData = this.options.rollData || this.options
|
||||
let rollItem = this.options.rollItem
|
||||
await rollMsg.setFlag("fvtt-cthulhu-eternal", "rollData", rollData)
|
||||
|
||||
// Manage the skill evolution if the roll is a failure
|
||||
if (rollData.resultType.includes("failure") && rollItem.type === "skill") {
|
||||
// Is the skill able to progress
|
||||
if (rollItem.system.diceEvolved && !rollItem.system.rollFailed) {
|
||||
|
||||
Reference in New Issue
Block a user