aboutsummaryrefslogtreecommitdiff
path: root/webAO/packets/handlers/handleHP.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-08-31 00:09:48 +0200
committerGitHub <noreply@github.com>2022-08-31 00:09:48 +0200
commitfbe2a62fd081a60860df4169f6f74425b3ff833e (patch)
tree57bf23055f63df56f9a65b4ac007d97e41a334a1 /webAO/packets/handlers/handleHP.ts
parenta453315983f6fa71b2b9f953d505cf63f6d7d8d0 (diff)
parent357b27c0aae95031a5d94bdbc504d82b797b22e2 (diff)
Merge pull request #160 from caleb-mabry/several
Several packets added
Diffstat (limited to 'webAO/packets/handlers/handleHP.ts')
-rw-r--r--webAO/packets/handlers/handleHP.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/webAO/packets/handlers/handleHP.ts b/webAO/packets/handlers/handleHP.ts
new file mode 100644
index 0000000..f365590
--- /dev/null
+++ b/webAO/packets/handlers/handleHP.ts
@@ -0,0 +1,23 @@
+import { client } from "../../client";
+
+
+ /**
+ * Handles a change in the health bars' states.
+ * @param {Array} args packet arguments
+ */
+export const handleHP = (args: string[]) => {
+ const percent_hp = Number(args[2]) * 10;
+ let healthbox;
+ if (args[1] === "1") {
+ // Def hp
+ client.hp[0] = Number(args[2]);
+ healthbox = document.getElementById("client_defense_hp");
+ } else {
+ // Pro hp
+ client.hp[1] = Number(args[2]);
+ healthbox = document.getElementById("client_prosecutor_hp");
+ }
+ (<HTMLElement>(
+ healthbox.getElementsByClassName("health-bar")[0]
+ )).style.width = `${percent_hp}%`;
+ } \ No newline at end of file