Rework combat
This commit is contained in:
parent
e95f7de0c5
commit
6a46faadc2
@ -160,7 +160,7 @@ export class HeritiersActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
prepareUtileSkill(item) {
|
||||
let specList = []
|
||||
if (item.system.categorie == "utile") {
|
||||
if (item && item.system.categorie && item.system.categorie == "utile") {
|
||||
for (let spec of item.system.specialites) {
|
||||
specList.push(spec.name)
|
||||
}
|
||||
@ -480,6 +480,20 @@ export class HeritiersActor extends Actor {
|
||||
}
|
||||
return talents
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCurrentParade() {
|
||||
if ( this.system.statutmasque == "masque") {
|
||||
return this.system.combat.parade.masquee
|
||||
}
|
||||
return this.system.combat.parade.demasquee
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getCurrentEsquive() {
|
||||
if ( this.system.statutmasque == "masque") {
|
||||
return this.system.combat.esquive.masquee
|
||||
}
|
||||
return this.system.combat.esquive.demasquee
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getTricherie() {
|
||||
@ -522,9 +536,15 @@ export class HeritiersActor extends Actor {
|
||||
}
|
||||
if (compName) {
|
||||
rollData.competence = duplicate(this.items.find(item => item.name.toLowerCase() == compName.toLowerCase()) || {})
|
||||
this.prepareUtileSkill(rollData.competence)
|
||||
rollData.actionImg = rollData.competence?.img
|
||||
if (rollData.competence && rollData.competence.name) {
|
||||
this.prepareUtileSkill(rollData.competence)
|
||||
rollData.actionImg = rollData.competence?.img
|
||||
} else {
|
||||
rollData.competence = undefined
|
||||
}
|
||||
}
|
||||
HeritiersUtility.updateWithTarget(rollData)
|
||||
|
||||
return rollData
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
|
@ -64,7 +64,7 @@ export const HERITIERS_CONFIG = {
|
||||
"demasque": "Démasqué"
|
||||
},
|
||||
seuilsDifficulte: {
|
||||
"0": "Aucun/Non applicable",
|
||||
"-1": "Aucun/Non applicable",
|
||||
"5": "Enfantine",
|
||||
"6": "Triviale",
|
||||
"7": "Moins Triviale",
|
||||
|
@ -13,32 +13,46 @@ export class HeritiersRollDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(actor, rollData, html, options, close = undefined) {
|
||||
let buttons = {
|
||||
rolld8: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer 1d8",
|
||||
callback: () => { this.roll("d8") }
|
||||
},
|
||||
rolld10: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer 1d10",
|
||||
callback: () => { this.roll("d10") }
|
||||
},
|
||||
rolld12: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer 1d12",
|
||||
callback: () => { this.roll("d12") }
|
||||
}
|
||||
}
|
||||
if (rollData.tricherie) {
|
||||
buttons["rollTricherie"] = {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer avec 1 Point de Tricherie",
|
||||
callback: () => { this.roll("tricherie") }
|
||||
}
|
||||
}
|
||||
if (rollData.heritage) {
|
||||
buttons["rollHeritage"] = {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer avec 1 Point d'Héritage",
|
||||
callback: () => { this.roll("heritage") }
|
||||
}
|
||||
}
|
||||
buttons["Cancel"] = {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Annuler",
|
||||
callback: () => { this.close() }
|
||||
}
|
||||
let conf = {
|
||||
title: "Test de Capacité",
|
||||
content: html,
|
||||
buttons:
|
||||
{
|
||||
rolld8: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer 1d8",
|
||||
callback: () => { this.roll("d8") }
|
||||
},
|
||||
rolld10: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer 1d10",
|
||||
callback: () => { this.roll("d10") }
|
||||
},
|
||||
rolld12: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: "Lancer 1d12",
|
||||
callback: () => { this.roll("d12") }
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: "Annuler",
|
||||
callback: () => { this.close() }
|
||||
}
|
||||
},
|
||||
buttons: buttons,
|
||||
close: close
|
||||
}
|
||||
// Overwrite in case of carac only -> 1d10
|
||||
@ -64,7 +78,16 @@ export class HeritiersRollDialog extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
roll(dice) {
|
||||
this.rollData.mainDice = dice
|
||||
if (dice == "heritage") {
|
||||
this.rollData.useHeritage = true
|
||||
}
|
||||
else {
|
||||
if (dice == "tricherie") {
|
||||
this.rollData.useTricherie = true
|
||||
} else {
|
||||
this.rollData.mainDice = dice
|
||||
}
|
||||
}
|
||||
HeritiersUtility.rollHeritiers(this.rollData)
|
||||
}
|
||||
|
||||
|
@ -288,14 +288,14 @@ export class HeritiersUtility {
|
||||
rollData.marge = 0
|
||||
|
||||
if (isTricherieHeritage) {
|
||||
let resTab = [ rollData.roll.terms[0].results[0].result, rollData.roll.terms[0].results[1].result, rollData.roll.terms[0].results[2].result ]
|
||||
let resTab = [rollData.roll.terms[0].results[0].result, rollData.roll.terms[0].results[1].result, rollData.roll.terms[0].results[2].result]
|
||||
rollData.diceResult = resTab[0] + "," + resTab[1] + "," + resTab[2]
|
||||
let subResult = Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
|
||||
let subResult = Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
|
||||
if (resTab[1] == 1) { resTab[1] -= 4 }
|
||||
if (resTab[2] == 1) { resTab[2] -= 6 }
|
||||
if (resTab[2] == 2) { resTab[2] -= 7 }
|
||||
rollData.finalResult = rollData.roll.total - subResult + Math.max(Math.max(resTab[0], resTab[1]), resTab[2])
|
||||
|
||||
|
||||
// Gestion des résultats spéciaux
|
||||
resTab = resTab.sort()
|
||||
if ((resTab[0] == resTab[1]) && (resTab[1] == resTab[2])) {
|
||||
@ -316,29 +316,59 @@ export class HeritiersUtility {
|
||||
if (rollData.useHeritage) {
|
||||
this.incDecHeritage()
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
rollData.finalResult = rollData.roll.total
|
||||
let rollValue = rollData.roll.terms[0].results[0].result
|
||||
rollData.diceResult = rollData.roll.terms[0].results[0].result
|
||||
if (rollData.mainDice.includes("d10")) {
|
||||
if (rollData.diceResult == 1) {
|
||||
rollData.finalResult -= 3 + rollData.diceResult // substract 3 and the 1 value that has been added
|
||||
if (rollValue == 1) {
|
||||
rollData.finalResult -= 3 + rollValue // substract 3 and the 1 value that has been added
|
||||
}
|
||||
}
|
||||
if (rollData.mainDice.includes("d12")) {
|
||||
if (rollData.diceResult == 1 || rollData.diceResult == 2) {
|
||||
rollData.finalResult -= 5 + rollData.diceResult // Remove also the dice result has it has been added already
|
||||
if (rollValue == 1 || rollValue == 2) {
|
||||
rollData.finalResult -= 5 + rollValue // Remove also the dice result has it has been added already
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//rollData.finalResult = Math.max(rollData.finalResult, 0)
|
||||
//console.log("Result : ", rollData)
|
||||
if (rollData.marge == 0 && rollData.sdValue > 0) {
|
||||
rollData.marge = rollData.finalResult - rollData.sdValue
|
||||
rollData.isSuccess = (rollData.finalResult >= rollData.sdValue)
|
||||
rollData.isCriticalSuccess = ((rollData.finalResult - rollData.sdValue) >= 7)
|
||||
rollData.isCriticalFailure = ((rollData.finalResult - rollData.sdValue) <= -7)
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeArmeDegats(rollData, actor) {
|
||||
rollData.degatsArme = rollData.arme.system.degats + rollData.marge
|
||||
if (rollData.arme.system.categorie == "lourde") {
|
||||
rollData.degatsArme += actor.system.caracteristiques.for.value
|
||||
}
|
||||
if (rollData.arme.system.categorie == "blanche" || rollData.arme.system.categorie == "improvise") {
|
||||
rollData.degatsArme += Math.max(0, actor.system.caracteristiques.for.value - 2)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeMarge(rollData, seuil) {
|
||||
if (rollData.marge == 0 && seuil >= 0) {
|
||||
rollData.marge = rollData.finalResult - seuil
|
||||
rollData.isSuccess = (rollData.finalResult >= seuil)
|
||||
rollData.isCriticalSuccess = ((rollData.finalResult - seuil) >= 7)
|
||||
rollData.isCriticalFailure = ((rollData.finalResult - seuil) <= -7)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static async displayUneDefense(rollData, actor, nomDefense, valeurDefense) {
|
||||
rollData.defenderMode = nomDefense
|
||||
rollData.defenderValue = valeurDefense
|
||||
rollData.marge = 0
|
||||
this.computeMarge(rollData, valeurDefense)
|
||||
if (rollData.isSuccess) {
|
||||
this.computeArmeDegats(rollData, actor)
|
||||
}
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-les-heritiers/templates/chat-cc-result.html`, rollData)
|
||||
}, rollData, "selfroll")
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -380,26 +410,26 @@ export class HeritiersUtility {
|
||||
rollData.roll = myRoll
|
||||
console.log(">>>> ", myRoll)
|
||||
this.computeResult(actor, rollData)
|
||||
|
||||
this.computeMarge(rollData, rollData.sdValue) // Calcul de la marge si seuil présent
|
||||
|
||||
if (rollData.mode == "init") {
|
||||
actor.setFlag("world", "last-initiative", rollData.finalResult)
|
||||
}
|
||||
|
||||
// Compute damages, cf p 187
|
||||
if (rollData.arme && rollData.isSuccess) {
|
||||
rollData.degatsArme = rollData.arme.system.degats + rollData.marge
|
||||
if (rollData.arme.system.categorie == "lourde") {
|
||||
rollData.degatsArme += actor.system.caracteristiques.for.value
|
||||
}
|
||||
if (rollData.arme.system.categorie == "blanche" || rollData.arme.system.categorie == "improvise") {
|
||||
rollData.degatsArme += Math.max(0, actor.system.caracteristiques.for.value - 2)
|
||||
}
|
||||
this.computeArmeDegats(rollData, actor)
|
||||
}
|
||||
|
||||
this.createChatWithRollMode(rollData.alias, {
|
||||
content: await renderTemplate(`systems/fvtt-les-heritiers/templates/chat-generic-result.html`, rollData)
|
||||
}, rollData)
|
||||
|
||||
if (rollData.defenderTokenId && rollData.arme && rollData.arme.system.categorie != "trait") {
|
||||
await this.displayUneDefense(rollData, actor, "Parade", rollData.defenderParade)
|
||||
await this.displayUneDefense(rollData, actor, "Esquive", rollData.defenderEsquive)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -509,7 +539,7 @@ export class HeritiersUtility {
|
||||
rollId: randomID(16),
|
||||
rollMode: game.settings.get("core", "rollMode"),
|
||||
sdList: game.system.lesheritiers.config.seuilsDifficulte,
|
||||
sdValue: 0,
|
||||
sdValue: -1,
|
||||
bonusMalusContext: 0
|
||||
}
|
||||
return rollData
|
||||
@ -521,18 +551,17 @@ export class HeritiersUtility {
|
||||
if (target) {
|
||||
rollData.defenderTokenId = target.id
|
||||
let defender = game.canvas.tokens.get(rollData.defenderTokenId).actor
|
||||
rollData.armeDefense = defender.getBestDefenseValue()
|
||||
rollData.targetVigueur = defender.getVigueur()
|
||||
if (rollData.armeDefense) {
|
||||
rollData.difficulte = rollData.armeDefense.system.totalDefensif
|
||||
} else {
|
||||
ui.notifications.warn("Aucune arme de défense équipée, difficulté manuelle à positionner.")
|
||||
}
|
||||
rollData.defenderName = defender.name
|
||||
rollData.defenderParade = defender.getCurrentParade()
|
||||
rollData.defenderEsquive = defender.getCurrentEsquive()
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static createChatWithRollMode(name, chatOptions, rollData = undefined) {
|
||||
static createChatWithRollMode(name, chatOptions, rollData = undefined, rollMode = undefined) {
|
||||
if ( rollMode == undefined) {
|
||||
rollMode = game.settings.get("core", "rollMode")
|
||||
}
|
||||
this.createChatMessage(name, game.settings.get("core", "rollMode"), chatOptions, rollData)
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,16 @@
|
||||
<label class="item-field-label-short">Malus</label>
|
||||
<input type="text" class="item-field-label-short" value="{{pvMalus}}" data-dtype="Number" disabled />
|
||||
<span> </span>
|
||||
|
||||
<select class="item-field-label-medium" type="text" name="system.statutmasque" value="{{system.statutmasque}}" data-dtype="string">
|
||||
{{#select system.statutmasque}}
|
||||
{{#each config.statutMasque as |categ cKey|}}
|
||||
<option value="{{cKey}}">{{categ}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
|
||||
<span> </span>
|
||||
<label class="item-field-label-short">Tricherie</label>
|
||||
<input type="text" class="item-field-label-short" name="system.rang.tricherie.value" value="{{system.rang.tricherie.value}}" data-dtype="Number" />
|
||||
<input type="text" class="item-field-label-short" name="system.rang.tricherie.max" value="{{system.rang.tricherie.max}}" data-dtype="Number" />
|
||||
|
34
templates/chat-cc-result.html
Normal file
34
templates/chat-cc-result.html
Normal file
@ -0,0 +1,34 @@
|
||||
<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 actionImg}}
|
||||
<div>
|
||||
<img class="chat-icon" src="{{actionImg}}" alt="{{name}}" />
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="flexcol">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<ul>
|
||||
<li>Défense de {{defenderName}} : {{defenderMode}} ({{defenderValue}})</li>
|
||||
|
||||
{{#if isSuccess}}
|
||||
<li>Marge : {{marge}}</li>
|
||||
<li>Degats de l'arme : {{degatsArme}}</li>
|
||||
{{#if isCriticalSuccess}}
|
||||
<Li>Critique : Aubaine ou +2 aux dégats ci-dessus</li>
|
||||
{{/if}}
|
||||
{{else}}
|
||||
<li>Echec face à la {{defenderMode}} !</li>
|
||||
{{/if}}
|
||||
|
||||
</ul>
|
||||
</div>
|
@ -1,28 +0,0 @@
|
||||
<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 actionImg}}
|
||||
<div>
|
||||
<img class="chat-icon" src="{{actionImg}}" alt="{{name}}" />
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="flexcol">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<ul>
|
||||
<li>Arme : {{arme.name}} (+{{arme.system.totalDegats}})</li>
|
||||
<li>Dégats : {{finalResult}}</li>
|
||||
{{#if targetVigueur}}
|
||||
<li>Vigueur de la cible : {{targetVigueur}}</li>
|
||||
<li>Etats Combativité supplémentaires perdus (manuel): {{nbEtatPerdus}} </li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</div>
|
@ -42,9 +42,9 @@
|
||||
|
||||
<li>Formule : {{diceFormula}}</li>
|
||||
<li>Résultat du dé : {{diceResult}} </li>
|
||||
<li>Total : {{finalResult}} (Marge : {{marge}})</li>
|
||||
<li>Total : {{finalResult}} {{#if (gt sdValue "-1")}}(Marge : {{marge}}){{/if}}</li>
|
||||
|
||||
{{#if sdValue}}
|
||||
{{#if (gt sdValue "-1")}}
|
||||
{{#if isSuccess}}
|
||||
<li class="chat-success">Succès...
|
||||
{{#if arme}}
|
||||
|
@ -71,20 +71,6 @@
|
||||
<span class="small-label roll-dialog-label">{{pvMalus}}</span>
|
||||
</div>
|
||||
|
||||
{{#if tricherie}}
|
||||
<div class="flexrow">
|
||||
<span class="roll-dialog-label">Utiliser 1 point de Tricherie ({{tricherie}}) ?</span>
|
||||
<input type="checkbox" class="item-field-label-short" id="useTricherie" {{checked useTricherie}}/>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if heritage}}
|
||||
<div class="flexrow">
|
||||
<span class="roll-dialog-label">Utiliser 1 point d'Heritage ? ({{heritage}})</span>
|
||||
<input type="checkbox" class="item-field-label-short" id="useHeritage" {{checked useHeritage}}/>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="flexrow">
|
||||
<span class="roll-dialog-label">Bonus/Malus </span>
|
||||
<select class="roll-dialog-label" id="bonus-malus-context" type="text" value="{{bonusMalusContext}}"
|
||||
|
Loading…
Reference in New Issue
Block a user