Add battle death stats and HUD updates
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
export async function fetchTodayDeathStats() {
|
||||
const response = await fetch("/api/death-stats/today", {
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Death stats fetch failed: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function addTodayDeathStats(deathStats) {
|
||||
const response = await fetch("/api/death-stats/today", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(deathStats),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Death stats update failed: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
+10
-1
@@ -3,7 +3,9 @@ import { NICKNAME_LENGTH } from "../constants.js";
|
||||
export function createMatchForm() {
|
||||
const form = getElement("#fighter-form");
|
||||
const namesInput = getElement("#player-names");
|
||||
const appNode = document.querySelector("#app");
|
||||
const statusNode = document.querySelector("#match-status");
|
||||
const statusTextNodes = document.querySelectorAll("[data-status-text]");
|
||||
const teamSizeInput = getElement("#team-size");
|
||||
const teamSizeOutput = getElement("#team-size-value");
|
||||
|
||||
@@ -27,8 +29,15 @@ export function createMatchForm() {
|
||||
readMatchConfig,
|
||||
setStatus(message) {
|
||||
if (statusNode) {
|
||||
statusNode.textContent = message;
|
||||
statusNode.setAttribute("aria-hidden", "false");
|
||||
statusNode.title = message;
|
||||
}
|
||||
|
||||
statusTextNodes.forEach((node) => {
|
||||
node.textContent = message;
|
||||
});
|
||||
|
||||
appNode?.classList.add("status-active");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user