Fix various minot stuff + add resources roll

This commit is contained in:
LeRatierBretonnien 2025-01-25 18:24:20 +01:00
parent 70c4fd5a74
commit 7758085bf8
15 changed files with 217 additions and 113 deletions

View File

@ -371,6 +371,10 @@ i.fvtt-cthulhu-eternal {
min-width: 2.4rem; min-width: 2.4rem;
max-width: 2.4rem; max-width: 2.4rem;
} }
.fvtt-cthulhu-eternal .protagonist-main .protagonist-pc .protagonist-right .willpower input[type="checkbox"] {
min-width: 1rem;
max-width: 1rem;
}
.fvtt-cthulhu-eternal .protagonist-main .protagonist-pc .protagonist-right .willpower .label-field { .fvtt-cthulhu-eternal .protagonist-main .protagonist-pc .protagonist-right .willpower .label-field {
flex-grow: 1; flex-grow: 1;
margin-left: 4px; margin-left: 4px;
@ -491,7 +495,7 @@ i.fvtt-cthulhu-eternal {
gap: 8px; gap: 8px;
} }
.fvtt-cthulhu-eternal .protagonist-biography .resources label { .fvtt-cthulhu-eternal .protagonist-biography .resources label {
min-width: 12rem; min-width: 8rem;
} }
.fvtt-cthulhu-eternal .protagonist-biography .features, .fvtt-cthulhu-eternal .protagonist-biography .features,
.fvtt-cthulhu-eternal .protagonist-biography .biodata { .fvtt-cthulhu-eternal .protagonist-biography .biodata {

View File

@ -323,6 +323,12 @@
"veryHarsh": "Very Harsh" "veryHarsh": "Very Harsh"
}, },
"Label": { "Label": {
"Hand": "Hand",
"Stowed": "Stowed",
"Storage": "Storage",
"resourceRating": "Resource rating",
"Resources": "Resources",
"multiplier": "Multiplier",
"setBP": "Set BP", "setBP": "Set BP",
"Vehicle": "Vehicle", "Vehicle": "Vehicle",
"Speed": "Speed", "Speed": "Speed",

View File

@ -191,6 +191,11 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
// 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 "resource":
item = foundry.utils.duplicate(this.actor.system.resources)
item.name = game.i18n.localize(`CTHULHUETERNAL.Label.Resources`)
item.targetScore = item.permanentRating
break
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])

View File

@ -209,6 +209,26 @@ export const WEAPON_SKILL_MAPPING = {
"unarmed": "CTHULHUETERNAL.Skill.UnarmedCombat" "unarmed": "CTHULHUETERNAL.Skill.UnarmedCombat"
} }
} }
export const MODIFIER_CHOICES = {
"-10": "-10",
"-20": "-20",
"-40": "-40",
"+0": "+0",
"+10": "+10",
"+20": "+20",
"+40": "+40",
}
export const MULTIPLIER_CHOICES = {
"0.25": "0.25",
"0.5": "0.5",
"1": "1",
"2": "2",
"4": "4",
"5": "5"
}
/** /**
* Include all constant definitions within the SYSTEM global export * Include all constant definitions within the SYSTEM global export
* @type {Object} * @type {Object}
@ -229,5 +249,7 @@ export const SYSTEM = {
EQUIPMENT_STATES, EQUIPMENT_STATES,
RESOURCE_BREAKDOWN, RESOURCE_BREAKDOWN,
VEHICLE_SPEED, VEHICLE_SPEED,
MODIFIER_CHOICES,
MULTIPLIER_CHOICES,
ASCII ASCII
} }

View File

@ -59,18 +59,6 @@ export default class CthulhuEternalRoll extends Roll {
return this.options.hasTarget return this.options.hasTarget
} }
get targetName() {
return this.options.targetName
}
get targetArmor() {
return this.options.targetArmor
}
get targetMalus() {
return this.options.targetMalus
}
get realDamage() { get realDamage() {
return this.options.realDamage return this.options.realDamage
} }
@ -91,6 +79,23 @@ export default class CthulhuEternalRoll extends Roll {
return this.options.isExhausted return this.options.isExhausted
} }
static updateResourceDialog(options) {
let rating = 0
if (options.rollItem.enableHand) {
rating += options.rollItem.hand
}
if (options.rollItem.enableStowed) {
rating += options.rollItem.stowed
}
if (options.rollItem.enableStorage) {
rating += options.rollItem.storage
}
let multiplier = Number($(`.roll-skill-multiplier`).val())
options.initialScore = rating
options.percentScore = rating * multiplier
$(".resource-score").text(`${rating} (${options.percentScore}%)`)
}
/** /**
* Prompt the user with a dialog to configure and execute a roll. * Prompt the user with a dialog to configure and execute a roll.
* *
@ -107,6 +112,9 @@ export default class CthulhuEternalRoll extends Roll {
*/ */
static async prompt(options = {}) { static async prompt(options = {}) {
let formula = "1d100" let formula = "1d100"
let hasModifier = true
let hasMultiplier = false
switch (options.rollType) { switch (options.rollType) {
case "skill": case "skill":
console.log(options.rollItem) console.log(options.rollItem)
@ -116,6 +124,16 @@ export default class CthulhuEternalRoll extends Roll {
case "char": case "char":
options.initialScore = options.rollItem.targetScore options.initialScore = options.rollItem.targetScore
break break
case "resource":
hasModifier = false
hasMultiplier = true
options.initialScore = options.rollItem.targetScore
options.totalRating = options.rollItem.targetScore
options.percentScore = options.rollItem.targetScore * 5
options.rollItem.enableHand = true
options.rollItem.enableStowed = true
options.rollItem.enableStorage = true
break
case "damage": case "damage":
let formula = options.rollItem.system.damage let formula = options.rollItem.system.damage
let damageRoll = new Roll(formula) let damageRoll = new Roll(formula)
@ -162,20 +180,11 @@ export default class CthulhuEternalRoll extends Roll {
default: "public", default: "public",
}) })
const choiceModifier = { const choiceModifier = SYSTEM.MODIFIER_CHOICES
"-10": "-10", const choiceMultiplier = SYSTEM.MULTIPLIER_CHOICES
"-20": "-20",
"-40": "-40",
"0": "0",
"+10": "+10",
"+20": "+20",
"+40": "+40",
}
let modifier = "0" let modifier = "+0"
let targetMalus = "0" let multiplier = "5"
let targetName
let targetArmor
let dialogContext = { let dialogContext = {
rollType: options.rollType, rollType: options.rollType,
@ -186,14 +195,19 @@ export default class CthulhuEternalRoll extends Roll {
isLowWP: options.isLowWP, isLowWP: options.isLowWP,
isZeroWP: options.isZeroWP, isZeroWP: options.isZeroWP,
isExhausted: options.isExhausted, isExhausted: options.isExhausted,
enableHand: options.rollItem.enableHand,
enableStowed: options.rollItem.enableStowed,
enableStorage: options.rollItem.enableStorage,
rollModes, rollModes,
fieldRollMode, fieldRollMode,
choiceModifier, choiceModifier,
choiceMultiplier,
formula, formula,
hasTarget: options.hasTarget, hasTarget: options.hasTarget,
hasModifier,
hasMultiplier,
modifier, modifier,
targetName, multiplier
targetArmor
} }
const content = await renderTemplate("systems/fvtt-cthulhu-eternal/templates/roll-dialog.hbs", dialogContext) const content = await renderTemplate("systems/fvtt-cthulhu-eternal/templates/roll-dialog.hbs", dialogContext)
@ -215,9 +229,27 @@ export default class CthulhuEternalRoll extends Roll {
}, },
}, },
], ],
actions: {
"selectHand": (event, button, dialog) => {
options.rollItem.enableHand = !options.rollItem.enableHand
this.updateResourceDialog(options)
},
"selectStowed": (event, button, dialog) => {
options.rollItem.enableStowed = !options.rollItem.enableStowed
this.updateResourceDialog(options)
},
"selectStorage": (event, button, dialog) => {
options.rollItem.enableStorage = !options.rollItem.enableStorage
this.updateResourceDialog(options)
}
},
rejectClose: false, // Click on Close button will not launch an error rejectClose: false, // Click on Close button will not launch an error
render: (event, dialog) => { render: (event, dialog) => {
}, $(".roll-skill-multiplier").change(event => {
options.multiplier = Number(event.target.value)
this.updateResourceDialog(options)
})
}
}) })
// If the user cancels the dialog, exit // If the user cancels the dialog, exit
@ -225,12 +257,12 @@ export default class CthulhuEternalRoll extends Roll {
let rollData = foundry.utils.mergeObject(foundry.utils.duplicate(options), rollContext) let rollData = foundry.utils.mergeObject(foundry.utils.duplicate(options), rollContext)
rollData.rollMode = rollContext.visibility rollData.rollMode = rollContext.visibility
rollData.targetName = targetName
rollData.targetArmor = targetArmor
rollData.targetMalus = targetMalus
// Update target score // Update target score
console.log(rollData) console.log(rollData)
if (options.rollType === "resource" ) {
rollData.targetScore = options.initialScore * Number(rollContext.multiplier)
} else {
rollData.targetScore = Math.min(Math.max(options.initialScore + Number(rollData.modifier), 0), 100) rollData.targetScore = Math.min(Math.max(options.initialScore + Number(rollData.modifier), 0), 100)
if (rollData.isLowWP || rollData.isExhausted) { if (rollData.isLowWP || rollData.isExhausted) {
rollData.targetScore -= 20 rollData.targetScore -= 20
@ -239,6 +271,7 @@ export default class CthulhuEternalRoll extends Roll {
rollData.targetScore = 0 rollData.targetScore = 0
} }
rollData.targetScore = Math.min(Math.max(rollData.targetScore, 0), 100) rollData.targetScore = Math.min(Math.max(rollData.targetScore, 0), 100)
}
/** /**
* A hook event that fires before the roll is made. * A hook event that fires before the roll is made.
@ -379,9 +412,6 @@ export default class CthulhuEternalRoll extends Roll {
actingCharName: this.actorName, actingCharName: this.actorName,
actingCharImg: this.actorImage, actingCharImg: this.actorImage,
hasTarget: this.hasTarget, hasTarget: this.hasTarget,
targetName: this.targetName,
targetArmor: this.targetArmor,
targetMalus: this.targetMalus,
realDamage: this.realDamage, realDamage: this.realDamage,
...messageData, ...messageData,
}, },

View File

@ -1 +1 @@
MANIFEST-000052 MANIFEST-000068

View File

@ -1,3 +1,8 @@
2025/01/10-00:04:46.700736 7f0abaffd6c0 Recovering log #50 2025/01/25-18:18:47.579516 7f69797fa6c0 Recovering log #66
2025/01/10-00:04:46.711152 7f0abaffd6c0 Delete type=3 #48 2025/01/25-18:18:47.635623 7f69797fa6c0 Delete type=3 #64
2025/01/10-00:04:46.711210 7f0abaffd6c0 Delete type=0 #50 2025/01/25-18:18:47.635705 7f69797fa6c0 Delete type=0 #66
2025/01/25-18:23:50.402055 7f6978bff6c0 Level-0 table #71: started
2025/01/25-18:23:50.402099 7f6978bff6c0 Level-0 table #71: 0 bytes OK
2025/01/25-18:23:50.411525 7f6978bff6c0 Delete type=0 #69
2025/01/25-18:23:50.411705 7f6978bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end)
2025/01/25-18:23:50.411749 7f6978bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end)

View File

@ -1,8 +1,8 @@
2025/01/09-15:39:16.704802 7f0abb7fe6c0 Recovering log #46 2025/01/25-17:02:58.822790 7f6979ffb6c0 Recovering log #62
2025/01/09-15:39:16.715860 7f0abb7fe6c0 Delete type=3 #44 2025/01/25-17:02:58.899589 7f6979ffb6c0 Delete type=3 #60
2025/01/09-15:39:16.715933 7f0abb7fe6c0 Delete type=0 #46 2025/01/25-17:02:58.899681 7f6979ffb6c0 Delete type=0 #62
2025/01/09-16:20:07.336867 7f0ab9bff6c0 Level-0 table #51: started 2025/01/25-18:12:05.328260 7f6978bff6c0 Level-0 table #67: started
2025/01/09-16:20:07.336898 7f0ab9bff6c0 Level-0 table #51: 0 bytes OK 2025/01/25-18:12:05.328291 7f6978bff6c0 Level-0 table #67: 0 bytes OK
2025/01/09-16:20:07.343031 7f0ab9bff6c0 Delete type=0 #49 2025/01/25-18:12:05.334284 7f6978bff6c0 Delete type=0 #65
2025/01/09-16:20:07.352821 7f0ab9bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) 2025/01/25-18:12:05.334447 7f6978bff6c0 Manual compaction at level-0 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end)
2025/01/09-16:20:07.369688 7f0ab9bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end) 2025/01/25-18:12:05.362492 7f6978bff6c0 Manual compaction at level-1 from '!folders!DD8331Hda4rhvEf9' @ 72057594037927935 : 1 .. '!items!zplzTG30QXHURusr' @ 0 : 0; will stop at (end)

Binary file not shown.

Binary file not shown.

View File

@ -130,6 +130,10 @@
min-width: 2.4rem; min-width: 2.4rem;
max-width: 2.4rem; max-width: 2.4rem;
} }
input[type="checkbox"] {
min-width: 1rem;
max-width: 1rem;
}
.label-field { .label-field {
flex-grow: 1; flex-grow: 1;
margin-left: 4px; margin-left: 4px;
@ -266,7 +270,7 @@
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
gap: 8px; gap: 8px;
label { label {
min-width: 12rem; min-width: 8rem;
} }
} }

View File

@ -18,7 +18,11 @@
<li><strong>Weapon : {{weapon.name}}</strong></li> <li><strong>Weapon : {{weapon.name}}</strong></li>
{{/if}} {{/if}}
{{#if (eq rollType "resource")}}
<li><strong>{{rollItem.name}} : {{initialScore}}</strong></li>
{{else}}
<li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li> <li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li>
{{/if}}
{{#if isZeroWP}} {{#if isZeroWP}}
<li class="red-warning">Zero WP : Automatic failure (ie 0%)</li> <li class="red-warning">Zero WP : Automatic failure (ie 0%)</li>
@ -32,7 +36,11 @@
<li class="orange-warning">Exhausted : -20%</li> <li class="orange-warning">Exhausted : -20%</li>
{{/if}} {{/if}}
{{#if (eq rollType "resource")}}
<li>{{localize "CTHULHUETERNAL.Label.multiplier"}} : {{multiplier}}</li>
{{else}}
<li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li> <li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li>
{{/if}}
<li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li> <li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li>
{{#if isSuccess}} {{#if isSuccess}}

View File

@ -4,9 +4,6 @@
<legend>{{localize "CTHULHUETERNAL.Label.resources"}}</legend> <legend>{{localize "CTHULHUETERNAL.Label.resources"}}</legend>
<div class="resources"> <div class="resources">
{{formField systemFields.resources.fields.permanentRating value=system.resources.permanentRating name="system.resources.permanentRating" localize=true}} {{formField systemFields.resources.fields.permanentRating value=system.resources.permanentRating name="system.resources.permanentRating" localize=true}}
{{formField systemFields.resources.fields.hand value=system.resources.hand name="system.resources.hand" localize=true disabled=true}}
{{formField systemFields.resources.fields.stowed value=system.resources.stowed name="system.resources.stowed" localize=true disabled=true}}
{{formField systemFields.resources.fields.storage value=system.resources.storage name="system.resources.storage" localize=true disabled=true}}
<div> <div>
<span class="label-field">{{localize "CTHULHUETERNAL.Label.resourceChecks"}}</span> <span class="label-field">{{localize "CTHULHUETERNAL.Label.resourceChecks"}}</span>
{{#each system.resources.checks as |check idx|}} {{#each system.resources.checks as |check idx|}}
@ -14,7 +11,10 @@
data-name="checks" {{#if check}} checked {{/if}} {{#if (gte @index @root.system.resources.nbValidChecks)}} disabled {{/if}}> data-name="checks" {{#if check}} checked {{/if}} {{#if (gte @index @root.system.resources.nbValidChecks)}} disabled {{/if}}>
{{/each}} {{/each}}
</div> </div>
<button class="resource-roll">Resource roll</button> <button class="resource-roll rollable" data-roll-type="resource"><img src="systems/fvtt-cthulhu-eternal/assets/ui/d100.svg" class="d100" />Resource roll</button>
{{formField systemFields.resources.fields.hand value=system.resources.hand name="system.resources.hand" localize=true disabled=true}}
{{formField systemFields.resources.fields.stowed value=system.resources.stowed name="system.resources.stowed" localize=true disabled=true}}
{{formField systemFields.resources.fields.storage value=system.resources.storage name="system.resources.storage" localize=true disabled=true}}
</div> </div>
</fieldset> </fieldset>

View File

@ -8,7 +8,15 @@
<legend>{{localize "CTHULHUETERNAL.Label.characteristic"}}</legend> <legend>{{localize "CTHULHUETERNAL.Label.characteristic"}}</legend>
{{/if}} {{/if}}
{{#if (eq rollType "resource")}}
<legend>{{localize "CTHULHUETERNAL.Label.resourceRating"}}</legend>
<div class="dialog-skill">{{rollItem.name}} : <span class="resource-score">{{initialScore}} ({{mul initialScore 5}}%)</span></div>
<div class="dialog-skill">{{localize "CTHULHUETERNAL.Label.Hand"}} : {{rollItem.hand}} <input type="checkbox" data-action="selectHand" {{checked rollItem.enableHand}}></div>
<div class="dialog-skill">{{localize "CTHULHUETERNAL.Label.Stowed"}} : {{rollItem.stowed}} <input type="checkbox" data-action="selectStowed" {{checked rollItem.enableStowed}}></div>
<div class="dialog-skill">{{localize "CTHULHUETERNAL.Label.Storage"}} : {{rollItem.storage}} <input type="checkbox" data-action="selectStorage" {{checked rollItem.enableStorage}}></div>
{{else}}
<div class="dialog-skill">{{rollItem.name}} : {{initialScore}}%</div> <div class="dialog-skill">{{rollItem.name}} : {{initialScore}}%</div>
{{/if}}
{{#if weapon}} {{#if weapon}}
<div class="dialog-skill">Weapon : {{weapon.name}}</div> <div class="dialog-skill">Weapon : {{weapon.name}}</div>
@ -28,12 +36,24 @@
</fieldSet> </fieldSet>
{{#if hasModifier}}
<fieldSet class="dialog-modifier"> <fieldSet class="dialog-modifier">
<legend>{{localize "CTHULHUETERNAL.Label.modifier"}}</legend> <legend>{{localize "CTHULHUETERNAL.Label.modifier"}}</legend>
<select name="modifier" class="roll-skill-modifier"> <select name="modifier" class="roll-skill-modifier">
{{selectOptions choiceModifier selected=modifier}} {{selectOptions choiceModifier selected=modifier}}
</select> </select>
</fieldSet> </fieldSet>
{{/if}}
{{#if hasMultiplier}}
<fieldSet class="dialog-modifier">
<legend>{{localize "CTHULHUETERNAL.Label.multiplier"}}</legend>
<select name="multiplier" class="roll-skill-modifier roll-skill-multiplier">
{{selectOptions choiceMultiplier selected=multiplier}}
</select>
</fieldSet>
{{/if}}
<fieldSet> <fieldSet>
<legend>{{localize "CTHULHUETERNAL.Label.rollView"}}</legend> <legend>{{localize "CTHULHUETERNAL.Label.rollView"}}</legend>
<select name="visibility"> <select name="visibility">