Merge branch 'stabilisation-v1.2' into 'v1.2'

Stabilisation v1.2

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!119
This commit is contained in:
Leratier Bretonnien 2021-01-19 22:55:02 +00:00
commit 86a3708a7e
11 changed files with 158 additions and 212 deletions

View File

@ -8,18 +8,18 @@ import { HtmlUtility } from "./html-utility.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
import { RdDActorSheet } from "./actor-sheet.js"; import { RdDActorSheet } from "./actor-sheet.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDActorCreatureSheet extends RdDActorSheet { export class RdDActorCreatureSheet extends RdDActorSheet {
/** @override */ /** @override */
static get defaultOptions() { static get defaultOptions() {
return mergeObject(super.defaultOptions, { return mergeObject(super.defaultOptions, {
classes: ["rdd", "sheet", "actor"], classes: ["rdd", "sheet", "actor"],
template: "systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html", template: "systems/foundryvtt-reve-de-dragon/templates/actor-creature-sheet.html",
width: 640, width: 640,
height: 720, height: 720,
tabs: [{navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac"}], tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "carac" }],
dragDrop: [{dragSelector: ".item-list .item", dropSelector: null}] dragDrop: [{ dragSelector: ".item-list .item", dropSelector: null }]
}); });
} }
@ -41,30 +41,30 @@ export class RdDActorCreatureSheet extends RdDActorSheet {
// Compute current carac sum // Compute current carac sum
let sum = 0; let sum = 0;
Object.values(data.data.carac).forEach(carac => { if (!carac.derivee) { sum += parseInt(carac.value) } } ); Object.values(data.data.carac).forEach(carac => { if (!carac.derivee) { sum += parseInt(carac.value) } });
data.data.caracSum = sum; data.data.caracSum = sum;
data.data.carac.taille.isTaille = true; // To avoid button link; data.data.carac.taille.isTaille = true; // To avoid button link;
data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures); data.data.blessures.resume = this.actor.computeResumeBlessure(data.data.blessures);
data.data.isGM = game.user.isGM; data.data.isGM = game.user.isGM;
data.data.competencecreature = data.itemsByType["competencecreature"]; data.data.competencecreature = data.itemsByType["competencecreature"];
this.actor.computeEncombrementTotalEtMalusArmure(); this.actor.computeEncombrementTotalEtMalusArmure();
RdDUtility.filterItemsPerTypeForSheet(data ); RdDUtility.filterItemsPerTypeForSheet(data);
RdDUtility.buildArbreDeConteneur( this, data ); RdDUtility.buildArbreDeConteneur(this, data);
data.data.encTotal = this.actor.encTotal; data.data.encTotal = this.actor.encTotal;
data.data.isGM = game.user.isGM; data.data.isGM = game.user.isGM;
console.log("Creature : ", this.objetVersConteneur , data); console.log("Creature : ", this.objetVersConteneur, data);
return data; return data;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM); HtmlUtility._showControlWhen($(".gm-only"), game.user.isGM);
@ -72,101 +72,25 @@ export class RdDActorCreatureSheet extends RdDActorSheet {
// Everything below here is only needed if the sheet is editable // Everything below here is only needed if the sheet is editable
if (!this.options.editable) return; if (!this.options.editable) return;
// Update Inventory Item
html.find('.item-edit').click(ev => {
const li = $(ev.currentTarget).parents(".item");
const item = this.actor.getOwnedItem(li.data("itemId"));
item.sheet.render(true);
});
// Delete Inventory Item
html.find('.item-delete').click(ev => {
const li = $(ev.currentTarget).parents(".item");
this.actor.deleteOwnedItem(li.data("itemId"));
li.slideUp(200, () => this.render(false));
});
// Blessure control
html.find('.blessure-control').click(ev => {
const li = $(ev.currentTarget).parents(".item");
let btype = li.data("blessure-type");
let index = li.data('blessure-index');
let active = $(ev.currentTarget).data('blessure-active');
//console.log(btype, index, active);
this.actor.manageBlessureFromSheet(btype, index, active).then( this.render(true) );
});
// Blessure data
html.find('.blessures-soins').change(ev => {
const li = $(ev.currentTarget).parents(".item");
let btype = li.data('blessure-type');
let index = li.data('blessure-index');
let psoins = li.find('input[name=premiers_soins]').val();
let pcomplets = li.find('input[name=soins_complets]').val();
let jours = li.find('input[name=jours]').val();
let loc = li.find('input[name=localisation]').val();
//console.log(btype, index, psoins, pcomplets, jours, loc);
this.actor.setDataBlessureFromSheet(btype, index, psoins, pcomplets, jours, loc).then( this.render(true) );
});
// Roll Carac
html.find('.carac-label a').click((event) => {
let caracName = event.currentTarget.attributes.name.value;
this.actor.rollCarac( caracName.toLowerCase() );
});
// On competence change // On competence change
html.find('.creature-carac').change((event) => { html.find('.creature-carac').change((event) => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "carac_value", parseInt(event.target.value) ); this.actor.updateCreatureCompetence(compName, "carac_value", parseInt(event.target.value));
} ); });
html.find('.creature-niveau').change((event) => { html.find('.creature-niveau').change((event) => {
let compName = event.currentTarget.attributes.compname.value; let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "niveau", parseInt(event.target.value) ); this.actor.updateCreatureCompetence(compName, "niveau", parseInt(event.target.value));
} );
html.find('.creature-dommages').change((event) => {
let compName = event.currentTarget.attributes.compname.value;
this.actor.updateCreatureCompetence( compName, "dommages", parseInt(event.target.value) );
} );
// Roll Skill
html.find('.competence-label a').click((event) => {
let compName = event.currentTarget.text;
this.actor.rollCompetenceCreature( compName );
}); });
html.find('.creature-dommages').change((event) => {
html.find('#vie-plus').click((event) => { let compName = event.currentTarget.attributes.compname.value;
this.actor.santeIncDec("vie", 1); this.actor.updateCreatureCompetence(compName, "dommages", parseInt(event.target.value));
this.render(true);
});
html.find('#vie-moins').click((event) => {
this.actor.santeIncDec("vie", -1);
this.render(true);
});
html.find('#endurance-plus').click((event) => {
this.actor.santeIncDec("endurance", 1);
this.render(true);
});
html.find('#endurance-moins').click((event) => {
this.actor.santeIncDec("endurance", -1);
this.render(true);
});
html.find('#encaisser-direct').click(ev => {
this.actor.encaisser();
});
html.find('#remise-a-neuf').click(ev => {
if (game.user.isGM) {
this.actor.remiseANeuf();
}
}); });
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
/** @override */ /** @override */
setPosition(options={}) { setPosition(options = {}) {
const position = super.setPosition(options); const position = super.setPosition(options);
const sheetBody = this.element.find(".sheet-body"); const sheetBody = this.element.find(".sheet-body");
const bodyHeight = position.height - 192; const bodyHeight = position.height - 192;

View File

@ -96,7 +96,7 @@ export class RdDActorEntiteSheet extends ActorSheet {
// Roll Skill // Roll Skill
html.find('.competence-label a').click((event) => { html.find('.competence-label a').click((event) => {
let compName = event.currentTarget.text; let compName = event.currentTarget.text;
this.actor.rollCompetenceCreature( compName ); this.actor.rollCompetence( compName );
}); });
html.find('#endurance-plus').click((event) => { html.find('#endurance-plus').click((event) => {
@ -112,7 +112,7 @@ export class RdDActorEntiteSheet extends ActorSheet {
this.actor.encaisser(); this.actor.encaisser();
}); });
html.find('#remise-a-neuf').click(ev => { html.find('.remise-a-neuf').click(ev => {
if (game.user.isGM) { if (game.user.isGM) {
this.actor.remiseANeuf(); this.actor.remiseANeuf();
} }

View File

@ -207,9 +207,10 @@ export class RdDActorSheet extends ActorSheet {
this.actor.encaisser(); this.actor.encaisser();
}); });
html.find('#remise-a-neuf').click(ev => { html.find('.remise-a-neuf').click(ev => {
if (game.user.isGM) { if (game.user.isGM) {
this.actor.remiseANeuf(); this.actor.remiseANeuf();
ev.preventDefault();
} }
}); });
html.find('#creer-tache').click(ev => { html.find('#creer-tache').click(ev => {

View File

@ -391,7 +391,9 @@ export class RdDActor extends Actor {
} }
await this.update({ "data.blessures": blessures }); await this.update({ "data.blessures": blessures });
} }
await this.setEthylisme(1); if (this.isPersonnage()) {
await this.setEthylisme(1);
}
await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value); await this.santeIncDec("vie", this.data.data.sante.vie.max - this.data.data.sante.vie.value);
await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value); await this.santeIncDec("endurance", this.data.data.sante.endurance.max - this.data.data.sante.endurance.value);
@ -1149,7 +1151,7 @@ export class RdDActor extends Actor {
const sante = duplicate(this.data.data.sante); const sante = duplicate(this.data.data.sante);
let compteur = sante[name]; let compteur = sante[name];
if (!compteur) { if (!compteur) {
return; return ;
} }
let result = { let result = {
sonne: false, sonne: false,
@ -1751,8 +1753,13 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
async rollCompetence(name) { async rollCompetence(name) {
let rollData = { competence: this.getCompetence(name) } let rollData = { competence: this.getCompetence(name) }
if (rollData.competence.type == 'competencecreature') { if (rollData.competence.type == 'competencecreature') {
if (rollData.competence.data.iscombat) {
const arme = RdDItemCompetenceCreature.toArme(competence);
RdDCombat.createUsingTarget(this).attaque(competence, arme);
return;
}
// Fake competence pour créature // Fake competence pour créature
RdDItemCompetenceCreature.setRollDataCreature(rollData); RdDItemCompetenceCreature.setRollDataCreature(rollData);
} }
@ -2123,19 +2130,6 @@ export class RdDActor extends Actor {
this.currentTMR.render(true); this.currentTMR.render(true);
} }
/* -------------------------------------------- */
async rollCompetenceCreature(compName) {
const competence = this.getCompetence(compName);
if (competence.type == 'competencecreature' && competence.data.iscombat) {
const arme = RdDItemCompetenceCreature.toArme(competence);
RdDCombat.createUsingTarget(this).attaque(competence, arme);
}
else {
this.rollCompetence(competence.name);
}
}
/* -------------------------------------------- */ /* -------------------------------------------- */
rollArme(compName, armeName = undefined) { rollArme(compName, armeName = undefined) {
let arme = armeName ? this.data.items.find(item => item.name == armeName && RdDItemArme.isArme(item)) : undefined; let arme = armeName ? this.data.items.find(item => item.name == armeName && RdDItemArme.isArme(item)) : undefined;
@ -2175,36 +2169,18 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */ /* -------------------------------------------- */
computeArmure(attackerRoll) { computeArmure(attackerRoll) {
let dmg = attackerRoll.dmg.dmgArme + attackerRoll.dmg.dmgActor; let dmg = (attackerRoll.dmg.dmgArme ??0) + (attackerRoll.dmg.dmgActor ?? 0);
let arme = attackerRoll.arme; let arme = attackerRoll.arme;
// TODO: arc ignore armure
let protection = 0; let protection = 0;
for (const item of this.data.items) { const armures = this.data.items.filter(it => it.type == "armure" && it.data.equipe);
if (item.type == "armure" && item.data.equipe) { for (const item of armures) {
let update = duplicate(item); protection += new Roll(item.data.protection.toString()).roll().total;
protection += new Roll(update.data.protection.toString()).roll().total; if (dmg > 0) {
update.data.deterioration = Misc.toInt(update.data.deterioration) + dmg; this._deteriorerArmure(item, dmg);
dmg = 0; // Reset it dmg = 0;
if (update.data.deterioration >= 10) {
update.data.deterioration = 0;
let res = /\d+/.exec(update.data.protection);
if (res)
update.data.protection = "1d" + update.data.protection;
// if ( update.data.protection.toString().length == 1 )
// update.data.protection = "1d"+update.data.protection;
else if (res = /(\d+d\d+)(\-\d+)?/.exec(update.data.protection)) {
let malus = Misc.toInt(res[2]) - 1;
update.data.protection = res[1] + malus;
}
else {
ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`)
}
ChatMessage.create({ content: "Détérioration d'armure: " + update.data.protection });
}
this.updateEmbeddedEntity("OwnedItem", update);
} }
} }
// TODO: max armure (chutes) // TODO: max armure sur chutes...
const penetration = arme ? Misc.toInt(arme.data.penetration) : 0; const penetration = arme ? Misc.toInt(arme.data.penetration) : 0;
protection = Math.max(protection - penetration, 0); protection = Math.max(protection - penetration, 0);
protection += this.getProtectionNaturelle(); protection += this.getProtectionNaturelle();
@ -2212,6 +2188,27 @@ export class RdDActor extends Actor {
return protection; return protection;
} }
_deteriorerArmure(item, dmg) {
let update = duplicate(item);
update.data.deterioration = (update.data.deterioration ?? 0) + dmg;
if (update.data.deterioration >= 10) {
update.data.deterioration = 0;
let res = /\d+/.exec(update.data.protection);
if (!res) {
update.data.protection = "1d" + update.data.protection;
}
else if (res = /(\d+d\d+)(\-\d+)?/.exec(update.data.protection)) {
let malus = Misc.toInt(res[2]) - 1;
update.data.protection = res[1] + malus;
}
else {
ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`);
}
ChatMessage.create({ content: "Votre armure s'est détériorée, elle protège maintenant de " + update.data.protection });
}
this.updateEmbeddedEntity("OwnedItem", update);
}
/* -------------------------------------------- */ /* -------------------------------------------- */
async encaisser() { async encaisser() {
let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() }; let data = { ajustementsEncaissement: RdDUtility.getAjustementsEncaissement() };
@ -2231,7 +2228,9 @@ export class RdDActor extends Actor {
let encaissement = this.jetEncaissement(rollData); let encaissement = this.jetEncaissement(rollData);
this.ajouterBlessure(encaissement); // Will upate the result table this.ajouterBlessure(encaissement); // Will upate the result table
const perteVie = await this.santeIncDec("vie", - encaissement.vie); const perteVie = this.isEntiteCauchemar()
? { newValue: 0}
: await this.santeIncDec("vie", - encaissement.vie);
const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, (encaissement.critiques > 0)); const perteEndurance = await this.santeIncDec("endurance", -encaissement.endurance, (encaissement.critiques > 0));
this.computeEtatGeneral(); this.computeEtatGeneral();
@ -2245,7 +2244,7 @@ export class RdDActor extends Actor {
encaissement.sonne = perteEndurance.sonne; encaissement.sonne = perteEndurance.sonne;
encaissement.jetEndurance = perteEndurance.jetEndurance; encaissement.jetEndurance = perteEndurance.jetEndurance;
encaissement.endurance = santeOrig.endurance.value - perteEndurance.newValue; encaissement.endurance = santeOrig.endurance.value - perteEndurance.newValue;
encaissement.vie = santeOrig.vie.value - perteVie.newValue; encaissement.vie = this.isEntiteCauchemar() ? 0 : (santeOrig.vie.value - perteVie.newValue);
ChatUtility.createChatWithRollMode(this.name, { ChatUtility.createChatWithRollMode(this.name, {
roll: encaissement.roll, roll: encaissement.roll,

View File

@ -107,27 +107,27 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _getAttaque(attackerId) { static _getAttaque(attackerId) {
return game.system.rdd.combatStore.attaques[attackerId]; return game.system.rdd.combatStore.attaques[attackerId];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _deleteAttaque(attackerId) { static _deleteAttaque(attackerId) {
delete game.system.rdd.combatStore.attaques[attackerId]; delete game.system.rdd.combatStore.attaques[attackerId];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _storeDefense(defenderRoll) { static _storeDefense(defenderRoll) {
game.system.rdd.combatStore.defenses[defenderRoll.passeArme] = duplicate(defenderRoll); game.system.rdd.combatStore.defenses[defenderRoll.passeArme] = duplicate(defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _getDefense(passeArme) { static _getDefense(passeArme) {
return game.system.rdd.combatStore.defenses[passeArme]; return game.system.rdd.combatStore.defenses[passeArme];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _deleteDefense(passeArme) { static _deleteDefense(passeArme) {
delete game.system.rdd.combatStore.defenses; delete game.system.rdd.combatStore.defenses[passeArme];
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static create(attacker, defender, defenderTokenId, target = undefined) { static create(attacker, defender, defenderTokenId, target = undefined) {
@ -135,15 +135,11 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static createForEvent(event) { static createForAttackerAndDefender(attackerId, defenderTokenId) {
let attackerId = event.currentTarget.attributes['data-attackerId'].value; const attacker = game.actors.get(attackerId);
let attacker = game.actors.get(attackerId); if (defenderTokenId) {
const defenderToken = canvas.tokens.get(defenderTokenId);
const dataDefenderTokenId = event.currentTarget.attributes['data-defenderTokenId']; const defender = defenderToken.actor;
if (dataDefenderTokenId) {
const defenderTokenId = dataDefenderTokenId.value;
let defenderToken = canvas.tokens.get(defenderTokenId);
let defender = defenderToken.actor;
return RdDCombat.create(attacker, defender, defenderTokenId); return RdDCombat.create(attacker, defender, defenderTokenId);
} }
@ -166,17 +162,19 @@ export class RdDCombat {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static onMsgDefense(msgData) { static onMsgDefense(msg) {
let defenderToken = canvas.tokens.get(msgData.defenderTokenId); let defenderToken = canvas.tokens.get(msg.defenderTokenId);
if (defenderToken) { if (defenderToken) {
if (!game.user.isGM && !game.user.character) { // vérification / sanity check if (!game.user.isGM && !game.user.character) { // vérification / sanity check
ui.notifications.error("Le joueur " + game.user.name + " n'est connecté à aucun personnage. Impossible de continuer."); ui.notifications.error("Le joueur " + game.user.name + " n'est connecté à aucun personnage. Impossible de continuer.");
return; return;
} }
if ((game.user.isGM && !defenderToken.actor.hasPlayerOwner) || (defenderToken.actor.hasPlayerOwner && (game.user.character.id == defenderToken.actor.data._id))) { if ((game.user.isGM && !defenderToken.actor.hasPlayerOwner) || (defenderToken.actor.hasPlayerOwner && (game.user.character._id == defenderToken.actor.data._id))) {
const defenderRoll = msgData.defenderRoll; const rddCombat = RdDCombat.createForAttackerAndDefender(msg.attackerId, msg.defenderTokenId);
RdDCombat._storeAttaque(msgData.attackerId, defenderRoll.attackerRoll); const defenderRoll = msg.defenderRoll;
RdDCombat._storeAttaque(msg.attackerId, defenderRoll.attackerRoll);
RdDCombat._storeDefense(defenderRoll); RdDCombat._storeDefense(defenderRoll);
rddCombat._chatMessageDefense(msg.paramChatDefense);
} }
} }
} }
@ -202,8 +200,12 @@ export class RdDCombat {
'#echec-total-attaque', '#echec-total-attaque',
]) { ]) {
html.on("click", button, event => { html.on("click", button, event => {
const rddCombat = RdDCombat.createForAttackerAndDefender(
event.currentTarget.attributes['data-attackerId']?.value,
event.currentTarget.attributes['data-defenderTokenId']?.value);
rddCombat.onEvent(button, event);
event.preventDefault(); event.preventDefault();
RdDCombat.createForEvent(event).onEvent(button, event);
}); });
} }
html.on("click", '#chat-jet-vie', event => { html.on("click", '#chat-jet-vie', event => {
@ -308,7 +310,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
removeChatMessageActionsPasseArme(passeArme) { removeChatMessageActionsPasseArme(passeArme) {
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) { if (game.user.isGM && game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) {
ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`); ChatUtility.removeMyChatMessageContaining(`<div data-passearme="${passeArme}">`);
} }
} }
@ -413,7 +415,8 @@ export class RdDCombat {
attackerId: this.attackerId, attackerId: this.attackerId,
defenderTokenId: this.defenderTokenId, defenderTokenId: this.defenderTokenId,
isFinesse: isMeleeDiffNegative, isFinesse: isMeleeDiffNegative,
isRapide: isMeleeDiffNegative && rollData.arme.data.rapide isRapide: isMeleeDiffNegative && rollData.arme.data.rapide,
passeArme: rollData.passeArme
}) })
}); });
} }
@ -423,9 +426,10 @@ export class RdDCombat {
console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll); console.log("RdDCombat.onAttaqueNormale >>>", attackerRoll);
attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar()); attackerRoll.dmg = RdDBonus.dmg(attackerRoll, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar());
let defenderRoll = { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} }
// Save rollData for defender // Save rollData for defender
RdDCombat._storeAttaque(this.attackerId, attackerRoll); RdDCombat._storeAttaque(this.attackerId, attackerRoll);
RdDCombat._storeDefense(defenderRoll)
attackerRoll.show = { attackerRoll.show = {
cible: this.target ? this.defender.data.name : 'la cible', cible: this.target ? this.defender.data.name : 'la cible',
@ -438,57 +442,69 @@ export class RdDCombat {
} }
if (this.target) { if (this.target) {
await this._sendMessageDefense(attackerRoll); await this._sendMessageDefense(attackerRoll, defenderRoll);
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
async _sendMessageDefense(attackerRoll, defenderRoll = undefined, essaisPrecedents = undefined) { async _sendMessageDefense(attackerRoll, defenderRoll, essaisPrecedents = undefined) {
console.log("RdDCombat._sendMessageDefense", attackerRoll, defenderRoll, essaisPrecedents, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie); console.log("RdDCombat._sendMessageDefense", attackerRoll, defenderRoll, essaisPrecedents, " / ", this.attacker, this.target, this.attackerId, attackerRoll.competence.data.categorie);
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme); this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
if (essaisPrecedents) { if (essaisPrecedents) {
mergeObject(attackerRoll.essais, essaisPrecedents, { overwrite: true }); mergeObject(attackerRoll.essais, essaisPrecedents, { overwrite: true });
} }
const paramDemandeDefense = { const paramChatDefense = {
passeArme: attackerRoll.passeArme, passeArme: attackerRoll.passeArme,
essais: attackerRoll.essais, essais: attackerRoll.essais,
defender: this.defender, defender: this.defender,
attacker: this.attacker,
attackerId: this.attackerId, attackerId: this.attackerId,
defenderTokenId: this.defenderTokenId, defenderTokenId: this.defenderTokenId,
mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"), mainsNues: attackerRoll.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps"),
armes: this._filterArmesParade(this.defender.data.items, attackerRoll.competence, attackerRoll.arme), armes: this._filterArmesParade(this.defender.data.items, attackerRoll.competence, attackerRoll.arme),
diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0, diffLibre: attackerRoll.ajustements?.diffLibre?.value ?? 0,
attaqueParticuliere: attackerRoll.particuliere, attaqueParticuliere: attackerRoll.particuliere,
dmg: attackerRoll.dmg attaqueCategorie: attackerRoll.competence.data.categorie,
attaqueArme: attackerRoll.arme,
dmg: attackerRoll.dmg,
}; };
RdDCombat._sendRollMessage(this.attacker, this.defender, this.defenderTokenId, const selfMessage = essaisPrecedents != undefined;
defenderRoll ?? { attackerRoll: attackerRoll, passeArme: attackerRoll.passeArme, show: {} }, if (!selfMessage && (!game.user.isGM || this.defender.hasPlayerOwner)) {
essaisPrecedents != undefined); this._socketSendMessageDefense(paramChatDefense, defenderRoll);
}
let chatMessage = { else {
alias: this.attacker.name, await this._chatMessageDefense(paramChatDefense);
whisper: ChatUtility.getWhisperRecipientsAndGMs(this.defender.name), }
content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', paramDemandeDefense),
};
ChatMessage.create(chatMessage);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _sendRollMessage(sender, recipient, defenderTokenId, defenderRoll, selfMessage) { async _chatMessageDefense(paramDemandeDefense) {
// envoyer le message au destinataire ChatMessage.create({
if (!selfMessage || !game.user.isGM || recipient.hasPlayerOwner) { // message privé: du défenseur à lui même (et aux GMs)
let data = { speaker: ChatMessage.getSpeaker(this.defender, canvas.tokens.get(this.defenderTokenId)),
attackerId: sender?.data._id, alias: this.attacker.name,
defenderId: recipient?.data._id, whisper: ChatUtility.getWhisperRecipientsAndGMs(this.defender.name),
defenderTokenId: defenderTokenId, content: await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/chat-demande-defense.html', paramDemandeDefense),
defenderRoll: duplicate(defenderRoll), });
rollMode: true
};
game.socket.emit("system.foundryvtt-reve-de-dragon", { msg: "msg_defense", data: data });
}
} }
/* -------------------------------------------- */
_socketSendMessageDefense(paramChatDefense, defenderRoll) {
// envoyer le message au destinataire
game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_defense", data: {
attackerId: this.attacker?.data._id,
defenderId: this.defender?.data._id,
defenderTokenId: this.defenderTokenId,
defenderRoll: duplicate(defenderRoll),
paramChatDefense: paramChatDefense,
rollMode: true
}
});
}
/* -------------------------------------------- */ /* -------------------------------------------- */
_filterArmesParade(items, competence) { _filterArmesParade(items, competence) {
items = items.filter(item => (item.type == 'arme' && item.data.equipe) || (item.type == 'competencecreature' && item.data.isparade)); items = items.filter(item => (item.type == 'arme' && item.data.equipe) || (item.type == 'competencecreature' && item.data.isparade));
@ -647,7 +663,7 @@ export class RdDCombat {
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true }); this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true });
this._storeDefense(defenderRoll); RdDCombat._storeDefense(defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -719,7 +735,7 @@ export class RdDCombat {
this.removeChatMessageActionsPasseArme(defenderRoll.passeArme); this.removeChatMessageActionsPasseArme(defenderRoll.passeArme);
this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true }) this._sendMessageDefense(defenderRoll.attackerRoll, defenderRoll, { defense: true })
this._storeDefense(defenderRoll); RdDCombat._storeDefense(defenderRoll);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -809,6 +825,10 @@ export class RdDCombat {
console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId); console.log("RdDCombat.encaisser >>>", attackerRoll, defenderTokenId);
let defenderRoll = RdDCombat._getDefense(attackerRoll.passeArme); let defenderRoll = RdDCombat._getDefense(attackerRoll.passeArme);
if (!defenderRoll) {
ui.notifications.warn("Cette passe d'arme est déjà terminée!")
return;
}
if (defenderRoll?.rolled && RdDCombat.isEchecTotal(defenderRoll)) { if (defenderRoll?.rolled && RdDCombat.isEchecTotal(defenderRoll)) {
this._onEchecTotal(defenderRoll); this._onEchecTotal(defenderRoll);
} }
@ -831,6 +851,7 @@ export class RdDCombat {
}); });
} }
RdDCombat._deleteDefense(attackerRoll.passeArme); RdDCombat._deleteDefense(attackerRoll.passeArme);
this.removeChatMessageActionsPasseArme(attackerRoll.passeArme);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */

View File

@ -30,9 +30,8 @@ export class StatusEffects {
restricted: true restricted: true
}); });
CONFIG.RDD.allEffects = rddStatusEffects.concat(CONFIG.statusEffects); CONFIG.RDD.allEffects = rddStatusEffects.concat(CONFIG.statusEffects);
StatusEffects._setUseStatusEffects(StatusEffects._getUseStatusEffects()); StatusEffects._setUseStatusEffects(StatusEffects._getUseStatusEffects());
console.log('statusEffects', CONFIG.statusEffects); console.log('statusEffects', CONFIG.statusEffects);
} }
@ -65,7 +64,9 @@ export class StatusEffects {
} }
static _setUseStatusEffects(useStatusEffects) { static _setUseStatusEffects(useStatusEffects) {
game.settings.set("foundryvtt-reve-de-dragon", "use-status-effects", StatusEffects._toSetting(useStatusEffects)); if (game.user.isGM) {
game.settings.set("foundryvtt-reve-de-dragon", "use-status-effects", StatusEffects._toSetting(useStatusEffects));
}
for (let effect of CONFIG.RDD.allEffects) { for (let effect of CONFIG.RDD.allEffects) {
effect.active = effect.rdd || useStatusEffects.has(effect.id); effect.active = effect.rdd || useStatusEffects.has(effect.id);

View File

@ -10,7 +10,7 @@
<div class="flexrow flex-group-center flex-actions-bar"> <div class="flexrow flex-group-center flex-actions-bar">
<div> <div>
<span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span> <span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
<span id="remise-a-neuf" class="gm-only"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span> <span class="gm-only remise-a-neuf"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
</div> </div>
</div> </div>
<div class="flexrow"> <div class="flexrow">

View File

@ -10,7 +10,7 @@
<div class="flexrow flex-group-center flex-actions-bar"> <div class="flexrow flex-group-center flex-actions-bar">
<div> <div>
<span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span> <span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
<span id="remise-a-neuf" class="gm-only"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span> <span class="gm-only remise-a-neuf"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
</div> </div>
</div> </div>
</div> </div>

View File

@ -10,7 +10,7 @@
<div class="flexrow flex-group-center flex-actions-bar"> <div class="flexrow flex-group-center flex-actions-bar">
<div> <div>
<span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span> <span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
<span id="remise-a-neuf" class="gm-only"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span> <span class="gm-only remise-a-neuf"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
</div> </div>
</div> </div>
<div class="flexrow"> <div class="flexrow">

View File

@ -57,7 +57,7 @@
<div class="flex-group-center flex-actions-bar"> <div class="flex-group-center flex-actions-bar">
<div> <div>
<span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span> <span id="encaisser-direct"><a title="Encaisser des dommages"><img class="button-img" src="icons/svg/bones.svg" alt="Encaisser des dommages"/></a></span>
<span id="remise-a-neuf" class="gm-only"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span> <span class="gm-only remise-a-neuf"><a title="Remise à neuf"><img class="button-img" src="icons/svg/regen.svg" alt="Remise à neuf"/></a></span>
<span id="dormir-une-heure"><a title="Dormir une heure"><img class="button-img" src="icons/svg/sleep.svg" alt="Dormir une heure"/></a></span> <span id="dormir-une-heure"><a title="Dormir une heure"><img class="button-img" src="icons/svg/sleep.svg" alt="Dormir une heure"/></a></span>
<span id="dormir-chateau-dormant"><a title="Chateau Dormant"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg" alt="Chateau Dormant"/></a></span> <span id="dormir-chateau-dormant"><a title="Chateau Dormant"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/icons/heures/hd12.svg" alt="Chateau Dormant"/></a></span>
<span id="monte-tmr"><a title="Montée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg" alt="Montée dans les Terres M&eacute;dianes !"/></a></span> <span id="monte-tmr"><a title="Montée dans les Terres M&eacute;dianes !"><img class="button-img" src="systems/foundryvtt-reve-de-dragon/styles/img/ui/icon-tmr-normal.svg" alt="Montée dans les Terres M&eacute;dianes !"/></a></span>

View File

@ -5,13 +5,13 @@
<span><strong>{{defender.name}}</strong> doit :</span> <span><strong>{{defender.name}}</strong> doit :</span>
{{else}} {{else}}
<span><strong>{{defender.name}}</strong> doit se défendre <span><strong>{{defender.name}}</strong> doit se défendre
{{~#if (eq surprise 'demi')}} avec une significative {{/if~}} {{~#if (eq surprise 'demi')}} avec une significative {{/if}} d'une attaque
{{~#if attaqueParticuliere}} contre une <strong>particulière en {{~#if attaqueParticuliere}} <strong>particulière en
{{~#if (eq attaqueParticuliere 'finesse')}} finesse {{~#if (eq attaqueParticuliere 'finesse')}} finesse
{{else if (eq attaqueParticuliere 'force')}} force {{else if (eq attaqueParticuliere 'force')}} force
{{else}} rapidité {{else if (eq attaqueParticuliere 'rapidite')}} rapidité
{{/if~}}</strong> {{/if~}}</strong>
{{/if~}} : {{/if}} de {{attacker.name}} ({{attaqueArme.name}}):
</span> </span>
{{/if}} {{/if}}
<span class='chat-card-button-area'> <span class='chat-card-button-area'>