Plusieurs compétences esquive

Pour les sirènes!
This commit is contained in:
Vincent Vandemeulebrouck 2021-11-20 02:53:28 +01:00
parent a2f859a460
commit 6fc6bfc540
3 changed files with 43 additions and 31 deletions

View File

@ -626,11 +626,13 @@ export class RdDCombat {
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;
const competence = event.currentTarget.attributes['data-competence']?.value;
const compId = event.currentTarget.attributes['data-compid']?.value;
switch (button) { switch (button) {
case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value); case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
case '#parer-button': return this.parade(attackerRoll, armeParadeId); case '#parer-button': return this.parade(attackerRoll, armeParadeId, competence);
case '#esquiver-button': return this.esquive(attackerRoll); case '#esquiver-button': return this.esquive(attackerRoll, compId, competence);
case '#encaisser-button': return this.encaisser(attackerRoll, defenderTokenId); case '#encaisser-button': return this.encaisser(attackerRoll, defenderTokenId);
case '#echec-total-attaque': return this._onEchecTotal(attackerRoll); case '#echec-total-attaque': return this._onEchecTotal(attackerRoll);
@ -888,18 +890,18 @@ export class RdDCombat {
} }
// # utilisation esquive // # utilisation esquive
const esquive = Misc.data(this.defender.getCompetence("esquive")); const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps", { onMessage: it => console.info(it, this.defender) }));
const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps")); const esquives = duplicate(this.defender.getCompetences("esquive", { onMessage: it => console.info(it, this.defender) }).map(c => Misc.data(c)));
const esquiveUsage = esquive ? this.defender.getItemUse(esquive._id) : 0; esquives.forEach(e => e.usages = e?.id ? this.defender.getItemUse(e.id) : 0);
const paramChatDefense = { const paramChatDefense = {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
essais: attackerRoll.essais, essais: attackerRoll.essais,
isPossession: this.isPossession( attackerRoll), isPossession: this.isPossession(attackerRoll),
defender: Misc.data(this.defender), defender: Misc.data(this.defender),
attacker: Misc.data(this.attacker), attacker: Misc.data(this.attacker),
attackerId: this.attackerId, attackerId: this.attackerId,
esquiveUsage: esquiveUsage, esquives: esquives,
defenderTokenId: this.defenderTokenId, defenderTokenId: this.defenderTokenId,
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && corpsACorps, mainsNues: attackerRoll.dmg.mortalite != 'mortel' && corpsACorps,
armes: this._filterArmesParade(this.defender, attackerRoll.competence, attackerRoll.arme), armes: this._filterArmesParade(this.defender, attackerRoll.competence, attackerRoll.arme),
@ -1014,12 +1016,12 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async parade(attackerRoll, armeParadeId) { async parade(attackerRoll, armeParadeId, competence) {
let arme = this.defender.getArmeParade(armeParadeId); let arme = this.defender.getArmeParade(armeParadeId);
console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme); console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme);
let rollData = this._prepareParade(attackerRoll, arme); let rollData = this._prepareParade(attackerRoll, arme, competence);
const dialog = await RdDRoll.create(this.defender, rollData, const dialog = await RdDRoll.create(this.defender, rollData,
{ {
@ -1042,20 +1044,16 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_prepareParade(attackerRoll, armeParade) { _prepareParade(attackerRoll, armeParade, competenceParade) {
const compName = armeParade.data.competence;
const armeAttaque = attackerRoll.arme;
const parade = Misc.data(this.defender.getCompetence(compName));
let defenderRoll = { let defenderRoll = {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre, diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll, attackerRoll: attackerRoll,
competence: parade, competence: Misc.data(this.defender.getCompetence(competenceParade)),
arme: armeParade, arme: armeParade,
surprise: this.defender.getSurprise(true), surprise: this.defender.getSurprise(true),
needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(armeAttaque, armeParade), needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(armeAttaque, armeParade),
needResist: RdDItemArme.needArmeResist(armeAttaque, armeParade), needResist: RdDItemArme.needArmeResist(attackerRoll.arme, armeParade),
carac: Misc.templateData(this.defender).carac, carac: Misc.templateData(this.defender).carac,
show: {} show: {}
}; };
@ -1101,10 +1099,10 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async esquive(attackerRoll) { async esquive(attackerRoll, compId, compName) {
const esquive = Misc.data(this.defender.getCompetence("esquive")); const esquive = Misc.data(this.defender.getCompetence(compId) ?? this.defender.getCompetence(compName));
if (esquive == undefined) { if (esquive == undefined) {
ui.notifications.error(this.defender.name + " n'a pas de compétence 'esquive'"); ui.notifications.error(this.defender.name + " n'a pas de compétence " + compName);
return; return;
} }
console.log("RdDCombat.esquive >>>", attackerRoll, esquive); console.log("RdDCombat.esquive >>>", attackerRoll, esquive);

View File

@ -290,13 +290,22 @@
<span class="competence-value">{{numberFormat arme.data.dommagesReels decimals=0 sign=true}}</span> <span class="competence-value">{{numberFormat arme.data.dommagesReels decimals=0 sign=true}}</span>
</li> </li>
{{/each}} {{/each}}
{{#each esquives as |esq key|}}
<li class="item flexrow list-item"> <li class="item flexrow list-item">
<span class="competence-label"><a data-competence-name="{{esquive.name}}">{{esquive.name}}</a></span> <span class="competence-label">
<a class="competence-label" name="{{esq.name}}">
<img class="sheet-competence-img" src="{{esq.img}}"/>
<span>{{esq.name}}</span>
{{log esq}}
</a>
</span>
<span class="arme-initiative"></span> <span class="arme-initiative"></span>
<span class="competence-label"></span> <span class="competence-label"></span>
<span class="competence-value">{{numberFormat esquive.niveau decimals=0 sign=true}}</span> <span class="competence-value">{{numberFormat esq.data.niveau decimals=0 sign=true}}</span>
<span class="competence-value"></span> <span class="competence-value"></span>
</li> </li>
{{/each}}
</ul> </ul>
<hr> <hr>
{{!-- Liste de blessures --}} {{!-- Liste de blessures --}}

View File

@ -36,22 +36,27 @@
{{/unless}} {{/unless}}
{{else}} {{else}}
{{#each armes as |arme key|}} {{#each armes as |arme key|}}
<a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}' data-armeid='{{arme.id }}'> <a class='chat-card-button' id='parer-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}'
data-armeid='{{arme._id}}'>
Parer avec {{arme.name}} à {{../diffLibre }}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}} Parer avec {{arme.name}} à {{../diffLibre }}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}}
</a> </a>
<br> <br>
{{/each}} {{/each}}
{{#if mainsNues}} {{#if mainsNues}}
<a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'> <a class='chat-card-button' id='parer-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'
data-armeid='{{arme._id}}' data-competence='{{arme.data.competence}}'>
Parer à mains nues à {{diffLibre}}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}} Parer à mains nues à {{diffLibre}}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}}
</a> </a>
<br> <br>
{{/if}} {{/if}}
{{#if (ne attaqueCategorie 'tir')}} {{#if (ne attaqueCategorie 'tir')}}
<a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'> {{#each esquives as |esq key|}}
Esquiver à {{diffLibre}} {{#if esquiveUsage}} (Utilisations : {{esquiveUsage}}){{/if}} <a class='chat-card-button' id='esquiver-button' data-attackerId='{{../attackerId}}' data-defenderTokenId='{{../defenderTokenId}}'
data-compid='{{esq._id}}' data-competence='{{esq.name}}'>
{{esq.name}} à {{../diffLibre}} {{#if esq.usage}} (Utilisations : {{esq.usage}}){{/if}}
</a> </a>
<br> <br>
{{/each}}
{{/if}} {{/if}}
{{/if}} {{/if}}
{{/unless}} {{/unless}}