Skip to content

Commit

Permalink
validate Foundry v12 compatability.
Browse files Browse the repository at this point in the history
change defaults for auth and server name from undefined to empty string
  • Loading branch information
ChunkLightTuna committed Feb 5, 2024
1 parent c0faeb3 commit c5a1f8f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 38 deletions.
4 changes: 2 additions & 2 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"manifestPlusVersion": "1.2.0",
"compatibility": {
"minimum": 11.303,
"verified": 11.315
"verified": 12.316
},
"authors": [
{
Expand All @@ -27,7 +27,7 @@
"manifest": "https://raw.githubusercontent.com/foundryvtt/dnd5e/master/system.json",
"compatibility": {
"minimum": "2.4.0",
"verified": "3.0.0"
"verified": "3.0.1"
}
}
]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build": "esbuild src/module.mjs --bundle --minify --format=esm --outdir=dist",
"build-dev": "esbuild src/module.mjs --bundle --sourcemap=inline --format=esm --outdir=dist",
"build-dev-with-copy": "esbuild src/module.mjs --bundle --sourcemap=inline --format=esm --outdir=dist && mkdir -p ../foundry_data/Data/modules/oronder/ && cp -r ./* ../foundry_data/Data/modules/oronder/"
"copy-11": "mkdir -p ../foundry_data/Data/modules/oronder/ && cp -r ./* ../foundry_data/Data/modules/oronder/",
"copy-12": "mkdir -p ../foundry_data_12/Data/modules/oronder/ && cp -r ./* ../foundry_data_12/Data/modules/oronder/"
}
}
37 changes: 5 additions & 32 deletions src/module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import {Logger} from "./util.mjs"
import {registerSettings} from "./settings.mjs"
import {AUTH, MODULE_ID, ORONDER_WS_URL} from "./constants.mjs"
import {del_actor, sync_actor} from "./sync.mjs"
import {monks_token_bar_hooks} from "./monks_token_bar_hooks.mjs";

let socket
export let socket
export let session_id
export let session_ts
let session_name
let session_id
let session_ts
let default_title

const SOCKET_NAME = `module.${MODULE_ID}`
Expand All @@ -27,36 +28,8 @@ Hooks.once("ready", async () => {
if (game.user.isGM) {
await registerSettings()
open_socket_with_oronder()

const monks_tokenbar = game.modules.get('monks-tokenbar')
if (monks_tokenbar?.active) {
Logger.info("Monk's Tokenbar found.")
let last_xp_ts = new Date().getTime()
Hooks.on("renderChatMessage", async (message, html, messageData) => {
const mtb = message.flags['monks-tokenbar']
if (
mtb &&
messageData.author.id === game.userId &&
game.user.role >= CONST.USER_ROLES.ASSISTANT &&
message['timestamp'] > last_xp_ts
) {
if (!mtb.actors.map(a => a.xp).every(xp => xp === mtb.actors[0].xp)) {
Logger.warn('Oronder does not currently support unequal XP distribution :(')
} else if (!mtb.actors.length) {
Logger.warn('No actors to reward xp to')
} else if (session_id === undefined) {
Logger.warn('No Session Found')
} else if (message['timestamp'] < session_ts) {
Logger.warn('XP reward predates session start')
} else {
last_xp_ts = message['timestamp']
socket.emit('xp', {session_id: session_id, id_to_xp: mtb.actors.map(a => ([a['id'], a['xp']]))})
}
}
})
}
monks_token_bar_hooks();
}

Logger.info('Ready')
})

Expand Down
32 changes: 32 additions & 0 deletions src/monks_token_bar_hooks.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {Logger} from "./util.mjs";
import {session_id, session_ts, socket} from "./module.mjs";

export function monks_token_bar_hooks() {
const monks_tokenbar = game.modules.get('monks-tokenbar')
if (monks_tokenbar?.active) {
Logger.info("Monk's Tokenbar found.")
let last_xp_ts = new Date().getTime()
Hooks.on("renderChatMessage", async (message, html, messageData) => {
const mtb = message.flags['monks-tokenbar']
if (
mtb &&
messageData.author.id === game.userId &&
game.user.role >= CONST.USER_ROLES.ASSISTANT &&
message['timestamp'] > last_xp_ts
) {
if (!mtb.actors.map(a => a.xp).every(xp => xp === mtb.actors[0].xp)) {
Logger.warn('Oronder does not currently support unequal XP distribution :(')
} else if (!mtb.actors.length) {
Logger.warn('No actors to reward xp to')
} else if (session_id === undefined) {
Logger.warn('No Session Found')
} else if (message['timestamp'] < session_ts) {
Logger.warn('XP reward predates session start')
} else {
last_xp_ts = message['timestamp']
socket.emit('xp', {session_id: session_id, id_to_xp: mtb.actors.map(a => ([a['id'], a['xp']]))})
}
}
})
}
}
2 changes: 1 addition & 1 deletion src/settings-form-application.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class OronderSettingsFormApplication extends FormApplication {
const guild = await this._handle_json_response(response)
this.object.guild_name = guild.name
} catch (error) {
this.object.guild_name = undefined
this.object.guild_name = ''
Logger.error(`Error setting guild name: ${error.message}`)
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/settings.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ export const registerSettings = async () => {
game.settings.register(MODULE_ID, GUILD_NAME, {
scope: "world",
type: String,
config: false
config: false,
default:''
})

game.settings.register(MODULE_ID, AUTH, {
scope: "world",
type: String,
config: false
config: false,
default:''
})

game.settings.register(MODULE_ID, ID_MAP, {
Expand Down

0 comments on commit c5a1f8f

Please sign in to comment.