Initial release

This commit is contained in:
LeRatierBretonnien 2025-01-04 22:24:39 +01:00
parent 15f512ea3a
commit b44ac05b1e
10 changed files with 73 additions and 26 deletions

View File

@ -98,7 +98,6 @@ Hooks.once("init", function () {
const type = anchor.dataset.rollType const type = anchor.dataset.rollType
const target = anchor.dataset.rollTarget const target = anchor.dataset.rollTarget
const title = anchor.dataset.rollTitle const title = anchor.dataset.rollTitle
const avantage = anchor.dataset.rollAvantage
}) })
console.info("CTHULHU ETERNAL | System Initialized") console.info("CTHULHU ETERNAL | System Initialized")

View File

@ -92,6 +92,9 @@
"RangedWeapons": "Ranged Weapons", "RangedWeapons": "Ranged Weapons",
"FirearmsBeams": "Firearms / Beam Weapons", "FirearmsBeams": "Firearms / Beam Weapons",
"FIELDS": { "FIELDS": {
"isAdversary": {
"label": "Adversary"
},
"settings": { "settings": {
"label": "Settings era" "label": "Settings era"
}, },
@ -253,6 +256,8 @@
"veryHarsh": "Very Harsh" "veryHarsh": "Very Harsh"
}, },
"Label": { "Label": {
"titleSkill": "Skill",
"titleWeapon": "Weapon",
"biodata": "Biodata", "biodata": "Biodata",
"skill": "Skill", "skill": "Skill",
"modifier": "Modifier", "modifier": "Modifier",

View File

@ -53,7 +53,7 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
/** /**
* Prepare an array of form header tabs. * Prepare an array of form header tabs.
* @returns {Record<string, Partial<ApplicationTab>>} * @returns {Record<string, Partial<ApplicationTab>>}
*/ */
#getTabs() { #getTabs() {
const tabs = { const tabs = {
skills: { id: "skills", group: "sheet", icon: "fa-solid fa-shapes", label: "CTHULHUETERNAL.Label.skills" }, skills: { id: "skills", group: "sheet", icon: "fa-solid fa-shapes", label: "CTHULHUETERNAL.Label.skills" },
@ -185,9 +185,10 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
async _onRoll(event, target) { async _onRoll(event, target) {
const rollType = $(event.currentTarget).data("roll-type") const rollType = $(event.currentTarget).data("roll-type")
let item let item
let li
// Debug : console.log(">>>>", event, target, rollType) // Debug : console.log(">>>>", event, target, rollType)
// Deprecated : if (this.isEditMode) return // Deprecated : if (this.isEditMode) return
switch(rollType) { switch (rollType) {
case "char": case "char":
let charId = $(event.currentTarget).data("char-id") let charId = $(event.currentTarget).data("char-id")
item = foundry.utils.duplicate(this.actor.system.characteristics[charId]) item = foundry.utils.duplicate(this.actor.system.characteristics[charId])
@ -195,7 +196,12 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
item.targetScore = item.value * 5 item.targetScore = item.value * 5
break break
case "skill": case "skill":
const li = $(event.currentTarget).parents(".item"); li = $(event.currentTarget).parents(".item");
item = this.actor.items.get(li.data("item-id"));
break
case "weapon":
case "damage":
li = $(event.currentTarget).parents(".item");
item = this.actor.items.get(li.data("item-id")); item = this.actor.items.get(li.data("item-id"));
break break
default: default:

View File

@ -1,4 +1,5 @@
import { SYSTEM } from "../config/system.mjs"
export default class CthulhuEternalRoll extends Roll { export default class CthulhuEternalRoll extends Roll {
/** /**
* The HTML template path used to render dice checks of this type * The HTML template path used to render dice checks of this type
@ -74,6 +75,10 @@ export default class CthulhuEternalRoll extends Roll {
return this.options.realDamage return this.options.realDamage
} }
get weapon() {
return this.options.weapon
}
/** /**
* Prompt the user with a dialog to configure and execute a roll. * Prompt the user with a dialog to configure and execute a roll.
* *
@ -98,6 +103,32 @@ export default class CthulhuEternalRoll extends Roll {
case "char": case "char":
options.initialScore = options.rollItem.targetScore options.initialScore = options.rollItem.targetScore
break break
case "damage":
let formula = options.rollItem.system.damage
let damageRoll = new Roll(formula)
await damageRoll.evaluate()
await damageRoll.toMessage({
flavor: `${options.rollItem.name} - Damage Roll`
});
let isLethal = false
if (options.rollItem.system.lethality > 0 ) {
let lethalityRoll = new Roll("1d100")
await lethalityRoll.evaluate()
isLethal = (lethalityRoll.total <= options.rollItem.system.lethality)
await lethalityRoll.toMessage({
flavor: `${options.rollItem.name} - Lethality Roll : ${lethalityRoll.total} <= ${options.rollItem.system.lethality} => ${isLethal}`
});
}
return
case "weapon":
let era = game.settings.get("fvtt-cthulhu-eternal", "settings-era")
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
let actor = game.actors.get(options.actorId)
options.weapon = options.rollItem
options.rollItem = actor.items.find(i => i.type === "skill" && i.name.toLowerCase() === skillName.toLowerCase())
options.initialScore = options.rollItem.system.computeScore()
console.log("WEAPON", skillName, era, options.rollItem)
break
default: default:
options.initialScore = 50 options.initialScore = 50
break break
@ -114,7 +145,7 @@ export default class CthulhuEternalRoll extends Roll {
"-10": "-10", "-10": "-10",
"-20": "-20", "-20": "-20",
"-40": "-40", "-40": "-40",
0: "0", "0": "0",
"+10": "+10", "+10": "+10",
"+20": "+20", "+20": "+20",
"+40": "+40", "+40": "+40",
@ -128,6 +159,7 @@ export default class CthulhuEternalRoll extends Roll {
let dialogContext = { let dialogContext = {
rollType: options.rollType, rollType: options.rollType,
rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class rollItem: foundry.utils.duplicate(options.rollItem), // Object only, no class
weapon: options?.weapon,
initialScore: options.initialScore, initialScore: options.initialScore,
targetScore: options.initialScore, targetScore: options.initialScore,
isLowWP: options.isLowWP, isLowWP: options.isLowWP,
@ -201,12 +233,12 @@ export default class CthulhuEternalRoll extends Roll {
if (roll.total <= rollData.targetScore) { if (roll.total <= rollData.targetScore) {
resultType = "success" resultType = "success"
// Detect if decimal == unit in the dire total result // Detect if decimal == unit in the dire total result
if (dec === unit || roll.total == 1) { if (dec === unit || roll.total === 1) {
resultType = "successCritical" resultType = "successCritical"
} }
} else { } else {
// Detect if decimal == unit in the dire total result // Detect if decimal == unit in the dire total result
if (dec === unit || roll.total == 100) { if (dec === unit || roll.total === 100) {
resultType = "failureCritical" resultType = "failureCritical"
} }
} }
@ -234,9 +266,11 @@ export default class CthulhuEternalRoll extends Roll {
static createTitle(type, target) { static createTitle(type, target) {
switch (type) { switch (type) {
case "skill": case "skill":
return `${game.i18n.localize("CTHULHUETERNAL.Dialog.titleSkill")}` return `${game.i18n.localize("CTHULHUETERNAL.Label.titleSkill")}`
case "weapon":
return `${game.i18n.localize("CTHULHUETERNAL.Label.titleWeapon")}`
default: default:
return game.i18n.localize("CTHULHUETERNAL.Dialog.titleStandard") return game.i18n.localize("CTHULHUETERNAL.Label.titleStandard")
} }
} }
@ -287,6 +321,7 @@ export default class CthulhuEternalRoll extends Roll {
cardData.targetArmor = this.targetArmor cardData.targetArmor = this.targetArmor
cardData.realDamage = this.realDamage cardData.realDamage = this.realDamage
cardData.isPrivate = isPrivate cardData.isPrivate = isPrivate
cardData.weapon = this.weapon
console.log(cardData) console.log(cardData)

View File

@ -155,25 +155,13 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
/** /**
* Rolls a dice for a character. * Rolls a dice for a character.
* @param {("save"|"resource|damage")} rollType The type of the roll. * @param {("save"|"resource|damage")} rollType The type of the roll.
* @param {number} rollTarget The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item. * @param {number} rollItem The target value for the roll. Which caracteristic or resource. If the roll is a damage roll, this is the id of the item.
* @param {"="|"+"|"++"|"-"|"--"} rollAdvantage If there is an avantage (+), a disadvantage (-), a double advantage (++), a double disadvantage (--) or a normal roll (=).
* @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled. * @returns {Promise<null>} - A promise that resolves to null if the roll is cancelled.
*/ */
async roll(rollType, rollTarget, rollAdvantage = "=") { async roll(rollType, rollItem) {
let rollValue
let opponentTarget let opponentTarget
switch (rollType) {
default:
// Handle other cases or do nothing
break
}
await this._roll(rollType, rollTarget, rollValue, opponentTarget, rollAdvantage)
}
/** Main roll function
*/
async _roll(rollType, rollItem, opponentTarget = undefined) {
const hasTarget = opponentTarget !== undefined const hasTarget = opponentTarget !== undefined
let roll = await CthulhuEternalRoll.prompt({ let roll = await CthulhuEternalRoll.prompt({
rollType, rollType,
rollItem, rollItem,

View File

@ -12,6 +12,7 @@ export default class CthulhuEternalSkill extends foundry.abstract.TypeDataModel
schema.bonus = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 }) schema.bonus = new fields.NumberField({ ...requiredInteger, required: true, initial: 0, min: 0 })
schema.diceEvolved = new fields.BooleanField({ required: true, initial: true }) schema.diceEvolved = new fields.BooleanField({ required: true, initial: true })
schema.rollFailed = new fields.BooleanField({ required: true, initial: false }) schema.rollFailed = new fields.BooleanField({ required: true, initial: false })
schema.isAdversary = new fields.BooleanField({ required: true, initial: false })
return schema return schema
} }

View File

@ -9,9 +9,15 @@
{{#if (eq rollType "char")}} {{#if (eq rollType "char")}}
<li><strong>{{localize "CTHULHUETERNAL.Label.charRoll"}}</strong></li> <li><strong>{{localize "CTHULHUETERNAL.Label.charRoll"}}</strong></li>
{{/if}} {{/if}}
{{#if (eq rollType "skill")}} {{#if (eq rollType "skill")}}
<li><strong>{{localize "CTHULHUETERNAL.Label.skillRoll"}}</strong></li> <li><strong>{{localize "CTHULHUETERNAL.Label.skillRoll"}}</strong></li>
{{/if}} {{/if}}
{{#if weapon}}
<li><strong>Weapon : {{weapon.name}}</strong></li>
{{/if}}
<li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li> <li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li>
<li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li> <li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li>
<li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li> <li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li>

View File

@ -6,9 +6,9 @@
<div class="weapons"> <div class="weapons">
{{#each weapons as |item|}} {{#each weapons as |item|}}
{{!log 'weapon' this}} {{!log 'weapon' this}}
<div class="weapon" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-drag="true" data-drag-type="damage"> <div class="weapon item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-drag="true" >
<img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" /> <img class="item-img" src="{{item.img}}" data-tooltip="{{item.name}}" />
<div class="name rollable" data-tooltip="{{{item.system.description}}}"> <div class="name rollable" data-roll-type="weapon" data-tooltip="{{{item.system.description}}}">
{{item.name}} {{item.name}}
</div> </div>
<a class="damage rollable" data-item-id="{{item.id}}" data-action="roll" data-roll-type="damage" data-roll-value="{{item.system.damage}}">{{localize "CTHULHUETERNAL.Label.damageShort"}} : {{item.system.damage}}</a> <a class="damage rollable" data-item-id="{{item.id}}" data-action="roll" data-roll-type="damage" data-roll-value="{{item.system.damage}}">{{localize "CTHULHUETERNAL.Label.damageShort"}} : {{item.system.damage}}</a>

View File

@ -7,7 +7,13 @@
{{#if (eq rollType "char")}} {{#if (eq rollType "char")}}
<legend>{{localize "CTHULHUETERNAL.Label.characteristic"}}</legend> <legend>{{localize "CTHULHUETERNAL.Label.characteristic"}}</legend>
{{/if}} {{/if}}
<div class="dialog-skill">{{rollItem.name}} : {{initialScore}}%</div> <div class="dialog-skill">{{rollItem.name}} : {{initialScore}}%</div>
{{#if weapon}}
<div class="dialog-skill">Weapon : {{weapon.name}}</div>
{{/if}}
{{#if isZeroWP}} {{#if isZeroWP}}
<div class="dialog-skill">Zero WP : Automatic failure (ie 0%)</div> <div class="dialog-skill">Zero WP : Automatic failure (ie 0%)</div>
{{else}} {{else}}

View File

@ -13,6 +13,7 @@
<legend>{{localize "CTHULHUETERNAL.Label.totalScore"}}</legend> <legend>{{localize "CTHULHUETERNAL.Label.totalScore"}}</legend>
{{system.skillTotal}} {{system.skillTotal}}
</div> </div>
{{formField systemFields.isAdversary value=system.isAdversary}}
{{formField systemFields.diceEvolved value=system.diceEvolved}} {{formField systemFields.diceEvolved value=system.diceEvolved}}
{{#if system.diceEvolved}} {{#if system.diceEvolved}}
{{formField systemFields.rollFailed value=system.rollFailed}} {{formField systemFields.rollFailed value=system.rollFailed}}