Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkLightTuna committed Jan 21, 2024
1 parent 979925b commit 24b4041
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,13 @@ function open_socket_with_oronder() {
auth: {'Guild-Id': guild_id, 'Authorization': authorization}
})

const asdf = JSON.stringify(game.actors
.filter(a => a.type === 'character')
.reduce((acc, cur) => {
acc[cur.id] = cur.system.details.xp.value + 1;
return acc
}, {}))


oronder_socket.on('xp', data => {
for (const [id, xp] of Object.entries(data)) {
const actor = game.actors.get(id)
if (actor === undefined) {
Logger.warn(`Failed to update XP. No Actor with ID ${id} found!`)
} else {
console.info(`${actor.name} xp: ${actor.system.details.xp.value} -> ${xp}`)
Logger.info(`${actor.name} xp: ${actor.system.details.xp.value} -> ${xp}`)
actor.update({"system.details.xp.value": xp})
}
}
Expand All @@ -55,7 +47,7 @@ Hooks.on("updateActor", async (actor, data, options, userId) => {
// if (currency !== undefined) {
// //todo handle currency
// }
if (game.user.id === userId) {
if (game.user.id === userId && !data?.system?.details?.xp?.value) {
await sync_actor(actor)
}
})
Expand Down

0 comments on commit 24b4041

Please sign in to comment.