Gestion plus fines des entites et corrections sur initiative #195
This commit is contained in:
@ -33,6 +33,7 @@ import { RollDataAjustements } from "./rolldata-ajustements.js";
|
||||
import { DialogItemAchat } from "./dialog-item-achat.js";
|
||||
import { RdDItem } from "./item.js";
|
||||
import { RdDPossession } from "./rdd-possession.js";
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/**
|
||||
@ -768,13 +769,13 @@ export class RdDActor extends Actor {
|
||||
const sustNeeded = tplData.attributs.sust.value;
|
||||
const sustConsomme = tplData.compteurs.sust.value;
|
||||
const eauConsomme = tplData.compteurs.eau.value;
|
||||
if (game.settings.get("foundryvtt-reve-de-dragon", "appliquer-famine-soif").includes('famine') && sustConsomme < sustNeeded) {
|
||||
if (game.settings.get(SYSTEM_RDD, "appliquer-famine-soif").includes('famine') && sustConsomme < sustNeeded) {
|
||||
const perte = sustConsomme < Math.min(0.5, sustNeeded) ? 3 : (sustConsomme <= (sustNeeded / 2) ? 2 : 1);
|
||||
message.content += `<br>Vous ne vous êtes sustenté que de ${sustConsomme} pour un appétit de ${sustNeeded}, vous avez faim!
|
||||
La famine devrait vous faire ${perte} points d'endurance non récupérables, notez le cumul de côté et ajustez l'endurance`;
|
||||
}
|
||||
|
||||
if (game.settings.get("foundryvtt-reve-de-dragon", "appliquer-famine-soif").includes('soif') && eauConsomme < sustNeeded) {
|
||||
if (game.settings.get(SYSTEM_RDD, "appliquer-famine-soif").includes('soif') && eauConsomme < sustNeeded) {
|
||||
const perte = eauConsomme < Math.min(0.5, sustNeeded) ? 12 : (eauConsomme <= (sustNeeded / 2) ? 6 : 3);
|
||||
message.content += `<br>Vous n'avez bu que ${eauConsomme} doses de liquide pour une soif de ${sustNeeded}, vous avez soif!
|
||||
La soif devrait vous faire ${perte} points d'endurance non récupérables, notez le cumul de côté et ajustez l'endurance`;
|
||||
@ -1904,9 +1905,8 @@ export class RdDActor extends Actor {
|
||||
ui.notifications.warn(`Il n'y a pas assez de ${itemData.name} pour manger ${choix.doses}`)
|
||||
return;
|
||||
}
|
||||
const surmonteExotisme = await this.surmonterExotisme(item, choix);
|
||||
if (!surmonteExotisme) {
|
||||
ui.notifications.warn(`Vous n'arrivez pas à manger de ${itemData.name}`)
|
||||
if (!this._apprecierCuisine(itemData, choix.seForcer)) {
|
||||
ui.notifications.info(`${this.name} ne n'arrive pas à manger de ${itemData.name}`)
|
||||
return;
|
||||
}
|
||||
await this.manger(item, choix.doses, { diminuerQuantite: false });
|
||||
@ -1914,24 +1914,53 @@ export class RdDActor extends Actor {
|
||||
await item.diminuerQuantite(choix.doses, choix);
|
||||
}
|
||||
|
||||
async _apprecierCuisine(itemData, seForcer) {
|
||||
const surmonteExotisme = await this._surmonterExotisme(itemData, seForcer);
|
||||
if (surmonteExotisme) {
|
||||
await this.apprecier('gout', 'cuisine', itemData.data.qualite, itemData.data.boisson ? "apprécie la boisson" : "apprécie le plat");
|
||||
}
|
||||
else if (seForcer) {
|
||||
await this.jetDeMoral('malheureux');
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async manger(item, doses, options = { diminuerQuantite: true }) {
|
||||
if (!item.getActionPrincipale()) return;
|
||||
await this.apprecierCuisine(item);
|
||||
async _surmonterExotisme(itemData) {
|
||||
const exotisme = Math.min(itemData.data.exotisme, itemData.data.qualite, 0);
|
||||
if (exotisme < 0) {
|
||||
const rolled = await this.rollCaracCompetence('volonte', 'cuisine', exotisme, { title: `tente de surmonter l'exotisme de ${itemData.name}` });
|
||||
return rolled.isSuccess;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async apprecier(carac, compName, qualite, title) {
|
||||
const rolled = await this.rollCaracCompetence(carac, compName, qualite, { title: title, apprecier: true });
|
||||
if (rolled?.isSuccess) {
|
||||
await this.jetDeMoral('heureux');
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async manger(item, doses, options = { diminuerQuantite: true}) {
|
||||
const sust = Misc.templateData(item).sust;
|
||||
if (sust > 0) {
|
||||
await this.updateCompteurValue('sust', Misc.keepDecimals(Misc.templateData(this).compteurs.sust.value + sust * doses, 2));
|
||||
await this.updateCompteurValue('sust', Misc.keepDecimals(Misc.templateData(this).compteurs.sust.value + sust * doses, 1));
|
||||
}
|
||||
await item.diminuerQuantite(doses, options);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async boire(item, doses, options = { diminuerQuantite: true }) {
|
||||
if (!item.getActionPrincipale()) return;
|
||||
const itemData = Misc.data(item);
|
||||
const desaltere = itemData.data.desaltere;
|
||||
if (desaltere > 0) {
|
||||
await this.updateCompteurValue('eau', Misc.keepDecimals(Misc.templateData(this).compteurs.eau.value + desaltere * doses, 2));
|
||||
await this.updateCompteurValue('eau', Misc.keepDecimals(Misc.templateData(this).compteurs.eau.value + desaltere * doses, 1));
|
||||
}
|
||||
if (item.isAlcool()) {
|
||||
for (let i = 0; i < doses; i++) {
|
||||
@ -2010,35 +2039,6 @@ export class RdDActor extends Actor {
|
||||
await RdDResolutionTable.displayRollData(ethylismeData, this, 'chat-resultat-ethylisme.html');
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async apprecierCuisine(item) {
|
||||
const cuisine = Misc.data(this.getCompetence('cuisine'));
|
||||
const itemData = Misc.data(item);
|
||||
const qualite = itemData.data.qualite;
|
||||
if (cuisine && qualite > 0 && qualite > cuisine.data.niveau) {
|
||||
const rolled = await this.rollCaracCompetence('gout', 'cuisine', qualite, { title: itemData.data.boisson ? "apprécie la boisson" : "apprécie le plat" });
|
||||
if (rolled.isSuccess) {
|
||||
await this.jetDeMoral('heureux');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async surmonterExotisme(item, choix = {}) {
|
||||
const itemData = Misc.data(item);
|
||||
const exotisme = Math.min(itemData.data.exotisme, itemData.data.qualite, 0);
|
||||
if (exotisme < 0) {
|
||||
const rolled = await this.rollCaracCompetence('volonte', 'cuisine', exotisme, { title: `tente de surmonter l'exotisme de ${itemData.name}` });
|
||||
if (rolled.isEchec) {
|
||||
if (!choix.seForcer) {
|
||||
return false;
|
||||
}
|
||||
await this.jetDeMoral('malheureux');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async jetGoutCuisine() {
|
||||
console.info('Jet de Gout/Cuisine');
|
||||
@ -2448,27 +2448,30 @@ export class RdDActor extends Actor {
|
||||
RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-general.html');
|
||||
}
|
||||
|
||||
async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) {
|
||||
async rollCaracCompetence(caracName, compName, diff, options = { title: "", apprecier: false}) {
|
||||
const carac = this.getCaracByName(caracName);
|
||||
if (!carac) {
|
||||
ui.notifications.warn(`${this.name} n'a pas de caractéristique correspondant à ${caracName}`)
|
||||
return;
|
||||
}
|
||||
const competence = Misc.data(this.getCompetence(compName));
|
||||
if (compName && !competence) {
|
||||
ui.notifications.warn(`${this.name} n'a pas de compétence correspondant à ${compName}`)
|
||||
return;
|
||||
if (options.apprecier && competence){
|
||||
const minQualite = Math.max(0, competence.data.niveau);
|
||||
if (diff <= minQualite) {
|
||||
ui.notifications.info(`${this.name} a un niveau ${competence.data.niveau} en ${competence.name}, trop élevé pour apprécier la qualité de ${diff}`)
|
||||
return;
|
||||
}
|
||||
}
|
||||
let rollData = {
|
||||
alias: this.name,
|
||||
caracValue: Number(carac.value),
|
||||
selectedCarac: carac,
|
||||
competence: competence,
|
||||
finalLevel: (Misc.templateData(competence)?.niveau ?? 0) + diff,
|
||||
diffLibre: diff,
|
||||
showDice: true,
|
||||
show: { title: options?.title ?? '' }
|
||||
};
|
||||
RollDataAjustements.calcul(rollData, this);
|
||||
await RdDResolutionTable.rollData(rollData);
|
||||
this._appliquerExperienceRollData(rollData);
|
||||
RdDResolutionTable.displayRollData(rollData, this)
|
||||
@ -3478,7 +3481,7 @@ export class RdDActor extends Actor {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async accorder(entite, when = 'avant-encaissement') {
|
||||
if (when != game.settings.get("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar")
|
||||
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
|
||||
|| !entite.isEntiteCauchemar()
|
||||
|| entite.isEntiteCauchemarAccordee(this)) {
|
||||
return true;
|
||||
@ -3555,7 +3558,7 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
let updates = []
|
||||
for (const [valeur, nombre] of Object.entries(nouvelleFortune)) {
|
||||
updates.push({ _id: parValeur[valeur]._id, 'data.quantite': nombre });
|
||||
updates.push({ _id: parValeur[valeur].id, 'data.quantite': nombre });
|
||||
}
|
||||
await this.updateEmbeddedDocuments('Item', updates);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import { RdDGemme } from "./rdd-gemme.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { HtmlUtility } from "./html-utility.js";
|
||||
import { ReglesOptionelles } from "./regles-optionelles.js";
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
|
||||
/**
|
||||
* Extend the basic ItemSheet with some very simple modifications
|
||||
@ -17,7 +18,7 @@ export class RdDItemSheet extends ItemSheet {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
|
||||
classes: [SYSTEM_RDD, "sheet", "item"],
|
||||
template: "systems/foundryvtt-reve-de-dragon/templates/item-sheet.html",
|
||||
width: 550,
|
||||
height: 550
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
import { RdDItemSigneDraconique } from "./item-signedraconique.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { TMRType, TMRUtility } from "./tmr-utility.js";
|
||||
@ -11,7 +12,7 @@ export class RdDSigneDraconiqueItemSheet extends ItemSheet {
|
||||
/** @override */
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
classes: ["foundryvtt-reve-de-dragon", "sheet", "item"],
|
||||
classes: [SYSTEM_RDD, "sheet", "item"],
|
||||
template: "systems/foundryvtt-reve-de-dragon/templates/item-signedraconique-sheet.html",
|
||||
width: 550,
|
||||
height: 550
|
||||
|
@ -14,7 +14,7 @@ export const defaultItemImg = {
|
||||
armure: "systems/foundryvtt-reve-de-dragon/icons/armes_armures/armure_plaques.webp",
|
||||
conteneur: "systems/foundryvtt-reve-de-dragon/icons/objets/sac_a_dos.webp",
|
||||
sort: "systems/foundryvtt-reve-de-dragon/icons/competence_oniros.webp",
|
||||
herbe: "systems/foundryvtt-reve-de-dragon/icons/botanique/Endorlotte.png",
|
||||
herbe: "systems/foundryvtt-reve-de-dragon/icons/botanique/Endorlotte.webp",
|
||||
ingredient: "systems/foundryvtt-reve-de-dragon/icons/objets/sable_poudre.webp",
|
||||
livre: "systems/foundryvtt-reve-de-dragon/icons/objets/livre.webp",
|
||||
potion: "systems/foundryvtt-reve-de-dragon/icons/objets/liqueur_de_bagdol.webp",
|
||||
@ -307,9 +307,6 @@ export class RdDItem extends Item {
|
||||
chatData.data.quantite = chatData.postQuantity;
|
||||
console.log("POST : ", chatData.finalPrice, chatData.data.cout_deniers_total, chatData.postQuantity);
|
||||
}
|
||||
// Don't post any image for the item (which would leave a large gap) if the default image is used
|
||||
if (chatData.img.includes("/blank.png"))
|
||||
chatData.img = null;
|
||||
|
||||
// JSON object for easy creation
|
||||
chatData.jsondata = JSON.stringify(
|
||||
|
@ -144,9 +144,13 @@ export class Misc {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static findFirstLike(value, elements, mapper = it=>it.name, description = 'valeurs') {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
value = Grammar.toLowerCaseNoAccent(value);
|
||||
const subset = elements.filter(it => Grammar.toLowerCaseNoAccent(mapper(it)).includes(value));
|
||||
if (subset.length == 0) {
|
||||
ui.notifications.info(`Pas de ${description} correspondant à ${value}`);
|
||||
return undefined;
|
||||
}
|
||||
let single = subset.find(it => Grammar.toLowerCaseNoAccent(mapper(it)) == value);
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const context2file = {
|
||||
@ -9,7 +10,7 @@ export class RdDAudio {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
static PlayContextAudio(context) {
|
||||
if (game.settings.get("foundryvtt-reve-de-dragon", "activer-sons-audio") ) {
|
||||
if (game.settings.get(SYSTEM_RDD, "activer-sons-audio") ) {
|
||||
let audioData = context2file[context];
|
||||
if ( audioData ) {
|
||||
let audioPath = "systems/foundryvtt-reve-de-dragon/sounds/" + audioData.file;
|
||||
|
@ -7,6 +7,7 @@ import { RdDUtility } from "./rdd-utility.js";
|
||||
import { Grammar } from "./grammar.js";
|
||||
import { RdDDice } from "./rdd-dice.js";
|
||||
import { Misc } from "./misc.js";
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
|
||||
/* -------------------------------------------- */
|
||||
const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/'
|
||||
@ -70,19 +71,19 @@ export class RdDCalendrier extends Application {
|
||||
constructor() {
|
||||
super();
|
||||
// position
|
||||
this.calendrierPos = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier-pos"));
|
||||
this.calendrierPos = duplicate(game.settings.get(SYSTEM_RDD, "calendrier-pos"));
|
||||
if (this.calendrierPos == undefined || this.calendrierPos.top == undefined) {
|
||||
this.calendrierPos = RdDCalendrier.createCalendrierPos();
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", this.calendrierPos);
|
||||
game.settings.set(SYSTEM_RDD, "calendrier-pos", this.calendrierPos);
|
||||
}
|
||||
|
||||
// Calendrier
|
||||
this.calendrier = duplicate(game.settings.get("foundryvtt-reve-de-dragon", "calendrier") ?? RdDCalendrier.getCalendrier(0));
|
||||
this.calendrier = duplicate(game.settings.get(SYSTEM_RDD, "calendrier") ?? RdDCalendrier.getCalendrier(0));
|
||||
this.calendrier.annee = this.calendrier.annee ?? Math.floor((this.calendrier.moisRdD ?? 0) / RDD_MOIS_PAR_AN);
|
||||
this.calendrier.moisRdD = (this.calendrier.moisRdD ?? 0) % RDD_MOIS_PAR_AN;
|
||||
|
||||
if (game.user.isGM) { // Uniquement si GM
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", this.calendrier);
|
||||
game.settings.set(SYSTEM_RDD, "calendrier", this.calendrier);
|
||||
}
|
||||
|
||||
// nombre astral
|
||||
@ -95,7 +96,7 @@ export class RdDCalendrier extends Application {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
getListeNombreAstral() {
|
||||
return game.settings.get("foundryvtt-reve-de-dragon", "liste-nombre-astral") ?? [];
|
||||
return game.settings.get(SYSTEM_RDD, "liste-nombre-astral") ?? [];
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -172,7 +173,7 @@ export class RdDCalendrier extends Application {
|
||||
/* -------------------------------------------- */
|
||||
resetNombreAstral() {
|
||||
this.listeNombreAstral = [];
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
|
||||
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
|
||||
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
msg: "msg_reset_nombre_astral",
|
||||
@ -203,7 +204,7 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
//console.log("SAVE list", newList, jourCourant);
|
||||
this.listeNombreAstral = newList;
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
|
||||
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +256,7 @@ export class RdDCalendrier extends Application {
|
||||
this.checkMaladie("heure");
|
||||
this.checkMaladie("jour");
|
||||
}
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
|
||||
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
|
||||
// Notification aux joueurs
|
||||
game.socket.emit("system.foundryvtt-reve-de-dragon", {
|
||||
msg: "msg_sync_time",
|
||||
@ -283,7 +284,7 @@ export class RdDCalendrier extends Application {
|
||||
}
|
||||
this.calendrier.heureRdD = indexHeure;
|
||||
this.calendrier.minutesRelative = 0;
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
|
||||
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
@ -339,7 +340,7 @@ export class RdDCalendrier extends Application {
|
||||
// Mise à jour des nombres astraux du joueur
|
||||
let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date);
|
||||
astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstral });
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "liste-nombre-astral", this.listeNombreAstral);
|
||||
game.settings.set(SYSTEM_RDD, "liste-nombre-astral", this.listeNombreAstral);
|
||||
}
|
||||
request.nbAstral = nbAstral;
|
||||
if (game.user.isGM) {
|
||||
@ -472,7 +473,7 @@ export class RdDCalendrier extends Application {
|
||||
this.calendrier.jour = Number(calendrierData.jourMois) - 1;
|
||||
this.calendrier.moisRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.moisKey);
|
||||
this.calendrier.heureRdD = RdDCalendrier.getChiffreFromSigne(calendrierData.heureKey);
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier", duplicate(this.calendrier));
|
||||
game.settings.set(SYSTEM_RDD, "calendrier", duplicate(this.calendrier));
|
||||
|
||||
await this.rebuildListeNombreAstral();
|
||||
|
||||
@ -607,7 +608,7 @@ export class RdDCalendrier extends Application {
|
||||
game.system.rdd.calendrier.calendrierPos.top = yPos;
|
||||
game.system.rdd.calendrier.calendrierPos.left = xPos;
|
||||
if (game.user.isGM) {
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
|
||||
game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -615,7 +616,7 @@ export class RdDCalendrier extends Application {
|
||||
game.system.rdd.calendrier.calendrierPos.top = 200;
|
||||
game.system.rdd.calendrier.calendrierPos.left = 200;
|
||||
if (game.user.isGM) {
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
|
||||
game.settings.set(SYSTEM_RDD, "calendrier-pos", duplicate(game.system.rdd.calendrier.calendrierPos));
|
||||
}
|
||||
this.setPos(game.system.rdd.calendrier.calendrierPos);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { ChatUtility } from "./chat-utility.js";
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
import { RdDItemArme } from "./item-arme.js";
|
||||
import { RdDItemCompetence } from "./item-competence.js";
|
||||
import { RdDItemCompetenceCreature } from "./item-competencecreature.js";
|
||||
@ -687,7 +688,7 @@ export class RdDCombat {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
removeChatMessageActionsPasseArme(passeArme) {
|
||||
if (game.settings.get("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat")) {
|
||||
if (game.settings.get(SYSTEM_RDD, "supprimer-dialogues-combat-chat")) {
|
||||
ChatUtility.removeChatMessageContaining(`<div data-passearme="${passeArme}">`);
|
||||
}
|
||||
}
|
||||
@ -1299,7 +1300,7 @@ export class RdDCombat {
|
||||
/* -------------------------------------------- */
|
||||
/* retourne true si on peut continuer, false si on ne peut pas continuer */
|
||||
async accorderEntite(when = 'avant-encaissement') {
|
||||
if (when != game.settings.get("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar")
|
||||
if (when != game.settings.get(SYSTEM_RDD, "accorder-entite-cauchemar")
|
||||
|| this.defender == undefined
|
||||
|| !this.defender.isEntiteCauchemar()
|
||||
|| this.defender.isEntiteCauchemarAccordee(this.attacker)) {
|
||||
|
@ -52,7 +52,7 @@ export class RdDHotbar {
|
||||
macro = await Macro.create({
|
||||
name: journal.data.name,
|
||||
type: "script",
|
||||
img: "systems/foundryvtt-reve-de-dragon/icons/templates/icone_parchement_vierge.png",
|
||||
img: "systems/foundryvtt-reve-de-dragon/icons/templates/icone_parchement_vierge.webp",
|
||||
command: command
|
||||
}, { displaySheet: false })
|
||||
game.user.assignHotbarMacro(macro, slot);
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
/* -------------------------------------------- */
|
||||
// Import Modules
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
import { RdDActor } from "./actor.js";
|
||||
import { RdDItemSheet } from "./item-sheet.js";
|
||||
import { RdDActorSheet } from "./actor-sheet.js";
|
||||
@ -55,7 +56,7 @@ Hooks.once("init", async function () {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "accorder-entite-cauchemar", {
|
||||
game.settings.register(SYSTEM_RDD, "accorder-entite-cauchemar", {
|
||||
name: "Accorder le rêve aux entités",
|
||||
hint: "A quel moment les personnages doivent accorder leur rêve aux entités de cauchemar",
|
||||
scope: "world",
|
||||
@ -70,7 +71,7 @@ Hooks.once("init", async function () {
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "calendrier", {
|
||||
game.settings.register(SYSTEM_RDD, "calendrier", {
|
||||
name: "calendrier",
|
||||
scope: "world",
|
||||
config: false,
|
||||
@ -79,7 +80,16 @@ Hooks.once("init", async function () {
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "liste-nombre-astral", {
|
||||
game.settings.register(SYSTEM_RDD, "migration-png-webp-1.5.34", {
|
||||
name: "calendrier",
|
||||
scope: "world",
|
||||
config: false,
|
||||
default: false,
|
||||
type: Boolean
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register(SYSTEM_RDD, "liste-nombre-astral", {
|
||||
name: "liste-nombre-astral",
|
||||
scope: "world",
|
||||
config: false,
|
||||
@ -88,7 +98,7 @@ Hooks.once("init", async function () {
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "calendrier-pos", {
|
||||
game.settings.register(SYSTEM_RDD, "calendrier-pos", {
|
||||
name: "calendrierPos",
|
||||
scope: "client",
|
||||
config: false,
|
||||
@ -97,7 +107,7 @@ Hooks.once("init", async function () {
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "dice-so-nice", {
|
||||
game.settings.register(SYSTEM_RDD, "dice-so-nice", {
|
||||
name: "Montrer les dés pour toutes les jets",
|
||||
hint: "Utilise Dice So Nice pour tous les jets de dés possibles. Décocher pour limiter à la table de résolution",
|
||||
scope: "client",
|
||||
@ -107,7 +117,7 @@ Hooks.once("init", async function () {
|
||||
});
|
||||
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "supprimer-dialogues-combat-chat", {
|
||||
game.settings.register(SYSTEM_RDD, "supprimer-dialogues-combat-chat", {
|
||||
name: "Supprimer les dialogues de combat",
|
||||
hint: "Si désactivée, tous les dialogues de combat sont conservés dans la conversation",
|
||||
scope: "world",
|
||||
@ -116,7 +126,7 @@ Hooks.once("init", async function () {
|
||||
type: Boolean
|
||||
});
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "activer-sons-audio", {
|
||||
game.settings.register(SYSTEM_RDD, "activer-sons-audio", {
|
||||
name: "Activer les bruitages intégrés",
|
||||
hint: "Si activé, certaines actions en jeu déclenchent un son d'ambiance",
|
||||
scope: "world",
|
||||
@ -125,7 +135,7 @@ Hooks.once("init", async function () {
|
||||
type: Boolean
|
||||
});
|
||||
/* -------------------------------------------- */
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "appliquer-famine-soif", {
|
||||
game.settings.register(SYSTEM_RDD, "appliquer-famine-soif", {
|
||||
name: "Notifier de la famine et la soif pour",
|
||||
hint: "Indique si les cas de famine et de soif seront indiqués durant Château Dormant",
|
||||
scope: "world",
|
||||
@ -170,19 +180,21 @@ Hooks.once("init", async function () {
|
||||
/* -------------------------------------------- */
|
||||
// Register sheet application classes
|
||||
Actors.unregisterSheet("core", ActorSheet);
|
||||
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorSheet, { types: ["personnage"], makeDefault: true });
|
||||
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorCreatureSheet, { types: ["creature"], makeDefault: true });
|
||||
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
|
||||
Actors.registerSheet("foundryvtt-reve-de-dragon", RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
|
||||
Actors.registerSheet(SYSTEM_RDD, RdDActorSheet, { types: ["personnage"], makeDefault: true });
|
||||
Actors.registerSheet(SYSTEM_RDD, RdDActorCreatureSheet, { types: ["creature"], makeDefault: true });
|
||||
Actors.registerSheet(SYSTEM_RDD, RdDActorVehiculeSheet, { types: ["vehicule"], makeDefault: true });
|
||||
Actors.registerSheet(SYSTEM_RDD, RdDActorEntiteSheet, { types: ["entite"], makeDefault: true });
|
||||
Items.unregisterSheet("core", ItemSheet);
|
||||
Items.registerSheet("foundryvtt-reve-de-dragon", RdDSigneDraconiqueItemSheet, {
|
||||
Items.registerSheet(SYSTEM_RDD, RdDSigneDraconiqueItemSheet, {
|
||||
label: "Signe draconique",
|
||||
types: ["signedraconique"],
|
||||
makeDefault: true
|
||||
});
|
||||
Items.registerSheet("foundryvtt-reve-de-dragon", RdDItemSheet, { types: ["arme", "armure", "objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
|
||||
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique", "gemme",
|
||||
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson"], makeDefault: true });
|
||||
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
|
||||
types: ["arme", "armure", "objet", "arme", "armure", "conteneur", "competence", "sort", "herbe", "ingredient", "livre", "potion", "munition", "rencontresTMR", "queue", "ombre", "souffle",
|
||||
"tete", "competencecreature", "tarot", "monnaie", "nombreastral", "tache", "meditation", "casetmr", "recettealchimique", "gemme",
|
||||
"musique", "chant", "danse", "jeu", "recettecuisine", "maladie", "poison", "oeuvre", "nourritureboisson"], makeDefault: true
|
||||
});
|
||||
CONFIG.Combat.documentClass = RdDCombatManager;
|
||||
|
||||
// préparation des différents modules
|
||||
@ -219,6 +231,7 @@ function messageDeBienvenue() {
|
||||
/* Foundry VTT Initialization */
|
||||
/* -------------------------------------------- */
|
||||
Hooks.once("ready", async function () {
|
||||
await migrationPngWebp_1_5_34()
|
||||
|
||||
StatusEffects.onReady();
|
||||
RdDHerbes.initializeHerbes();
|
||||
@ -240,12 +253,41 @@ Hooks.once("ready", async function () {
|
||||
content: "<b>ATTENTION</b> Le joueur " + game.user.name + " n'est connecté à aucun personnage !",
|
||||
user: game.user.id
|
||||
});
|
||||
//whisper: [ ChatMessage.getWhisperRecipients("GM") ] } );
|
||||
}
|
||||
|
||||
messageDeBienvenue();
|
||||
if (game.user.isGM) {
|
||||
messageDeBienvenue();
|
||||
}
|
||||
});
|
||||
|
||||
async function migrationPngWebp_1_5_34() {
|
||||
if (!game.settings.get(SYSTEM_RDD, "migration-png-webp-1.5.34")) {
|
||||
const regexOldPngJpg = /(systems\/foundryvtt-reve-de-dragon\/icons\/.*)\.(png|jpg)/;
|
||||
const replaceWithWebp = '$1.webp';
|
||||
function convertImgToWebp(img) {
|
||||
return img.replace(regexOldPngJpg, replaceWithWebp);
|
||||
}
|
||||
function prepareDocumentsImgUpdate(documents) {
|
||||
return documents.filter(it => it.img.match(regexOldPngJpg))
|
||||
.map(it => {
|
||||
return { _id: it.id, img: convertImgToWebp(it.img) }
|
||||
});
|
||||
}
|
||||
const itemsUpdates = prepareDocumentsImgUpdate(game.items);
|
||||
const actorsUpdates = prepareDocumentsImgUpdate(game.actors);
|
||||
//Migrate system png to webp
|
||||
await Item.updateDocuments(itemsUpdates);
|
||||
await Actor.updateDocuments(actorsUpdates);
|
||||
game.actors.forEach(actor => {
|
||||
if (actor.data.token.img.match(regexOldPngJpg)){
|
||||
actor.update({ "token.img": convertImgToWebp(actor.data.token.img) });
|
||||
}
|
||||
const actorItemsToUpdate = prepareDocumentsImgUpdate(actor.items);
|
||||
actor.updateEmbeddedDocuments('Item', actorItemsToUpdate);
|
||||
});
|
||||
game.settings.set(SYSTEM_RDD, "migration-png-webp-1.5.34", true)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Dice-so-nice ready */
|
||||
/* -------------------------------------------- */
|
||||
|
@ -21,7 +21,7 @@ export class RdDEncaisser extends Dialog {
|
||||
title: "Jet d'Encaissement",
|
||||
content: html,
|
||||
buttons: buttons,
|
||||
default: "coupMortel"
|
||||
default: "mortel"
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
import { Misc } from "./misc.js";
|
||||
|
||||
const listeReglesOptionelles = [
|
||||
@ -21,10 +22,10 @@ export class ReglesOptionelles extends FormApplication {
|
||||
for (const regle of listeReglesOptionelles) {
|
||||
const name = regle.name;
|
||||
const id = ReglesOptionelles._getIdRegle(name);
|
||||
game.settings.register("foundryvtt-reve-de-dragon", id, { name: id, scope: "world", config: false, default: regle.default == undefined ? true : regle.default, type: Boolean });
|
||||
game.settings.register(SYSTEM_RDD, id, { name: id, scope: "world", config: false, default: regle.default == undefined ? true : regle.default, type: Boolean });
|
||||
}
|
||||
|
||||
game.settings.registerMenu("foundryvtt-reve-de-dragon", "rdd-options-regles", {
|
||||
game.settings.registerMenu(SYSTEM_RDD, "rdd-options-regles", {
|
||||
name: "Choisir les règles optionelles",
|
||||
label: "Choix des règles optionelles",
|
||||
hint: "Ouvre la fenêtre de sélection des règles optionelles",
|
||||
@ -70,7 +71,7 @@ export class ReglesOptionelles extends FormApplication {
|
||||
}
|
||||
|
||||
static isUsing(name) {
|
||||
return game.settings.get("foundryvtt-reve-de-dragon", ReglesOptionelles._getIdRegle(name));
|
||||
return game.settings.get(SYSTEM_RDD, ReglesOptionelles._getIdRegle(name));
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
@ -78,7 +79,7 @@ export class ReglesOptionelles extends FormApplication {
|
||||
if (event.currentTarget.attributes.name) {
|
||||
let id = event.currentTarget.attributes.name.value;
|
||||
let isChecked = event.currentTarget.checked;
|
||||
game.settings.set("foundryvtt-reve-de-dragon", id, isChecked);
|
||||
game.settings.set(SYSTEM_RDD, id, isChecked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -157,10 +157,10 @@ export class RollDataAjustements {
|
||||
descr: reference.getDescr && reference.getDescr(rollData, actor)
|
||||
}
|
||||
}
|
||||
rollData.finalLevel = RollDataAjustements.sum(rollData.ajustements);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
static sum(ajustements) {
|
||||
let sum = 0;
|
||||
for (var key in ajustements) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SYSTEM_RDD } from "./constants.js";
|
||||
|
||||
const rddStatusEffects = [
|
||||
{ rdd: true, id: 'stun', label: 'EFFECT.StatusStunned', icon: 'icons/svg/stoned.svg', "duration.rounds": 1 },
|
||||
@ -21,7 +22,7 @@ export class StatusEffects {
|
||||
static onReady() {
|
||||
const rddStatusIds = rddStatusEffects.map(it => it.id);
|
||||
const defaultStatusEffectIds = CONFIG.statusEffects.map(it => it.id);
|
||||
game.settings.register("foundryvtt-reve-de-dragon", "use-status-effects", {
|
||||
game.settings.register(SYSTEM_RDD, "use-status-effects", {
|
||||
name: "use-status-effects",
|
||||
scope: "world",
|
||||
config: false,
|
||||
@ -29,7 +30,7 @@ export class StatusEffects {
|
||||
type: String
|
||||
});
|
||||
|
||||
game.settings.registerMenu("foundryvtt-reve-de-dragon", "select-status-effect", {
|
||||
game.settings.registerMenu(SYSTEM_RDD, "select-status-effect", {
|
||||
name: "Choisir les effets disponibles",
|
||||
label: "Choix des effets",
|
||||
hint: "Ouvre la fenêtre de sélection des effets/status appliqués aux acteurs",
|
||||
@ -58,13 +59,13 @@ export class StatusEffects {
|
||||
}
|
||||
|
||||
static _getUseStatusEffects() {
|
||||
const setting = game.settings.get("foundryvtt-reve-de-dragon", "use-status-effects");
|
||||
const setting = game.settings.get(SYSTEM_RDD, "use-status-effects");
|
||||
return setting ? new Set(setting.split(',')) : new Set();
|
||||
}
|
||||
|
||||
static _setUseStatusEffects(useStatusEffects) {
|
||||
if (game.user.isGM) {
|
||||
game.settings.set("foundryvtt-reve-de-dragon", "use-status-effects", StatusEffects._toSetting(useStatusEffects));
|
||||
game.settings.set(SYSTEM_RDD, "use-status-effects", StatusEffects._toSetting(useStatusEffects));
|
||||
}
|
||||
|
||||
for (let effect of CONFIG.RDD.allEffects) {
|
||||
|
Reference in New Issue
Block a user