added gameboard

This commit is contained in:
yoshi 2025-04-22 11:59:50 -07:00
parent 93d278340e
commit fa36efa455
68 changed files with 7800 additions and 1 deletions

View file

@ -0,0 +1,24 @@
const mediaCache: { [key: string]: string } = {};
export async function fetchCustomizationSvgDef(type: string, name: string) {
const mediaPath = `snakes/${type}s/${name}.svg`;
if (!(mediaPath in mediaCache)) {
mediaCache[mediaPath] = await fetch(`https://media.battlesnake.com/${mediaPath}`)
.then((response) => response.text())
.then((textSVG) => {
const tempElememt = document.createElement("template");
tempElememt.innerHTML = textSVG.trim();
console.debug(`[customizations] loaded svg definition for ${mediaPath}`);
if (tempElememt.content.firstChild === null) {
console.debug("[customizations] error loading customization, no elements found");
return "";
}
const child = <HTMLElement>tempElememt.content.firstChild;
return child.innerHTML;
});
}
return mediaCache[mediaPath];
}