Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkLightTuna committed May 8, 2024
1 parent cb12167 commit e25abff
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 62 deletions.
65 changes: 64 additions & 1 deletion languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,68 @@
"oronder.No-Level": "Actor has no Level.",
"oronder.No-Race": "Actor has no Race.",
"oronder.No-Background": "Actor has no Background.",
"oronder.No-Class": "Actor has no Class."
"oronder.No-Class": "Actor has no Class.",
"oronder.Its-Your-Turn": "It's your turn",
"oronder.Initiative": "Initiative",
"oronder.Round": "Round",
"oronder.Current-Round": "Current Round",
"oronder.Unharmed": "Unharmed",
"oronder.Healthy": "Healthy",
"oronder.Injured": "Injured",
"oronder.Bloodied": "Bloodied",
"oronder.Severe": "Severe",
"oronder.Critical": "Critical",
"oronder.Dead": "Dead",
"oronder.Publish-Combat-Tracker-To-Discord": "Publish Combat Tracker to Discord",
"oronder.Actor-Not-Found": "Actor Not Found",
"oronder.Item-Not-Found": "Item Not Found",
"oronder.LibWrapper-Error": "Oronder requires the 'libWrapper' module. Please install and activate it.",
"oronder.Connection-Failed": "Oronder connection failed",
"oronder.Failed-To-Update-Actor": "Failed to update XP. No Actor with ID",
"oronder.Found": "Found!",
"oronder.No-Actors-To-Reward-Xp-To": "No actors to reward xp to",
"oronder.No-Session-Found": "No Session Found",
"oronder.XP-Reward-Predates-Session-Start": "XP reward predates session start",
"oronder.Discord-Popup-Blocked": "Could not launch Discord Authentication window! Check your browser's popup settings.",
"oronder.GM-XP": "GM XP",
"oronder.GM-XP-Label": "How much experience a GM may reward one of their PCs for running a session.",
"oronder.Starting-Level": "Starting Level",
"oronder.Starting-Level-Label": "Starting level for new PCs. Override by assigning a PC to a Campaign.",
"oronder.Timezone": "Timezone",
"oronder.Timezone-Label": "Default timezone for scheduling and roll calls.",
"oronder.GM-Role": "GM Role",
"oronder.GM-Role-Label": "Discord Role for GMs.",
"oronder.Discord-Status": "Discord Status",
"oronder.Channels": "Channels",
"oronder.Session-Channel": "Session Channel",
"oronder.Session-Channel-Label": "Channel Sessions will be posted to. If a Forum Channel is selected, Oronder will create a new thread for each session.",
"oronder.Downtime-Channel": "Downtime Channel",
"oronder.Downtime-Channel-Label": "Channel where /downtime... rolls should take place.",
"oronder.Downtime-GM-Channel": "Downtime GM Channel",
"oronder.Downtime-GM-Channel-Label": "Optional Channel where downtime activities may be claimed by a GM.",
"oronder.DISABLED": "DISABLED",
"oronder.Voice-Channel": "Voice Channel",
"oronder.Voice-Channel-Label": "Voice Channel where Oronder will create session events.",
"oronder.Scheduling-Channel": "Scheduling Channel",
"oronder.Scheduling-Channel-Label": "Channel where Oronder will advertise new Sessions.",
"oronder.Rollcall": "Rollcall",
"oronder.Rollcall-Label": "If enabled, Oronder will prompt members for their weekly availability.",
"oronder.Role": "Role",
"oronder.Rollcall-Role-Label": "Role Oronder will @ mention when posting roll call.",
"oronder.Channel": "Channel",
"oronder.Rollcall-Channel-Label": "Channel where roll call messages will be posted to.",
"oronder.Day": "Day",
"oronder.Rollcall-Day-Label": "Day of the week when roll call messages will be posted.",
"oronder.Time": "Time",
"oronder.Rollcall-Time-Label": "Time of day when roll call messages will be posted.",
"oronder.Advanced-Options": "Advanced Options",
"oronder.Advanced-Options-Label": "Display Advanced and Experimental Options.",
"oronder.Publish-Discord-Rolls-To-Foundry": "(Under Development) Publish Discord Rolls to Foundry",
"oronder.Publish-Discord-Rolls-To-Foundry-Label": "Oronder will post rolls from Discord to Foundry if a GM is logged into Foundry.",
"oronder.Combat-Tracking-Enable": "Publish Combat Tracker to Discord",
"oronder.Combat-Tracking-Enable-Label": "Oronder will post changes in the combat tracker to the Combat Channel configured below.",
"oronder.Combat-Channel": "Combat Channel",
"oronder.Combat-Channel-Label": "Channel where Combat Tracking Messages will be posted.",
"oronder.Combat-Health-Estimate": "Combat Health Estimate",
"oronder.Combat-Health-Estimate-Label": "Select whose health will be described(i.e. Healthy) rather than shown (HP 8/9)."
}
30 changes: 15 additions & 15 deletions src/combat.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ function parse_turn(combat, updateData) {

let output = ''
if (discordId.length)
output += `It's your turn <@${discordId[0]}>\n`
output += `${game.i18n.localize("oronder.Its-Your-Turn")} <@${discordId[0]}>\n`
output += '```md\n'
output += `# Initiative ${actor.initiative} Round ${c.round}\n`
output += `# ${game.i18n.localize("oronder.Initiative")} ${actor.initiative} ${game.i18n.localize("oronder.Round")} ${c.round}\n`

if (turn.defeated) {
output += `${actor.name} <Defeated>\n`
Expand Down Expand Up @@ -109,7 +109,7 @@ function parse_combat_round(combat) {
const healthSetting = game.settings.get(MODULE_ID, COMBAT_HEALTH_ESTIMATE)

let output = "```md\n"
output += `Current Round: ${combat.round}\n`
output += `${game.i18n.localize("oronder.Current-Round")}: ${combat.round}\n`
output += "==================\n"

// Parse each combatant
Expand Down Expand Up @@ -147,19 +147,19 @@ function get_health(hp, combatHealthSetting, actorType) {
const pct = Math.round(hp.effectiveMax ? (hp.value / hp.effectiveMax) * 100 : 0, 0, 100);
switch (true) {
case pct > 99:
return "Unharmed";
return game.i18n.localize("oronder.Unharmed");
case pct > 75:
return "Healthy";
return game.i18n.localize("oronder.Healthy");
case pct > 50:
return "Injured";
return game.i18n.localize("oronder.Injured");
case pct > 25:
return "Bloodied";
return game.i18n.localize("oronder.Bloodied");
case pct > 10:
return "Severe";
return game.i18n.localize("oronder.Severe");
case pct > 0:
return "Critical";
return game.i18n.localize("oronder.Critical");
default:
return "Dead";
return game.i18n.localize("oronder.Dead");
}
}

Expand Down Expand Up @@ -188,7 +188,7 @@ export function register_combat_settings_toggle() {
$('<div/>', {class: "form-group"})
.append(
$("<label/>", {
text: 'Publish Combat Tracker to Discord',
text: game.i18n.localize("oronder.Publish-Combat-Tracker-To-Discord"),
for: 'oronder_combat_tracker_toggle'
}),
$("<input/>", {
Expand All @@ -208,7 +208,7 @@ export function handle_incoming_rolls() {
socket.on('roll', async data => {
const actor = game.actors.find(a => a.id === data.actor_id)
if (actor === undefined) {
Logger.error('actor not found')
Logger.error(game.i18n.localize("oronder.Actor-Not-Found"))
return
}

Expand All @@ -226,11 +226,11 @@ export function handle_incoming_rolls() {

switch (data['type']) {
case 'stat':
Logger.info(`stat roll`)
Logger.info(`Stat Roll`)
Logger.info(data)
break
case 'attack':
Logger.info(`attack roll`)
Logger.info(`Attack Roll`)
//Actors who haven't been synced after 3/27/24 may only have reference to item name and not id
const item_match_fun = data?.item_id ?
i => i.id === data.item_id :
Expand All @@ -239,7 +239,7 @@ export function handle_incoming_rolls() {
const item = actor.items.find(item_match_fun)

if (item === undefined) {
Logger.error('item not found')
Logger.error(game.i18n.localize("oronder.Item-Not-Found"))
return
}

Expand Down
6 changes: 3 additions & 3 deletions src/module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function set_session(session) {
Hooks.once("ready", async () => {
if (game.user.isGM) {
if (!game.modules.get('lib-wrapper')?.active) {
ui.notifications.error("Oronder requires the 'libWrapper' module. Please install and activate it.")
Logger.error(game.i18n.localize("oronder.LibWrapper-Error"))
}
await registerSettings()
open_socket_with_oronder()
Expand Down Expand Up @@ -82,7 +82,7 @@ export function open_socket_with_oronder(update = false) {
})

socket.on('connect_error', (error) => {
Logger.warn(`Oronder connection failed: ${error.message}`)
Logger.warn(`${game.i18n.localize("oronder.Connection-Failed")}: ${error.message}`)
})

socket.on('connect', () => {
Expand All @@ -92,7 +92,7 @@ export function open_socket_with_oronder(update = false) {
for (const [actor_id, xp] of Object.entries(data)) {
const actor = game.actors.get(actor_id)
if (actor === undefined) {
Logger.warn(`Failed to update XP. No Actor with ID ${actor_id} found!`)
Logger.warn(`${game.i18n.localize("oronder.Failed-To-Update-Actor")} ${actor_id} ${game.i18n.localize("oronder.Found")}`)
} else {
Logger.info(`${actor.name} xp: ${actor.system.details.xp.value} -> ${xp}`)
await actor.update({"system.details.xp.value": xp})
Expand Down
6 changes: 3 additions & 3 deletions src/monks_token_bar_hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export function monks_token_bar_hooks() {
message['timestamp'] > last_xp_ts
) {
if (!mtb.actors.length) {
Logger.warn('No actors to reward xp to')
Logger.warn(game.i18n.localize("oronder.No-Actors-To-Reward-Xp-To"))
} else 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 (session_id === undefined) {
Logger.warn('No Session Found')
Logger.warn(game.i18n.localize("oronder.No-Session-Found"))
} else if (message['timestamp'] < session_ts) {
Logger.warn('XP reward predates session start')
Logger.warn(game.i18n.localize("oronder.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']]))})
Expand Down
2 changes: 1 addition & 1 deletion src/settings-form-application.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class OronderSettingsFormApplication extends FormApplication {
if (popup && !popup.closed && popup.focus) {
popup.focus()
} else {
Logger.error("Could not launch Discord Authentication window! Check your browser's popup settings.")
Logger.error(game.i18n.localize("oronder.Discord-Popup-Blocked"))
}

const message_interval = setInterval(() => {
Expand Down
Loading

0 comments on commit e25abff

Please sign in to comment.