Skip to content

Commit

Permalink
fix: fixes max hp logging
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Apr 25, 2023
1 parent ebd2b5e commit 5996907
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions src/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default class Logger {
async setFile() {
const file = (await this.adapter.exists(normalizePath(this.logFile)))
? await this.vault.getAbstractFileByPath(
normalizePath(this.logFile)
)
normalizePath(this.logFile)
)
: await this.vault.create(this.logFile, ``);

if (file instanceof TFile) {
Expand All @@ -38,7 +38,7 @@ export default class Logger {
return this.file;
}
private file: TFile;
constructor(public plugin: InitiativeTracker) { }
constructor(public plugin: InitiativeTracker) {}
get enabled() {
return this.plugin.data.logging;
}
Expand Down Expand Up @@ -137,19 +137,38 @@ export default class Logger {
if (message.hp) {
if (message.temp) {
perCreature.push(
`${message.name
} gained ${message.hp.toString()} temporary HP`
`${message.name} gained ${(
-1 * message.hp
).toString()} temporary HP`
);
} else if (message.max) {
if (message.hp < 0) {
perCreature.push(
`${message.name} took ${(
-1 * message.hp
).toString()} max HP damage${
message.unc ? " and died" : ""
}`
);
} else {
perCreature.push(
`${
message.name
} gained ${message.hp.toString()} max HP`
);
}
} else if (message.hp < 0) {
perCreature.push(
`${message.name} took ${(
-1 * message.hp
).toString()} damage${message.unc ? " and was knocked unconscious" : ""
).toString()} damage${
message.unc ? " and was knocked unconscious" : ""
}`
);
} else if (message.hp > 0) {
perCreature.push(
`${message.name
`${
message.name
} was healed for ${message.hp.toString()} HP`
);
}
Expand All @@ -162,7 +181,9 @@ export default class Logger {
}

if (message.ac_add) {
perCreature.push(`${message.name} added ${message.ac} to AC`);
perCreature.push(
`${message.name} added ${message.ac} to AC`
);
} else {
perCreature.push(`${message.name} AC set to ${message.ac}`);
}
Expand Down

0 comments on commit 5996907

Please sign in to comment.