Preparation access documentData #390
@ -62,7 +62,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
|
||||
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 = {
|
||||
comptageArchetype: RdDItemCompetence.computeResumeArchetype(formData.data.competences),
|
||||
@ -453,9 +453,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
// On pts de reve change
|
||||
html.find('.pointsreve-value').change((event) => {
|
||||
let reveValue = event.currentTarget.value;
|
||||
let reve = duplicate(this.actor.data.data.reve.reve);
|
||||
reve.value = reveValue;
|
||||
this.actor.update({ "data.reve.reve": reve });
|
||||
this.actor.update({ "data.reve.reve.value": reveValue });
|
||||
});
|
||||
|
||||
// On seuil de reve change
|
||||
@ -465,7 +463,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
});
|
||||
|
||||
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
|
||||
|
480
module/actor.js
480
module/actor.js
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,5 @@
|
||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js"
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDCombatManager } from "./rdd-combat.js";
|
||||
|
||||
const nomCategorieParade = {
|
||||
@ -17,16 +18,18 @@ const nomCategorieParade = {
|
||||
/* -------------------------------------------- */
|
||||
export class RdDItemArme extends Item {
|
||||
|
||||
static isArme(item) {
|
||||
return (item.type == 'competencecreature' && item.data.iscombat) || item.type == 'arme';
|
||||
static isArme(itemData) {
|
||||
itemData = Misc.data(itemData);
|
||||
return (itemData.type == 'competencecreature' && itemData.data.iscombat) || itemData.type == 'arme';
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getArmeData(item) {
|
||||
switch (item ? item.data.type : '') {
|
||||
case 'arme': return item.data;
|
||||
static getArmeData(armeData) {
|
||||
armeData = Misc.data(armeData);
|
||||
switch (armeData ? armeData.type : '') {
|
||||
case 'arme': return armeData;
|
||||
case 'competencecreature':
|
||||
return RdDItemCompetenceCreature.toArme(item.data);
|
||||
return RdDItemCompetenceCreature.toArme(armeData);
|
||||
}
|
||||
return RdDItemArme.mainsNues();
|
||||
}
|
||||
@ -61,21 +64,22 @@ export class RdDItemArme extends Item {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getCategorieParade(arme) {
|
||||
if (arme.data.categorie_parade) {
|
||||
return arme.data.categorie_parade;
|
||||
static getCategorieParade(armeData) {
|
||||
armeData = Misc.data(armeData);
|
||||
if (armeData.data.categorie_parade) {
|
||||
return armeData.data.categorie_parade;
|
||||
}
|
||||
// pour compatibilité avec des personnages existants
|
||||
if (arme.type == 'competencecreature' || arme.data.categorie == 'creature') {
|
||||
return arme.data.categorie_parade || (arme.data.isparade ? 'sans-armes' : '');
|
||||
if (armeData.type == 'competencecreature' || armeData.data.categorie == 'creature') {
|
||||
return armeData.data.categorie_parade || (armeData.data.isparade ? 'sans-armes' : '');
|
||||
}
|
||||
if (!arme.type.match(/arme|competencecreature/)) {
|
||||
if (!armeData.type.match(/arme|competencecreature/)) {
|
||||
return '';
|
||||
}
|
||||
if (arme.data.competence == undefined) {
|
||||
if (armeData.data.competence == undefined) {
|
||||
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('hache')) return 'haches';
|
||||
@ -84,9 +88,9 @@ export class RdDItemArme extends Item {
|
||||
if (compname.match('bouclier')) return 'boucliers';
|
||||
if (compname.match('masse')) return 'masses';
|
||||
if (compname.match('epée') || compname.match('épée')) {
|
||||
if (arme.name.toLowerCase().match(/(gnome)/))
|
||||
if (armeData.name.toLowerCase().match(/(gnome)/))
|
||||
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-lourdes';
|
||||
}
|
||||
@ -131,33 +135,35 @@ export class RdDItemArme extends Item {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static armeUneOuDeuxMains(arme, aUneMain) {
|
||||
if (arme) {
|
||||
arme.data.unemain = arme.data.unemain || !arme.data.deuxmains;
|
||||
const uneOuDeuxMains = arme.data.unemain && arme.data.deuxmains;
|
||||
const containsSlash = !Number.isInteger(arme.data.dommages) && arme.data.dommages.includes("/");
|
||||
static armeUneOuDeuxMains(armeData, aUneMain) {
|
||||
armeData = Misc.data(armeData);
|
||||
if (armeData) {
|
||||
armeData.data.unemain = armeData.data.unemain || !armeData.data.deuxmains;
|
||||
const uneOuDeuxMains = armeData.data.unemain && armeData.data.deuxmains;
|
||||
const containsSlash = !Number.isInteger(armeData.data.dommages) && armeData.data.dommages.includes("/");
|
||||
if (containsSlash) { // Sanity check
|
||||
arme = duplicate(arme);
|
||||
armeData = duplicate(armeData);
|
||||
|
||||
const tableauDegats = arme.data.dommages.split("/");
|
||||
const tableauDegats = armeData.data.dommages.split("/");
|
||||
if (aUneMain)
|
||||
arme.data.dommagesReels = Number(tableauDegats[0]);
|
||||
armeData.data.dommagesReels = Number(tableauDegats[0]);
|
||||
else // 2 mains
|
||||
arme.data.dommagesReels = Number(tableauDegats[1]);
|
||||
armeData.data.dommagesReels = Number(tableauDegats[1]);
|
||||
}
|
||||
else {
|
||||
arme.data.dommagesReels = Number(arme.data.dommages);
|
||||
armeData.data.dommagesReels = Number(armeData.data.dommages);
|
||||
}
|
||||
|
||||
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) {
|
||||
return item.type == 'arme' && item.data.equipe && (item.data.resistance > 0 || item.data.portee_courte > 0);
|
||||
static isArmeUtilisable(itemData) {
|
||||
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) {
|
||||
|
@ -148,7 +148,7 @@ export class RdDItemCompetence extends Item {
|
||||
static computeCompetenceXPCost(competence) {
|
||||
let xp = RdDItemCompetence.getDeltaXp(competence.data.base, competence.data.niveau ?? competence.data.base);
|
||||
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;
|
||||
return xp;
|
||||
}
|
||||
@ -158,33 +158,33 @@ export class RdDItemCompetence extends Item {
|
||||
let economie = 0;
|
||||
for (let troncList of competenceTroncs) {
|
||||
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
|
||||
list.splice(0,1); // ignorer la plus élevée
|
||||
.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.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;
|
||||
}
|
||||
|
||||
static levelUp(item) {
|
||||
item.data.xpNext = RdDItemCompetence.getCompetenceNextXp(item.data.niveau);
|
||||
item.data.isLevelUp = item.data.xp >= item.data.xpNext;
|
||||
static levelUp(itemData) {
|
||||
itemData.data.xpNext = RdDItemCompetence.getCompetenceNextXp(itemData.data.niveau);
|
||||
itemData.data.isLevelUp = itemData.data.xp >= itemData.data.xpNext;
|
||||
}
|
||||
|
||||
static isVisible(item) {
|
||||
return Number(item.data.niveau) != RdDItemCompetence.getNiveauBase(item.data.categorie);
|
||||
static isVisible(itemData) {
|
||||
return Number(itemData.data.niveau) != RdDItemCompetence.getNiveauBase(itemData.data.categorie);
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isNiveauBase(item) {
|
||||
return Number(item.data.niveau) == RdDItemCompetence.getNiveauBase(item.data.categorie);
|
||||
static isNiveauBase(itemData) {
|
||||
return Number(itemData.data.niveau) == RdDItemCompetence.getNiveauBase(itemData.data.categorie);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static findCompetence(list, name) {
|
||||
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) {
|
||||
console.warn(`Niveau ${niveau} en dehors des niveaux de compétences: [-11, ${competence_niveau_max} ]`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static computeResumeArchetype(competences) {
|
||||
const archetype = RdDItemCompetence.getLimitesArchetypes();
|
||||
competences.forEach(item => {
|
||||
let niveau = (item.data.niveau_archetype < 0) ? 0 : item.data.niveau_archetype;
|
||||
competences.forEach(it => {
|
||||
let niveau = Math.max(0, it.data.niveau_archetype);
|
||||
archetype[niveau] = archetype[niveau] ?? { "niveau": niveau, "nombreMax": 0, "nombre": 0 };
|
||||
archetype[niveau].nombre = (archetype[niveau]?.nombre ?? 0) + 1;
|
||||
});
|
||||
return archetype;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getLimitesArchetypes() {
|
||||
return duplicate(limitesArchetypes);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static getLimitesArchetypes() {
|
||||
return duplicate(limitesArchetypes);
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDItemCompetenceCreature extends Item {
|
||||
|
||||
@ -15,12 +17,13 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static toArme(item) {
|
||||
if (RdDItemCompetenceCreature.isCompetenceAttaque(item)) {
|
||||
let arme = { name: item.name, data: duplicate(item.data) };
|
||||
static toArme(itemData) {
|
||||
if (RdDItemCompetenceCreature.isCompetenceAttaque(itemData)) {
|
||||
itemData = Misc.data(itemData);
|
||||
let arme = { name: itemData.name, data: duplicate(itemData) };
|
||||
mergeObject(arme.data,
|
||||
{
|
||||
competence: item.name,
|
||||
competence: itemData.name,
|
||||
resistance: 100,
|
||||
equipe: true,
|
||||
penetration: 0,
|
||||
@ -29,17 +32,19 @@ export class RdDItemCompetenceCreature extends Item {
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isCompetenceAttaque(item) {
|
||||
return item.type == 'competencecreature' && item.data.iscombat;
|
||||
static isCompetenceAttaque(itemData) {
|
||||
itemData = Misc.data(itemData);
|
||||
return itemData.type == 'competencecreature' && itemData.data.iscombat;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isCompetenceParade(item) {
|
||||
return item.type == 'competencecreature' && item.data.isparade;
|
||||
static isCompetenceParade(itemData) {
|
||||
itemData = Misc.data(itemData);
|
||||
return itemData.type == 'competencecreature' && itemData.data.isparade;
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Misc } from "./misc.js";
|
||||
import { RdDUtility } from "./rdd-utility.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -7,7 +8,8 @@ export class RdDItem extends Item {
|
||||
async postItem() {
|
||||
console.log(this);
|
||||
const properties = this[`_${this.data.type}ChatData`]();
|
||||
let chatData = duplicate(this.data);
|
||||
const itemData = Misc.data(this);
|
||||
let chatData = duplicate(itemData);
|
||||
chatData["properties"] = properties
|
||||
|
||||
//Check if the posted item should have availability/pay buttons
|
||||
@ -49,17 +51,17 @@ export class RdDItem extends Item {
|
||||
{
|
||||
if (this.isOwned)
|
||||
{
|
||||
if (this.data.data.quantite == 0)
|
||||
if (itemData.data.quantite == 0)
|
||||
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]}.`)
|
||||
this.update({"data.quantite" : 0})
|
||||
}
|
||||
else {
|
||||
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(
|
||||
{
|
||||
compendium : "postedItem",
|
||||
payload: this.data,
|
||||
payload: itemData,
|
||||
});
|
||||
|
||||
renderTemplate('systems/foundryvtt-reve-de-dragon/templates/post-item.html', chatData).then(html => {
|
||||
@ -95,217 +97,217 @@ export class RdDItem extends Item {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_objetChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Encombrement</b>: ${data.encombrement}`
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_armeChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Compétence</b>: ${data.competence}`,
|
||||
`<b>Dommages</b>: ${data.dommages}`,
|
||||
`<b>Force minimum</b>: ${data.force}`,
|
||||
`<b>Resistance</b>: ${data.resistance}`,
|
||||
`<b>Encombrement</b>: ${data.encombrement}`
|
||||
`<b>Compétence</b>: ${rddData.competence}`,
|
||||
`<b>Dommages</b>: ${rddData.dommages}`,
|
||||
`<b>Force minimum</b>: ${rddData.force}`,
|
||||
`<b>Resistance</b>: ${rddData.resistance}`,
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_conteneurChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Capacité</b>: ${data.capacite} Enc.`,
|
||||
`<b>Encombrement</b>: ${data.encombrement}`
|
||||
`<b>Capacité</b>: ${rddData.capacite} Enc.`,
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_munitionChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Encombrement</b>: ${data.encombrement}`
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_armureChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Protection</b>: ${data.protection}`,
|
||||
`<b>Détérioration</b>: ${data.deterioration}`,
|
||||
`<b>Malus armure</b>: ${data.malus}`,
|
||||
`<b>Encombrement</b>: ${data.encombrement}`
|
||||
`<b>Protection</b>: ${rddData.protection}`,
|
||||
`<b>Détérioration</b>: ${rddData.deterioration}`,
|
||||
`<b>Malus armure</b>: ${rddData.malus}`,
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_competenceChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Catégorie</b>: ${data.categorie}`,
|
||||
`<b>Niveau</b>: ${data.niveau}`,
|
||||
`<b>Caractéristique par défaut</b>: ${data.carac_defaut}`,
|
||||
`<b>XP</b>: ${data.xp}`
|
||||
`<b>Catégorie</b>: ${rddData.categorie}`,
|
||||
`<b>Niveau</b>: ${rddData.niveau}`,
|
||||
`<b>Caractéristique par défaut</b>: ${rddData.carac_defaut}`,
|
||||
`<b>XP</b>: ${rddData.xp}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_competencecreatureChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Catégorie</b>: ${data.categorie}`,
|
||||
`<b>Niveau</b>: ${data.niveau}`,
|
||||
`<b>Caractéristique</b>: ${data.carac_value}`,
|
||||
`<b>XP</b>: ${data.xp}`
|
||||
`<b>Catégorie</b>: ${rddData.categorie}`,
|
||||
`<b>Niveau</b>: ${rddData.niveau}`,
|
||||
`<b>Caractéristique</b>: ${rddData.carac_value}`,
|
||||
`<b>XP</b>: ${rddData.xp}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_sortChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Draconic</b>: ${data.draconic}`,
|
||||
`<b>Difficulté</b>: ${data.difficulte}`,
|
||||
`<b>Case TMR</b>: ${data.caseTMR}`,
|
||||
`<b>Points de Rêve</b>: ${data.ptreve}`
|
||||
`<b>Draconic</b>: ${rddData.draconic}`,
|
||||
`<b>Difficulté</b>: ${rddData.difficulte}`,
|
||||
`<b>Case TMR</b>: ${rddData.caseTMR}`,
|
||||
`<b>Points de Rêve</b>: ${rddData.ptreve}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_herbeChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Milieu</b>: ${data.milieu}`,
|
||||
`<b>Rareté</b>: ${data.rarete}`,
|
||||
`<b>Catégorie</b>: ${data.categorie}`,
|
||||
`<b>Milieu</b>: ${rddData.milieu}`,
|
||||
`<b>Rareté</b>: ${rddData.rarete}`,
|
||||
`<b>Catégorie</b>: ${rddData.categorie}`,
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_ingredientChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Milieu</b>: ${data.milieu}`,
|
||||
`<b>Rareté</b>: ${data.rarete}`,
|
||||
`<b>Catégorie</b>: ${data.categorie}`,
|
||||
`<b>Milieu</b>: ${rddData.milieu}`,
|
||||
`<b>Rareté</b>: ${rddData.rarete}`,
|
||||
`<b>Catégorie</b>: ${rddData.categorie}`,
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_tacheChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Caractéristique</b>: ${data.carac}`,
|
||||
`<b>Compétence</b>: ${data.competence}`,
|
||||
`<b>Périodicité</b>: ${data.periodicite}`,
|
||||
`<b>Fatigue</b>: ${data.fatigue}`,
|
||||
`<b>Difficulté</b>: ${data.difficulte}`,
|
||||
`<b>Points de Tâche</b>: ${data.points_de_tache}`,
|
||||
`<b>Points de Tâche atteints</b>: ${data.points_de_tache_courant}`
|
||||
`<b>Caractéristique</b>: ${rddData.carac}`,
|
||||
`<b>Compétence</b>: ${rddData.competence}`,
|
||||
`<b>Périodicité</b>: ${rddData.periodicite}`,
|
||||
`<b>Fatigue</b>: ${rddData.fatigue}`,
|
||||
`<b>Difficulté</b>: ${rddData.difficulte}`,
|
||||
`<b>Points de Tâche</b>: ${rddData.points_de_tache}`,
|
||||
`<b>Points de Tâche atteints</b>: ${rddData.points_de_tache_courant}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_livreChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Compétence</b>: ${data.competence}`,
|
||||
`<b>Auteur</b>: ${data.auteur}`,
|
||||
`<b>Difficulté</b>: ${data.difficulte}`,
|
||||
`<b>Points de Tâche</b>: ${data.points_de_tache}`,
|
||||
`<b>Encombrement</b>: ${data.encombrement}`
|
||||
`<b>Compétence</b>: ${rddData.competence}`,
|
||||
`<b>Auteur</b>: ${rddData.auteur}`,
|
||||
`<b>Difficulté</b>: ${rddData.difficulte}`,
|
||||
`<b>Points de Tâche</b>: ${rddData.points_de_tache}`,
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_potionChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Rareté</b>: ${data.rarete}`,
|
||||
`<b>Catégorie</b>: ${data.categorie}`,
|
||||
`<b>Encombrement</b>: ${data.encombrement}`,
|
||||
`<b>Rareté</b>: ${rddData.rarete}`,
|
||||
`<b>Catégorie</b>: ${rddData.categorie}`,
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`,
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_queueChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Refoulement</b>: ${data.refoulement}`
|
||||
`<b>Refoulement</b>: ${rddData.refoulement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_ombreChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Refoulement</b>: ${data.refoulement}`
|
||||
`<b>Refoulement</b>: ${rddData.refoulement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_souffleChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [];
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_teteChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [];
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_tarotChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Concept</b>: ${data.concept}`,
|
||||
`<b>Aspect</b>: ${data.aspect}`,
|
||||
`<b>Concept</b>: ${rddData.concept}`,
|
||||
`<b>Aspect</b>: ${rddData.aspect}`,
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_nombreastralChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Valeur</b>: ${data.value}`,
|
||||
`<b>Jour</b>: ${data.jourlabel}`,
|
||||
`<b>Valeur</b>: ${rddData.value}`,
|
||||
`<b>Jour</b>: ${rddData.jourlabel}`,
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_monnaieChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Valeur en Deniers</b>: ${data.valeur_deniers}`,
|
||||
`<b>Encombrement</b>: ${data.encombrement}`
|
||||
`<b>Valeur en Deniers</b>: ${rddData.valeur_deniers}`,
|
||||
`<b>Encombrement</b>: ${rddData.encombrement}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_meditationChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Thème</b>: ${data.theme}`,
|
||||
`<b>Compétence</b>: ${data.competence}`,
|
||||
`<b>Support</b>: ${data.support}`,
|
||||
`<b>Heure</b>: ${data.heure}`,
|
||||
`<b>Purification</b>: ${data.purification}`,
|
||||
`<b>Vêture</b>: ${data.veture}`,
|
||||
`<b>Comportement</b>: ${data.comportement}`,
|
||||
`<b>Case TMR</b>: ${data.tmr}`
|
||||
`<b>Thème</b>: ${rddData.theme}`,
|
||||
`<b>Compétence</b>: ${rddData.competence}`,
|
||||
`<b>Support</b>: ${rddData.support}`,
|
||||
`<b>Heure</b>: ${rddData.heure}`,
|
||||
`<b>Purification</b>: ${rddData.purification}`,
|
||||
`<b>Vêture</b>: ${rddData.veture}`,
|
||||
`<b>Comportement</b>: ${rddData.comportement}`,
|
||||
`<b>Case TMR</b>: ${rddData.tmr}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
_casetmrChatData() {
|
||||
const data = duplicate(this.data.data);
|
||||
const rddData = Misc.data(this).data;
|
||||
let properties = [
|
||||
`<b>Coordonnée</b>: ${data.coord}`,
|
||||
`<b>Spécificité</b>: ${data.specific}`
|
||||
`<b>Coordonnée</b>: ${rddData.coord}`,
|
||||
`<b>Spécificité</b>: ${rddData.specific}`
|
||||
]
|
||||
return properties;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import { RdDUtility } from "./rdd-utility.js";
|
||||
import { RdDItem } from "./item-rdd.js";
|
||||
import { RdDAlchimie } from "./rdd-alchimie.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
@ -30,7 +31,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
{
|
||||
class: "post",
|
||||
icon: "fas fa-comment",
|
||||
onclick: ev => new RdDItem(this.item.data).postItem()
|
||||
onclick: ev => new RdDItem(Misc.data(this.item)).postItem()
|
||||
})
|
||||
return buttons
|
||||
}
|
||||
|
@ -6,26 +6,24 @@
|
||||
export class Misc {
|
||||
static isFunction(v) {
|
||||
return v && {}.toString.call(v) === '[object Function]';
|
||||
}
|
||||
}
|
||||
|
||||
static upperFirst(text) {
|
||||
return text.charAt(0).toUpperCase() + text.slice(1);
|
||||
}
|
||||
|
||||
static toSignedString(number){
|
||||
static toSignedString(number) {
|
||||
const value = parseInt(number)
|
||||
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
|
||||
* @param {*} value value to convert to an integer using parseInt
|
||||
*/
|
||||
static toInt(value)
|
||||
{
|
||||
if (value == undefined)
|
||||
{
|
||||
static toInt(value) {
|
||||
if (value == undefined) {
|
||||
return 0;
|
||||
}
|
||||
const parsed = parseInt(value);
|
||||
@ -78,4 +76,25 @@ export class Misc {
|
||||
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 ?? {}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
|
||||
/**
|
||||
@ -61,7 +62,7 @@ export class RdDAstrologieJoueur extends Dialog {
|
||||
/* -------------------------------------------- */
|
||||
requestJetAstrologie( ) {
|
||||
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,
|
||||
astrologie: this.dataNombreAstral.astrologie,
|
||||
conditions: $("#diffConditions").val(),
|
||||
|
@ -82,22 +82,22 @@ export class RdDCombatManager extends Combat {
|
||||
if (!rollFormula) {
|
||||
let armeCombat, competence;
|
||||
if (c.actor.data.type == 'creature' || c.actor.data.type == 'entite') {
|
||||
for (const competenceItem of c.actor.data.items) {
|
||||
if (competenceItem.data.iscombat) {
|
||||
competence = duplicate(competenceItem);
|
||||
for (const competenceItemData of c.actor.data.items) {
|
||||
if (competenceItemData.data.iscombat) {
|
||||
competence = duplicate(competenceItemData);
|
||||
}
|
||||
}
|
||||
rollFormula = "2+( (" + RdDCombatManager.calculInitiative(competence.data.niveau, competence.data.carac_value) + ")/100)";
|
||||
} else {
|
||||
for (const item of c.actor.data.items) {
|
||||
if (item.type == "arme" && item.data.equipe) {
|
||||
armeCombat = duplicate(item);
|
||||
for (const itemData of c.actor.data.items) {
|
||||
if (itemData.type == "arme" && itemData.data.equipe) {
|
||||
armeCombat = duplicate(itemData);
|
||||
}
|
||||
}
|
||||
let compName = (armeCombat == undefined) ? "Corps à corps" : armeCombat.data.competence;
|
||||
competence = RdDItemCompetence.findCompetence(c.actor.data.items, compName);
|
||||
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);
|
||||
@ -192,7 +192,7 @@ export class RdDCombatManager extends Combat {
|
||||
.concat(RdDItemArme.mainsNues());
|
||||
|
||||
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" } });
|
||||
}
|
||||
@ -293,7 +293,7 @@ export class RdDCombatManager extends Combat {
|
||||
initOffset = 5;
|
||||
}
|
||||
} 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
|
||||
initOffset = 4;
|
||||
}
|
||||
@ -861,7 +861,7 @@ export class RdDCombat {
|
||||
/* -------------------------------------------- */
|
||||
_filterArmesParade(defender, competence) {
|
||||
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) {
|
||||
item.data.nbUsage = defender.getItemUse(item._id); // Ajout du # d'utilisation ce round
|
||||
}
|
||||
|
@ -38,18 +38,19 @@ export class RdDRoll extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static _setDefaultOptions(actor, rollData) {
|
||||
const actorData = Misc.data(actor);
|
||||
let defaultRollData = {
|
||||
alias: actor.name,
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
difficultesLibres: CONFIG.RDD.difficultesLibres,
|
||||
etat: actor.getEtatGeneral(),
|
||||
moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */
|
||||
carac: actor.data.data.carac,
|
||||
carac: actorData.data.carac,
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
diffLibre: rollData.competence?.data.default_diffLibre ?? 0,
|
||||
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(),
|
||||
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. */
|
||||
|
@ -11,6 +11,7 @@ import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
|
||||
import { PixiTMR } from "./tmr/pixi-tmr.js";
|
||||
import { Draconique } from "./tmr/draconique.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
export class RdDTMRDialog extends Dialog {
|
||||
@ -72,7 +73,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
|
||||
loadSortsReserve() {
|
||||
this.sortsReserves = this.actor.data.data.reve.reserve.list;
|
||||
this.sortsReserves = Misc.data(this.actor).data.reve.reserve.list;
|
||||
}
|
||||
|
||||
loadRencontres() {
|
||||
@ -136,7 +137,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
return EffetsDraconiques.sortReserve.token(this.pixiTMR, sortEnReserve.sort, () => sortEnReserve.coord);
|
||||
}
|
||||
_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() {
|
||||
@ -155,7 +156,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
else {
|
||||
// Roll Sort
|
||||
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) {
|
||||
@ -170,7 +171,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
|
||||
// Le reste...
|
||||
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, () => {
|
||||
this.postRencontre(tmr);
|
||||
});
|
||||
@ -179,21 +180,22 @@ export class RdDTMRDialog extends Dialog {
|
||||
/* -------------------------------------------- */
|
||||
updateValuesDisplay() {
|
||||
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 tmr = TMRUtility.getTMR(this.actor.data.data.reve.tmrpos.coord);
|
||||
tmrpos.innerHTML = this.actor.data.data.reve.tmrpos.coord + " (" + tmr.label + ")";
|
||||
let tmr = TMRUtility.getTMR(actorData.data.reve.tmrpos.coord);
|
||||
tmrpos.innerHTML = actorData.data.reve.tmrpos.coord + " (" + tmr.label + ")";
|
||||
|
||||
let etat = document.getElementById("tmr-etatgeneral-value");
|
||||
etat.innerHTML = this.actor.getEtatGeneral();
|
||||
|
||||
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");
|
||||
//console.log("Refresh : ", this.actor.data.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>";
|
||||
//console.log("Refresh : ", actorData.data.sante.fatigue.value);
|
||||
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,
|
||||
nbRounds: 1,
|
||||
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);
|
||||
@ -780,7 +782,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -846,7 +848,7 @@ export class RdDTMRDialog extends Dialog {
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
msg: "msg_tmr_move", data: {
|
||||
actorId: this.actor.data._id,
|
||||
tmrPos: this.actor.data.data.reve.tmrpos
|
||||
tmrPos: Misc.data(this.actor).data.reve.tmrpos
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -18,9 +18,9 @@ import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||
*/
|
||||
export const referenceAjustements = {
|
||||
competence: {
|
||||
isUsed: (rollData, actor) => rollData.competence,
|
||||
getLabel: (rollData, actor) => rollData.competence?.name,
|
||||
getValue: (rollData, actor) => rollData.competence?.data?.niveau,
|
||||
isUsed: (rollData, actor) => Misc.data(rollData.competence),
|
||||
getLabel: (rollData, actor) => Misc.data(rollData.competence)?.name,
|
||||
getValue: (rollData, actor) => Misc.data(rollData.competence)?.data?.niveau,
|
||||
},
|
||||
meditation: {
|
||||
isUsed: (rollData, actor) => rollData.meditation,
|
||||
@ -32,7 +32,7 @@ export const referenceAjustements = {
|
||||
getLabel: (rollData, actor) => rollData.selectedSort?.name ?? rollData.attackerRoll ? 'Imposée' : 'Libre',
|
||||
getValue: (rollData, actor) => rollData.selectedSort
|
||||
? 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: {
|
||||
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">×${Misc.getFractionHtml(rollData.diviseurSignificative)}</span>` : ''
|
||||
},
|
||||
isEcaille: {
|
||||
isVisible: (rollData, actor) => rollData.arme?.data.magique && Number(rollData.arme?.data.ecaille_efficacite) > 0,
|
||||
isUsed: (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) => Misc.data(rollData.arme)?.data.magique && Number(Misc.data(rollData.arme)?.data.ecaille_efficacite) > 0,
|
||||
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: {
|
||||
isUsed: (rollData, actor) => RdDBonus.isDefenseAttaqueFinesse(rollData),
|
||||
|
@ -16,6 +16,7 @@ import { Conquete } from "./conquete.js";
|
||||
import { Pelerinage } from "./pelerinage.js";
|
||||
import { Periple } from "./periple.js";
|
||||
import { UrgenceDraconique } from "./urgence-draconique.js";
|
||||
import { Misc } from "../misc.js";
|
||||
|
||||
|
||||
export class EffetsDraconiques {
|
||||
@ -92,98 +93,100 @@ export class EffetsDraconiques {
|
||||
return EffetsDraconiques.presentCites.isCase(caseTMR, coord);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
static isMauvaiseRencontre(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('mauvaise rencontre'));
|
||||
static isMauvaiseRencontre(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('mauvaise rencontre'));
|
||||
}
|
||||
|
||||
static isMonteeLaborieuse(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('montée laborieuse'));
|
||||
static isMonteeLaborieuse(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => Draconique.isQueueSouffle(it) && it.name.toLowerCase().includes('montée laborieuse'));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isFermetureCite(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.fermetureCites.match(it));
|
||||
static isFermetureCite(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.fermetureCites.match(it));
|
||||
}
|
||||
|
||||
static isPontImpraticable(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.pontImpraticable.match(it));
|
||||
static isPontImpraticable(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.pontImpraticable.match(it));
|
||||
}
|
||||
|
||||
static isDoubleResistanceFleuve(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('résistance du fleuve'));
|
||||
static isDoubleResistanceFleuve(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('résistance du fleuve'));
|
||||
}
|
||||
|
||||
static isPeage(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('péage'));
|
||||
static isPeage(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => Draconique.isSouffleDragon(it) && it.name.toLowerCase().includes('péage'));
|
||||
}
|
||||
|
||||
static isPeriple(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.periple.match(it));
|
||||
static isPeriple(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.periple.match(it));
|
||||
}
|
||||
|
||||
static isDesorientation(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.desorientation.match(it)); // TODO
|
||||
static isDesorientation(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.desorientation.match(it)); // TODO
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isSortImpossible(element) {
|
||||
return EffetsDraconiques.isMatching(element, it =>
|
||||
static isSortImpossible(item) {
|
||||
return EffetsDraconiques.isMatching(item, it =>
|
||||
EffetsDraconiques.conquete.match(it) ||
|
||||
EffetsDraconiques.periple.match(it) ||
|
||||
EffetsDraconiques.urgenceDraconique.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.periple.match(it) ||
|
||||
EffetsDraconiques.pelerinage.match(it)
|
||||
);
|
||||
}
|
||||
|
||||
static isConquete(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.conquete.match(it));
|
||||
static isConquete(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.conquete.match(it));
|
||||
}
|
||||
|
||||
static isPelerinage(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.pelerinage.match(it));
|
||||
static isPelerinage(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.pelerinage.match(it));
|
||||
}
|
||||
|
||||
static countInertieDraconique(element) {
|
||||
return EffetsDraconiques.count(element, it => Draconique.isQueueDragon(it) && it.name.toLowerCase().includes('inertie draconique'));
|
||||
|
||||
static countInertieDraconique(item) {
|
||||
return EffetsDraconiques.count(item, it => Draconique.isQueueDragon(it) && it.name.toLowerCase().includes('inertie draconique'));
|
||||
}
|
||||
|
||||
static isUrgenceDraconique(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => EffetsDraconiques.urgenceDraconique.match(it));
|
||||
|
||||
static isUrgenceDraconique(item) {
|
||||
return EffetsDraconiques.isMatching(item, it => EffetsDraconiques.urgenceDraconique.match(it));
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static isDonDoubleReve(element) {
|
||||
return EffetsDraconiques.isMatching(element, it => Draconique.isTeteDragon(it) && it.name == 'Don de double-rêve');
|
||||
static isDonDoubleReve(item) {
|
||||
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) {
|
||||
return EffetsDraconiques.isMatching(element, it => Draconique.isTeteDragon(it) && it.name.toLowerCase().includes('connaissance du fleuve'));
|
||||
}
|
||||
|
||||
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] : [];
|
||||
static toItems(item) {
|
||||
return (item?.entity === 'Actor') ? item.data.items : (item?.entity === 'Item') ? [Misc.data(item)] : [];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user