Utilisation des ajustements

This commit is contained in:
Vincent Vandemeulebrouck 2021-01-13 03:11:03 +01:00
parent 4133ffeefa
commit 1d56bff61d
7 changed files with 19 additions and 40 deletions

View File

@ -1779,8 +1779,7 @@ export class RdDActor extends Actor {
competence: competence, competence: competence,
tache: tache, tache: tache,
diffConditions: tache.data.difficulte, diffConditions: tache.data.difficulte,
editLibre: false, use: { libre: false, conditions: false},
editConditions: false,
carac: {} carac: {}
}; };
rollData.carac[tache.data.carac] = duplicate(this.data.data.carac[tache.data.carac]); // Single carac rollData.carac[tache.data.carac] = duplicate(this.data.data.carac[tache.data.carac]); // Single carac
@ -1830,8 +1829,7 @@ export class RdDActor extends Actor {
isPurification: false, isPurification: false,
}, },
diffConditions: 0, diffConditions: 0,
editLibre: false, use: { libre: false, conditions: true, },
editConditions: true,
carac: {} carac: {}
}; };
meditationData.carac["intellect"] = duplicate(this.data.data.carac["intellect"]); meditationData.carac["intellect"] = duplicate(this.data.data.carac["intellect"]);

View File

@ -36,9 +36,9 @@ export class RdDBonus {
} else { } else {
dmg.dmgArme = RdDBonus._dmgArme(rollData); dmg.dmgArme = RdDBonus._dmgArme(rollData);
dmg.penetration = RdDBonus._peneration(rollData); dmg.penetration = RdDBonus._peneration(rollData);
dmg.dmgTactique = RdDBonus.dmgBonus(rollData.tactique); dmg.dmgTactique = RdDBonus.dmgBonus(rollData.ajustements?.tactique);
dmg.dmgParticuliere = RdDBonus._dmgParticuliere(rollData); dmg.dmgParticuliere = RdDBonus._dmgParticuliere(rollData);
dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.surpriseDefenseur); dmg.dmgSurprise = RdDBonus.dmgBonus(rollData.ajustements?.attaqueDefenseurSurpris);
dmg.dmgActor = rollData.selectedCarac ? RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac.label, dmg.dmgArme) : 0; dmg.dmgActor = rollData.selectedCarac ? RdDBonus._dmgPerso(dmgActor, rollData.selectedCarac.label, dmg.dmgArme) : 0;
dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere; dmg.total = dmg.dmgSurprise + dmg.dmgTactique + dmg.dmgArme + dmg.dmgActor + dmg.dmgParticuliere;
dmg.mortalite = RdDBonus._calculMortalite(rollData, isCauchemar) dmg.mortalite = RdDBonus._calculMortalite(rollData, isCauchemar)

View File

