2024-09-25 22:59:42 +02:00
|
|
|
import { SYSTEM_RDD, SYSTEM_SOCKET_ID, RDD_CONFIG } from "./constants.js"
|
|
|
|
import { Migrations } from './migrations.js'
|
2023-01-18 01:37:22 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
import { RdDUtility } from "./rdd-utility.js"
|
|
|
|
import { TMRUtility } from "./tmr-utility.js"
|
|
|
|
import { TMRRencontres } from "./tmr-rencontres.js"
|
|
|
|
import { RdDCalendrier } from "./time/rdd-calendrier.js"
|
|
|
|
import { RdDTimestamp } from "./time/rdd-timestamp.js"
|
|
|
|
import { DialogChronologie } from "./dialog-chronologie.js"
|
2023-01-18 01:37:22 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
import { RdDResolutionTable } from "./rdd-resolution-table.js"
|
|
|
|
import { RdDTokenHud } from "./rdd-token-hud.js"
|
|
|
|
import { RdDCommands } from "./rdd-commands.js"
|
|
|
|
import { RdDCombatManager, RdDCombat } from "./rdd-combat.js"
|
|
|
|
import { ChatUtility } from "./chat-utility.js"
|
|
|
|
import { StatusEffects } from "./settings/status-effects.js"
|
|
|
|
import { RdDCompendiumOrganiser } from "./rdd-compendium-organiser.js"
|
|
|
|
import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"
|
2021-02-08 22:51:31 +01:00
|
|
|
import { RdDHotbar } from "./rdd-hotbar-drop.js"
|
2024-09-25 22:59:42 +02:00
|
|
|
import { EffetsDraconiques } from "./tmr/effets-draconiques.js"
|
|
|
|
import { RdDHerbes } from "./rdd-herbes.js"
|
|
|
|
import { RdDDice } from "./rdd-dice.js"
|
|
|
|
import { RdDPossession } from "./rdd-possession.js"
|
|
|
|
import { Misc } from "./misc.js"
|
2023-01-18 01:37:22 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
import { SystemCompendiums } from "./settings/system-compendiums.js"
|
|
|
|
import { Environnement } from "./environnement.js"
|
2023-01-18 01:37:22 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
import { RdDActor } from "./actor.js"
|
|
|
|
import { RdDBaseActor } from "./actor/base-actor.js"
|
|
|
|
import { RdDCommerce } from "./actor/commerce.js"
|
|
|
|
import { RdDEntite } from "./actor/entite.js"
|
|
|
|
import { RdDVehicule } from "./actor/vehicule.js"
|
|
|
|
import { RdDActorSheet } from "./actor-sheet.js"
|
|
|
|
import { RdDCommerceSheet } from "./actor/commerce-sheet.js"
|
|
|
|
import { RdDCreatureSheet } from "./actor/creature-sheet.js"
|
|
|
|
import { RdDActorEntiteSheet } from "./actor/entite-sheet.js"
|
|
|
|
import { RdDActorVehiculeSheet } from "./actor/vehicule-sheet.js"
|
2023-01-18 01:37:22 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
import { RdDItem } from "./item.js"
|
|
|
|
import { RdDItemBlessure } from "./item/blessure.js"
|
|
|
|
import { RdDItemService } from "./item/service.js"
|
|
|
|
import { RdDItemMaladie } from "./item/maladie.js"
|
|
|
|
import { RdDItemPoison } from "./item/poison.js"
|
|
|
|
import { RdDItemSigneDraconique } from "./item/signedraconique.js"
|
|
|
|
import { RdDItemQueue } from "./item/queue.js"
|
|
|
|
import { RdDItemOmbre } from "./item/ombre.js"
|
|
|
|
import { RdDItemSouffle } from "./item/souffle.js"
|
|
|
|
import { RdDRencontre } from "./item/rencontre.js"
|
2023-01-05 00:55:04 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
import { RdDItemSheet } from "./item-sheet.js"
|
|
|
|
import { RdDBlessureItemSheet } from "./item/sheet-blessure.js"
|
|
|
|
import { RdDServiceItemSheet } from "./item/sheet-service.js"
|
|
|
|
import { RdDRencontreItemSheet } from "./item/sheet-rencontre.js"
|
|
|
|
import { RdDHerbeItemSheet } from "./item/sheet-herbe.js"
|
|
|
|
import { RdDPlanteItemSheet } from "./item/sheet-plante.js"
|
|
|
|
import { RdDIngredientItemSheet } from "./item/sheet-ingredient.js"
|
|
|
|
import { RdDFauneItemSheet } from "./item/sheet-faune.js"
|
|
|
|
import { RdDConteneurItemSheet } from "./item/sheet-conteneur.js"
|
|
|
|
import { RdDSigneDraconiqueItemSheet } from "./item/sheet-signedraconique.js"
|
|
|
|
import { RdDItemInventaireSheet } from "./item/sheet-base-inventaire.js"
|
|
|
|
import { AppAstrologie } from "./sommeil/app-astrologie.js"
|
|
|
|
import { RdDItemArmure } from "./item/armure.js"
|
|
|
|
import { AutoAdjustDarkness as AutoAdjustDarkness } from "./time/auto-adjust-darkness.js"
|
|
|
|
import { RdDCreature } from "./actor/creature.js"
|
|
|
|
import { RdDTMRDialog } from "./rdd-tmr-dialog.js"
|
|
|
|
import { RdDActorExportSheet } from "./actor/actor-export-sheet.js"
|
2020-06-07 23:16:50 +02:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
/**
|
|
|
|
* RdD system
|
|
|
|
* Author: LeRatierBretonnien
|
|
|
|
* Software License: GNU GPLv3
|
|
|
|
*/
|
|
|
|
export class SystemReveDeDragon {
|
2024-09-25 22:59:42 +02:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
static start() {
|
2023-11-24 01:31:55 +01:00
|
|
|
const system = new SystemReveDeDragon()
|
|
|
|
Hooks.once('init', async () => await system.onInit())
|
|
|
|
Hooks.once('diceSoNiceReady', (dice3d) => RdDDice.diceSoNiceReady(dice3d))
|
|
|
|
Hooks.once('ready', () => system.onReady())
|
2021-01-29 15:13:59 +01:00
|
|
|
}
|
2024-09-25 22:59:42 +02:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
constructor() {
|
2024-09-25 22:59:42 +02:00
|
|
|
this.config = RDD_CONFIG
|
|
|
|
this.RdDUtility = RdDUtility
|
|
|
|
this.RdDHotbar = RdDHotbar
|
2022-12-23 00:22:13 +01:00
|
|
|
this.itemClasses = {
|
2023-05-24 21:59:17 +02:00
|
|
|
armure: RdDItemArmure,
|
2023-03-10 22:37:21 +01:00
|
|
|
blessure: RdDItemBlessure,
|
2023-01-05 00:55:04 +01:00
|
|
|
maladie: RdDItemMaladie,
|
2023-03-13 22:25:52 +01:00
|
|
|
ombre: RdDItemOmbre,
|
2023-01-05 00:55:04 +01:00
|
|
|
poison: RdDItemPoison,
|
|
|
|
queue: RdDItemQueue,
|
2023-03-13 22:25:52 +01:00
|
|
|
rencontre: RdDRencontre,
|
|
|
|
service: RdDItemService,
|
2023-01-05 00:55:04 +01:00
|
|
|
signedraconique: RdDItemSigneDraconique,
|
2023-03-13 22:25:52 +01:00
|
|
|
souffle: RdDItemSouffle,
|
2022-12-23 00:22:13 +01:00
|
|
|
}
|
|
|
|
this.actorClasses = {
|
2023-03-13 22:25:52 +01:00
|
|
|
commerce: RdDCommerce,
|
2023-11-04 17:48:50 +01:00
|
|
|
creature: RdDCreature,
|
2023-11-04 03:42:39 +01:00
|
|
|
entite: RdDEntite,
|
2022-12-28 23:36:48 +01:00
|
|
|
personnage: RdDActor,
|
2023-11-03 20:21:17 +01:00
|
|
|
vehicule: RdDVehicule,
|
2022-12-23 00:22:13 +01:00
|
|
|
}
|
2022-12-22 22:18:36 +01:00
|
|
|
}
|
2022-11-04 20:41:16 +01:00
|
|
|
|
2021-01-07 01:54:38 +01:00
|
|
|
/* -------------------------------------------- */
|
2022-12-22 22:18:36 +01:00
|
|
|
/* Foundry VTT Initialization */
|
2021-01-12 20:58:30 +01:00
|
|
|
/* -------------------------------------------- */
|
2022-12-22 22:18:36 +01:00
|
|
|
async onInit() {
|
2024-09-25 22:59:42 +02:00
|
|
|
game.system.rdd = this
|
|
|
|
this.AppAstrologie = AppAstrologie
|
2023-03-07 02:28:10 +01:00
|
|
|
|
2021-01-10 00:30:37 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
console.log(`Initializing Reve de Dragon System`)
|
2021-01-10 00:30:37 +01:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
// preload handlebars templates
|
2024-09-25 22:59:42 +02:00
|
|
|
RdDUtility.preloadHandlebarsTemplates()
|
2020-06-07 23:16:50 +02:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
/* -------------------------------------------- */
|
2024-09-25 22:59:42 +02:00
|
|
|
this.initSystemSettings()
|
2022-01-30 16:11:20 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
2022-12-22 22:18:36 +01:00
|
|
|
// Set an initiative formula for the system
|
|
|
|
CONFIG.Combat.initiative = {
|
|
|
|
formula: "1+(1d6/10)",
|
|
|
|
decimals: 2
|
2024-09-25 22:59:42 +02:00
|
|
|
}
|
2022-01-30 16:11:20 +01:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
game.socket.on(SYSTEM_SOCKET_ID, async (sockmsg) => {
|
2024-09-25 22:59:42 +02:00
|
|
|
console.log(">>>>> MSG RECV", sockmsg)
|
2022-12-22 22:18:36 +01:00
|
|
|
try {
|
2024-09-25 22:59:42 +02:00
|
|
|
RdDUtility.onSocketMessage(sockmsg)
|
|
|
|
RdDCombat.onSocketMessage(sockmsg)
|
|
|
|
ChatUtility.onSocketMessage(sockmsg)
|
|
|
|
RdDBaseActor.onSocketMessage(sockmsg)
|
2022-12-22 22:18:36 +01:00
|
|
|
} catch (e) {
|
|
|
|
console.error('game.socket.on(SYSTEM_SOCKET_ID) Exception: ', sockmsg, ' => ', e)
|
|
|
|
}
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
2021-05-10 18:39:35 +02:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Define custom Entity classes
|
2024-09-25 22:59:42 +02:00
|
|
|
CONFIG.Actor.documentClass = RdDBaseActor
|
|
|
|
CONFIG.Item.documentClass = RdDItem
|
2022-12-22 22:18:36 +01:00
|
|
|
CONFIG.RDD = {
|
|
|
|
resolutionTable: RdDResolutionTable.resolutionTable,
|
|
|
|
carac_array: RdDUtility.getCaracArray(),
|
|
|
|
ajustementsConditions: RdDUtility.getAjustementsConditions(),
|
|
|
|
difficultesLibres: RdDUtility.getDifficultesLibres()
|
|
|
|
}
|
2020-12-08 21:40:41 +01:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
// Register sheet application classes
|
2024-09-25 22:59:42 +02:00
|
|
|
Actors.unregisterSheet("core", ActorSheet)
|
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDCommerceSheet, { types: ["commerce"], makeDefault: true })
|
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDActorExportSheet, { types: ["personnage"], makeDefault: false })
|
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDActorSheet, { types: ["personnage"], makeDefault: true })
|
|
|
|
Actors.registerSheet(SYSTEM_RDD, RdDCreatureSheet, { 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)
|
2022-12-22 22:18:36 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
RdDItemSheet.register(RdDSigneDraconiqueItemSheet)
|
|
|
|
RdDItemSheet.register(RdDRencontreItemSheet)
|
|
|
|
RdDItemSheet.register(RdDConteneurItemSheet)
|
|
|
|
RdDItemSheet.register(RdDHerbeItemSheet)
|
|
|
|
RdDItemSheet.register(RdDFauneItemSheet)
|
|
|
|
RdDItemSheet.register(RdDPlanteItemSheet)
|
|
|
|
RdDItemSheet.register(RdDIngredientItemSheet)
|
|
|
|
RdDItemSheet.register(RdDServiceItemSheet)
|
|
|
|
RdDItemSheet.register(RdDBlessureItemSheet)
|
2022-12-22 22:18:36 +01:00
|
|
|
|
2023-01-18 01:37:22 +01:00
|
|
|
Items.registerSheet(SYSTEM_RDD, RdDItemInventaireSheet, {
|
|
|
|
types: [
|
|
|
|
"objet", "arme", "armure", "livre", "potion", "munition",
|
|
|
|
"monnaie", "nourritureboisson", "gemme",
|
|
|
|
], makeDefault: true
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
2022-12-22 22:18:36 +01:00
|
|
|
Items.registerSheet(SYSTEM_RDD, RdDItemSheet, {
|
|
|
|
types: [
|
|
|
|
"competence", "competencecreature",
|
|
|
|
"recettealchimique", "musique", "chant", "danse", "jeu", "recettecuisine", "oeuvre",
|
|
|
|
"meditation", "queue", "ombre", "souffle", "tete", "casetmr", "sort", "sortreserve",
|
|
|
|
"nombreastral", "tache", "maladie", "poison", "possession",
|
2023-04-21 18:18:20 +02:00
|
|
|
"tarot", "extraitpoetique", "empoignade"
|
2022-12-22 22:18:36 +01:00
|
|
|
], makeDefault: true
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
|
|
|
CONFIG.Combat.documentClass = RdDCombatManager
|
2022-12-22 22:18:36 +01:00
|
|
|
|
|
|
|
// préparation des différents modules
|
2024-09-25 22:59:42 +02:00
|
|
|
AutoAdjustDarkness.init()
|
|
|
|
RdDTimestamp.init()
|
|
|
|
RdDCalendrier.init()
|
|
|
|
SystemCompendiums.init()
|
|
|
|
DialogChronologie.init()
|
|
|
|
ReglesOptionnelles.init()
|
|
|
|
RdDUtility.init()
|
|
|
|
RdDDice.init()
|
|
|
|
RdDCommands.init()
|
|
|
|
RdDCombatManager.init()
|
|
|
|
RdDTokenHud.init()
|
|
|
|
RdDBaseActor.init()
|
|
|
|
RdDCompendiumOrganiser.init()
|
2022-12-22 22:18:36 +01:00
|
|
|
EffetsDraconiques.init()
|
2024-09-25 22:59:42 +02:00
|
|
|
TMRUtility.init()
|
2023-11-15 22:14:00 +01:00
|
|
|
await RdDTMRDialog.init()
|
2024-09-25 22:59:42 +02:00
|
|
|
RdDHotbar.init()
|
|
|
|
RdDPossession.init()
|
|
|
|
TMRRencontres.init()
|
|
|
|
Environnement.init()
|
2020-12-04 10:15:55 +01:00
|
|
|
}
|
2020-07-24 10:51:11 +02:00
|
|
|
|
2023-01-01 22:20:26 +01:00
|
|
|
initSystemSettings() {
|
|
|
|
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",
|
|
|
|
config: true,
|
|
|
|
type: String,
|
|
|
|
choices: {
|
|
|
|
"avant-attaque": "Avant l'attaque",
|
|
|
|
"avant-defense": "Avant la défense",
|
|
|
|
"avant-encaissement": "Avant l'encaissement",
|
|
|
|
},
|
|
|
|
default: "avant-encaissement"
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
2023-01-01 22:20:26 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
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",
|
|
|
|
config: true,
|
|
|
|
default: true,
|
|
|
|
type: Boolean
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
2023-01-01 22:20:26 +01:00
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
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",
|
|
|
|
config: true,
|
|
|
|
default: true,
|
|
|
|
type: Boolean
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
|
|
|
|
2023-01-01 22:20:26 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
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",
|
|
|
|
config: true,
|
|
|
|
type: String,
|
|
|
|
choices: {
|
|
|
|
"aucun": "ni la famine, ni la soif",
|
|
|
|
"famine": "seulement la famine",
|
|
|
|
"famine-soif": "la famine et la soif",
|
|
|
|
},
|
|
|
|
default: "aucun"
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
2023-01-01 22:20:26 +01:00
|
|
|
}
|
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
async onReady() {
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Foundry VTT Initialization */
|
|
|
|
/* -------------------------------------------- */
|
2024-09-25 22:59:42 +02:00
|
|
|
game.system.rdd.calendrier = new RdDCalendrier()
|
2022-12-22 22:18:36 +01:00
|
|
|
if (Misc.isUniqueConnectedGM()) {
|
2024-09-25 22:59:42 +02:00
|
|
|
new Migrations().migrate()
|
|
|
|
this.messageDeBienvenue()
|
|
|
|
import("https://www.uberwald.me/fvtt_appcount/count-class-ready.js").then(moduleCounter => {
|
2024-02-29 21:22:42 +01:00
|
|
|
console.log("ClassCounter loaded", moduleCounter)
|
|
|
|
moduleCounter.ClassCounter.registerUsageCount()
|
2024-09-25 22:59:42 +02:00
|
|
|
}).catch(err =>
|
2024-02-29 21:22:42 +01:00
|
|
|
console.log("No stats available, giving up.")
|
2024-09-25 22:59:42 +02:00
|
|
|
)
|
2021-11-11 02:43:01 +01:00
|
|
|
}
|
2022-12-22 22:18:36 +01:00
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
StatusEffects.onReady()
|
|
|
|
RdDHerbes.onReady()
|
|
|
|
RdDDice.onReady()
|
2022-12-22 22:18:36 +01:00
|
|
|
/* -------------------------------------------- */
|
|
|
|
/* Affiche/Init le calendrier */
|
2024-09-25 22:59:42 +02:00
|
|
|
game.system.rdd.calendrier.display()
|
2022-12-22 22:18:36 +01:00
|
|
|
// Avertissement si joueur sans personnage
|
|
|
|
if (!game.user.isGM && game.user.character == undefined) {
|
2024-09-25 22:59:42 +02:00
|
|
|
ui.notifications.info("Attention ! Vous n'êtes connecté à aucun personnage !")
|
2022-12-22 22:18:36 +01:00
|
|
|
ChatMessage.create({
|
|
|
|
content: "<b>ATTENTION</b> Le joueur " + game.user.name + " n'est connecté à aucun personnage !",
|
|
|
|
user: game.user.id
|
2024-09-25 22:59:42 +02:00
|
|
|
})
|
2022-12-22 22:18:36 +01:00
|
|
|
}
|
|
|
|
}
|
2023-01-17 21:51:49 +01:00
|
|
|
|
2022-12-22 22:18:36 +01:00
|
|
|
/* -------------------------------------------- */
|
2023-01-17 21:51:49 +01:00
|
|
|
messageDeBienvenue() {
|
2022-12-22 22:18:36 +01:00
|
|
|
if (game.user.isGM) {
|
2024-09-25 22:59:42 +02:00
|
|
|
ChatUtility.removeChatMessageContaining('<div id="message-bienvenue-rdd">')
|
2022-12-22 22:18:36 +01:00
|
|
|
ChatMessage.create({
|
|
|
|
user: game.user.id,
|
|
|
|
content: `<div id="message-bienvenue-rdd"><span class="rdd-roll-part">Bienvenue dans le Rêve des Dragons !</span>
|
|
|
|
<br>Vous trouverez quelques informations pour démarrer dans ce document : @Compendium[foundryvtt-reve-de-dragon.rappel-des-regles.7uGrUHGdPu0EmIu2]{Documentation MJ/Joueurs}
|
|
|
|
<br>La commande <code>/aide</code> dans le chat permet de voir les commandes spécifiques à Rêve de Dragon.</div>
|
2024-09-25 22:59:42 +02:00
|
|
|
` })
|
2022-12-22 22:18:36 +01:00
|
|
|
}
|
2021-11-11 02:43:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-25 22:59:42 +02:00
|
|
|
SystemReveDeDragon.start()
|
2021-04-29 02:57:56 +02:00
|
|
|
|