Fix parade créatures

This commit is contained in:
Vincent Vandemeulebrouck 2021-01-14 00:35:55 +01:00
parent 23966c1056
commit 0d599d41f9
4 changed files with 19 additions and 12 deletions

View File

@ -2119,10 +2119,10 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollCompetenceCreature(compName) { async rollCompetenceCreature(compName) {
let competence = this.getCompetence(compName); const competence = this.getCompetence(compName);
if (competence.type == 'competencecreature' && competence.data.iscombat) { if (competence.type == 'competencecreature' && competence.data.iscombat) {
let competence = this.getCompetence(compName); const arme = RdDItemCompetenceCreature.toArme(competence);
RdDCombat.createUsingTarget(this).attaque(competence, armeItem); RdDCombat.createUsingTarget(this).attaque(competence, arme);
} }
else { else {
this.rollCompetence(competence.name); this.rollCompetence(competence.name);
@ -2131,7 +2131,7 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
rollArme(compName, armeName = undefined) { rollArme(compName, armeName = undefined) {
let arme = this.data.items.find(item => item.name == armeName && RdDItemArme.isArme(item)); let arme = armeName ? this.data.items.find(item => item.name == armeName && RdDItemArme.isArme(item)) : undefined;
let competence = this.getCompetence(compName); let competence = this.getCompetence(compName);
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) { if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
@ -2151,6 +2151,11 @@ export class RdDActor extends Actor {
return undefined; return undefined;
} }
getArmeParade(armeParadeId) {
const item = armeParadeId ? this.getOwnedItem(armeParadeId) : undefined;
return RdDItemArme.getArmeData(item);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async equiperObjet(itemID) { async equiperObjet(itemID) {
let item = this.getOwnedItem(itemID); let item = this.getOwnedItem(itemID);

View File

@ -25,7 +25,7 @@ export class RdDItemArme extends Item {
switch (item ? item.data.type : '') { switch (item ? item.data.type : '') {
case 'arme': return item.data; case 'arme': return item.data;
case 'competencecreature': case 'competencecreature':
return RdDItemCompetenceCreature.toArme(item); return RdDItemCompetenceCreature.toArme(item.data);
} }
return RdDItemArme.mainsNues(); return RdDItemArme.mainsNues();
} }

View File

@ -10,7 +10,7 @@ export class RdDItemCompetenceCreature extends Item {
rollData.competence.data.categorie = "creature"; rollData.competence.data.categorie = "creature";
rollData.selectedCarac = rollData.carac.carac_creature; rollData.selectedCarac = rollData.carac.carac_creature;
if (rollData.competence.data.iscombat) { if (rollData.competence.data.iscombat) {
rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence) rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence);
} }
} }

View File

@ -355,7 +355,7 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async attaque(competence, arme) { async attaque(competence, arme = undefined) {
if (!await this.accorderEntite('avant-attaque')) { if (!await this.accorderEntite('avant-attaque')) {
return; return;
} }
@ -535,8 +535,8 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
async parade(attackerRoll, armeParadeId) { async parade(attackerRoll, armeParadeId) {
let arme = RdDItemArme.getArmeData(armeParadeId ? this.defender.getOwnedItem(armeParadeId) : null); 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);
@ -559,10 +559,11 @@ export class RdDCombat {
dialog.render(true); dialog.render(true);
} }
_prepareParade(attackerRoll, armeParade) { _prepareParade(attackerRoll, armeParade) {
const compName = armeParade.data.competence; const compName = armeParade.data.competence;
const armeAttaque = attackerRoll.arme; const armeAttaque = attackerRoll.arme;
let rollData = { let rollData = {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
forceValue: this.defender.getForceValue(), forceValue: this.defender.getForceValue(),
@ -581,15 +582,16 @@ export class RdDCombat {
if (this.defender.isCreature()) { if (this.defender.isCreature()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData); RdDItemCompetenceCreature.setRollDataCreature(rollData);
} }
return rollData; return rollData;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_getDiviseurSignificative(defenderRoll) { _getDiviseurSignificative(defenderRoll) {
let facteurSign = 1; let facteurSign = 1;
if (defenderRoll.surprise == 'demi'){ if (defenderRoll.surprise == 'demi') {
facteurSign *= 2; facteurSign *= 2;
} }
if (defenderRoll.needParadeSignificative) { if (defenderRoll.needParadeSignificative) {
facteurSign *= 2; facteurSign *= 2;
} }