forked from public/fvtt-cthulhu-eternal
Fix various minot stuff + add resources roll
This commit is contained in:
parent
70c4fd5a74
commit
7758085bf8
@ -371,6 +371,10 @@ i.fvtt-cthulhu-eternal {
|
||||
min-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 {
|
||||
flex-grow: 1;
|
||||
margin-left: 4px;
|
||||
@ -491,7 +495,7 @@ i.fvtt-cthulhu-eternal {
|
||||
gap: 8px;
|
||||
}
|
||||
.fvtt-cthulhu-eternal .protagonist-biography .resources label {
|
||||
min-width: 12rem;
|
||||
min-width: 8rem;
|
||||
}
|
||||
.fvtt-cthulhu-eternal .protagonist-biography .features,
|
||||
.fvtt-cthulhu-eternal .protagonist-biography .biodata {
|
||||
|
@ -323,6 +323,12 @@
|
||||
"veryHarsh": "Very Harsh"
|
||||
},
|
||||
"Label": {
|
||||
"Hand": "Hand",
|
||||
"Stowed": "Stowed",
|
||||
"Storage": "Storage",
|
||||
"resourceRating": "Resource rating",
|
||||
"Resources": "Resources",
|
||||
"multiplier": "Multiplier",
|
||||
"setBP": "Set BP",
|
||||
"Vehicle": "Vehicle",
|
||||
"Speed": "Speed",
|
||||
|
@ -191,6 +191,11 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
|
||||
// Debug : console.log(">>>>", event, target, rollType)
|
||||
// Deprecated : if (this.isEditMode) return
|
||||
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":
|
||||
let charId = $(event.currentTarget).data("char-id")
|
||||
item = foundry.utils.duplicate(this.actor.system.characteristics[charId])
|
||||
|
@ -209,6 +209,26 @@ export const WEAPON_SKILL_MAPPING = {
|
||||
"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
|
||||
* @type {Object}
|
||||
@ -229,5 +249,7 @@ export const SYSTEM = {
|
||||
EQUIPMENT_STATES,
|
||||
RESOURCE_BREAKDOWN,
|
||||
VEHICLE_SPEED,
|
||||
MODIFIER_CHOICES,
|
||||
MULTIPLIER_CHOICES,
|
||||
ASCII
|
||||
}
|
||||
|
@ -59,18 +59,6 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
return this.options.hasTarget
|
||||
}
|
||||
|
||||
get targetName() {
|
||||
return this.options.targetName
|
||||
}
|
||||
|
||||
get targetArmor() {
|
||||
return this.options.targetArmor
|
||||
}
|
||||
|
||||
get targetMalus() {
|
||||
return this.options.targetMalus
|
||||
}
|
||||
|
||||
get realDamage() {
|
||||
return this.options.realDamage
|
||||
}
|
||||
@ -91,6 +79,23 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
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.
|
||||
*
|
||||
@ -107,6 +112,9 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
*/
|
||||
static async prompt(options = {}) {
|
||||
let formula = "1d100"
|
||||
let hasModifier = true
|
||||
let hasMultiplier = false
|
||||
|
||||
switch (options.rollType) {
|
||||
case "skill":
|
||||
console.log(options.rollItem)
|
||||
@ -116,6 +124,16 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
case "char":
|
||||
options.initialScore = options.rollItem.targetScore
|
||||
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":
|
||||
let formula = options.rollItem.system.damage
|
||||
let damageRoll = new Roll(formula)
|
||||
@ -124,7 +142,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
flavor: `${options.rollItem.name} - Damage Roll`
|
||||
});
|
||||
let isLethal = false
|
||||
if (options.rollItem.system.lethality > 0 ) {
|
||||
if (options.rollItem.system.lethality > 0) {
|
||||
let lethalityRoll = new Roll("1d100")
|
||||
await lethalityRoll.evaluate()
|
||||
isLethal = (lethalityRoll.total <= options.rollItem.system.lethality)
|
||||
@ -136,7 +154,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
case "weapon":
|
||||
let era = game.settings.get("fvtt-cthulhu-eternal", "settings-era")
|
||||
if (!SYSTEM.WEAPON_SKILL_MAPPING[era] || !SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType]) {
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.NoWeaponType") )
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.NoWeaponType"))
|
||||
return
|
||||
}
|
||||
let skillName = game.i18n.localize(SYSTEM.WEAPON_SKILL_MAPPING[era][options.rollItem.system.weaponType])
|
||||
@ -144,7 +162,7 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
options.weapon = options.rollItem
|
||||
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") )
|
||||
ui.notifications.error(game.i18n.localize("CTHULHUETERNAL.Notifications.NoWeaponSkill"))
|
||||
return
|
||||
}
|
||||
options.initialScore = options.rollItem.system.computeScore()
|
||||
@ -162,20 +180,11 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
default: "public",
|
||||
})
|
||||
|
||||
const choiceModifier = {
|
||||
"-10": "-10",
|
||||
"-20": "-20",
|
||||
"-40": "-40",
|
||||
"0": "0",
|
||||
"+10": "+10",
|
||||
"+20": "+20",
|
||||
"+40": "+40",
|
||||
}
|
||||
const choiceModifier = SYSTEM.MODIFIER_CHOICES
|
||||
const choiceMultiplier = SYSTEM.MULTIPLIER_CHOICES
|
||||
|
||||
let modifier = "0"
|
||||
let targetMalus = "0"
|
||||
let targetName
|
||||
let targetArmor
|
||||
let modifier = "+0"
|
||||
let multiplier = "5"
|
||||
|
||||
let dialogContext = {
|
||||
rollType: options.rollType,
|
||||
@ -186,14 +195,19 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
isLowWP: options.isLowWP,
|
||||
isZeroWP: options.isZeroWP,
|
||||
isExhausted: options.isExhausted,
|
||||
enableHand: options.rollItem.enableHand,
|
||||
enableStowed: options.rollItem.enableStowed,
|
||||
enableStorage: options.rollItem.enableStorage,
|
||||
rollModes,
|
||||
fieldRollMode,
|
||||
choiceModifier,
|
||||
choiceMultiplier,
|
||||
formula,
|
||||
hasTarget: options.hasTarget,
|
||||
hasModifier,
|
||||
hasMultiplier,
|
||||
modifier,
|
||||
targetName,
|
||||
targetArmor
|
||||
multiplier
|
||||
}
|
||||
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
|
||||
render: (event, dialog) => {
|
||||
},
|
||||
$(".roll-skill-multiplier").change(event => {
|
||||
options.multiplier = Number(event.target.value)
|
||||
this.updateResourceDialog(options)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// If the user cancels the dialog, exit
|
||||
@ -225,20 +257,21 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
|
||||
let rollData = foundry.utils.mergeObject(foundry.utils.duplicate(options), rollContext)
|
||||
rollData.rollMode = rollContext.visibility
|
||||
rollData.targetName = targetName
|
||||
rollData.targetArmor = targetArmor
|
||||
rollData.targetMalus = targetMalus
|
||||
|
||||
// Update target score
|
||||
console.log(rollData)
|
||||
rollData.targetScore = Math.min( Math.max(options.initialScore + Number(rollData.modifier), 0), 100)
|
||||
if ( rollData.isLowWP || rollData.isExhausted) {
|
||||
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)
|
||||
if (rollData.isLowWP || rollData.isExhausted) {
|
||||
rollData.targetScore -= 20
|
||||
}
|
||||
if ( rollData.isZeroWP ) {
|
||||
if (rollData.isZeroWP) {
|
||||
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.
|
||||
@ -250,8 +283,8 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
|
||||
// Compute the result quality
|
||||
let resultType = "failure"
|
||||
let dec = Math.floor(roll.total/10)
|
||||
let unit = roll.total - (dec*10)
|
||||
let dec = Math.floor(roll.total / 10)
|
||||
let unit = roll.total - (dec * 10)
|
||||
if (roll.total <= rollData.targetScore) {
|
||||
resultType = "success"
|
||||
// Detect if decimal == unit in the dire total result
|
||||
@ -379,9 +412,6 @@ export default class CthulhuEternalRoll extends Roll {
|
||||
actingCharName: this.actorName,
|
||||
actingCharImg: this.actorImage,
|
||||
hasTarget: this.hasTarget,
|
||||
targetName: this.targetName,
|
||||
targetArmor: this.targetArmor,
|
||||
targetMalus: this.targetMalus,
|
||||
realDamage: this.realDamage,
|
||||
...messageData,
|
||||
},
|
||||
|
@ -1 +1 @@
|
||||
MANIFEST-000052
|
||||
MANIFEST-000068
|
||||
|
@ -1,3 +1,8 @@
|
||||
2025/01/10-00:04:46.700736 7f0abaffd6c0 Recovering log #50
|
||||
2025/01/10-00:04:46.711152 7f0abaffd6c0 Delete type=3 #48
|
||||
2025/01/10-00:04:46.711210 7f0abaffd6c0 Delete type=0 #50
|
||||
2025/01/25-18:18:47.579516 7f69797fa6c0 Recovering log #66
|
||||
2025/01/25-18:18:47.635623 7f69797fa6c0 Delete type=3 #64
|
||||
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)
|
||||
|
@ -1,8 +1,8 @@
|
||||
2025/01/09-15:39:16.704802 7f0abb7fe6c0 Recovering log #46
|
||||
2025/01/09-15:39:16.715860 7f0abb7fe6c0 Delete type=3 #44
|
||||
2025/01/09-15:39:16.715933 7f0abb7fe6c0 Delete type=0 #46
|
||||
2025/01/09-16:20:07.336867 7f0ab9bff6c0 Level-0 table #51: started
|
||||
2025/01/09-16:20:07.336898 7f0ab9bff6c0 Level-0 table #51: 0 bytes OK
|
||||
2025/01/09-16:20:07.343031 7f0ab9bff6c0 Delete type=0 #49
|
||||
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/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-17:02:58.822790 7f6979ffb6c0 Recovering log #62
|
||||
2025/01/25-17:02:58.899589 7f6979ffb6c0 Delete type=3 #60
|
||||
2025/01/25-17:02:58.899681 7f6979ffb6c0 Delete type=0 #62
|
||||
2025/01/25-18:12:05.328260 7f6978bff6c0 Level-0 table #67: started
|
||||
2025/01/25-18:12:05.328291 7f6978bff6c0 Level-0 table #67: 0 bytes OK
|
||||
2025/01/25-18:12:05.334284 7f6978bff6c0 Delete type=0 #65
|
||||
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/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.
BIN
packs-system/skills/MANIFEST-000068
Normal file
BIN
packs-system/skills/MANIFEST-000068
Normal file
Binary file not shown.
@ -130,6 +130,10 @@
|
||||
min-width: 2.4rem;
|
||||
max-width: 2.4rem;
|
||||
}
|
||||
input[type="checkbox"] {
|
||||
min-width: 1rem;
|
||||
max-width: 1rem;
|
||||
}
|
||||
.label-field {
|
||||
flex-grow: 1;
|
||||
margin-left: 4px;
|
||||
@ -266,7 +270,7 @@
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
label {
|
||||
min-width: 12rem;
|
||||
min-width: 8rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,11 @@
|
||||
<li><strong>Weapon : {{weapon.name}}</strong></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq rollType "resource")}}
|
||||
<li><strong>{{rollItem.name}} : {{initialScore}}</strong></li>
|
||||
{{else}}
|
||||
<li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li>
|
||||
{{/if}}
|
||||
|
||||
{{#if isZeroWP}}
|
||||
<li class="red-warning">Zero WP : Automatic failure (ie 0%)</li>
|
||||
@ -32,7 +36,11 @@
|
||||
<li class="orange-warning">Exhausted : -20%</li>
|
||||
{{/if}}
|
||||
|
||||
{{#if (eq rollType "resource")}}
|
||||
<li>{{localize "CTHULHUETERNAL.Label.multiplier"}} : {{multiplier}}</li>
|
||||
{{else}}
|
||||
<li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li>
|
||||
{{/if}}
|
||||
|
||||
<li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li>
|
||||
{{#if isSuccess}}
|
||||
|
@ -4,9 +4,6 @@
|
||||
<legend>{{localize "CTHULHUETERNAL.Label.resources"}}</legend>
|
||||
<div class="resources">
|
||||
{{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>
|
||||
<span class="label-field">{{localize "CTHULHUETERNAL.Label.resourceChecks"}}</span>
|
||||
{{#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}}>
|
||||
{{/each}}
|
||||
</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>
|
||||
</fieldset>
|
||||
|
||||
|
@ -8,7 +8,15 @@
|
||||
<legend>{{localize "CTHULHUETERNAL.Label.characteristic"}}</legend>
|
||||
{{/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>
|
||||
{{/if}}
|
||||
|
||||
{{#if weapon}}
|
||||
<div class="dialog-skill">Weapon : {{weapon.name}}</div>
|
||||
@ -28,12 +36,24 @@
|
||||
|
||||
</fieldSet>
|
||||
|
||||
{{#if hasModifier}}
|
||||
<fieldSet class="dialog-modifier">
|
||||
<legend>{{localize "CTHULHUETERNAL.Label.modifier"}}</legend>
|
||||
<select name="modifier" class="roll-skill-modifier">
|
||||
{{selectOptions choiceModifier selected=modifier}}
|
||||
</select>
|
||||
</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>
|
||||
<legend>{{localize "CTHULHUETERNAL.Label.rollView"}}</legend>
|
||||
<select name="visibility">
|
||||
|
Loading…
x
Reference in New Issue
Block a user