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 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) {
case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value);
case '#parer-button': return this.parade(attackerRoll, armeParadeId);
case '#esquiver-button': return this.esquive(attackerRoll);
case '#parer-button': return this.parade(attackerRoll, armeParadeId, competence);
case '#esquiver-button': return this.esquive(attackerRoll, compId, competence);
case '#encaisser-button': return this.encaisser(attackerRoll, defenderTokenId);
case '#echec-total-attaque': return this._onEchecTotal(attackerRoll);
@ -872,7 +874,7 @@ export class RdDCombat {
await this._sendMessageDefense(attackerRoll, defenderRoll);
}
}
/* -------------------------------------------- */
isPossession( attackerRoll) {
return attackerRoll.selectedCarac.label.toLowerCase() == 'possession';
@ -888,18 +890,18 @@ export class RdDCombat {
}
// # utilisation esquive
const esquive = Misc.data(this.defender.getCompetence("esquive"));
const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps"));
const esquiveUsage = esquive ? this.defender.getItemUse(esquive._id) : 0;
const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps", { onMessage: it => console.info(it, this.defender) }));
const esquives = duplicate(this.defender.getCompetences("esquive", { onMessage: it => console.info(it, this.defender) }).map(c => Misc.data(c)));
esquives.forEach(e => e.usages = e?.id ? this.defender.getItemUse(e.id) : 0);
const paramChatDefense = {
passeArme: attackerRoll.passeArme,
essais: attackerRoll.essais,
isPossession: this.isPossession( attackerRoll),
isPossession: this.isPossession(attackerRoll),
defender: Misc.data(this.defender),
attacker: Misc.data(this.attacker),
attackerId: this.attackerId,
esquiveUsage: esquiveUsage,
esquives: esquives,
defenderTokenId: this.defenderTokenId,
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && corpsACorps,
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);
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,
{
@ -1042,20 +1044,16 @@ export class RdDCombat {
}
/* -------------------------------------------- */
_prepareParade(attackerRoll, armeParade) {
const compName = armeParade.data.competence;
const armeAttaque = attackerRoll.arme;
const parade = Misc.data(this.defender.getCompetence(compName));
_prepareParade(attackerRoll, armeParade, competenceParade) {
let defenderRoll = {
passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll,
competence: parade,
competence: Misc.data(this.defender.getCompetence(competenceParade)),
arme: armeParade,
surprise: this.defender.getSurprise(true),
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,
show: {}
};
@ -1101,10 +1099,10 @@ export class RdDCombat {
}
/* -------------------------------------------- */
async esquive(attackerRoll) {
const esquive = Misc.data(this.defender.getCompetence("esquive"));
async esquive(attackerRoll, compId, compName) {
const esquive = Misc.data(this.defender.getCompetence(compId) ?? this.defender.getCompetence(compName));
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;
}
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>
</li>
{{/each}}
<li class="item flexrow list-item">
<span class="competence-label"><a data-competence-name="{{esquive.name}}">{{esquive.name}}</a></span>
<span class="arme-initiative"></span>
<span class="competence-label"></span>
<span class="competence-value">{{numberFormat esquive.niveau decimals=0 sign=true}}</span>
<span class="competence-value"></span>
</li>
{{#each esquives as |esq key|}}
<li class="item flexrow list-item">
<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="competence-label"></span>
<span class="competence-value">{{numberFormat esq.data.niveau decimals=0 sign=true}}</span>
<span class="competence-value"></span>
</li>
{{/each}}
</ul>
<hr>
{{!-- Liste de blessures --}}

View File

@ -36,22 +36,27 @@
{{/unless}}
{{else}}
{{#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}}
</a>
<br>
{{/each}}
{{#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}}
</a>
<br>
{{/if}}
{{#if (ne attaqueCategorie 'tir')}}
<a class='chat-card-button' id='esquiver-button' data-attackerId='{{attackerId}}' data-defenderTokenId='{{defenderTokenId}}'>
Esquiver à {{diffLibre}} {{#if esquiveUsage}} (Utilisations : {{esquiveUsage}}){{/if}}
{{#each esquives as |esq key|}}
<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>
<br>
{{/each}}
{{/if}}
{{/if}}
{{/unless}}