2022-03-21 23:21:05 +01:00
/* -------------------------------------------- */
2021-07-08 10:12:12 +02:00
// Import Modules
2022-03-21 23:21:05 +01:00
import { BoLActor } from "./actor/actor.js"
import { BoLActorSheet } from "./actor/actor-sheet.js"
2022-10-10 08:46:41 +02:00
import { BoLVehicleSheet } from "./actor/vehicle-sheet.js"
2024-09-05 20:14:17 +02:00
import { BoLHordeSheet } from "./actor/horde-sheet.js"
2022-03-21 23:21:05 +01:00
import { BoLItem } from "./item/item.js"
import { BoLItemSheet } from "./item/item-sheet.js"
import { System , BOL } from "./system/config.js"
import { preloadHandlebarsTemplates } from "./system/templates.js"
import { registerHandlebarsHelpers } from "./system/helpers.js"
import registerHooks from "./system/hooks.js"
import { Macros } from "./system/macros.js"
import { BoLUtility } from "./system/bol-utility.js"
import { BoLCombatManager } from "./system/bol-combat.js"
import { BoLTokenHud } from "./system/bol-action-hud.js"
2022-03-27 22:56:43 +02:00
import { BoLHotbar } from "./system/bol-hotbar.js"
2024-01-12 18:42:12 +01:00
import { BoLCommands } from "./system/bol-commands.js"
import { BoLRoll } from "./controllers/bol-rolls.js"
2021-07-08 10:12:12 +02:00
2022-03-21 23:21:05 +01:00
/* -------------------------------------------- */
2021-07-08 10:12:12 +02:00
Hooks . once ( 'init' , async function ( ) {
2021-12-29 19:15:06 +01:00
game . bol = {
BoLActor ,
BoLItem ,
2022-03-27 22:56:43 +02:00
BoLHotbar ,
2024-01-02 23:34:38 +01:00
BoLRoll ,
2024-04-26 18:00:56 +02:00
BoLUtility ,
2021-12-29 19:15:06 +01:00
macros : Macros ,
config : BOL
} ;
2024-01-12 18:42:12 +01:00
2021-12-29 19:15:06 +01:00
// Game socket
game . socket . on ( "system.bol" , sockmsg => {
BoLUtility . onSocketMessage ( sockmsg ) ;
2022-05-20 21:50:18 +02:00
} )
2021-12-29 19:15:06 +01:00
/ * *
* Set an initiative formula for the system
* @ type { String }
* /
CONFIG . Combat . initiative = {
formula : "2d6+@attributes.mind.value+@aptitudes.init.value" ,
2022-11-30 20:58:27 +01:00
decimals : 2
2021-12-29 19:15:06 +01:00
} ;
2024-10-13 17:08:33 +02:00
2021-12-29 19:15:06 +01:00
// Define custom Entity classes
CONFIG . Actor . documentClass = BoLActor ;
CONFIG . Item . documentClass = BoLItem ;
2022-01-16 22:53:41 +01:00
CONFIG . Combat . documentClass = BoLCombatManager ;
2021-12-29 19:15:06 +01:00
// Register sheet application classes
Actors . unregisterSheet ( "core" , ActorSheet ) ;
2022-10-10 08:46:41 +02:00
Actors . registerSheet ( "bol" , BoLActorSheet , { types : [ "character" , "encounter" ] , makeDefault : true } )
Actors . registerSheet ( "bol" , BoLVehicleSheet , { types : [ "vehicle" ] , makeDefault : true } )
2024-09-05 20:14:17 +02:00
Actors . registerSheet ( "bol" , BoLHordeSheet , { types : [ "horde" ] , makeDefault : true } )
2022-10-10 08:46:41 +02:00
2021-12-29 19:15:06 +01:00
Items . unregisterSheet ( "core" , ItemSheet ) ;
Items . registerSheet ( "bol" , BoLItemSheet , { makeDefault : true } ) ;
// Inot useful stuff
2022-03-21 23:21:05 +01:00
BoLUtility . init ( )
BoLTokenHud . init ( )
2022-03-27 22:56:43 +02:00
BoLHotbar . init ( )
2022-05-20 21:50:18 +02:00
BoLCommands . init ( )
2024-10-13 17:08:33 +02:00
2021-12-29 19:15:06 +01:00
// Preload Handlebars Templates
await preloadHandlebarsTemplates ( ) ;
// Register Handlebars helpers
registerHandlebarsHelpers ( ) ;
// Register hooks
2022-02-12 21:49:26 +01:00
registerHooks ( )
2024-10-13 17:08:33 +02:00
if ( typeof Babele !== 'undefined' ) {
Babele . get ( ) . setSystemTranslationsDir ( "compendiums" ) ;
}
2024-11-15 23:46:11 +01:00
2022-01-30 20:44:28 +01:00
} ) ;
2022-02-12 21:49:26 +01:00
/* -------------------------------------------- */
function welcomeMessage ( ) {
ChatMessage . create ( {
user : game . user . id ,
whisper : [ game . user . id ] ,
2024-09-05 20:14:17 +02:00
content : ` <div id="welcome-message-bol"><span class="rdd-roll-part">
2022-05-12 23:21:00 +02:00
< strong > ` + game.i18n.localize("BOL.chat.welcome1") + ` < / s t r o n g > < p > ` +
2024-01-12 18:42:12 +01:00
game . i18n . localize ( "BOL.chat.welcome2" ) + "<p>" +
game . i18n . localize ( "BOL.chat.welcome3" ) + "<p>" +
game . i18n . localize ( "BOL.chat.welcome4" ) + "</p>" +
game . i18n . localize ( "BOL.chat.welcome5" ) + "<br>" +
game . i18n . localize ( "BOL.chat.welcome6" )
} )
2024-12-12 21:50:28 +01:00
if ( game . user . isGM && game . i18n . lang == 'en' && ! game . modules . find ( m => m . id == "babele" ) ) {
ChatMessage . create ( {
user : game . user . id ,
whisper : [ game . user . id ] ,
content : ` <div id="welcome-message-bol"><span class="rdd-roll-part">
< strong > WARNING ! English language selected , but babele module is not installed ! < br > Please install babele from the module tab in Foundry interface . `
} )
ui . notifications . warn ( "WARNING ! English language selected, but babele module is not installed !<br>Please install babele from the module tab in Foundry interface." )
}
2022-02-12 21:49:26 +01:00
}
2022-01-30 20:44:28 +01:00
/* -------------------------------------------- */
Hooks . once ( 'ready' , async function ( ) {
2022-11-25 20:47:28 +01:00
2022-07-17 18:20:05 +02:00
BoLUtility . ready ( )
2022-11-25 20:47:28 +01:00
2024-10-13 17:08:33 +02:00
import ( "https://www.uberwald.me/fvtt_appcount/count-class-ready.js" ) . then ( moduleCounter => {
2024-04-26 18:00:56 +02:00
console . log ( "ClassCounter loaded" , moduleCounter )
moduleCounter . ClassCounter . registerUsageCount ( )
2024-10-13 17:08:33 +02:00
} ) . catch ( err =>
2024-04-26 18:00:56 +02:00
console . log ( "No stats available, giving up." )
)
2022-02-12 21:49:26 +01:00
welcomeMessage ( )
2024-01-12 18:42:12 +01:00
// User warning
if ( ! game . user . isGM && game . user . character == undefined ) {
ui . notifications . info ( game . i18n . localize ( "BOL.chat.pcwarning" ) ) ;
ChatMessage . create ( {
content : game . i18n . localize ( "BOL.chat.pcwarningmsg" ) + game . user . name ,
user : game . user . _id
} ) ;
}
if ( ! game . user . isGM && game . user . character && ! game . user . character . prototypeToken . actorLink ) {
ui . notifications . info ( game . i18n . localize ( "BOL.chat.pcnotlinked" ) ) ;
ChatMessage . create ( {
content : game . i18n . localize ( "BOL.chat.pcnotlinkedmsg" ) + game . user . name ,
user : game . user . _id
} ) ;
}
2024-11-15 23:46:11 +01:00
const damageFR = {
"0" : "0" ,
"1" : "1" ,
"2" : "2" ,
"3" : "3" ,
"d3" : "d3" ,
"d6M" : "d6M (Malus)" ,
"d6" : "d6" ,
"d6B" : "d6B (Bonus)" ,
"d6BB" : "d6B + dé bonus" ,
}
const damageEN = {
"0" : "0" ,
"1" : "1" ,
"2" : "2" ,
"3" : "3" ,
"d3" : "d3" ,
"d6M" : "d6L (Penalty)" ,
"d6" : "d6" ,
"d6B" : "d6H (Bonus)" ,
"d6BB" : "d6H + Bonus die" ,
}
if ( game . i18n . lang === "fr" ) {
game . bol . config . damageValues = damageFR ;
} else {
game . bol . config . damageValues = damageEN ;
}
2022-05-20 21:50:18 +02:00
} )
2022-01-30 20:44:28 +01:00