Fix rolls

This commit is contained in:
LeRatierBretonnien 2023-07-21 21:21:17 +02:00
parent 0551d7812f
commit 166f3367fb
6 changed files with 163 additions and 18 deletions

View File

@ -30,6 +30,18 @@
"bonusmalustraits": "Traits Bonus/Malus", "bonusmalustraits": "Traits Bonus/Malus",
"spectranscend": "Self-Transcend : " "spectranscend": "Self-Transcend : "
}, },
"rule": {
"cephaly-success-2": "Duration : 1 scene - Impact : Superficial - Bonus : 1 - Elegy : 1",
"cephaly-success-4": "Duration : 1 week - Impact : Light - Bonus : 2 - Elegy : 2",
"cephaly-success-6": "Duration : 1 month - Impact : Serious - Bonus : 3 - Elegy : 3",
"cephaly-success-8": "Duration : 1 year - Impact : Major - Bonus : 4 - Elegy : 4",
"cephaly-success-10": "Duration : Permanent - Impact : Dead - Bonus : 5 - Elegy : 5",
"cephaly-failure-2": "Duration : 1 scene - Impact : Superficial - Malus : 1",
"cephaly-failure-4": "Duration : 1 week - Impact : Light - Malus : 2",
"cephaly-failure-6": "Duration : 1 month - Impact : Serious - Malus : 3",
"cephaly-failure-8": "Duration : 1 year - Impact : Major - Malus : 4",
"cephaly-failure-10": "Duration : Permanent - Impact : Death/Madness - Malus : 5"
},
"warn": { "warn": {
"notenoughdice": "Execution and Preservation must have 2 dices allocated" "notenoughdice": "Execution and Preservation must have 2 dices allocated"
}, },
@ -129,7 +141,8 @@
"entelechy": "Entelechy", "entelechy": "Entelechy",
"mekany": "Mekany", "mekany": "Mekany",
"psyche": "Psyche", "psyche": "Psyche",
"scoria": "Scoria" "scoria": "Scoria",
"cephalydifficulty": "Set Cephaly difficulty"
} }
} }
} }

View File

@ -30,6 +30,19 @@
"bonusmalustraits": "Bonus/Malus des Traits", "bonusmalustraits": "Bonus/Malus des Traits",
"spectranscend": "Dépassement de soi : " "spectranscend": "Dépassement de soi : "
}, },
"rule": {
"cephaly-success-12": "Durée : 1 scène - Impact : Superficiel - Bonus : 1 - Elegie : 1",
"cephaly-success-34": "Durée : 1 semaine - Impact : Léger - Bonus : 2 - Elegie : 2",
"cephaly-success-56": "Durée : 1 mois - Impact : Grave - Bonus : 3 - Elegie : 3",
"cephaly-success-78": "Durée : 1 année - Impact : Majeur - Bonus : 4 - Elegie : 4",
"cephaly-success-910": "Durée : Permanent - Impact : Mort - Bonus : 5 - Elegie : 5",
"cephaly-failure-2": "Durée : 1 scène - Impact : Superficiel - Malus : 1 - Symptôme non visible et sans gravité - Altération bégigne difficilement repérable",
"cephaly-failure-4": "Durée : 1 semaine - Impact : Léger - Malus : 2 - Symptôme visible non incapacitant - Altération repérable",
"cephaly-failure-6": "Durée : 1 mois - Impact : Grave - Malus : 3 - Symptôme incapacitant - Altération repérable et fâcheuse",
"cephaly-failure-8": "Durée : 1 année - Impact : Majeur - Malus : 4 - Symptôme très incapacitant - Altération dangereuse",
"cephaly-failure-10": "Durée : Permanent - Impact : Mort/Folie - Malus : 5 - Symptôme spectaculaire et repoussant - Altération dangereuse globalement"
},
"warn": { "warn": {
"notenoughdice": "L'Accomplissement et la Préservation doivent avoir 2 dés chacun" "notenoughdice": "L'Accomplissement et la Préservation doivent avoir 2 dés chacun"
}, },
@ -129,7 +142,8 @@
"entelechy": "Entéléchie", "entelechy": "Entéléchie",
"mekany": "Mekanë", "mekany": "Mekanë",
"psyche": "Psyché", "psyche": "Psyché",
"scoria": "Scorie" "scoria": "Scorie",
"cephalydifficulty": "Difficulté de la Céphalie"
} }
} }
} }

View File

