aboutsummaryrefslogtreecommitdiff
path: root/webAO/packets/handlers/handleHP.ts
diff options
context:
space:
mode:
authorstonedDiscord <Tukz@gmx.de>2022-08-31 20:31:54 +0200
committerstonedDiscord <Tukz@gmx.de>2022-08-31 20:31:54 +0200
commitd124c7466ec13dc0353edeb5fab49f03f3035b5e (patch)
tree8f278b39e51fa5d3b738bd2d47c6f3b1d123ca9c /webAO/packets/handlers/handleHP.ts
parent1847fcf939c4a079b2f016df212e2b6c832aa2e5 (diff)
parentda992f9b3623955ef777c343a9f2c7b81d8ca942 (diff)
Merge branch 'master' of https://github.com/AttorneyOnline/webAO
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