Enhance roll result colors

This commit is contained in:
LeRatierBretonnien 2025-01-07 22:22:15 +01:00
parent 44842ff655
commit adb4923d00
12 changed files with 119 additions and 67 deletions

View File

@ -357,6 +357,9 @@
"newArchetype": "New Archetype",
"newSkill": "New Skill"
},
"ChatMessage": {
"exhausted": "Your protagonist is exhausted. He loses [[/r 1d6]] Willpower Points."
},
"Edit": "Edit",
"Delete": "Delete",
"ToggleSheet": "Toggle Sheet",

View File

@ -195,7 +195,7 @@ export default class CthulhuEternalProtagonistSheet extends CthulhuEternalActorS
case "char":
let charId = $(event.currentTarget).data("char-id")
item = foundry.utils.duplicate(this.actor.system.characteristics[charId])
item.name = game.i18n.localize("CTHULHUETERNAL.Label." + charId + "Long")
item.name = game.i18n.localize(`CTHULHUETERNAL.Label.${charId}Long`)
item.targetScore = item.value * 5
break
case "skill":

View File

@ -28,6 +28,19 @@ export default class CthulhuEternalActor extends Actor {
return super.create(data, options);
}
_onUpdate(changed, options, userId) {
// DEBUG : console.log("CthulhuEternalActor.update", changed, options, userId)
if ( changed?.system?.wp?.exhausted) {
ChatMessage.create({
user: userId,
speaker: { alias: this.name },
rollMode: "selfroll",
content: game.i18n.localize("CTHULHUETERNAL.ChatMessage.exhausted"),
type: CONST.CHAT_MESSAGE_STYLES.OTHER
})
}
return super._onUpdate(changed, options, userId)
}
async _preCreate(data, options, user) {
await super._preCreate(data, options, user)

View File

@ -79,6 +79,18 @@ export default class CthulhuEternalRoll extends Roll {
return this.options.weapon
}
get isLowWP() {
return this.options.isLowWP
}
get isZeroWP() {
return this.options.isZeroWP
}
get isExhausted() {
return this.options.isExhausted
}
/**
* Prompt the user with a dialog to configure and execute a roll.
*
@ -165,6 +177,7 @@ export default class CthulhuEternalRoll extends Roll {
targetScore: options.initialScore,
isLowWP: options.isLowWP,
isZeroWP: options.isZeroWP,
isExhausted: options.isExhausted,
rollModes,
fieldRollMode,
choiceModifier,
@ -211,7 +224,7 @@ export default class CthulhuEternalRoll extends Roll {
// Update target score
console.log(rollData)
rollData.targetScore = Math.min( Math.max(options.initialScore + Number(rollData.modifier), 0), 100)
if ( rollData.isLowWP ) {
if ( rollData.isLowWP || rollData.isExhausted) {
rollData.targetScore -= 20
}
if ( rollData.isZeroWP ) {
@ -248,6 +261,9 @@ export default class CthulhuEternalRoll extends Roll {
roll.options.isSuccess = resultType === "success" || resultType === "successCritical"
roll.options.isFailure = resultType === "failure" || resultType === "failureCritical"
roll.options.isCritical = resultType === "successCritical" || resultType === "failureCritical"
roll.options.isLowWP = rollData.isLowWP
roll.options.isZeroWP = rollData.isZeroWP
roll.options.isExhausted = rollData.isExhausted
/**
* A hook event that fires after the roll has been made.
@ -327,6 +343,10 @@ export default class CthulhuEternalRoll extends Roll {
cardData.realDamage = this.realDamage
cardData.isPrivate = isPrivate
cardData.weapon = this.weapon
cardData.isLowWP = this.isLowWP
cardData.isZeroWP = this.isZeroWP
cardData.isExhausted = this.isExhausted
console.log(cardData)

View File

@ -154,6 +154,10 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
return this.wp.value === 0
}
isExhausted() {
return this.wp.exhausted
}
/** */
/**
* Rolls a dice for a character.
@ -170,6 +174,7 @@ export default class CthulhuEternalProtagonist extends foundry.abstract.TypeData
rollItem,
isLowWP: this.isLowWP(),
isZeroWP: this.isZeroWP(),
isExhausted: this.isExhausted(),
actorId: this.parent.id,
actorName: this.parent.name,
actorImage: this.parent.img,

BIN
packs/skills/CURRENT (Stored with Git LFS)

Binary file not shown.

BIN
packs/skills/LOG (Stored with Git LFS)

Binary file not shown.

BIN
packs/skills/LOG.old (Stored with Git LFS)

Binary file not shown.

BIN
packs/skills/MANIFEST-000016 (Stored with Git LFS)

Binary file not shown.

View File

@ -1,6 +0,0 @@
<div class="tenebris ask-roll">
<h4 class="ask-roll-title">{{title}}<br>{{text}}</h4>
<a class="ask-roll-dice" data-type="{{rollType}}" data-value="{{value}}" data-avantage="{{avantage}}">
<i class="fas fa-dice-d20" title="{{localize 'TENEBRIS.Manager.roll'}}"></i> {{localize 'TENEBRIS.Manager.roll'}}
</a>
</div>

View File

@ -1,55 +1,70 @@
{{!log 'chat-message' this}}
<div class="{{cssClass}}">
<div class="intro-chat">
<div class="intro-img">
<img src="{{actingCharImg}}" data-tooltip="{{actingCharName}}" />
</div>
<div class="intro-right">
<ul>
{{#if (eq rollType "char")}}
<li><strong>{{localize "CTHULHUETERNAL.Label.charRoll"}}</strong></li>
{{/if}}
{{#if (eq rollType "skill")}}
<li><strong>{{localize "CTHULHUETERNAL.Label.skillRoll"}}</strong></li>
{{/if}}
{{#if weapon}}
<li><strong>Weapon : {{weapon.name}}</strong></li>
{{/if}}
<li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li>
<li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li>
<li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li>
{{#if isSuccess}}
{{#if isCritical}}
<li class="result-critical-success">{{localize "CTHULHUETERNAL.Label.criticalSuccess"}}</li>
{{else}}
<li class="result-success">{{localize "CTHULHUETERNAL.Label.success"}}</li>
{{/if}}
{{/if}}
{{#if isFailure}}
{{#if isCritical}}
<li class="result-critical-failure">{{localize "CTHULHUETERNAL.Label.criticalFailure"}}</li>
{{else}}
<li class="result-failure">{{localize "CTHULHUETERNAL.Label.failure"}}</li>
{{/if}}
{{/if}}
</ul>
</div>
<div class="intro-chat">
<div class="intro-img">
<img src="{{actingCharImg}}" data-tooltip="{{actingCharName}}" />
</div>
{{#if isDamage}}
<div>
{{#if (and isGM hasTarget)}}
{{{localize "CTHULHUETERNAL.Roll.displayArmor" targetName=targetName targetArmor=targetArmor realDamage=realDamage}}}
{{/if}}
</div>
{{/if}}
{{#unless isPrivate}}
<div class="dice-result">
<h4 class="dice-total">{{total}}</h4>
<div class="dice-formula">{{formula}}</div>
{{{tooltip}}}
</div>
{{/unless}}
<div class="intro-right">
<ul>
{{#if (eq rollType "char")}}
<li><strong>{{localize "CTHULHUETERNAL.Label.charRoll"}}</strong></li>
{{/if}}
{{#if (eq rollType "skill")}}
<li><strong>{{localize "CTHULHUETERNAL.Label.skillRoll"}}</strong></li>
{{/if}}
{{#if weapon}}
<li><strong>Weapon : {{weapon.name}}</strong></li>
{{/if}}
<li><strong>{{rollItem.name}} : {{initialScore}}%</strong></li>
{{#if isZeroWP}}
<li class="red-warning">Zero WP : Automatic failure (ie 0%)</li>
{{else}}
{{#if isLowWP}}
<li class="orange-warning">Low WP : -20%</li>
{{/if}}
{{/if}}
{{#if isExhausted}}
<li class="orange-warning">Exhausted : -20%</li>
{{/if}}
<li>{{localize "CTHULHUETERNAL.Label.modifier"}} : {{modifier}}%</li>
<li>{{localize "CTHULHUETERNAL.Label.targetScore"}} : {{targetScore}}%</li>
{{#if isSuccess}}
{{#if isCritical}}
<li class="result-critical-success">{{localize "CTHULHUETERNAL.Label.criticalSuccess"}}</li>
{{else}}
<li class="result-success">{{localize "CTHULHUETERNAL.Label.success"}}</li>
{{/if}}
{{/if}}
{{#if isFailure}}
{{#if isCritical}}
<li class="result-critical-failure">{{localize "CTHULHUETERNAL.Label.criticalFailure"}}</li>
{{else}}
<li class="result-failure">{{localize "CTHULHUETERNAL.Label.failure"}}</li>
{{/if}}
{{/if}}
</ul>
</div>
</div>
{{#if isDamage}}
<div>
{{#if (and isGM hasTarget)}}
{{{localize "CTHULHUETERNAL.Roll.displayArmor" targetName=targetName targetArmor=targetArmor
realDamage=realDamage}}}
{{/if}}
</div>
{{/if}}
{{#unless isPrivate}}
<div class="dice-result">
<h4 class="dice-total">{{total}}</h4>
<div class="dice-formula">{{formula}}</div>
{{{tooltip}}}
</div>
{{/unless}}
</div>

View File

@ -21,6 +21,11 @@
<div class="dialog-skill orange-warning">Low WP : -20%</div>
{{/if}}
{{/if}}
{{#if isExhausted}}
<div class="dialog-skill orange-warning">Exhausted : -20%</div>
{{/if}}
</fieldSet>
<fieldSet class="dialog-modifier">