Merge branch 'master-prepare-080' into 'master'

Preparation access documentData

See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!173
This commit is contained in:
Leratier Bretonnien 2021-03-22 19:20:02 +00:00
commit d95a0ebfc1
14 changed files with 543 additions and 483 deletions

View File

@ -62,7 +62,7 @@ export class RdDActorSheet extends ActorSheet {
if (this.actor.data.type == 'creature') return formData; // Shortcut if (this.actor.data.type == 'creature') return formData; // Shortcut
formData.competenceByCategory = Misc.classify(formData.data.competences, item => item.data.categorie); formData.competenceByCategory = Misc.classify(formData.data.competences, it => it.data.categorie);
formData.calc = { formData.calc = {
comptageArchetype: RdDItemCompetence.computeResumeArchetype(formData.data.competences), comptageArchetype: RdDItemCompetence.computeResumeArchetype(formData.data.competences),
@ -453,9 +453,7 @@ export class RdDActorSheet extends ActorSheet {
// On pts de reve change // On pts de reve change
html.find('.pointsreve-value').change((event) => { html.find('.pointsreve-value').change((event) => {
let reveValue = event.currentTarget.value; let reveValue = event.currentTarget.value;
let reve = duplicate(this.actor.data.data.reve.reve); this.actor.update({ "data.reve.reve.value": reveValue });
reve.value = reveValue;
this.actor.update({ "data.reve.reve": reve });
}); });
// On seuil de reve change // On seuil de reve change
@ -465,7 +463,7 @@ export class RdDActorSheet extends ActorSheet {
}); });
html.find('#attribut-protection-edit').change((event) => { html.find('#attribut-protection-edit').change((event) => {
this.actor.updateProtectionValue(event.currentTarget.attributes.name.value, parseInt(event.target.value)); this.actor.updateAttributeValue(event.currentTarget.attributes.name.value, parseInt(event.target.value));
}); });
// On stress change // On stress change

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
import { RdDItemCompetenceCreature } from "./item-competencecreature.js" import { RdDItemCompetenceCreature } from "./item-competencecreature.js"
import { Misc } from "./misc.js";
import { RdDCombatManager } from "./rdd-combat.js"; import { RdDCombatManager } from "./rdd-combat.js";
const nomCategorieParade = { const nomCategorieParade = {
@ -17,16 +18,18 @@ const nomCategorieParade = {
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDItemArme extends Item { export class RdDItemArme extends Item {
static isArme(item) { static isArme(itemData) {
return (item.type == 'competencecreature' && item.data.iscombat) || item.type == 'arme'; itemData = Misc.data(itemData);
return (itemData.type == 'competencecreature' && itemData.data.iscombat) || itemData.type == 'arme';
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getArmeData(item) { static getArmeData(armeData) {
switch (item ? item.data.type : '') { armeData = Misc.data(armeData);
case 'arme': return item.data; switch (armeData ? armeData.type : '') {
case 'arme': return armeData;
case 'competencecreature': case 'competencecreature':
return RdDItemCompetenceCreature.toArme(item.data); return RdDItemCompetenceCreature.toArme(armeData);
} }
return RdDItemArme.mainsNues(); return RdDItemArme.mainsNues();
} }
@ -61,21 +64,22 @@ export class RdDItemArme extends Item {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getCategorieParade(arme) { static getCategorieParade(armeData) {
if (arme.data.categorie_parade) { armeData = Misc.data(armeData);
return arme.data.categorie_parade; if (armeData.data.categorie_parade) {
return armeData.data.categorie_parade;
} }
// pour compatibilité avec des personnages existants // pour compatibilité avec des personnages existants
if (arme.type == 'competencecreature' || arme.data.categorie == 'creature') { if (armeData.type == 'competencecreature' || armeData.data.categorie == 'creature') {
return arme.data.categorie_parade || (arme.data.isparade ? 'sans-armes' : ''); return armeData.data.categorie_parade || (armeData.data.isparade ? 'sans-armes' : '');
} }
if (!arme.type.match(/arme|competencecreature/)) { if (!armeData.type.match(/arme|competencecreature/)) {
return ''; return '';
} }
if (arme.data.competence == undefined) { if (armeData.data.competence == undefined) {
return 'competencecreature'; return 'competencecreature';
} }
let compname = arme.data.competence.toLowerCase(); let compname = armeData.data.competence.toLowerCase();
if (compname.match(/^(dague de jet|javelot|fouet|arc|arbalête|fronde|hache de jet|fléau)$/)) return ''; if (compname.match(/^(dague de jet|javelot|fouet|arc|arbalête|fronde|hache de jet|fléau)$/)) return '';
if (compname.match('hache')) return 'haches'; if (compname.match('hache')) return 'haches';
@ -84,9 +88,9 @@ export class RdDItemArme extends Item {
if (compname.match('bouclier')) return 'boucliers'; if (compname.match('bouclier')) return 'boucliers';
if (compname.match('masse')) return 'masses'; if (compname.match('masse')) return 'masses';
if (compname.match('epée') || compname.match('épée')) { if (compname.match('epée') || compname.match('épée')) {
if (arme.name.toLowerCase().match(/(gnome)/)) if (armeData.name.toLowerCase().match(/(gnome)/))
return 'epees-courtes'; return 'epees-courtes';
if (arme.name.toLowerCase().match(/((e|é)pée dragone|esparlongue|demi-dragonne)/)) if (armeData.name.toLowerCase().match(/((e|é)pée dragone|esparlongue|demi-dragonne)/))
return 'epees-longues'; return 'epees-longues';
return 'epees-lourdes'; return 'epees-lourdes';
} }
@ -131,33 +135,35 @@ export class RdDItemArme extends Item {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static armeUneOuDeuxMains(arme, aUneMain) { static armeUneOuDeuxMains(armeData, aUneMain) {
if (arme) { armeData = Misc.data(armeData);
arme.data.unemain = arme.data.unemain || !arme.data.deuxmains; if (armeData) {
const uneOuDeuxMains = arme.data.unemain && arme.data.deuxmains; armeData.data.unemain = armeData.data.unemain || !armeData.data.deuxmains;
const containsSlash = !Number.isInteger(arme.data.dommages) && arme.data.dommages.includes("/"); const uneOuDeuxMains = armeData.data.unemain && armeData.data.deuxmains;
const containsSlash = !Number.isInteger(armeData.data.dommages) && armeData.data.dommages.includes("/");
if (containsSlash) { // Sanity check if (containsSlash) { // Sanity check
arme = duplicate(arme); armeData = duplicate(armeData);
const tableauDegats = arme.data.dommages.split("/"); const tableauDegats = armeData.data.dommages.split("/");
if (aUneMain) if (aUneMain)
arme.data.dommagesReels = Number(tableauDegats[0]); armeData.data.dommagesReels = Number(tableauDegats[0]);
else // 2 mains else // 2 mains
arme.data.dommagesReels = Number(tableauDegats[1]); armeData.data.dommagesReels = Number(tableauDegats[1]);
} }
else { else {
arme.data.dommagesReels = Number(arme.data.dommages); armeData.data.dommagesReels = Number(armeData.data.dommages);
} }
if (uneOuDeuxMains != containsSlash) { if (uneOuDeuxMains != containsSlash) {
ui.notifications.info("Les dommages de l'arme à 1/2 mains " + arme.name + " ne sont pas corrects (ie sous la forme X/Y)"); ui.notifications.info("Les dommages de l'arme à 1/2 mains " + armeData.name + " ne sont pas corrects (ie sous la forme X/Y)");
} }
} }
return arme; return armeData;
} }
static isArmeUtilisable(item) { static isArmeUtilisable(itemData) {
return item.type == 'arme' && item.data.equipe && (item.data.resistance > 0 || item.data.portee_courte > 0); itemData = Misc.data(itemData);
return itemData.type == 'arme' && itemData.data.equipe && (itemData.data.resistance > 0 || itemData.data.portee_courte > 0);
} }
static ajoutCorpsACorps(armes, competences, carac) { static ajoutCorpsACorps(armes, competences, carac) {

View File

@ -148,7 +148,7 @@ export class RdDItemCompetence extends Item {
static computeCompetenceXPCost(competence) { static computeCompetenceXPCost(competence) {
let xp = RdDItemCompetence.getDeltaXp(competence.data.base, competence.data.niveau ?? competence.data.base); let xp = RdDItemCompetence.getDeltaXp(competence.data.base, competence.data.niveau ?? competence.data.base);
xp += competence.data.xp ?? 0; xp += competence.data.xp ?? 0;
if ( competence.name.includes('Thanatos') ) xp *= 2; /// Thanatos compte double ! if (competence.name.includes('Thanatos')) xp *= 2; /// Thanatos compte double !
xp += competence.data.xp_sort ?? 0; xp += competence.data.xp_sort ?? 0;
return xp; return xp;
} }
@ -158,33 +158,33 @@ export class RdDItemCompetence extends Item {
let economie = 0; let economie = 0;
for (let troncList of competenceTroncs) { for (let troncList of competenceTroncs) {
let list = troncList.map(name => RdDItemCompetence.findCompetence(competences, name)) let list = troncList.map(name => RdDItemCompetence.findCompetence(competences, name))
.sort( (c1, c2) => c2.data.niveau - c1.data.niveau); // tri du plus haut au plus bas .sort((c1, c2) => c2.data.niveau - c1.data.niveau); // tri du plus haut au plus bas
list.splice(0,1); // ignorer la plus élevée list.splice(0, 1); // ignorer la plus élevée
list.forEach(c => { list.forEach(c => {
economie += RdDItemCompetence.getDeltaXp(c.data.base, Math.min(c.data.niveau, 0) ); economie += RdDItemCompetence.getDeltaXp(c.data.base, Math.min(c.data.niveau, 0));
}); });
} }
return economie; return economie;
} }
static levelUp(item) { static levelUp(itemData) {
item.data.xpNext = RdDItemCompetence.getCompetenceNextXp(item.data.niveau); itemData.data.xpNext = RdDItemCompetence.getCompetenceNextXp(itemData.data.niveau);
item.data.isLevelUp = item.data.xp >= item.data.xpNext; itemData.data.isLevelUp = itemData.data.xp >= itemData.data.xpNext;
} }
static isVisible(item) { static isVisible(itemData) {
return Number(item.data.niveau) != RdDItemCompetence.getNiveauBase(item.data.categorie); return Number(itemData.data.niveau) != RdDItemCompetence.getNiveauBase(itemData.data.categorie);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isNiveauBase(item) { static isNiveauBase(itemData) {
return Number(item.data.niveau) == RdDItemCompetence.getNiveauBase(item.data.categorie); return Number(itemData.data.niveau) == RdDItemCompetence.getNiveauBase(itemData.data.categorie);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static findCompetence(list, name) { static findCompetence(list, name) {
name = name.toLowerCase(); name = name.toLowerCase();
return list.find(item => item.name.toLowerCase() == name && (item.type == "competence" || item.type == "competencecreature")) return list.find(it => it.name.toLowerCase() == name && (it.type == "competence" || it.type == "competencecreature"))
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -206,26 +206,26 @@ export class RdDItemCompetence extends Item {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static _valideNiveau(niveau){ static _valideNiveau(niveau) {
if (niveau < -11 || niveau > competence_niveau_max) { if (niveau < -11 || niveau > competence_niveau_max) {
console.warn(`Niveau ${niveau} en dehors des niveaux de compétences: [-11, ${competence_niveau_max} ]`); console.warn(`Niveau ${niveau} en dehors des niveaux de compétences: [-11, ${competence_niveau_max} ]`);
} }
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static computeResumeArchetype(competences) { static computeResumeArchetype(competences) {
const archetype = RdDItemCompetence.getLimitesArchetypes(); const archetype = RdDItemCompetence.getLimitesArchetypes();
competences.forEach(item => { competences.forEach(it => {
let niveau = (item.data.niveau_archetype < 0) ? 0 : item.data.niveau_archetype; let niveau = Math.max(0, it.data.niveau_archetype);
archetype[niveau] = archetype[niveau] ?? { "niveau": niveau, "nombreMax": 0, "nombre": 0 }; archetype[niveau] = archetype[niveau] ?? { "niveau": niveau, "nombreMax": 0, "nombre": 0 };
archetype[niveau].nombre = (archetype[niveau]?.nombre ?? 0) + 1; archetype[niveau].nombre = (archetype[niveau]?.nombre ?? 0) + 1;
}); });
return archetype; return archetype;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static getLimitesArchetypes() { static getLimitesArchetypes() {
return duplicate(limitesArchetypes); return duplicate(limitesArchetypes);
} }
} }

View File

@ -1,3 +1,5 @@
import { Misc } from "./misc.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDItemCompetenceCreature extends Item { export class RdDItemCompetenceCreature extends Item {
@ -15,12 +17,13 @@ export class RdDItemCompetenceCreature extends Item {
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static toArme(item) { static toArme(itemData) {
if (RdDItemCompetenceCreature.isCompetenceAttaque(item)) { if (RdDItemCompetenceCreature.isCompetenceAttaque(itemData)) {
let arme = { name: item.name, data: duplicate(item.data) }; itemData = Misc.data(itemData);
let arme = { name: itemData.name, data: duplicate(itemData) };
mergeObject(arme.data, mergeObject(arme.data,
{ {
competence: item.name, competence: itemData.name,
resistance: 100, resistance: 100,
equipe: true, equipe: true,
penetration: 0, penetration: 0,
@ -29,17 +32,19 @@ export class RdDItemCompetenceCreature extends Item {
}); });
return arme; return arme;
} }
console.error("RdDItemCompetenceCreature.toArme(", item, ") : impossible de transformer l'Item en arme"); console.error("RdDItemCompetenceCreature.toArme(", itemData, ") : impossible de transformer l'Item en arme");
return undefined; return undefined;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isCompetenceAttaque(item) { static isCompetenceAttaque(itemData) {
return item.type == 'competencecreature' && item.data.iscombat; itemData = Misc.data(itemData);
return itemData.type == 'competencecreature' && itemData.data.iscombat;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isCompetenceParade(item) { static isCompetenceParade(itemData) {
return item.type == 'competencecreature' && item.data.isparade; itemData = Misc.data(itemData);
return itemData.type == 'competencecreature' && itemData.data.isparade;
} }
} }

View File

@ -1,3 +1,4 @@
import { Misc } from "./misc.js";
import { RdDUtility } from "./rdd-utility.js"; import { RdDUtility } from "./rdd-utility.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -7,7 +8,8 @@ export class RdDItem extends Item {
async postItem() { async postItem() {
console.log(this); console.log(this);
const properties = this[`_${this.data.type}ChatData`](); const properties = this[`_${this.data.type}ChatData`]();
let chatData = duplicate(this.data); const itemData = Misc.data(this);
let chatData = duplicate(itemData);
chatData["properties"] = properties chatData["properties"] = properties
//Check if the posted item should have availability/pay buttons //Check if the posted item should have availability/pay buttons
@ -49,17 +51,17 @@ export class RdDItem extends Item {
{ {
if (this.isOwned) if (this.isOwned)
{ {
if (this.data.data.quantite == 0) if (itemData.data.quantite == 0)
dialogResult[0] = -1 dialogResult[0] = -1
else if (this.data.data.quantite < dialogResult[0]) else if (itemData.data.quantite < dialogResult[0])
{ {
dialogResult[0] = this.data.data.quantite; dialogResult[0] = itemData.data.quantite;
ui.notifications.notify(`Impossible de poster plus que ce que vous avez. La quantité à été réduite à ${dialogResult[0]}.`) ui.notifications.notify(`Impossible de poster plus que ce que vous avez. La quantité à été réduite à ${dialogResult[0]}.`)
this.update({"data.quantite" : 0}) this.update({"data.quantite" : 0})
} }
else { else {
ui.notifications.notify(`Quantité réduite par ${dialogResult[0]}.`) ui.notifications.notify(`Quantité réduite par ${dialogResult[0]}.`)
this.update({"data.quantite" : this.data.data.quantite - dialogResult[0]}) this.update({"data.quantite" : itemData.data.quantite - dialogResult[0]})
} }
} }
} }
@ -84,7 +86,7 @@ export class RdDItem extends Item {
chatData.jsondata = JSON.stringify( chatData.jsondata = JSON.stringify(
{ {
compendium : "postedItem", compendium : "postedItem",
payload: this.data, payload: itemData,
}); });
renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-item.html', chatData).then(html => { renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-item.html', chatData).then(html => {
@ -95,217 +97,217 @@ export class RdDItem extends Item {
/* -------------------------------------------- */ /* -------------------------------------------- */
_objetChatData() { _objetChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Encombrement</b>: ${data.encombrement}` `<b>Encombrement</b>: ${rddData.encombrement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_armeChatData() { _armeChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Compétence</b>: ${data.competence}`, `<b>Compétence</b>: ${rddData.competence}`,
`<b>Dommages</b>: ${data.dommages}`, `<b>Dommages</b>: ${rddData.dommages}`,
`<b>Force minimum</b>: ${data.force}`, `<b>Force minimum</b>: ${rddData.force}`,
`<b>Resistance</b>: ${data.resistance}`, `<b>Resistance</b>: ${rddData.resistance}`,
`<b>Encombrement</b>: ${data.encombrement}` `<b>Encombrement</b>: ${rddData.encombrement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_conteneurChatData() { _conteneurChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Capacité</b>: ${data.capacite} Enc.`, `<b>Capacité</b>: ${rddData.capacite} Enc.`,
`<b>Encombrement</b>: ${data.encombrement}` `<b>Encombrement</b>: ${rddData.encombrement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_munitionChatData() { _munitionChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Encombrement</b>: ${data.encombrement}` `<b>Encombrement</b>: ${rddData.encombrement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_armureChatData() { _armureChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Protection</b>: ${data.protection}`, `<b>Protection</b>: ${rddData.protection}`,
`<b>Détérioration</b>: ${data.deterioration}`, `<b>Détérioration</b>: ${rddData.deterioration}`,
`<b>Malus armure</b>: ${data.malus}`, `<b>Malus armure</b>: ${rddData.malus}`,
`<b>Encombrement</b>: ${data.encombrement}` `<b>Encombrement</b>: ${rddData.encombrement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_competenceChatData() { _competenceChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Catégorie</b>: ${data.categorie}`, `<b>Catégorie</b>: ${rddData.categorie}`,
`<b>Niveau</b>: ${data.niveau}`, `<b>Niveau</b>: ${rddData.niveau}`,
`<b>Caractéristique par défaut</b>: ${data.carac_defaut}`, `<b>Caractéristique par défaut</b>: ${rddData.carac_defaut}`,
`<b>XP</b>: ${data.xp}` `<b>XP</b>: ${rddData.xp}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_competencecreatureChatData() { _competencecreatureChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Catégorie</b>: ${data.categorie}`, `<b>Catégorie</b>: ${rddData.categorie}`,
`<b>Niveau</b>: ${data.niveau}`, `<b>Niveau</b>: ${rddData.niveau}`,
`<b>Caractéristique</b>: ${data.carac_value}`, `<b>Caractéristique</b>: ${rddData.carac_value}`,
`<b>XP</b>: ${data.xp}` `<b>XP</b>: ${rddData.xp}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_sortChatData() { _sortChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Draconic</b>: ${data.draconic}`, `<b>Draconic</b>: ${rddData.draconic}`,
`<b>Difficulté</b>: ${data.difficulte}`, `<b>Difficulté</b>: ${rddData.difficulte}`,
`<b>Case TMR</b>: ${data.caseTMR}`, `<b>Case TMR</b>: ${rddData.caseTMR}`,
`<b>Points de Rêve</b>: ${data.ptreve}` `<b>Points de Rêve</b>: ${rddData.ptreve}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_herbeChatData() { _herbeChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Milieu</b>: ${data.milieu}`, `<b>Milieu</b>: ${rddData.milieu}`,
`<b>Rareté</b>: ${data.rarete}`, `<b>Rareté</b>: ${rddData.rarete}`,
`<b>Catégorie</b>: ${data.categorie}`, `<b>Catégorie</b>: ${rddData.categorie}`,
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_ingredientChatData() { _ingredientChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Milieu</b>: ${data.milieu}`, `<b>Milieu</b>: ${rddData.milieu}`,
`<b>Rareté</b>: ${data.rarete}`, `<b>Rareté</b>: ${rddData.rarete}`,
`<b>Catégorie</b>: ${data.categorie}`, `<b>Catégorie</b>: ${rddData.categorie}`,
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_tacheChatData() { _tacheChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Caractéristique</b>: ${data.carac}`, `<b>Caractéristique</b>: ${rddData.carac}`,
`<b>Compétence</b>: ${data.competence}`, `<b>Compétence</b>: ${rddData.competence}`,
`<b>Périodicité</b>: ${data.periodicite}`, `<b>Périodicité</b>: ${rddData.periodicite}`,
`<b>Fatigue</b>: ${data.fatigue}`, `<b>Fatigue</b>: ${rddData.fatigue}`,
`<b>Difficulté</b>: ${data.difficulte}`, `<b>Difficulté</b>: ${rddData.difficulte}`,
`<b>Points de Tâche</b>: ${data.points_de_tache}`, `<b>Points de Tâche</b>: ${rddData.points_de_tache}`,
`<b>Points de Tâche atteints</b>: ${data.points_de_tache_courant}` `<b>Points de Tâche atteints</b>: ${rddData.points_de_tache_courant}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_livreChatData() { _livreChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Compétence</b>: ${data.competence}`, `<b>Compétence</b>: ${rddData.competence}`,
`<b>Auteur</b>: ${data.auteur}`, `<b>Auteur</b>: ${rddData.auteur}`,
`<b>Difficulté</b>: ${data.difficulte}`, `<b>Difficulté</b>: ${rddData.difficulte}`,
`<b>Points de Tâche</b>: ${data.points_de_tache}`, `<b>Points de Tâche</b>: ${rddData.points_de_tache}`,
`<b>Encombrement</b>: ${data.encombrement}` `<b>Encombrement</b>: ${rddData.encombrement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_potionChatData() { _potionChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Rareté</b>: ${data.rarete}`, `<b>Rareté</b>: ${rddData.rarete}`,
`<b>Catégorie</b>: ${data.categorie}`, `<b>Catégorie</b>: ${rddData.categorie}`,
`<b>Encombrement</b>: ${data.encombrement}`, `<b>Encombrement</b>: ${rddData.encombrement}`,
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_queueChatData() { _queueChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Refoulement</b>: ${data.refoulement}` `<b>Refoulement</b>: ${rddData.refoulement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_ombreChatData() { _ombreChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Refoulement</b>: ${data.refoulement}` `<b>Refoulement</b>: ${rddData.refoulement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_souffleChatData() { _souffleChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = []; let properties = [];
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_teteChatData() { _teteChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = []; let properties = [];
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_tarotChatData() { _tarotChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Concept</b>: ${data.concept}`, `<b>Concept</b>: ${rddData.concept}`,
`<b>Aspect</b>: ${data.aspect}`, `<b>Aspect</b>: ${rddData.aspect}`,
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_nombreastralChatData() { _nombreastralChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Valeur</b>: ${data.value}`, `<b>Valeur</b>: ${rddData.value}`,
`<b>Jour</b>: ${data.jourlabel}`, `<b>Jour</b>: ${rddData.jourlabel}`,
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_monnaieChatData() { _monnaieChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Valeur en Deniers</b>: ${data.valeur_deniers}`, `<b>Valeur en Deniers</b>: ${rddData.valeur_deniers}`,
`<b>Encombrement</b>: ${data.encombrement}` `<b>Encombrement</b>: ${rddData.encombrement}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_meditationChatData() { _meditationChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Thème</b>: ${data.theme}`, `<b>Thème</b>: ${rddData.theme}`,
`<b>Compétence</b>: ${data.competence}`, `<b>Compétence</b>: ${rddData.competence}`,
`<b>Support</b>: ${data.support}`, `<b>Support</b>: ${rddData.support}`,
`<b>Heure</b>: ${data.heure}`, `<b>Heure</b>: ${rddData.heure}`,
`<b>Purification</b>: ${data.purification}`, `<b>Purification</b>: ${rddData.purification}`,
`<b>Vêture</b>: ${data.veture}`, `<b>Vêture</b>: ${rddData.veture}`,
`<b>Comportement</b>: ${data.comportement}`, `<b>Comportement</b>: ${rddData.comportement}`,
`<b>Case TMR</b>: ${data.tmr}` `<b>Case TMR</b>: ${rddData.tmr}`
] ]
return properties; return properties;
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
_casetmrChatData() { _casetmrChatData() {
const data = duplicate(this.data.data); const rddData = Misc.data(this).data;
let properties = [ let properties = [
`<b>Coordonnée</b>: ${data.coord}`, `<b>Coordonnée</b>: ${rddData.coord}`,
`<b>Spécificité</b>: ${data.specific}` `<b>Spécificité</b>: ${rddData.specific}`
] ]
return properties; return properties;
} }

View File

@ -3,6 +3,7 @@ import { RdDUtility } from "./rdd-utility.js";
import { RdDItem } from "./item-rdd.js"; import { RdDItem } from "./item-rdd.js";
import { RdDAlchimie } from "./rdd-alchimie.js"; import { RdDAlchimie } from "./rdd-alchimie.js";
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { Misc } from "./misc.js";
/** /**
* Extend the basic ItemSheet with some very simple modifications * Extend the basic ItemSheet with some very simple modifications
@ -30,7 +31,7 @@ export class RdDItemSheet extends ItemSheet {
{ {
class: "post", class: "post",
icon: "fas fa-comment", icon: "fas fa-comment",
onclick: ev => new RdDItem(this.item.data).postItem() onclick: ev => new RdDItem(Misc.data(this.item)).postItem()
}) })
return buttons return buttons
} }

View File

@ -6,26 +6,24 @@
export class Misc { export class Misc {
static isFunction(v) { static isFunction(v) {
return v && {}.toString.call(v) === '[object Function]'; return v && {}.toString.call(v) === '[object Function]';
} }
static upperFirst(text) { static upperFirst(text) {
return text.charAt(0).toUpperCase() + text.slice(1); return text.charAt(0).toUpperCase() + text.slice(1);
} }
static toSignedString(number){ static toSignedString(number) {
const value = parseInt(number) const value = parseInt(number)
const isPositiveNumber = value != NaN && value > 0; const isPositiveNumber = value != NaN && value > 0;
return isPositiveNumber ? "+"+number : number return isPositiveNumber ? "+" + number : number
} }
/** /**
* Converts the value to an integer, or to 0 if undefined/null/not representing integer * Converts the value to an integer, or to 0 if undefined/null/not representing integer
* @param {*} value value to convert to an integer using parseInt * @param {*} value value to convert to an integer using parseInt
*/ */
static toInt(value) static toInt(value) {
{ if (value == undefined) {
if (value == undefined)
{
return 0; return 0;
} }
const parsed = parseInt(value); const parsed = parseInt(value);
@ -78,4 +76,25 @@ export class Misc {
return [...new Set(array)]; return [...new Set(array)];
} }
static actorData(actor) {
return Misc.data(actor);
}
static itemData(item) {
return Misc.data(item);
}
static data(it) {
if (it instanceof Item) {
return it.data;
}
if (it instanceof Actor) {
return it.data;
}
return it;
}
static templateData(it) {
return Misc.data(it)?.data ?? {}
}
} }

View File

@ -1,4 +1,5 @@
import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetence } from "./item-competence.js";
import { Misc } from "./misc.js";
/** /**
@ -61,7 +62,7 @@ export class RdDAstrologieJoueur extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
requestJetAstrologie( ) { requestJetAstrologie( ) {
let data = { id: this.actor.data._id, let data = { id: this.actor.data._id,
carac_vue: this.actor.data.data.carac['vue'].value, carac_vue: Misc.data(this.actor).data.carac['vue'].value,
etat: this.dataNombreAstral.etat, etat: this.dataNombreAstral.etat,
astrologie: this.dataNombreAstral.astrologie, astrologie: this.dataNombreAstral.astrologie,
conditions: $("#diffConditions").val(), conditions: $("#diffConditions").val(),

View File

@ -82,22 +82,22 @@ export class RdDCombatManager extends Combat {
if (!rollFormula) { if (!rollFormula) {
let armeCombat, competence; let armeCombat, competence;
if (c.actor.data.type == 'creature' || c.actor.data.type == 'entite') { if (c.actor.data.type == 'creature' || c.actor.data.type == 'entite') {
for (const competenceItem of c.actor.data.items) { for (const competenceItemData of c.actor.data.items) {
if (competenceItem.data.iscombat) { if (competenceItemData.data.iscombat) {
competence = duplicate(competenceItem); competence = duplicate(competenceItemData);
} }
} }
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, competence.data.carac_value) + ")/100)"; rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, competence.data.carac_value) + ")/100)";
} else { } else {
for (const item of c.actor.data.items) { for (const itemData of c.actor.data.items) {
if (item.type == "arme" && item.data.equipe) { if (itemData.type == "arme" && itemData.data.equipe) {
armeCombat = duplicate(item); armeCombat = duplicate(itemData);
} }
} }
let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence; let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
competence = RdDItemCompetence.findCompetence(c.actor.data.items, compName); competence = RdDItemCompetence.findCompetence(c.actor.data.items, compName);
let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.data.ecaille_efficacite : 0; let bonusEcaille = (armeCombat && armeCombat.data.magique) ? armeCombat.data.ecaille_efficacite : 0;
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, c.actor.data.data.carac[competence.data.defaut_carac].value, bonusEcaille) + ")/100)"; rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, Misc.data(c.actor).data.carac[competence.data.defaut_carac].value, bonusEcaille) + ")/100)";
} }
} }
//console.log("Combatat", c); //console.log("Combatat", c);
@ -192,7 +192,7 @@ export class RdDCombatManager extends Combat {
.concat(RdDItemArme.mainsNues()); .concat(RdDItemArme.mainsNues());
let competences = items.filter(it => it.type == 'competence'); let competences = items.filter(it => it.type == 'competence');
actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, combatant.actor.data.data.carac)); actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, Misc.data(combatant.actor).data.carac));
actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } }); actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } });
} }
@ -293,7 +293,7 @@ export class RdDCombatManager extends Combat {
initOffset = 5; initOffset = 5;
} }
} else { } else {
caracForInit = combatant.actor.data.data.carac[competence.data.defaut_carac].value; caracForInit = Misc.data(combatant.actor).data.carac[competence.data.defaut_carac].value;
if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
initOffset = 4; initOffset = 4;
} }
@ -861,7 +861,7 @@ export class RdDCombat {
/* -------------------------------------------- */ /* -------------------------------------------- */
_filterArmesParade(defender, competence) { _filterArmesParade(defender, competence) {
let items = defender.data.items; let items = defender.data.items;
items = items.filter(item => RdDItemArme.isArmeUtilisable(item) || RdDItemCompetenceCreature.isCompetenceParade(item)); items = items.filter(it => RdDItemArme.isArmeUtilisable(it) || RdDItemCompetenceCreature.isCompetenceParade(it));
for (let item of items) { for (let item of items) {
item.data.nbUsage = defender.getItemUse(item._id); // Ajout du # d'utilisation ce round item.data.nbUsage = defender.getItemUse(item._id); // Ajout du # d'utilisation ce round
} }

View File

@ -38,18 +38,19 @@ export class RdDRoll extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
static _setDefaultOptions(actor, rollData) { static _setDefaultOptions(actor, rollData) {
const actorData = Misc.data(actor);
let defaultRollData = { let defaultRollData = {
alias: actor.name, alias: actor.name,
ajustementsConditions: CONFIG.RDD.ajustementsConditions, ajustementsConditions: CONFIG.RDD.ajustementsConditions,
difficultesLibres: CONFIG.RDD.difficultesLibres, difficultesLibres: CONFIG.RDD.difficultesLibres,
etat: actor.getEtatGeneral(), etat: actor.getEtatGeneral(),
moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */ moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */
carac: actor.data.data.carac, carac: actorData.data.carac,
finalLevel: 0, finalLevel: 0,
diffConditions: 0, diffConditions: 0,
diffLibre: rollData.competence?.data.default_diffLibre ?? 0, diffLibre: rollData.competence?.data.default_diffLibre ?? 0,
malusArmureValue: actor.getMalusArmure(), malusArmureValue: actor.getMalusArmure(),
surencMalusFlag: actor.isPersonnage() ? (actor.data.data.compteurs.surenc.value < 0) : false, surencMalusFlag: actor.isPersonnage() ? (actorData.data.compteurs.surenc.value < 0) : false,
surencMalusValue: actor.getSurenc(), surencMalusValue: actor.getSurenc(),
useMalusSurenc: false, useMalusSurenc: false,
useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */ useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */

View File

@ -11,6 +11,7 @@ import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
import { PixiTMR } from "./tmr/pixi-tmr.js"; import { PixiTMR } from "./tmr/pixi-tmr.js";
import { Draconique } from "./tmr/draconique.js"; import { Draconique } from "./tmr/draconique.js";
import { Grammar } from "./grammar.js"; import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js";
/* -------------------------------------------- */ /* -------------------------------------------- */
export class RdDTMRDialog extends Dialog { export class RdDTMRDialog extends Dialog {
@ -72,7 +73,7 @@ export class RdDTMRDialog extends Dialog {
} }
loadSortsReserve() { loadSortsReserve() {
this.sortsReserves = this.actor.data.data.reve.reserve.list; this.sortsReserves = Misc.data(this.actor).data.reve.reserve.list;
} }
loadRencontres() { loadRencontres() {
@ -136,7 +137,7 @@ export class RdDTMRDialog extends Dialog {
return EffetsDraconiques.sortReserve.token(this.pixiTMR, sortEnReserve.sort, () => sortEnReserve.coord); return EffetsDraconiques.sortReserve.token(this.pixiTMR, sortEnReserve.sort, () => sortEnReserve.coord);
} }
_tokenDemiReve() { _tokenDemiReve() {
return EffetsDraconiques.demiReve.token(this.pixiTMR, this.actor, () => this.actor.data.data.reve.tmrpos.coord); return EffetsDraconiques.demiReve.token(this.pixiTMR, this.actor, () => Misc.data(this.actor).data.reve.tmrpos.coord);
} }
_updateDemiReve() { _updateDemiReve() {
@ -155,7 +156,7 @@ export class RdDTMRDialog extends Dialog {
else { else {
// Roll Sort // Roll Sort
html.find('#lancer-sort').click((event) => { html.find('#lancer-sort').click((event) => {
this.actor.rollUnSort(this.actor.data.data.reve.tmrpos.coord); this.actor.rollUnSort(Misc.data(this.actor).data.reve.tmrpos.coord);
}); });
} }
if (this.viewOnly) { if (this.viewOnly) {
@ -170,7 +171,7 @@ export class RdDTMRDialog extends Dialog {
// Le reste... // Le reste...
this.updateValuesDisplay(); this.updateValuesDisplay();
let tmr = TMRUtility.getTMR(this.actor.data.data.reve.tmrpos.coord); let tmr = TMRUtility.getTMR(Misc.data(this.actor).data.reve.tmrpos.coord);
await this.manageRencontre(tmr, () => { await this.manageRencontre(tmr, () => {
this.postRencontre(tmr); this.postRencontre(tmr);
}); });
@ -179,21 +180,22 @@ export class RdDTMRDialog extends Dialog {
/* -------------------------------------------- */ /* -------------------------------------------- */
updateValuesDisplay() { updateValuesDisplay() {
let ptsreve = document.getElementById("tmr-pointsreve-value"); let ptsreve = document.getElementById("tmr-pointsreve-value");
ptsreve.innerHTML = this.actor.data.data.reve.reve.value; const actorData = Misc.data(this.actor);
ptsreve.innerHTML = actorData.data.reve.reve.value;
let tmrpos = document.getElementById("tmr-pos"); let tmrpos = document.getElementById("tmr-pos");
let tmr = TMRUtility.getTMR(this.actor.data.data.reve.tmrpos.coord); let tmr = TMRUtility.getTMR(actorData.data.reve.tmrpos.coord);
tmrpos.innerHTML = this.actor.data.data.reve.tmrpos.coord + " (" + tmr.label + ")"; tmrpos.innerHTML = actorData.data.reve.tmrpos.coord + " (" + tmr.label + ")";
let etat = document.getElementById("tmr-etatgeneral-value"); let etat = document.getElementById("tmr-etatgeneral-value");
etat.innerHTML = this.actor.getEtatGeneral(); etat.innerHTML = this.actor.getEtatGeneral();
let refoulement = document.getElementById("tmr-refoulement-value"); let refoulement = document.getElementById("tmr-refoulement-value");
refoulement.innerHTML = this.actor.data.data.reve.refoulement.value; refoulement.innerHTML = actorData.data.reve.refoulement.value;
let fatigueItem = document.getElementById("tmr-fatigue-table"); let fatigueItem = document.getElementById("tmr-fatigue-table");
//console.log("Refresh : ", this.actor.data.data.sante.fatigue.value); //console.log("Refresh : ", actorData.data.sante.fatigue.value);
fatigueItem.innerHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(this.actor.data.data.sante.fatigue.value, this.actor.data.data.sante.endurance.max).html() + "</table>"; fatigueItem.innerHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(actorData.data.sante.fatigue.value, actorData.data.sante.endurance.max).html() + "</table>";
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
@ -310,7 +312,7 @@ export class RdDTMRDialog extends Dialog {
rencontre: this.currentRencontre, rencontre: this.currentRencontre,
nbRounds: 1, nbRounds: 1,
canClose: false, canClose: false,
tmr: TMRUtility.getTMR(this.actor.data.data.reve.tmrpos.coord) tmr: TMRUtility.getTMR(Misc.data(this.actor).data.reve.tmrpos.coord)
} }
await this._tentativeMaitrise(rencontreData); await this._tentativeMaitrise(rencontreData);
@ -780,7 +782,7 @@ export class RdDTMRDialog extends Dialog {
} }
async _onClickTMRPos(eventPos) { async _onClickTMRPos(eventPos) {
let currentPos = TMRUtility.convertToCellPos(this.actor.data.data.reve.tmrpos.coord); let currentPos = TMRUtility.convertToCellPos(Misc.data(this.actor).data.reve.tmrpos.coord);
console.log("deplacerDemiReve >>>>", currentPos, eventPos); console.log("deplacerDemiReve >>>>", currentPos, eventPos);
@ -846,7 +848,7 @@ export class RdDTMRDialog extends Dialog {
game.socket.emit("system.foundryvtt-reve-de-dragon", { game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_tmr_move", data: { msg: "msg_tmr_move", data: {
actorId: this.actor.data._id, actorId: this.actor.data._id,
tmrPos: this.actor.data.data.reve.tmrpos tmrPos: Misc.data(this.actor).data.reve.tmrpos
} }
}); });

View File

@ -18,9 +18,9 @@ import { ReglesOptionelles } from "./regles-optionelles.js";
*/ */
export const referenceAjustements = { export const referenceAjustements = {
competence: { competence: {
isUsed: (rollData, actor) => rollData.competence, isUsed: (rollData, actor) => Misc.data(rollData.competence),
getLabel: (rollData, actor) => rollData.competence?.name, getLabel: (rollData, actor) => Misc.data(rollData.competence)?.name,
getValue: (rollData, actor) => rollData.competence?.data?.niveau, getValue: (rollData, actor) => Misc.data(rollData.competence)?.data?.niveau,
}, },
meditation: { meditation: {
isUsed: (rollData, actor) => rollData.meditation, isUsed: (rollData, actor) => rollData.meditation,
@ -32,7 +32,7 @@ export const referenceAjustements = {
getLabel: (rollData, actor) => rollData.selectedSort?.name ?? rollData.attackerRoll ? 'Imposée' : 'Libre', getLabel: (rollData, actor) => rollData.selectedSort?.name ?? rollData.attackerRoll ? 'Imposée' : 'Libre',
getValue: (rollData, actor) => rollData.selectedSort getValue: (rollData, actor) => rollData.selectedSort
? RdDItemSort.getDifficulte(rollData.selectedSort, rollData.diffLibre) ? RdDItemSort.getDifficulte(rollData.selectedSort, rollData.diffLibre)
: rollData.diffLibre ?? rollData.competence?.data.default_diffLibre ?? 0 : rollData.diffLibre ?? Misc.data(rollData.competence)?.data.default_diffLibre ?? 0
}, },
diffConditions: { diffConditions: {
isUsed: (rollData, actor) => rollData.diffConditions != undefined, isUsed: (rollData, actor) => rollData.diffConditions != undefined,
@ -94,10 +94,10 @@ export const referenceAjustements = {
getDescr: (rollData, actor) => rollData.diviseurSignificative > 1 ? `Facteur significative <span class="rdd-diviseur">&times;${Misc.getFractionHtml(rollData.diviseurSignificative)}</span>` : '' getDescr: (rollData, actor) => rollData.diviseurSignificative > 1 ? `Facteur significative <span class="rdd-diviseur">&times;${Misc.getFractionHtml(rollData.diviseurSignificative)}</span>` : ''
}, },
isEcaille: { isEcaille: {
isVisible: (rollData, actor) => rollData.arme?.data.magique && Number(rollData.arme?.data.ecaille_efficacite) > 0, isVisible: (rollData, actor) => Misc.data(rollData.arme)?.data.magique && Number(Misc.data(rollData.arme)?.data.ecaille_efficacite) > 0,
isUsed: (rollData, actor) => rollData.arme?.data.magique && Number(rollData.arme?.data.ecaille_efficacite) > 0, isUsed: (rollData, actor) => Misc.data(rollData.arme)?.data.magique && Number(Misc.data(rollData.arme)?.data.ecaille_efficacite) > 0,
getLabel: (rollData, actor) => "Ecaille d'Efficacité: ", getLabel: (rollData, actor) => "Ecaille d'Efficacité: ",
getValue: (rollData, actor) => (rollData.arme?.data.magique && Number(rollData.arme.data.ecaille_efficacite) > 0) ? rollData.arme.data.ecaille_efficacite : 0, getValue: (rollData, actor) => Math.max(Number(Misc.data(rollData.arme)?.data.ecaille_efficacite), 0),
}, },
finesse: { finesse: {
isUsed: (rollData, actor) => RdDBonus.isDefenseAttaqueFinesse(rollData), isUsed: (rollData, actor) => RdDBonus.isDefenseAttaqueFinesse(rollData),

View File

@ -16,6 +16,7 @@ import { Conquete } from "./conquete.js";
import { Pelerinage } from "./pelerinage.js"; import { Pelerinage } from "./pelerinage.js";
import { Periple } from "./periple.js"; import { Periple } from "./periple.js";
import { UrgenceDraconique } from "./urgence-draconique.js"; import { UrgenceDraconique } from "./urgence-draconique.js";
import { Misc } from "../misc.js";
export class EffetsDraconiques { export class EffetsDraconiques {
@ -92,98 +93,100 @@ export class EffetsDraconiques {
return EffetsDraconiques.presentCites.isCase(caseTMR, coord); return EffetsDraconiques.presentCites.isCase(caseTMR, coord);
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isMauvaiseRencontre(element) { static isMauvaiseRencontre(item) {
return EffetsDraconiques.isMatching(element, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('mauvaise rencontre')); return EffetsDraconiques.isMatching(item, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('mauvaise rencontre'));
} }
static isMonteeLaborieuse(element) { static isMonteeLaborieuse(item) {
return EffetsDraconiques.isMatching(element, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('montée laborieuse')); return EffetsDraconiques.isMatching(item, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('montée laborieuse'));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isFermetureCite(element) { static isFermetureCite(item) {
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.fermetureCites.match(it)); return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.fermetureCites.match(it));
} }
static isPontImpraticable(element) { static isPontImpraticable(item) {
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.pontImpraticable.match(it)); return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.pontImpraticable.match(it));
} }
static isDoubleResistanceFleuve(element) { static isDoubleResistanceFleuve(item) {
return EffetsDraconiques.isMatching(element, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('résistance du fleuve')); return EffetsDraconiques.isMatching(item, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('résistance du fleuve'));
} }
static isPeage(element) { static isPeage(item) {
return EffetsDraconiques.isMatching(element, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('péage')); return EffetsDraconiques.isMatching(item, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('péage'));
} }
static isPeriple(element) { static isPeriple(item) {
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.periple.match(it)); return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.periple.match(it));
} }
static isDesorientation(element) { static isDesorientation(item) {
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.desorientation.match(it)); // TODO return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.desorientation.match(it)); // TODO
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isSortImpossible(element) { static isSortImpossible(item) {
return EffetsDraconiques.isMatching(element, it => return EffetsDraconiques.isMatching(item, it =>
EffetsDraconiques.conquete.match(it) || EffetsDraconiques.conquete.match(it) ||
EffetsDraconiques.periple.match(it) || EffetsDraconiques.periple.match(it) ||
EffetsDraconiques.urgenceDraconique.match(it) || EffetsDraconiques.urgenceDraconique.match(it) ||
EffetsDraconiques.pelerinage.match(it) EffetsDraconiques.pelerinage.match(it)
); );
} }
static isSortReserveImpossible(element) {
return EffetsDraconiques.isMatching(element, it => static isSortReserveImpossible(item) {
return EffetsDraconiques.isMatching(item, it =>
EffetsDraconiques.conquete.match(it) || EffetsDraconiques.conquete.match(it) ||
EffetsDraconiques.periple.match(it) || EffetsDraconiques.periple.match(it) ||
EffetsDraconiques.pelerinage.match(it) EffetsDraconiques.pelerinage.match(it)
); );
} }
static isConquete(element) { static isConquete(item) {
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.conquete.match(it)); return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.conquete.match(it));
} }
static isPelerinage(element) { static isPelerinage(item) {
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.pelerinage.match(it)); return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.pelerinage.match(it));
} }
static countInertieDraconique(element) { static countInertieDraconique(item) {
return EffetsDraconiques.count(element, it => Draconique.isQueueDragon(it) && it.name.toLowerCase().includes('inertie draconique')); return EffetsDraconiques.count(item, it => Draconique.isQueueDragon(it) && it.name.toLowerCase().includes('inertie draconique'));
} }
static isUrgenceDraconique(element) { static isUrgenceDraconique(item) {
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.urgenceDraconique.match(it)); return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.urgenceDraconique.match(it));
} }
/* -------------------------------------------- */ /* -------------------------------------------- */
static isDonDoubleReve(element) { static isDonDoubleReve(item) {
return EffetsDraconiques.isMatching(element, it => Draconique.isTeteDragon(it) && it.name == 'Don de double-rêve'); return EffetsDraconiques.isMatching(item, it => Draconique.isTeteDragon(it) && it.name == 'Don de double-rêve');
}
static isConnaissanceFleuve(item) {
return EffetsDraconiques.isMatching(item, it => Draconique.isTeteDragon(it) && it.name.toLowerCase().includes('connaissance du fleuve'));
}
static isReserveEnSecurite(item) {
return EffetsDraconiques.isMatching(item, it => Draconique.isTeteDragon(it) && it.name.toLowerCase().includes(' en sécurité'));
}
static isDeplacementAccelere(item) {
item = Misc.data(item);
return EffetsDraconiques.isMatching(item, it => Draconique.isTeteDragon(it) && it.name.toLowerCase().includes(' déplacement accéléré'));
}
static isMatching(item, matcher) {
return EffetsDraconiques.toItems(item).find(matcher);
}
static count(item, matcher) {
return EffetsDraconiques.toItems(item).filter(matcher).length;
} }
static isConnaissanceFleuve(element) { static toItems(item) {
return EffetsDraconiques.isMatching(element, it => Draconique.isTeteDragon(it) && it.name.toLowerCase().includes('connaissance du fleuve')); return (item?.entity === 'Actor') ? item.data.items : (item?.entity === 'Item') ? [Misc.data(item)] : [];
}
static isReserveEnSecurite(element) {
return EffetsDraconiques.isMatching(element, it => Draconique.isTeteDragon(it) && it.name.toLowerCase().includes(' en sécurité'));
}
static isDeplacementAccelere(element) {
return EffetsDraconiques.isMatching(element, it => Draconique.isTeteDragon(it) && it.name.toLowerCase().includes(' déplacement accéléré'));
}
static isMatching(element, matcher) {
return EffetsDraconiques.toItems(element).find(matcher);
}
static count(element, matcher) {
return EffetsDraconiques.toItems(element).filter(matcher).length;
}
static toItems(element) {
return (element?.entity === 'Actor') ? element.data.items : (element?.entity === 'Item') ? [element] : [];
} }
} }