@ -393,6 +393,8 @@ export class EcrymeActor extends Actor {
rollData.title = game.i18n.localize("ECRY.ui.cephaly") + " : " + game.i18n.localize(rollData.skill.name) rollData.title = game.i18n.localize("ECRY.ui.cephaly") + " : " + game.i18n.localize(rollData.skill.name)
rollData.executionTotal = rollData.skill.value rollData.executionTotal = rollData.skill.value
rollData.preservationTotal = rollData.skill.value rollData.preservationTotal = rollData.skill.value
rollData.traitsBonus = duplicate(rollData.traits)
rollData.traitsMalus = duplicate(rollData.traits)
rollData.applyTranscendence = "execution" rollData.applyTranscendence = "execution"
let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData) let confrontStartDialog = await EcrymeConfrontStartDialog.create(this, rollData)
confrontStartDialog.render(true) confrontStartDialog.render(true)

View File

@ -5,6 +5,31 @@ import { EcrymeCommands } from "../app/ecryme-commands.js";
const __maxImpacts = { superficial: 4, light: 3, serious: 2, major: 1 } const __maxImpacts = { superficial: 4, light: 3, serious: 2, major: 1 }
const __nextImpacts = { superficial: "light", light: "serious", serious: "major", major: "major" } const __nextImpacts = { superficial: "light", light: "serious", serious: "major", major: "major" }
const __effect2Impact = ["none", "superficial", "superficial", "light", "light", "serious", "serious", "major", "major"] const __effect2Impact = ["none", "superficial", "superficial", "light", "light", "serious", "serious", "major", "major"]
const __cephalySuccess = {
1: "cephaly-success-2",
2: "cephaly-success-2",
3: "cephaly-success-4",
4: "cephaly-success-4",
5: "cephaly-success-6",
6: "cephaly-success-6",
7: "cephaly-success-8",
8: "cephaly-success-8",
9: "cephaly-success-9",
10: "cephaly-success-10"
}
const __cephalyFailure = {
1: "cephaly-failure-2",
2: "cephaly-failure-2",
3: "cephaly-failure-4",
4: "cephaly-failure-4",
5: "cephaly-failure-6",
6: "cephaly-failure-6",
7: "cephaly-failure-8",
8: "cephaly-failure-8",
9: "cephaly-failure-9",
10: "cephaly-failure-10"
}
/* -------------------------------------------- */ /* -------------------------------------------- */
export class EcrymeUtility { export class EcrymeUtility {
@ -56,6 +81,9 @@ export class EcrymeUtility {
accum += block.fn(i); accum += block.fn(i);
return accum; return accum;
}) })
Handlebars.registerHelper('isGM', function () {
return game.user.isGM
})
game.settings.register("fvtt-ecryme", "ecryme-game-level", { game.settings.register("fvtt-ecryme", "ecryme-game-level", {
name: game.i18n.localize("ECRY.settings.gamelevel"), name: game.i18n.localize("ECRY.settings.gamelevel"),
@ -188,6 +216,27 @@ export class EcrymeUtility {
this.lastConfront = confront this.lastConfront = confront
} }
/* -------------------------------------------- */
static async manageCephalyDifficulty(rollData, difficulty) {
rollData.difficulty = Number(difficulty)
if (rollData.executionTotal > difficulty) {
rollData.marginExecution = rollData.executionTotal - difficulty
rollData.cephalySuccess = "ECRY.rule." + __cephalySuccess[(rollData.marginExecution > 10) ? 10 : rollData.marginExecution]
} else {
rollData.marginExecution = -1
}
if (rollData.preservationTotal < difficulty) {
rollData.marginPreservation = difficulty - rollData.preservationTotal
rollData.cephalyFailure = "ECRY.rule." + __cephalyFailure[(rollData.marginPreservation > 10) ? 10 : rollData.marginPreservation]
} else {
rollData.marginPreservation = -1
}
let msg = await this.createChatWithRollMode(rollData.alias, {
content: await renderTemplate(`systems/fvtt-ecryme/templates/chat/chat-cephaly-result.hbs`, rollData)
})
msg.setFlag("world", "ecryme-rolldata", rollData)
console.log("Cephaly result", rollData)
}
/* -------------------------------------------- */ /* -------------------------------------------- */
static manageConfrontation(rollData) { static manageConfrontation(rollData) {
@ -243,6 +292,13 @@ export class EcrymeUtility {
let rollData = message.getFlag("world", "ecryme-rolldata") let rollData = message.getFlag("world", "ecryme-rolldata")
EcrymeUtility.manageConfrontation(rollData) EcrymeUtility.manageConfrontation(rollData)
}) })
html.on("click", '.button-apply-cephaly-difficulty', event => {
let messageId = EcrymeUtility.findChatMessageId(event.currentTarget)
let message = game.messages.get(messageId)
let rollData = message.getFlag("world", "ecryme-rolldata")
let difficulty = $("#" + rollData.rollId + "-cephaly-difficulty").val()
EcrymeUtility.manageCephalyDifficulty(rollData, difficulty)
})
html.on("click", '.button-apply-impact', event => { html.on("click", '.button-apply-impact', event => {
let messageId = EcrymeUtility.findChatMessageId(event.currentTarget) let messageId = EcrymeUtility.findChatMessageId(event.currentTarget)
let message = game.messages.get(messageId) let message = game.messages.get(messageId)
@ -255,10 +311,6 @@ export class EcrymeUtility {
let actor = game.actors.get($(event.currentTarget).data("actor-id")) let actor = game.actors.get($(event.currentTarget).data("actor-id"))
actor.modifyConfrontBonus($(event.currentTarget).data("bonus")) actor.modifyConfrontBonus($(event.currentTarget).data("bonus"))
}) })
html.on("click", '.draw-tarot-card', event => {
let messageId = EcrymeUtility.findChatMessageId(event.currentTarget)
this.drawDeckCard(messageId)
})
} }

View File

@ -0,0 +1,30 @@
<div class="chat-message-header">
{{#if actorImg}}
<img class="actor-icon" src="{{actorImg}}" alt="{{alias}}" />
{{/if}}
<h4 class="chat-actor-name">{{alias}}</h4>
</div>
<hr>
{{#if img}}
<div>
<img class="chat-icon" src="{{img}}" alt="{{alias}}" />
</div>
{{/if}}
<div>
<ul>
<li>{{localize "ECRY.ui.cephaly"}} : {{localize skill.name}}</li>
{{#if (gt marginExecution 0)}}
<li>{{localize "ECRY.ui.execution"}} {{executionTotal}} vs {{difficulty}} : {{marginExecution}}</li>
<li>{{localize cephalySuccess}}</li>
{{/if}}
{{#if (gt marginPreservation 0)}}
<li>{{localize "ECRY.ui.preservation"}} {{preservationTotal}} vs {{difficulty}} : {{marginPreservation}}</li>
<li>{{localize cephalyFailure}}</li>
{{/if}}
</ul>
</div>
</div>

View File

@ -15,13 +15,47 @@
<div> <div>
<ul> <ul>
{{#if (eq mode "cephaly")}}
<li>{{localize "ECRY.ui.cephaly"}} : {{localize skill.name}} </li>
{{else}}
<li>Confrontation : {{alias}} </li> <li>Confrontation : {{alias}} </li>
{{/if}}
<li>{{localize skill.name}}: {{skill.value}} </li> <li>{{localize skill.name}}: {{skill.value}} </li>
{{#if spec}} {{#if spec}}
<li>{{localize "ECRY.chat.specialization"}} {{spec.name}} (+2) </li> <li>{{localize "ECRY.chat.specialization"}} {{spec.name}} (+2) </li>
{{/if}} {{/if}}
{{#each traitsBonus as |trait idx|}}
{{#if trait.activated}}
<li>{{localize "ECRY.chat.traitbonus"}}: {{trait.name}} ({{trait.system.level}}) </li>
{{/if}}
{{/each}}
{{#each traitsMalus as |trait idx|}}
{{#if trait.activated}}
<li>{{localize "ECRY.chat.traitmalus"}}: {{trait.name}} ({{trait.system.level}}) </li>
{{/if}}
{{/each}}
{{#if bonusMalusTraits}}
<li>{{localize "ECRY.chat.bonusmalustraits"}}: {{bonusMalusTraits}} </li>
{{/if}}
</ul> </ul>
{{#if (isGM)}}
{{#if (eq mode "cephaly")}}
<div>
<span>{{localize "ECRY.chat.difficulty"}}</span>
<select id="{{rollId}}-cephaly-difficulty" name="cephaly-difficulty">
{{#for 1 20 1}}
<option value="{{this}}">{{this}}</option>
{{/for}}
</select>
</div>
<button class="button-apply-cephaly-difficulty">{{localize "ECRY.ui.cephalydifficulty"}}</button>
{{else}}
<button class="button-select-confront">{{localize "ECRY.ui.selectconfront"}}</button> <button class="button-select-confront">{{localize "ECRY.ui.selectconfront"}}</button>
{{/if}}
{{/if}}
</div> </div>
</div> </div>