/**
 * A Foundry implementation of the Ironsworn family of systems, by Shawn Tomkin
 */ import { IRONSWORN } from './config' ; import { IronswornActor } from './module/actor/actor' ; import { IronswornCharacterSheet } from './module/actor/sheets/charactersheet' ; import { IronswornCharacterSheetV2 } from './module/actor/sheets/charactersheet-v2' ; import { IronswornCompactCharacterSheet } from './module/actor/sheets/compactsheet' ; import { IronswornSharedSheet } from './module/actor/sheets/sharedsheet' ; import { IronswornSharedSheetV2 } from './module/actor/sheets/sharedsheet-v2' ; import { IronswornSiteSheet } from './module/actor/sheets/sitesheet' ; import { IronswornSiteSheetV2 } from './module/actor/sheets/sitesheet-v2' ; import { CreateActorDialog } from './module/applications/createActorDialog' ; import { WorldTruthsDialog } from './module/applications/worldTruthsDialog' ; import { IronswornChatCard } from './module/chat/cards' ; import { activateChangelogListeners } from './module/features/changelog' ; import { maybePromptForDependencies } from './module/features/dependencies' ; import { activateDragDropListeners } from './module/features/dragdrop' ; import { IronswornHandlebarsHelpers } from './module/helpers/handlebars' ; import { runDataMigrations } from './module/helpers/migrations' ; import { IronswornSettings } from './module/helpers/settings' ; import { TemplatePreloader } from './module/helpers/templatepreloader' ; import { AssetSheet } from './module/item/asset/assetsheet' ; import { AssetSheetV2 } from './module/item/asset/assetsheet-v2' ; import { BondsetSheet } from './module/item/bondset/bondsetsheet' ; import { BondsetSheetV2 } from './module/item/bondset/bondsetsheet-v2' ; import { DelveThemeOrDomainSheet } from './module/item/delve-theme-domain/delvethemeordomainsheet' ; import { IronswornItem } from './module/item/item' ; import { MoveSheet } from './module/item/move/movesheet' ; import { ProgressSheet } from './module/item/progress/progresssheet' ; import { ProgressSheetV2 } from './module/item/progress/progresssheet-v2' ; import './styles/styles.less' ; declare global { interface LenientGlobalVariableTypes { game : never ; } } Hooks . once ( 'init' , async ( ) => { console . log ( 'Ironsworn | initializing system' ) ; IronswornSettings . registerSettings ( ) ; require ( `./styles/themes/${ IronswornSettings . theme }.less` ) ; CONFIG . IRONSWORN = IRONSWORN ; CONFIG . Actor . documentClass = IronswornActor ; CONFIG . Item . documentClass = IronswornItem ; Actors . unregisterSheet ( 'core' , ActorSheet ) ; Items . unregisterSheet ( 'core' , ItemSheet ) ; Actors . registerSheet ( 'ironsworn' , IronswornCharacterSheetV2 , { label : 'Character sheet v2' , types : [ 'character' ] , makeDefault : true , } ) ; Actors . registerSheet ( 'ironsworn' , IronswornCompactCharacterSheet , { label : 'Compact sheet' , types : [ 'character' ] , } ) ; Actors . registerSheet ( 'ironsworn' , IronswornCharacterSheet , { types : [ 'character' ] , label : 'Classic character sheet' , } ) ; Actors . registerSheet ( 'ironsworn' , IronswornSharedSheetV2 , { types : [ 'shared' ] , label : 'Shared sheet v2' , makeDefault : true , } ) ; Actors . registerSheet ( 'ironsworn' , IronswornSharedSheet , { types : [ 'shared' ] , label : 'Classic shared sheet' , } ) ; Actors . registerSheet ( 'ironsworn' , IronswornSiteSheetV2 , { types : [ 'site' ] , label : 'Site sheet v2' , makeDefault : true , } ) ; Actors . registerSheet ( 'ironsworn' , IronswornSiteSheet , { types : [ 'site' ] , label : 'Classic site sheet' , } ) ; Items . registerSheet ( 'ironsworn' , AssetSheetV2 , { types : [ 'asset' ] , label : 'Asset sheet v2' , makeDefault : true , } ) ; Items . registerSheet ( 'ironsworn' , AssetSheet , { types : [ 'asset' ] , label : 'Asset sheet' , } ) ; Items . registerSheet ( 'ironsworn' , BondsetSheetV2 , { types : [ 'bondset' ] , label : 'Bondset sheet v2' , makeDefault : true , } ) ; Items . registerSheet ( 'ironsworn' , BondsetSheet , { types : [ 'bondset' ] , label : 'Bondset sheet' , } ) ; Items . registerSheet ( 'ironsworn' , MoveSheet , { types : [ 'move' ] , label : 'Move sheet' , makeDefault : true , } ) ; Items . registerSheet ( 'ironsworn' , DelveThemeOrDomainSheet , { types : [ 'delve-theme' , 'delve-domain' ] , label : 'Delve Theme/Domain Sheet' , makeDefault : true , } ) ; Items . registerSheet ( 'ironsworn' , ProgressSheetV2 , { types : [ 'vow' , 'progress' ] , label : 'Progress sheet v2' , makeDefault : true , } ) ; Items . registerSheet ( 'ironsworn' , ProgressSheet , { types : [ 'vow' , 'progress' ] , label : 'Progress Sheet' , } ) ; await TemplatePreloader . preloadHandlebarsTemplates ( ) ; IronswornHandlebarsHelpers . registerHelpers ( ) ; IronswornChatCard . registerHooks ( ) ; } ) ; Hooks . once ( 'ready' , async ( ) => { await runDataMigrations ( ) ; await maybePromptForDependencies ( ) ; activateDragDropListeners ( ) ; activateChangelogListeners ( ) ; CONFIG . IRONSWORN . applications . createActorDialog = new CreateActorDialog ( { } ) ; WorldTruthsDialog . maybeShow ( ) ; } ) ; Hooks . once ( 'setup' , ( ) => { Roll . prototype . render = async function ( chatOptions = { } ) { const template = 'systems/foundry-ironsworn/templates/chat/default-roll.hbs' ; chatOptions = mergeObject ( { user : game ?. user ?. id , flavor : null , template : template , blind : false , } , chatOptions ) ; const isPrivate = chatOptions . isPrivate ; if ( ! this . _evaluated ) await this . evaluate ( ) ; const chatData = { themeClass : `theme-${ IronswornSettings . theme }` , formula : isPrivate ? '???' : this . formula , roll : this , flavor : isPrivate ? null : chatOptions . flavor , user : chatOptions . user , tooltip : isPrivate ? '' : await this . getTooltip ( ) , total : isPrivate ? '?' : Math . round ( this . total * 100 ) / 100 , } ; return renderTemplate ( chatOptions . template || template , chatData ) ; } ; } ) ; if ( module . hot ) { module . hot . accept ( ) ; if ( module . hot . status ( ) === 'apply' ) { for ( const template in _templateCache ) { if ( Object . prototype . hasOwnProperty . call ( _templateCache , template ) ) { delete _templateCache [ template ] ; } } TemplatePreloader . preloadHandlebarsTemplates ( ) . then ( ( ) => { for ( const application in ui . windows ) { if ( Object . prototype . hasOwnProperty . call ( ui . windows , application ) ) { ui . windows [ application ] . render ( true ) ; } } } ) ; } }