@ -222,7 +222,7 @@ export class RdDCombat {
ui.notifications.warn("Action automatisée impossible, le jet de l'attaquant a été perdu (suite à un raffraichissement?)") ui.notifications.warn("Action automatisée impossible, le jet de l'attaquant a été perdu (suite à un raffraichissement?)")
return; return;
} }
const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId'].value; const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId']?.value;
const armeParadeId = event.currentTarget.attributes['data-armeid']?.value; const armeParadeId = event.currentTarget.attributes['data-armeid']?.value;
@ -323,7 +323,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isEchec(rollData) { static isEchec(rollData) {
switch (rollData.surprise) { switch (rollData.ajustements.surprise.used) {
case 'totale': return true; case 'totale': return true;
} }
return rollData.rolled.isEchec; return rollData.rolled.isEchec;
@ -331,7 +331,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isEchecTotal(rollData) { static isEchecTotal(rollData) {
if (!rollData.attackerRoll && rollData.surprise) { if (!rollData.attackerRoll && rollData.ajustements.surprise.used) {
return rollData.rolled.isEchec; return rollData.rolled.isEchec;
} }
return rollData.rolled.isETotal; return rollData.rolled.isETotal;
@ -339,7 +339,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isParticuliere(rollData) { static isParticuliere(rollData) {
if (!rollData.attackerRoll && rollData.surprise) { if (!rollData.attackerRoll && rollData.ajustements.surprise.used) {
return false; return false;
} }
return rollData.rolled.isPart; return rollData.rolled.isPart;
@ -347,7 +347,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static isReussite(rollData) { static isReussite(rollData) {
switch (rollData.surprise) { switch (rollData.ajustements.surprise.used) {
case 'totale': return false; case 'totale': return false;
} }
return rollData.rolled.isSuccess; return rollData.rolled.isSuccess;
@ -414,7 +414,7 @@ export class RdDCombat {
const isMeleeDiffNegative = rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0; const isMeleeDiffNegative = rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0;
ChatMessage.create({ ChatMessage.create({
whisper: ChatMessage.getWhisperRecipients(this.attacker.name), whisper: ChatMessage.getWhisperRecipients(this.attacker.name),
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', { content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-attaque-particuliere.html', {
attackerId: this.attackerId, attackerId: this.attackerId,
defenderTokenId: this.defenderTokenId, defenderTokenId: this.defenderTokenId,
isFinesse: isMeleeDiffNegative, isFinesse: isMeleeDiffNegative,

View File

@ -49,10 +49,7 @@ export class RdDRoll extends Dialog {
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false,
surencMalusValue: actor.getSurenc(), surencMalusValue: actor.getSurenc(),
useMalusSurenc: false, useMalusSurenc: false,
use: { use: { libre:true, conditions: true, surenc: false, encTotal: false, },
surenc: false,
encTotal: false,
},
isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence),
useMalusEncTotal: false, useMalusEncTotal: false,
encTotal: actor.getEncTotal(), encTotal: actor.getEncTotal(),
@ -245,23 +242,7 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
_computeFinalLevel(rollData) { _computeFinalLevel(rollData) {
const etat = RdDCarac.isIgnoreEtatGeneral(rollData.selectedCarac) ? 0 : rollData.etat; return RollDataAjustements.sum(rollData.ajustements);
const diffConditions = Misc.toInt(rollData.diffConditions);
const malusSurenc = (rollData.useMalusSurenc) ? rollData.surencMalusValue : 0;
const bonusTactique = RdDBonus.bonusAttaque(rollData.tactique);
const malusEncTotal = (rollData.useMalusEncTotal) ? -rollData.encTotal : 0;
const ajustementChance = RdDResolutionTable.isAjustementAstrologique(rollData) ? rollData.ajustementAstrologique : 0;
// Gestion malus armure
const malusArmureValue = this._computeMalusArmure(rollData);
const diffMeditation = RdDItemMeditation.calculDifficulte(rollData);
const diffLibre = this._computeDiffLibre(rollData);
const diffCompetence = this._computeDiffCompetence(rollData);
const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0;
let ajust = RollDataAjustements.sum(rollData.ajustements);
return ajust;
//return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusSurenc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -83,7 +83,7 @@
<span class="competence-label flexrow" name="data.sante.sonne.label">Sonné : </span> <span class="competence-label flexrow" name="data.sante.sonne.label">Sonné : </span>
<input class="resource-content" type="checkbox" name="data.sante.sonne.value" <input class="resource-content" type="checkbox" name="data.sante.sonne.value"
value="{{data.sante.sonne.value}}" {{#if data.sante.sonne.value}}checked{{/if}} /> value="{{data.sante.sonne.value}}" {{#if data.sante.sonne.value}}checked{{/if}} />
<img class="img-sonne" {{#if data.sante.sonne.value}}style="opacity: 1;"{{else}}style="opacity: 0;"{{/if}} src="icons/svg/stoned.svg" height="16" width="16"/> <img class="button-effect-img" {{#if data.sante.sonne.value}}style="opacity: 1;"{{else}}style="opacity: 0;"{{/if}} src="icons/svg/stoned.svg" height="16" width="16"/>
</li> </li>
<li class="competence flexrow list-item" data-attribute="etat"> <li class="competence flexrow list-item" data-attribute="etat">
<span class="competence-label flexrow" name="data.compteurs.etat.label">Etat Général : </span> <span class="competence-label flexrow" name="data.compteurs.etat.label">Etat Général : </span>

View File

@ -83,7 +83,7 @@
<span class="competence-label flexrow" name="data.sante.sonne.label">Sonné : </span> <span class="competence-label flexrow" name="data.sante.sonne.label">Sonné : </span>
<input class="resource-content" type="checkbox" name="data.sante.sonne.value" <input class="resource-content" type="checkbox" name="data.sante.sonne.value"
value="{{data.sante.sonne.value}}" {{#if data.sante.sonne.value}}checked{{/if}} /> value="{{data.sante.sonne.value}}" {{#if data.sante.sonne.value}}checked{{/if}} />
<img class="img-sonne" {{#if data.sante.sonne.value}}style="opacity: 1;"{{else}}style="opacity: 0;"{{/if}} src="icons/svg/stoned.svg" height="16" width="16"/> <img class="button-effect-img" {{#if data.sante.sonne.value}}style="opacity: 1;"{{else}}style="opacity: 0;"{{/if}} src="icons/svg/stoned.svg" height="16" width="16"/>
</li> </li>
<li class="competence flexrow list-item" data-attribute="etat"> <li class="competence flexrow list-item" data-attribute="etat">
<span class="competence-label flexrow" name="data.compteurs.etat.label">Etat Général : </span> <span class="competence-label flexrow" name="data.compteurs.etat.label">Etat Général : </span>

View File

@ -17,7 +17,7 @@
<label>{{diffLibre}}</label> <label>{{diffLibre}}</label>
{{else}} {{else}}
<label for="categorie">Difficulté libre</label> <label for="categorie">Difficulté libre</label>
<select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless editLibre}}disabled{{/unless}}> <select name="diffLibre" id="diffLibre" data-dtype="number" {{#unless use.libre}}disabled{{/unless}}>
{{#select diffLibre}} {{#select diffLibre}}
{{#each difficultesLibres as |key|}} {{#each difficultesLibres as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
@ -26,7 +26,7 @@
</select> </select>
{{/if}} {{/if}}
<label for="categorie">&nbsp;&nbsp;Conditions</label> <label for="categorie">&nbsp;&nbsp;Conditions</label>
<select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless editConditions}}disabled{{/unless}}> <select name="diffConditions" id="diffConditions" data-dtype="number" {{#unless use.conditions}}disabled{{/unless}}>
{{#select diffConditions}} {{#select diffConditions}}
{{#each ajustementsConditions as |key|}} {{#each ajustementsConditions as |key|}}
<option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option> <option value={{key}}>{{numberFormat key decimals=0 sign=true}}</option>
@ -45,7 +45,7 @@
<label></label> <label></label>
{{else}} {{else}}
<label for="categorie">Tactique:</label> <label for="categorie">Tactique:</label>
<select name="tactique-combat" id="tactique-combat" data-dtype="String" {{#unless editConditions}}disabled{{/unless}}> <select name="tactique-combat" id="tactique-combat" data-dtype="String" {{#unless use.conditions}}disabled{{/unless}}>
<option value="Attaque normale">Attaque normale</option> <option value="Attaque normale">Attaque normale</option>
<option value="charge">Charge</option> <option value="charge">Charge</option>
<option value="feinte">Feinte</option> <option value="feinte">Feinte</option>
@ -54,8 +54,8 @@
<label>Non Mortel</label> <label>Non Mortel</label>
<input class="attribute-value" type="checkbox" id="coupsNonMortels" name="coupsNonMortels" {{#if coupsNonMortels}}checked{{/if}}/> <input class="attribute-value" type="checkbox" id="coupsNonMortels" name="coupsNonMortels" {{#if coupsNonMortels}}checked{{/if}}/>
{{/if}} {{/if}}
{{#if surpriseDefenseur}} {{#if ajustements.attaqueDefenseurSurpris}}
<label for="categorie" id="defenseur-surprise"></label> <label for="categorie" id="defenseur-surprise">{{ajustements.attaqueDefenseurSurpris.descr}}</label>
{{/if}} {{/if}}
</div> </div>
{{/if}} {{/if}}