Amélioration usage armes

Décompter uniquemlent si le jet n'est pas une particulière

Sur attaque particulière, décompter si le choix n'est pas une attaque
en rapidité
This commit is contained in:
Vincent Vandemeulebrouck 2021-03-14 19:04:35 +01:00
parent 620b34443d
commit 300419cbad
2 changed files with 16 additions and 21 deletions

View File

@ -2788,19 +2788,11 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
async decItemUse( itemId ) {
async incDecItemUse( itemId, inc = 1 ) {
let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {});
itemUse[itemId] = (itemUse[itemId] ?? 0) - 1;
itemUse[itemId] = (itemUse[itemId] ?? 0) + inc;
await this.setFlag( 'foundryvtt-reve-de-dragon', 'itemUse', itemUse);
console.log("ITEM USE DEC", itemUse);
}
/* -------------------------------------------- */
async incItemUse( itemId ) {
let itemUse = duplicate(this.getFlag('foundryvtt-reve-de-dragon', 'itemUse') ?? {});
itemUse[itemId] = (itemUse[itemId] ?? 0) + 1;
await this.setFlag( 'foundryvtt-reve-de-dragon', 'itemUse', itemUse);
console.log("ITEM USE INC", itemUse);
console.log("ITEM USE INC", inc, itemUse);
}
/* -------------------------------------------- */

View File

@ -50,10 +50,10 @@ export class RdDCombatManager extends Combat {
/* -------------------------------------------- */
cleanSonne() {
for (let combatant of this.data.combatants) {
if (combatant.actor){
if (combatant.actor) {
combatant.actor.verifierSonneRound(this.current.round);
}
else{
else {
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`)
}
}
@ -686,7 +686,6 @@ export class RdDCombat {
let rollData = this._prepareAttaque(competence, arme);
console.log("RdDCombat.attaque >>>", rollData);
if (arme) {
this.attacker.incItemUse(arme._id); // Usage
this.attacker.verifierForceMin(arme);
}
@ -700,6 +699,7 @@ export class RdDCombat {
callbacks: [
this.attacker.createCallbackExperience(),
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ condition: r => arme && !RdDCombat.isParticuliere(r), action: r => this.attacker.incDecItemUse(arme._id) },
{ condition: r => (RdDCombat.isReussite(r) && !RdDCombat.isParticuliere(r)), action: r => this._onAttaqueNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onAttaqueParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onAttaqueEchec(r) },
@ -738,7 +738,6 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onAttaqueParticuliere(rollData) {
RdDCombat._storeAttaque(this.attackerId, rollData);
this.attacker.decItemUse( rollData.arme._id ); // Usage décrémenté sur particulière
// Finesse et Rapidité seulement en mêlée et si la difficulté libre est de -1 minimum
const isMeleeDiffNegative = rollData.selectedCarac.label == "Mêlée" && rollData.diffLibre < 0;
@ -909,6 +908,10 @@ export class RdDCombat {
async choixParticuliere(rollData, choix) {
console.log("RdDCombat.choixParticuliere >>>", rollData, choix);
if (choix != "rapidite") {
this.attacker.incDecItemUse(rollData.arme._id);
}
this.removeChatMessageActionsPasseArme(rollData.passeArme);
rollData.particuliere = choix;
await this._onAttaqueNormale(rollData);
@ -919,7 +922,6 @@ export class RdDCombat {
let arme = this.defender.getArmeParade(armeParadeId);
console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme);
this.defender.incItemUse(armeParadeId); // Usage
let rollData = this._prepareParade(attackerRoll, arme);
@ -933,6 +935,7 @@ export class RdDCombat {
callbacks: [
this.defender.createCallbackExperience(),
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(armeParadeId) },
{ condition: RdDCombat.isReussite, action: r => this._onParadeNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onParadeParticuliere(r) },
{ condition: RdDCombat.isEchec, action: r => this._onParadeEchec(r) },
@ -946,7 +949,7 @@ export class RdDCombat {
const compName = armeParade.data.competence;
const armeAttaque = attackerRoll.arme;
let rollData = {
let defenderRoll = {
passeArme: attackerRoll.passeArme,
diffLibre: attackerRoll.diffLibre,
attackerRoll: attackerRoll,
@ -958,13 +961,13 @@ export class RdDCombat {
carac: this.defender.data.data.carac,
show: {}
};
rollData.diviseurSignificative = this._getDiviseurSignificative(rollData);
defenderRoll.diviseurSignificative = this._getDiviseurSignificative(defenderRoll);
if (this.defender.isCreature()) {
RdDItemCompetenceCreature.setRollDataCreature(rollData);
RdDItemCompetenceCreature.setRollDataCreature(defenderRoll);
}
return rollData;
return defenderRoll;
}
/* -------------------------------------------- */
@ -1027,7 +1030,6 @@ export class RdDCombat {
}
console.log("RdDCombat.esquive >>>", attackerRoll, esquive);
let rollData = this._prepareEsquive(attackerRoll, esquive);
this.defender.incItemUse(esquive._id); // Usage
const dialog = await RdDRoll.create(this.defender, rollData,
{ html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html' }, {
@ -1035,6 +1037,7 @@ export class RdDCombat {
label: 'Esquiver',
callbacks: [
this.defender.createCallbackExperience(),
{ condition: r => !RdDCombat.isParticuliere(r), action: r => this.defender.incDecItemUse(esquive._id) },
{ action: r => this.removeChatMessageActionsPasseArme(r.passeArme) },
{ condition: RdDCombat.isReussite, action: r => this._onEsquiveNormale(r) },
{ condition: RdDCombat.isParticuliere, action: r => this._onEsquiveParticuliere(r) },