Merge branch 'v1.4-fix' into 'v1.4'
Fix ajout list/filterItemsData See merge request LeRatierBretonnien/foundryvtt-reve-de-dragon!183
This commit is contained in:
commit
852cf51dc1
61
dev-notes.md
Normal file
61
dev-notes.md
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# Actor notes
|
||||||
|
|
||||||
|
> The Actor#getData default implementation gives you the following for use in sheet rendering:
|
||||||
|
|
||||||
|
```
|
||||||
|
actor -> the Actor instance
|
||||||
|
data -> a cloned copy of Actor#data
|
||||||
|
items -> a cloned copy of Actor#data#items
|
||||||
|
effects -> a cloned copy of Actor#data#effects
|
||||||
|
```
|
||||||
|
|
||||||
|
> if all you need is a safe copy of `Actor#data`, you'll be much better off by simply defining your own function and avoiding all the wasted work that the parent class does which will slow down your sheet
|
||||||
|
```js
|
||||||
|
getData(options) {
|
||||||
|
return {
|
||||||
|
data: foundry.utils.deepClone(this.object.data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
who knows, maybe you don't even need to copy your actor data, skip the copy and it's even faster:
|
||||||
|
```js
|
||||||
|
getData(options) {
|
||||||
|
return {
|
||||||
|
data: this.object.data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Atropos19/02/2021
|
||||||
|
There are two recommended ways to create owned items in 0.8.0:
|
||||||
|
```js
|
||||||
|
await Item.create(itemData, {parent: actor});
|
||||||
|
await actor.createEmbeddedDocuments("Item", itemDataArray);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
You can update an embedded item in one of two ways:
|
||||||
|
```js
|
||||||
|
//Method 1:
|
||||||
|
|
||||||
|
const item = actor.items.get(itemId);
|
||||||
|
item.update(data);
|
||||||
|
|
||||||
|
//Method 2:
|
||||||
|
actor.updateEmbeddedDocuments("Item", [{_id: itemId, ...}]);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
I noticed adding an ActiveEffect to an actor in code using
|
||||||
|
|
||||||
|
```js
|
||||||
|
this.createEmbeddedDocuments('ActiveEffect', [effet], options);
|
||||||
|
this.applyActiveEffects();
|
||||||
|
```
|
||||||
|
|
||||||
|
Atropos — Aujourd’hui à 14:42
|
||||||
|
Two notes on this:
|
||||||
|
1. You don't actually need to call this.applyActiveEffects() because this will happen automatically whenever an effect is created/updated/deleted
|
||||||
|
2. If you want to suppress the automatic display of the sheet for the newly created document, you can pass options.renderSheet = false as part of your options object
|
@ -57,33 +57,33 @@ export class RdDActor extends Actor {
|
|||||||
* This overrided create() function adds initial items
|
* This overrided create() function adds initial items
|
||||||
* Namely: Basic skills, money,
|
* Namely: Basic skills, money,
|
||||||
*
|
*
|
||||||
* @param {Object} data Barebones actor data which this function adds onto.
|
* @param {Object} actorData Barebones actor data which this function adds onto.
|
||||||
* @param {Object} options (Unused) Additional options which customize the creation workflow.
|
* @param {Object} options (Unused) Additional options which customize the creation workflow.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static async create(data, options) {
|
static async create(actorData, options) {
|
||||||
// Case of compendium global import
|
// Case of compendium global import
|
||||||
if (data instanceof Array) {
|
if (actorData instanceof Array) {
|
||||||
return super.create(data, options);
|
return super.create(actorData, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isPersonnage = data.type == "personnage";
|
const isPersonnage = actorData.type == "personnage";
|
||||||
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
|
// If the created actor has items (only applicable to duplicated actors) bypass the new actor creation logic
|
||||||
if (data.items) {
|
if (actorData.items) {
|
||||||
let actor = super.create(data, options);
|
let actor = super.create(actorData, options);
|
||||||
if (isPersonnage) {
|
if (isPersonnage) {
|
||||||
await actor.checkMonnaiePresence(data.items);
|
await actor.checkMonnaiePresence(actorData.items);
|
||||||
}
|
}
|
||||||
return actor;
|
return actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
const competences = await RdDUtility.loadCompendium(RdDItemCompetence.actorCompendium(data.type));
|
const competences = await RdDUtility.loadCompendium(RdDItemCompetence.actorCompendium(actorData.type));
|
||||||
data.items = competences.map(it => Misc.data(it));
|
actorData.items = competences.map(it => Misc.data(it));
|
||||||
if (isPersonnage) {
|
if (isPersonnage) {
|
||||||
data.items = data.items.concat(Monnaie.monnaiesData());
|
actorData.items = actorData.items.concat(Monnaie.monnaiesData());
|
||||||
}
|
}
|
||||||
return super.create(data, options);
|
return super.create(actorData, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -245,8 +245,14 @@ export class RdDActor extends Actor {
|
|||||||
getObjet(id) {
|
getObjet(id) {
|
||||||
return id ? this.data.items.find(it => it.id == id) : undefined;
|
return id ? this.data.items.find(it => it.id == id) : undefined;
|
||||||
}
|
}
|
||||||
|
listItemsData(type) {
|
||||||
|
return this.filterItemsData(it => it.type == type);
|
||||||
|
}
|
||||||
|
filterItemsData(filter) {
|
||||||
|
return this.data.items.map(it => Misc.data(it)).filter(filter);
|
||||||
|
}
|
||||||
getItemOfType(id, type) {
|
getItemOfType(id, type) {
|
||||||
return id ? this.data.items.find(it => it.id == id && it.type == type) : undefined;
|
return id ? this.data.items.find(it => it.id == id && Misc.data(it).type == type) : undefined;
|
||||||
}
|
}
|
||||||
getMonnaie(id) {
|
getMonnaie(id) {
|
||||||
return this.getItemOfType(id, 'monnaie');
|
return this.getItemOfType(id, 'monnaie');
|
||||||
@ -925,7 +931,7 @@ export class RdDActor extends Actor {
|
|||||||
// gestion conteneur/contenu
|
// gestion conteneur/contenu
|
||||||
if (item.conteneurId) { // l'Objet était dans un conteneur
|
if (item.conteneurId) { // l'Objet était dans un conteneur
|
||||||
let newConteneurId = itemMap[item.conteneurId]; // Get conteneur
|
let newConteneurId = itemMap[item.conteneurId]; // Get conteneur
|
||||||
let newConteneur = this.data.items.find(subItem => subItem._id == newConteneurId);
|
let newConteneur = this.getObjet(newConteneurId);
|
||||||
|
|
||||||
let newItemId = itemMap[item.id]; // Get newItem
|
let newItemId = itemMap[item.id]; // Get newItem
|
||||||
|
|
||||||
@ -955,8 +961,7 @@ export class RdDActor extends Actor {
|
|||||||
async computeEncombrementTotalEtMalusArmure() {
|
async computeEncombrementTotalEtMalusArmure() {
|
||||||
let encTotal = 0;
|
let encTotal = 0;
|
||||||
let newMalusArmure = 0;
|
let newMalusArmure = 0;
|
||||||
for (const item of this.data.items.filter(it => Misc.templateData(it).encombrement != undefined)) {
|
for (const itemData of this.filterItemsData(it => it.data.encombrement)) {
|
||||||
let itemData = item.data; // v0.8 normalization
|
|
||||||
if (itemData.type == 'armure' && itemData.data.equipe) { // Armure équipée, intégration du malus armure total
|
if (itemData.type == 'armure' && itemData.data.equipe) { // Armure équipée, intégration du malus armure total
|
||||||
newMalusArmure += itemData.data.malus;
|
newMalusArmure += itemData.data.malus;
|
||||||
}
|
}
|
||||||
@ -987,14 +992,10 @@ export class RdDActor extends Actor {
|
|||||||
let prixTotalEquipement = 0;
|
let prixTotalEquipement = 0;
|
||||||
|
|
||||||
// prix total de l'équipement est la somme du cout de chaque équipement multiplié par sa quantité.
|
// prix total de l'équipement est la somme du cout de chaque équipement multiplié par sa quantité.
|
||||||
for (const item of this.data.items) {
|
for (const itemData of this.filterItemsData(it => it?.data.cout)) {
|
||||||
let itemData = item.data; // v0.8 normalization
|
const cout = Math.min(Number(itemData.data.cout) ?? 0, 0);
|
||||||
if (itemData.data && itemData.data.cout != undefined) {
|
const quantite = Math.min(Number(itemData.data.quantite) ?? 1, 1);
|
||||||
if (!Number(itemData.data.cout)) itemData.data.cout = 0; // Auto-fix
|
prixTotalEquipement += cout * quantite;
|
||||||
if (itemData.data.quantite == undefined) itemData.data.quantite = 1; // Auto-fix
|
|
||||||
if (itemData.data.cout < 0) itemData.data.cout = 0; // Auto-fix
|
|
||||||
prixTotalEquipement += Number(itemData.data.cout) * Number(itemData.data.quantite);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Mise à jour valeur totale de l'équipement
|
// Mise à jour valeur totale de l'équipement
|
||||||
this.prixTotalEquipement = prixTotalEquipement;
|
this.prixTotalEquipement = prixTotalEquipement;
|
||||||
@ -1113,7 +1114,7 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildTMRInnaccessible() {
|
buildTMRInnaccessible() {
|
||||||
const tmrInnaccessibles = this.data.items.filter(it => Draconique.isCaseTMR(it) &&
|
const tmrInnaccessibles = this.filterItemsData(it => Draconique.isCaseTMR(it) &&
|
||||||
EffetsDraconiques.isInnaccessible(it));
|
EffetsDraconiques.isInnaccessible(it));
|
||||||
return tmrInnaccessibles.map(it => it.data.coord);
|
return tmrInnaccessibles.map(it => it.data.coord);
|
||||||
}
|
}
|
||||||
@ -1664,7 +1665,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async checkCompetenceXP(compName, newXP = undefined) {
|
async checkCompetenceXP(compName, newXP = undefined) {
|
||||||
let competence = RdDItemCompetence.findCompetence(this.data.items, compName);
|
let competence = this.getCompetence(compName);
|
||||||
if (competence && newXP && newXP == competence.data.xp) { // Si édition, mais sans changement XP
|
if (competence && newXP && newXP == competence.data.xp) { // Si édition, mais sans changement XP
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1831,7 +1832,7 @@ export class RdDActor extends Actor {
|
|||||||
let addMsg = "";
|
let addMsg = "";
|
||||||
let rencSpecial = this.data.items.find(item => EffetsDraconiques.isMauvaiseRencontre(item));
|
let rencSpecial = this.data.items.find(item => EffetsDraconiques.isMauvaiseRencontre(item));
|
||||||
if (rencSpecial) {
|
if (rencSpecial) {
|
||||||
rencSpecial = duplicate(rencSpecial); // To keep it
|
rencSpecial = Misc.data(rencSpecial); // To keep it
|
||||||
if (rencSpecial.type != 'souffle') {
|
if (rencSpecial.type != 'souffle') {
|
||||||
this.deleteEmbeddedDocuments('Item', [rencSpecial._id]); // Suppression dans la liste des queues
|
this.deleteEmbeddedDocuments('Item', [rencSpecial._id]); // Suppression dans la liste des queues
|
||||||
addMsg = " La queue a été supprimée de votre fiche automatiquement";
|
addMsg = " La queue a été supprimée de votre fiche automatiquement";
|
||||||
@ -2318,7 +2319,8 @@ export class RdDActor extends Actor {
|
|||||||
}
|
}
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
checkDesirLancinant() {
|
checkDesirLancinant() {
|
||||||
let queue = this.data.items.filter((item) => item.name.toLowerCase().includes('lancinant'));
|
let queue = this.filterItemsData(it => it.type == 'queue' || it.type == 'ombre')
|
||||||
|
.filter(it => Grammar.toLowerCaseNoAccent(it.name).includes('desir lancinant'));
|
||||||
return (queue.length > 0);
|
return (queue.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2368,7 +2370,7 @@ export class RdDActor extends Actor {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async ajouteNombreAstral(data) {
|
async ajouteNombreAstral(data) {
|
||||||
// Gestion expérience (si existante)
|
// Gestion expérience (si existante)
|
||||||
data.competence = RdDItemCompetence.findCompetence(this.data.items, "astrologie");
|
data.competence = this.getCompetence("astrologie");
|
||||||
data.selectedCarac = Misc.templateData(this).carac["vue"];
|
data.selectedCarac = Misc.templateData(this).carac["vue"];
|
||||||
this._appliquerAjoutExperience(data);
|
this._appliquerAjoutExperience(data);
|
||||||
|
|
||||||
@ -2380,7 +2382,7 @@ export class RdDActor extends Actor {
|
|||||||
await this.createEmbeddedDocuments("Item", [item]);
|
await this.createEmbeddedDocuments("Item", [item]);
|
||||||
|
|
||||||
// Suppression des anciens nombres astraux
|
// Suppression des anciens nombres astraux
|
||||||
let toDelete = this.data.items.filter(it => it.data.jourindex < game.system.rdd.calendrier.getCurrentDayIndex());
|
let toDelete = this.listItemsData('nombreastral').filter(it => it.data.jourindex < game.system.rdd.calendrier.getCurrentDayIndex());
|
||||||
const deletions = toDelete.map(it => it._id);
|
const deletions = toDelete.map(it => it._id);
|
||||||
await this.deleteEmbeddedDocuments("Item", deletions);
|
await this.deleteEmbeddedDocuments("Item", deletions);
|
||||||
|
|
||||||
@ -2443,12 +2445,12 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
getSortList() {
|
getSortList() {
|
||||||
return this.data.items.filter(it => it.data.type == "sort");
|
return this.listItemsData("sort");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
countMonteeLaborieuse() { // Return +1 par queue/ombre/souffle Montée Laborieuse présente
|
countMonteeLaborieuse() { // Return +1 par queue/ombre/souffle Montée Laborieuse présente
|
||||||
let countMonteeLaborieuse = this.data.items.filter(it => EffetsDraconiques.isMonteeLaborieuse(it)).length;
|
let countMonteeLaborieuse = this.filterItemsData(it => EffetsDraconiques.isMonteeLaborieuse(it)).length;
|
||||||
if (countMonteeLaborieuse > 0) {
|
if (countMonteeLaborieuse > 0) {
|
||||||
ChatMessage.create({
|
ChatMessage.create({
|
||||||
content: `Vous êtes sous le coup d'une Montée Laborieuse : vos montées en TMR coûtent ${countMonteeLaborieuse} Point de Rêve de plus.`,
|
content: `Vous êtes sous le coup d'une Montée Laborieuse : vos montées en TMR coûtent ${countMonteeLaborieuse} Point de Rêve de plus.`,
|
||||||
@ -2502,7 +2504,7 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
rollArme(compName, armeName = undefined) {
|
rollArme(compName, armeName = undefined) {
|
||||||
let arme = armeName ? this.data.items.find(it => it.name == armeName && RdDItemArme.isArme(it)) : undefined;
|
let arme = armeName ? this.data.items.find(it => Misc.data(it).name == armeName && RdDItemArme.isArme(it)) : undefined;
|
||||||
let competence = this.getCompetence(compName);
|
let competence = this.getCompetence(compName);
|
||||||
|
|
||||||
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) {
|
||||||
@ -2915,10 +2917,10 @@ export class RdDActor extends Actor {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
async effectuerTacheAlchimie(recetteId, alchimieName, alchimieData) {
|
async effectuerTacheAlchimie(recetteId, alchimieName, alchimieData) {
|
||||||
let recette = this.data.items.find(item => item.type == 'recettealchimique' && item.id == recetteId);
|
let recette = this.getItemOfType(recetteId, 'recettealchimique');
|
||||||
const actorData = Misc.data(this);
|
const actorData = Misc.data(this);
|
||||||
if (recette) {
|
if (recette) {
|
||||||
let competence = this.data.items.find(item => item.type == 'competence' && item.name.toLowerCase() == "alchimie");
|
let competence = this.getCompetence("alchimie");
|
||||||
let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData);
|
let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData);
|
||||||
let rollData = {
|
let rollData = {
|
||||||
recette: recette,
|
recette: recette,
|
||||||
|
@ -30,7 +30,7 @@ export class Monnaie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static filtrerMonnaies(items) {
|
static filtrerMonnaies(items) {
|
||||||
return items.filter(it => it.type == 'monnaie');
|
return items.filter(it => Misc.data(it).type == 'monnaie');
|
||||||
}
|
}
|
||||||
|
|
||||||
static monnaiesManquantes(items) {
|
static monnaiesManquantes(items) {
|
||||||
|
@ -73,7 +73,7 @@ export class RdDItemSheet extends ItemSheet {
|
|||||||
console.log(formData.competences);
|
console.log(formData.competences);
|
||||||
}
|
}
|
||||||
if ( formData.type == 'recettealchimique' ) {
|
if ( formData.type == 'recettealchimique' ) {
|
||||||
RdDAlchimie.processManipulation(formData.item, this.actor && this.actor.id );
|
RdDAlchimie.processManipulation(objectData, this.actor && this.actor.id );
|
||||||
}
|
}
|
||||||
if ( this.actor ) {
|
if ( this.actor ) {
|
||||||
formData.isOwned = true;
|
formData.isOwned = true;
|
||||||
|
@ -1,68 +1,56 @@
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
import { Misc } from "./misc.js";
|
import { Misc } from "./misc.js";
|
||||||
|
|
||||||
|
const matchOperations = new RegExp(/@(\w*){([\w\-]+)}/ig);
|
||||||
|
const matchOperationTerms = new RegExp(/@(\w*){([\w\-]+)}/i);
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
export class RdDAlchimie {
|
export class RdDAlchimie {
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static processManipulation( recette, actorId = undefined ) {
|
static processManipulation(recetteData, actorId = undefined) {
|
||||||
//console.log("CALLED", recette, recette.isOwned, actorId );
|
//console.log("CALLED", recette, recette.isOwned, actorId );
|
||||||
let manip = duplicate(recette.data.manipulation);
|
let manip = recetteData.data.manipulation;
|
||||||
let reg1 = new RegExp(/@(\w*){([\w\-]+)}/ig);
|
let matchArray = manip.match(matchOperations);
|
||||||
let matchArray = manip.match( reg1 );
|
|
||||||
if (matchArray) {
|
if (matchArray) {
|
||||||
for (let matchStr of matchArray) {
|
for (let matchStr of matchArray) {
|
||||||
let reg2 = new RegExp(/@(\w*){([\w\-]+)}/i);
|
let result = matchStr.match(matchOperationTerms);
|
||||||
let result = matchStr.match(reg2);
|
|
||||||
//console.log("RESULT ", result);
|
//console.log("RESULT ", result);
|
||||||
if (result[1] && result[2]) {
|
if (result[1] && result[2]) {
|
||||||
let commande = Misc.upperFirst(result[1]);
|
let commande = Misc.upperFirst(result[1]);
|
||||||
let replacement = this[`_alchimie${commande}`](recette, result[2], actorId);
|
let replacement = this[`_alchimie${commande}`](recetteData, result[2], actorId);
|
||||||
manip = manip.replace(result[0], replacement);
|
manip = manip.replace(result[0], replacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recette.data.manipulation_update = manip;
|
recetteData.data.manipulation_update = manip;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static _alchimieCouleur(recette, couleurs, actorId) {
|
static _alchimieCouleur(recette, couleurs, actorId) {
|
||||||
let replacement
|
|
||||||
if (actorId) {
|
if (actorId) {
|
||||||
replacement = `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="couleur" data-alchimie-data="${couleurs}">couleur ${couleurs}</a></span>`;
|
return `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="couleur" data-alchimie-data="${couleurs}">couleur ${couleurs}</a></span>`;
|
||||||
} else {
|
} else {
|
||||||
replacement = `<span class="alchimie-tache">couleur ${couleurs} </span>`;
|
return `<span class="alchimie-tache">couleur ${couleurs} </span>`;
|
||||||
}
|
}
|
||||||
return replacement;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static _alchimieConsistance(recette, consistances, actorId) {
|
static _alchimieConsistance(recette, consistances, actorId) {
|
||||||
let replacement
|
|
||||||
if (actorId) {
|
if (actorId) {
|
||||||
replacement = `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="consistance" data-alchimie-data="${consistances}">consistance ${consistances}</a></span>`;
|
return `<span class="alchimie-tache"><a data-recette-id="${recette._id}" data-actor-id="${actorId}" data-alchimie-tache="consistance" data-alchimie-data="${consistances}">consistance ${consistances}</a></span>`;
|
||||||
} else {
|
} else {
|
||||||
replacement = `<span class="alchimie-tache">consistance ${consistances} </span>`;
|
return `<span class="alchimie-tache">consistance ${consistances} </span>`;
|
||||||
}
|
}
|
||||||
return replacement;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static getDifficulte(aspects) {
|
static getDifficulte(aspects) {
|
||||||
let aspectsArray = aspects.split('-');
|
let elements = aspects.split('-');
|
||||||
let diff = 0;
|
let composantes = elements.length;
|
||||||
let nbDifferent = 0;
|
let distincts = Object.keys(Misc.classifyFirst(elements, it => it)).length;
|
||||||
let aspectsHash = {}
|
if (distincts == 1) {
|
||||||
for (let colconst of aspectsArray) {
|
composantes--;
|
||||||
if ( aspectsHash[colconst] ){ // Deja present, augmente difficulté de 1
|
}
|
||||||
diff -= 1;
|
return Math.min(0, -composantes);
|
||||||
} else {
|
|
||||||
nbDifferent++;
|
|
||||||
aspectsHash[colconst] = colconst; // Keep track
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff = diff - ((nbDifferent>1) ? nbDifferent : 0); // Ca doit marcher ....
|
|
||||||
return Math.min(0, diff); // Pour être sur
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ export class RdDAstrologieJoueur extends Dialog {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async create(actor, dialogConfig) {
|
static async create(actor, dialogConfig) {
|
||||||
|
|
||||||
let data = { nombres: this.organizeNombres( actor),
|
let data = {
|
||||||
|
nombres: this.organizeNombres(actor),
|
||||||
dates: game.system.rdd.calendrier.getJoursSuivants(10),
|
dates: game.system.rdd.calendrier.getJoursSuivants(10),
|
||||||
etat: actor.getEtatGeneral(),
|
etat: actor.getEtatGeneral(),
|
||||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||||
@ -44,7 +45,7 @@ export class RdDAstrologieJoueur extends Dialog {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static organizeNombres(actor) {
|
static organizeNombres(actor) {
|
||||||
let itemNombres = actor.data.items.filter( (item) => item.type == 'nombreastral');
|
let itemNombres = actor.listItemsData('nombreastral');
|
||||||
let itemFiltered = {};
|
let itemFiltered = {};
|
||||||
for (let item of itemNombres) {
|
for (let item of itemNombres) {
|
||||||
if (itemFiltered[item.data.jourindex]) {
|
if (itemFiltered[item.data.jourindex]) {
|
||||||
@ -61,7 +62,8 @@ export class RdDAstrologieJoueur extends Dialog {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
requestJetAstrologie() {
|
requestJetAstrologie() {
|
||||||
let data = { id: this.actor.data._id,
|
let data = {
|
||||||
|
id: this.actor.data._id,
|
||||||
carac_vue: Misc.data(this.actor).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,
|
||||||
|
@ -199,7 +199,7 @@ export class RdDCalendrier extends Application {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
syncPlayerTime(calendrier) {
|
syncPlayerTime(calendrier) {
|
||||||
this.calendrier = duplicate(calendrier); // Local copy update
|
this.calendrier = duplicate(calendrier); // Local copy update
|
||||||
this.updateDisplay(); // Then update
|
this.updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -247,21 +247,19 @@ export class RdDCalendrier extends Application {
|
|||||||
console.log(request);
|
console.log(request);
|
||||||
let jourDiff = this.getLectureAstrologieDifficulte(request.date);
|
let jourDiff = this.getLectureAstrologieDifficulte(request.date);
|
||||||
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat);
|
let niveau = Number(request.astrologie.data.niveau) + Number(request.conditions) + Number(jourDiff) + Number(request.etat);
|
||||||
let rolled = await RdDResolutionTable.rollData({
|
let rollData= {
|
||||||
caracValue: request.carac_vue,
|
caracValue: request.carac_vue,
|
||||||
finalLevel: niveau,
|
finalLevel: niveau,
|
||||||
showDice: false
|
showDice: false
|
||||||
});
|
};
|
||||||
|
await RdDResolutionTable.rollData(rollData);
|
||||||
let nbAstral = this.getNombreAstral(request.date);
|
let nbAstral = this.getNombreAstral(request.date);
|
||||||
let nbAstralFaux = nbAstral;
|
request.rolled = rollData.rolled;
|
||||||
request.isValid = true;
|
request.isValid = true;
|
||||||
request.rolled = rolled;
|
if (!request.rolled.isSuccess) {
|
||||||
if (!rolled.isSuccess) {
|
|
||||||
request.isValid = false;
|
request.isValid = false;
|
||||||
while (nbAstralFaux == nbAstral) {
|
let nbAstralFaux = new Roll("1d11").evaluate( { async: false} ).total;
|
||||||
nbAstralFaux = new Roll("1d12").evaluate( { async: false} ).total;
|
nbAstral = nbAstral==nbAstralFaux ? 12 : nbAstralFaux;
|
||||||
}
|
|
||||||
nbAstral = nbAstralFaux;
|
|
||||||
// Mise à jour des nombres astraux du joueur
|
// Mise à jour des nombres astraux du joueur
|
||||||
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
|
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
|
||||||
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstralFaux });
|
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstralFaux });
|
||||||
@ -338,7 +336,7 @@ export class RdDCalendrier extends Application {
|
|||||||
if (game.user.isGM) {
|
if (game.user.isGM) {
|
||||||
dateHTML = dateHTML + " - NA: " + this.getCurrentNombreAstral();
|
dateHTML = dateHTML + " - NA: " + this.getCurrentNombreAstral();
|
||||||
}
|
}
|
||||||
for (let handle of document.getElementsByClassName("calendar-move-handle")) {
|
for (let handle of document.getElementsByClassName("calendar-date-rdd")) {
|
||||||
handle.innerHTML = dateHTML;
|
handle.innerHTML = dateHTML;
|
||||||
}
|
}
|
||||||
for (let heure of document.getElementsByClassName("calendar-heure-texte")) {
|
for (let heure of document.getElementsByClassName("calendar-heure-texte")) {
|
||||||
|
@ -1093,12 +1093,7 @@ ul, li {
|
|||||||
.calendar-date-rdd {
|
.calendar-date-rdd {
|
||||||
font-family: "GoudyAcc";
|
font-family: "GoudyAcc";
|
||||||
color: #CCC;
|
color: #CCC;
|
||||||
font-weight: bold;
|
|
||||||
font-size: 1.10rem;
|
|
||||||
opacity: 90;
|
opacity: 90;
|
||||||
}
|
|
||||||
#calendar-move-handle {
|
|
||||||
font-family: "GoudyAcc";
|
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -461,8 +461,19 @@
|
|||||||
|
|
||||||
{{!-- Connaissances Tab --}}
|
{{!-- Connaissances Tab --}}
|
||||||
<div class="tab connaissances" data-group="primary" data-tab="connaissances">
|
<div class="tab connaissances" data-group="primary" data-tab="connaissances">
|
||||||
<span class="item-name"><a class="creer-une-oeuvre">Créer une oeuvre</a></span>
|
<h3>Tâches</h3><a class='creer-tache'>Créer une nouvelle Tâche</a>
|
||||||
<h3>Oeuvres diverses :</h3>
|
<ul class="item-list alterne-list">
|
||||||
|
{{#each taches as |tache id|}}
|
||||||
|
<li class="item flexrow list-item" data-item-id="{{tache._id}}"><span class="competence-title tache-label"><a>{{tache.name}} ({{tache.data.points_de_tache_courant}}/{{tache.data.points_de_tache}})</a></span>
|
||||||
|
<div class="item-controls">
|
||||||
|
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
||||||
|
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
<hr>
|
||||||
|
<h3>Oeuvres diverses :</h3><a class="creer-une-oeuvre">Créer une oeuvre</a>
|
||||||
<ul class="item-list alterne-list">
|
<ul class="item-list alterne-list">
|
||||||
{{#each chants as |chant id|}}
|
{{#each chants as |chant id|}}
|
||||||
<li class="item flexrow list-item" data-item-id="{{chant._id}}"><span>Chant</span><span class="competence-title chant-label"><a>{{chant.name}} (niveau {{chant.data.niveau}})</a></span>
|
<li class="item flexrow list-item" data-item-id="{{chant._id}}"><span>Chant</span><span class="competence-title chant-label"><a>{{chant.name}} (niveau {{chant.data.niveau}})</a></span>
|
||||||
@ -527,18 +538,9 @@
|
|||||||
</li>
|
</li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
<h3>Tâches</h3><a class='creer-tache'>Créer une nouvelle Tâche</a>
|
|
||||||
<ul class="item-list alterne-list">
|
|
||||||
{{#each taches as |tache id|}}
|
|
||||||
<li class="item flexrow list-item" data-item-id="{{tache._id}}"><span class="competence-title tache-label"><a>{{tache.name}} ({{tache.data.points_de_tache_courant}}/{{tache.data.points_de_tache}})</a></span>
|
|
||||||
<div class="item-controls">
|
|
||||||
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
|
|
||||||
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
|
||||||
<hr>
|
<hr>
|
||||||
|
<h3>Astrologie</h3>
|
||||||
|
<span class="astrologie-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{!-- hautreve Tab --}}
|
{{!-- hautreve Tab --}}
|
||||||
@ -576,9 +578,6 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="item flexrow" >
|
|
||||||
<span class="astrologie-label"><a id="jet-astrologie">Astrologie : Nombres Astraux</a></span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<img class="chat-icon" src="{{competence.img}}" alt="{{oeuvre.data.competence}}" />
|
<img class="chat-icon" src="{{competence.img}}" alt="{{oeuvre.data.competence}}" />
|
||||||
<h4>
|
<h4>
|
||||||
{{alias}} tente de chanter la chanson : {{oeuvre.name}} (niveau {{oeuvre.data.niveau}})
|
{{alias}} tente de chanter : {{oeuvre.name}} (niveau {{oeuvre.data.niveau}})
|
||||||
</h4>
|
</h4>
|
||||||
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}}
|
{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}}
|
||||||
<hr>
|
<hr>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<div class="rdd-hud-list tokenhudext left">
|
<div class="rdd-hud-list tokenhudext left">
|
||||||
{{#each armes as |arme key|}}
|
{{#each armes as |arme key|}}
|
||||||
{{#unless arme.data.initOnly}}
|
{{#unless arme.data.initOnly}}
|
||||||
<div class="control-icon tokenhudicon rdd-hud-menu rdd-attaque" data-combatant-id="{{../combatant._id}}" data-arme-id="{{arme.index}}" title="{{arme.name}}">
|
<div class="control-icon tokenhudicon rdd-hud-menu rdd-attaque" data-combatant-id="{{../combatant.id}}" data-arme-id="{{arme.index}}" title="{{arme.name}}">
|
||||||
<label>C:{{arme.name}} {{arme.data.mainInfo}}</label>
|
<label>C:{{arme.name}} {{arme.data.mainInfo}}</label>
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
|
<img class="rdd-hud-togglebutton" src="icons/svg/sword.svg" width="36" height="36" title="Initiative" />
|
||||||
<div class="rdd-hud-list tokenhudext right">
|
<div class="rdd-hud-list tokenhudext right">
|
||||||
{{#each armes as |arme key|}}
|
{{#each armes as |arme key|}}
|
||||||
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{arme.command}}" data-combatant-id="{{../combatant._id}}" data-arme-id="{{arme.index}}" title="{{arme.name}}">
|
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{arme.command}}" data-combatant-id="{{../combatant.id}}" data-arme-id="{{arme.index}}" title="{{arme.name}}">
|
||||||
<label>I:{{arme.name}} {{arme.data.mainInfo}}</label>
|
<label>I:{{arme.name}} {{arme.data.mainInfo}}</label>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{#each commandes as |commande key|}}
|
{{#each commandes as |commande key|}}
|
||||||
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{commande.command}}" data-combatant-id="{{../combatant._id}}" data-arme-id="{{commande.index}}" title="{{commande.name}}">
|
<div class="control-icon tokenhudicon rdd-hud-menu" data-command="{{commande.command}}" data-combatant-id="{{../combatant.id}}" data-arme-id="{{commande.index}}" title="{{commande.name}}">
|
||||||
<label>I:{{commande.name}}</label>
|
<label>I:{{commande.name}}</label>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
@ -24,16 +24,16 @@
|
|||||||
<label>Exotisme</label>
|
<label>Exotisme</label>
|
||||||
<input class="attribute-value" type="text" name="data.exotisme" value="{{data.exotisme}}" data-dtype="Number"/>
|
<input class="attribute-value" type="text" name="data.exotisme" value="{{data.exotisme}}" data-dtype="Number"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Référence / Auteur</label>
|
||||||
|
<input class="attribute-value" type="text" name="data.reference" value="{{data.reference}}" data-dtype="String"/>
|
||||||
|
</div>
|
||||||
<div class="flexcol">
|
<div class="flexcol">
|
||||||
<span><label>Ingrédients : </label></span>
|
<span><label>Ingrédients : </label></span>
|
||||||
<div class="form-group editor">
|
<div class="form-group editor">
|
||||||
{{editor content=data.ingredients target="data.ingredients" button=true owner=owner editable=editable}}
|
{{editor content=data.ingredients target="data.ingredients" button=true owner=owner editable=editable}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<label>Référence / Auteur</label>
|
|
||||||
<input class="attribute-value" type="text" name="data.reference" value="{{data.reference}}" data-dtype="String"/>
|
|
||||||
</div>
|
|
||||||
<div class="flexcol">
|
<div class="flexcol">
|
||||||
<span><label>Description : </label></span>
|
<span><label>Description : </label></span>
|
||||||
<div class="form-group editor">
|
<div class="form-group editor">
|
||||||
|
Loading…
Reference in New Issue
Block a user