diff --git a/module/actor.js b/module/actor.js
index 5c3032fe..ee98948b 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -15,6 +15,7 @@ import { RdDEncaisser } from "./rdd-roll-encaisser.js";
import { RdDCombat } from "./rdd-combat.js";
import { DeDraconique } from "./de-draconique.js";
import { RdDAudio } from "./rdd-audio.js";
+import { RdDItemCompetence } from "./item-competence.js";
/* -------------------------------------------- */
/**
@@ -1556,16 +1557,15 @@ export class RdDActor extends Actor {
/* -------------------------------------------- */
async rollCompetence( name ) {
let rollData = {
- competence: duplicate(this.getCompetence(name)),
+ competence: this.getCompetence(name),
needSignificative : !this.isEntiteCauchemar() && this.data.data.sante.sonne.value
}
if (rollData.competence.type == 'competencecreature') {
// Fake competence pour créature
- rollData.competence.data = { defaut_carac: "carac_creature", categorie: "creature" };
- rollData.carac = { carac_creature: { label: competence.name, value: competence.data.carac_value } };
+ RdDItemCompetence.setRollDataCreature(rollData);
}
- else{
+ else {
rollData.carac = this.data.data.carac;
}
console.log("rollCompetence !!!", rollData);
@@ -1889,7 +1889,7 @@ export class RdDActor extends Actor {
RdDCombat.createUsingTarget(this).attaque(competence, armeItem);
}
else {
- this.rollCompetence(name);
+ this.rollCompetence(competence.name);
}
}
diff --git a/module/item-arme.js b/module/item-arme.js
index 33f3b4c5..e0490e15 100644
--- a/module/item-arme.js
+++ b/module/item-arme.js
@@ -2,6 +2,24 @@
export class RdDItemArme extends Item {
/* -------------------------------------------- */
+ static getArmeData(item) {
+ switch (item ? item.data.type : '') {
+ case 'arme': return item.data;
+ case 'competencecreature':
+ return RdDItemArme._getArmeCompetenceCreature(item);
+ }
+ return RdDItemArme.mainsNues();
+ }
+
+ /* -------------------------------------------- */
+ static _getArmeCompetenceCreature(competenceCreature) {
+ let armeData = duplicate(competenceCreature.data);
+ armeData.data.resistance = 100;
+ armeData.data.competence = armeData.name;
+ armeData.data.dommagesReels = armeData.data.dommagesReels || armeData.data.dommages;
+ return armeData;
+ }
+
/* -------------------------------------------- */
static getCategorieParade(arme) {
if (arme.data.categorie_parade) {
@@ -38,6 +56,11 @@ export class RdDItemArme extends Item {
return 'sans-armes';
}
+ /* -------------------------------------------- */
+ static isArmeParade(arme) {
+ return RdDItemArme.getCategorieParade(arme);
+ }
+
/* -------------------------------------------- */
static needParadeSignificative(armeAttaque, armeParade) {
let attCategory = RdDItemArme.getCategorieParade(armeAttaque);
diff --git a/module/item-competence.js b/module/item-competence.js
index e48f8b3e..21f5dc73 100644
--- a/module/item-competence.js
+++ b/module/item-competence.js
@@ -11,4 +11,12 @@ export class RdDItemCompetence extends Item {
static isMalusEncombrementTotal(competence) {
return competence && competence.name.toLowerCase().match(/(natation|acrobatie)/);
}
+
+ static setRollDataCreature(rollData) {
+ rollData.carac = { "carac_creature": { label: rollData.competence.name, value: rollData.competence.data.carac_value } };
+ rollData.competence = duplicate(rollData.competence);
+ rollData.competence.data.defaut_carac = "carac_creature";
+ rollData.competence.data.categorie = "creature";
+ rollData.selectedCarac = rollData.carac.carac_creature
+ }
}
\ No newline at end of file
diff --git a/module/rdd-combat.js b/module/rdd-combat.js
index 2442ea72..55bc810d 100644
--- a/module/rdd-combat.js
+++ b/module/rdd-combat.js
@@ -192,7 +192,7 @@ export class RdDCombat {
};
if (this.attacker.isCreature()) {
- this._modifieRollDataCreature(rollData, competence);
+ RdDItemCompetence.setRollDataCreature(rollData);
}
else if (arme) {
// Usual competence
@@ -205,22 +205,6 @@ export class RdDCombat {
return rollData;
}
- /* -------------------------------------------- */
- _modifieRollDataCreature(rollData, competence) {
- competence = duplicate(competence);
- competence.data.defaut_carac = "carac_creature";
- competence.data.categorie = "creature";
-
- rollData.competence = competence;
- rollData.carac = { "carac_creature": { label: competence.name, value: competence.data.carac_value } };
- rollData.arme = {
- name: competence.name, data: {
- dommages: competence.data.dommages,
- dommagesReels: competence.data.dommages
- }
- };
- }
-
/* -------------------------------------------- */
_onAttaqueParticuliere(rollData) {
console.log("RdDCombat.onAttaqueParticuliere >>>", rollData);
@@ -243,34 +227,15 @@ export class RdDCombat {
/* -------------------------------------------- */
async _onAttaqueNormale(rollData) {
console.log("RdDCombat.onAttaqueNormale >>>", rollData);
- let explications = "";
rollData.dmg = RdDBonus.dmg(rollData, this.attacker.getBonusDegat(), this.defender.isEntiteCauchemar());
- if (this.target) {
- explications += "
Cible : " + this.defender.data.name;
- }
- explications += "
Encaissement à " + Misc.toSignedString(rollData.dmg.total) + " (" + rollData.dmg.loc.label + ")";
-
// Save rollData for defender
game.system.rdd.rollDataHandler[this.attackerId] = duplicate(rollData);
- // Message spécial pour la rapidité, qui reste difficile à gérer automatiquement
- if (rollData.particuliereAttaque == 'rapidite') {
- explications += "
Vous avez attaqué en Rapidité. Vous pourrez faire une deuxième attaque, ou utiliser votre arme pour vous défendre.";
- }
-
- // Final chat message
- let chatOptions = {
- content: "Test : " + rollData.selectedCarac.label + " / " + rollData.competence.name + ""
- + RdDResolutionTable.explainRollData(rollData)
- + explications
- }
- ChatUtility.chatWithRollMode(chatOptions, this.attacker.name)
-
rollData.show = {
- cible: this.target ? this.defender.data.name : 'la cible',
- isRecul : (rollData.particuliereAttaque == 'force' || rollData.tactique == 'charge')
+ cible: this.target ? this.defender.data.name : 'la cible',
+ isRecul: (rollData.particuliereAttaque == 'force' || rollData.tactique == 'charge')
}
ChatUtility.chatWithRollMode(
{ content: await RdDResolutionTable.explainRollDataV2(rollData, 'chat-resultat-attaque.html') },
@@ -306,7 +271,7 @@ export class RdDCombat {
message += "
Parer avec " + arme.name + "";
}
// corps à corps
- if (rollData.dmg.mortalite != 'mortel') {
+ if (rollData.dmg.mortalite != 'mortel' && this.defender.getCompetence("Corps à corps")) {
message += "
Parer à mains nues";
}
// esquive
@@ -327,20 +292,9 @@ export class RdDCombat {
switch (categorie) {
case 'tir':
case 'lancer':
- return items.filter(item =>
- item.type == 'arme' &&
- item.data.competence.toLowerCase().match("bouclier"));
+ return items.filter(item => RdDItemArme.getCategorieParade(item) == 'boucliers')
default:
- return items.filter(item => {
- if (item.type == 'competencecreature') {
- return item.data.isparade;
- }
- if (item.type == 'arme') {
- const comp = this.defender.getCompetence(item.data.competence);
- return comp && comp.data.categorie == 'melee';
- }
- return false;
- });
+ return items.filter(item => RdDItemArme.getCategorieParade(item));
}
}
@@ -349,7 +303,7 @@ export class RdDCombat {
console.log("RdDCombat.onEchecTotal >>>", rollData);
let chatOptions = {
content: "Echec total à l'attaque! "
- + await RdDRollTables.getMaladresse({ arme: rollData.arme && !rollData.arme.data.sansArme })
+ + await RdDRollTables.getMaladresse({ arme: rollData.arme && rollData.arme.data.categorie_parade != 'sans-armes' })
}
ChatUtility.chatWithRollMode(chatOptions, this.attacker.name)
}
@@ -400,17 +354,12 @@ export class RdDCombat {
}
_findArmeParade(armeParadeId) {
- if (armeParadeId) {
- const armeItem = this.defender.getOwnedItem(armeParadeId);
- return armeItem.data;
-
- }
- return RdDItemArme.mainsNues()
+ return RdDItemArme.getArmeData(armeParadeId ? this.defender.getOwnedItem(armeParadeId) : null);
}
_prepareParade(attackerRoll, armeParade) {
const isCreature = this.defender.isCreature();
- const compName = isCreature ? armeParade.name : armeParade.data.competence;
+ const compName = armeParade.data.competence;
const competence = this.defender.getCompetence(compName);
const armeAttaque = attackerRoll.arme;
@@ -432,7 +381,7 @@ export class RdDCombat {
carac: this.defender.data.data.carac
};
if (isCreature) {
- this._modifieRollDataCreature(rollData, competence);
+ RdDItemCompetence.setRollDataCreature(rollData);
}
return rollData;
}
@@ -444,11 +393,11 @@ export class RdDCombat {
/* -------------------------------------------- */
_needResist(armeAttaque, armeParade) {
- // Manage weapon categories when parrying (cf. page 115 )
- let attCategory = RdDItemArme.getCategorieArme(armeAttaque);
- let defCategory = RdDItemArme.getCategorieArme(armeParade);
+ // Epées parant une arme de bois (cf. page 115 ), une résistance est nécessaire
+ let attCategory = RdDItemArme.getCategorieParade(armeAttaque);
+ let defCategory = RdDItemArme.getCategorieParade(armeParade);
- return (attCategory.match("epee") && (defCategory == "hache" || defCategory == "lance"));
+ return attCategory.match(/epees-/) && defCategory.match(/(haches|lances)/);
}
/* -------------------------------------------- */
@@ -482,7 +431,7 @@ export class RdDCombat {
console.log("RdDCombat._onParadeEchecTotal >>>", rollData);
let chatOptions = {
content: "Echec total à la parade! "
- + await RdDRollTables.getMaladresse({ arme: rollData.arme && !rollData.arme.data.sansArme })
+ + await RdDRollTables.getMaladresse({ arme: rollData.arme && rollData.arme.data.categorie_parade != 'sans-armes' })
}
ChatUtility.chatWithRollMode(chatOptions, this.defender.name)
}
@@ -550,7 +499,7 @@ export class RdDCombat {
};
if (this.defender.isCreature()) {
- this._modifieRollDataCreature(rollData, competence);
+ RdDItemCompetence.setRollDataCreature(rollData);
}
return rollData;
}
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index 22e588af..dc780b90 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -197,8 +197,14 @@ export class RdDUtility {
// HUD
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-init.html',
'systems/foundryvtt-reve-de-dragon/templates/hud-actor-attaque.html',
- // POST
- 'systems/foundryvtt-reve-de-dragon/templates/post-item.html'
+ // messages tchat
+ 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-appelchance.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-attaque.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-competence.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-general.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-tache.html',
+ 'systems/foundryvtt-reve-de-dragon/templates/chat-resultat-sort.html',
+
];
return loadTemplates(templatePaths);
diff --git a/styles/simple.css b/styles/simple.css
index 322baeab..380c72b1 100644
--- a/styles/simple.css
+++ b/styles/simple.css
@@ -813,6 +813,10 @@ ul, li {
background: rgba(220,220,210,0.75);
border: 2px solid #545469;
}
+.chat-message .chat-icon {
+ border: 0;
+ float: left;
+}
#sidebar-tabs {
flex: 0 0 32px;
diff --git a/templates/chat-resultat-attaque.html b/templates/chat-resultat-attaque.html
index fede44cf..dfdcefb3 100644
--- a/templates/chat-resultat-attaque.html
+++ b/templates/chat-resultat-attaque.html
@@ -23,24 +23,24 @@
{{#if tactique}}