diff options
| author | Caleb <caleb.mabry.15@cnu.edu> | 2022-08-30 18:08:05 -0400 |
|---|---|---|
| committer | Caleb <caleb.mabry.15@cnu.edu> | 2022-08-30 18:08:05 -0400 |
| commit | 357b27c0aae95031a5d94bdbc504d82b797b22e2 (patch) | |
| tree | 57bf23055f63df56f9a65b4ac007d97e41a334a1 /webAO/packets/handlers/handleHP.ts | |
| parent | a453315983f6fa71b2b9f953d505cf63f6d7d8d0 (diff) | |
Several packets added
Diffstat (limited to 'webAO/packets/handlers/handleHP.ts')
| -rw-r--r-- | webAO/packets/handlers/handleHP.ts | 23 |
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 |
