Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?

/public/sprites
49 changes: 45 additions & 4 deletions build-sprites.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
#!/bin/sh
#!/usr/bin/env bash

ROOT="$(git rev-parse --show-toplevel)"
SRC="$ROOT/sprites"
TMP="$(mktemp -d)/sprites"
DEST="$ROOT/public/sprites"

rm -rf "$DEST"

sub_inputs=(220022 440044 aa00aa ff00ff)

declare -A palettes=(
[lightblue]="#305182 #4192c3 #61d3e3 #a2fff3"
[turqoise]="#165950 #189572 #37da94 #a0ffc2"
[green]="#006130 #19a239 #5ff040 #ccffad"
[lime]="#263e0a #6e8d1b #bee344 #edff89"
[yellow]="#6d3c05 #b87a0c #ffd42d #fff392"
[orange]="#732200 #c64b01 #ff8b17 #ffdba2"
[warmred]="#681d27 #ae2b28 #ff5d32 #ffae93"
[red]="#641b3b #9d193c #ff4656 #ff9ba1"
[magenta]="#612b79 #9c37ba #f75aff #ffa9f0"
[purple]="#342561 #6b42a7 #b76cff #e2abff"
[indigo]="#1f1d51 #3e3c8b #6979e8 #88baff"
[blue]="#19295b #305faa #3f9eff #8ad1ff"
[white]="#535353 #8a8a8a #c6c6c6 #ffffff"
)

find "$SRC" -type f -name '*.aseprite' | while read -r file; do
rel="${file#"$SRC"/}"
Expand All @@ -17,11 +36,33 @@ find "$SRC" -type f -name '*.aseprite' | while read -r file; do
--save-as "$out"
done

run_with_palette() {
local in="$1" out="$2" palette_str="$3"
local s1 s2 s3 s4
read -r s1 s2 s3 s4 <<< "$palette_str"

png-subs "$in" "$out" \
--subs "${sub_inputs[0]}" "${s1#"#"}" \
--subs "${sub_inputs[1]}" "${s2#"#"}" \
--subs "${sub_inputs[2]}" "${s3#"#"}" \
--subs "${sub_inputs[3]}" "${s4#"#"}"
}


find "$TMP" -type f -name '*.png' | while read -r file; do
rel="${file#"$TMP"/}"
out="$DEST/${rel%.png}.png"
out_rel="${rel//\/substitute\//\/}"
dest_base="$DEST/${out_rel%.png}"

mkdir -p "$(dirname "$out")"
mkdir -p "$(dirname "$dest_base")"

png-subs "$file" "$out"
if [[ "$rel" == *"/substitute/"* ]]; then
for name in "${!palettes[@]}"; do
out="${dest_base}-${name}.png"
run_with_palette "$file" "$out" "${palettes[$name]}"
done
else
out="${dest_base}.png"
png-subs "$file" "$out"
fi
done
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"build": "./build-sprites.sh && vite build",
"preview": "vite preview",
"sprites": "./build-sprites.sh",
"deploy": "npm run build && gh-pages -d dist --nojekyll --cname elementipelago.peppidesu.dev"
"deploy": "bun run build && gh-pages -d dist --nojekyll --cname elementipelago.peppidesu.dev"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^6.2.4",
Expand Down
Binary file removed public/sprites/elements/apple.png
Binary file not shown.
Binary file removed public/sprites/elements/armor.png
Binary file not shown.
Binary file removed public/sprites/elements/ball.png
Binary file not shown.
Binary file removed public/sprites/elements/berry.png
Binary file not shown.
Binary file removed public/sprites/elements/boat.png
Binary file not shown.
Binary file removed public/sprites/elements/book.png
Binary file not shown.
Binary file removed public/sprites/elements/boots.png
Binary file not shown.
Binary file removed public/sprites/elements/bow.png
Binary file not shown.
Binary file removed public/sprites/elements/car.png
Binary file not shown.
Binary file removed public/sprites/elements/cave.png
Binary file not shown.
Binary file removed public/sprites/elements/chest.png
Binary file not shown.
Binary file removed public/sprites/elements/coin.png
Binary file not shown.
Binary file removed public/sprites/elements/desert.png
Binary file not shown.
Binary file removed public/sprites/elements/egg.png
Binary file not shown.
Binary file removed public/sprites/elements/element.png
Binary file not shown.
Binary file removed public/sprites/elements/emerald.png
Binary file not shown.
Binary file removed public/sprites/elements/fire.png
Binary file not shown.
Binary file removed public/sprites/elements/gun.png
Binary file not shown.
Binary file removed public/sprites/elements/hammer.png
Binary file not shown.
Binary file removed public/sprites/elements/hat.png
Binary file not shown.
Binary file removed public/sprites/elements/heart.png
Binary file not shown.
Binary file removed public/sprites/elements/hills.png
Binary file not shown.
Binary file removed public/sprites/elements/hourglass.png
Binary file not shown.
Binary file removed public/sprites/elements/house.png
Binary file not shown.
Binary file removed public/sprites/elements/ice.png
Binary file not shown.
Binary file removed public/sprites/elements/island.png
Diff not rendered.
Binary file removed public/sprites/elements/key.png
Diff not rendered.
Binary file removed public/sprites/elements/leaf.png
Diff not rendered.
Binary file removed public/sprites/elements/magic.png
Diff not rendered.
Binary file removed public/sprites/elements/map.png
Diff not rendered.
Binary file removed public/sprites/elements/marker.png
Diff not rendered.
Binary file removed public/sprites/elements/metal.png
Diff not rendered.
Binary file removed public/sprites/elements/money.png
Diff not rendered.
Binary file removed public/sprites/elements/mountains.png
Diff not rendered.
Binary file removed public/sprites/elements/music.png
Diff not rendered.
Binary file removed public/sprites/elements/piece.png
Diff not rendered.
Binary file removed public/sprites/elements/planet.png
Diff not rendered.
Binary file removed public/sprites/elements/potion.png
Diff not rendered.
Binary file removed public/sprites/elements/quest.png
Diff not rendered.
Binary file removed public/sprites/elements/ring.png
Diff not rendered.
Binary file removed public/sprites/elements/rock.png
Diff not rendered.
Binary file removed public/sprites/elements/sand.png
Diff not rendered.
Binary file removed public/sprites/elements/shop.png
Diff not rendered.
Binary file removed public/sprites/elements/sign.png
Diff not rendered.
Binary file removed public/sprites/elements/skull.png
Diff not rendered.
Binary file removed public/sprites/elements/spear.png
Diff not rendered.
Binary file removed public/sprites/elements/sword.png
Diff not rendered.
Binary file removed public/sprites/elements/tree.png
Diff not rendered.
Binary file removed public/sprites/elements/upgrade.png
Diff not rendered.
Binary file removed public/sprites/elements/void.png
Diff not rendered.
Binary file removed public/sprites/elements/wand.png
Diff not rendered.
Binary file removed public/sprites/elements/water.png
Diff not rendered.
Binary file removed public/sprites/ui/broom.png
Diff not rendered.
Binary file removed public/sprites/ui/burger.png
Diff not rendered.
Binary file removed public/sprites/ui/chat.png
Diff not rendered.
Binary file removed public/sprites/ui/check.png
Diff not rendered.
Binary file removed public/sprites/ui/download.png
Diff not rendered.
Binary file removed public/sprites/ui/hint1.png
Diff not rendered.
Binary file removed public/sprites/ui/hint2.png
Diff not rendered.
Binary file removed public/sprites/ui/new.png
Diff not rendered.
Binary file removed public/sprites/ui/settings.png
Diff not rendered.
Binary file removed sprites/elements/apple.aseprite
Binary file not shown.
Binary file removed sprites/elements/armor.aseprite
Binary file not shown.
Binary file removed sprites/elements/ball.aseprite
Binary file not shown.
Binary file removed sprites/elements/berry.aseprite
Binary file not shown.
Binary file removed sprites/elements/boat.aseprite
Binary file not shown.
Binary file removed sprites/elements/book.aseprite
Binary file not shown.
Binary file removed sprites/elements/boots.aseprite
Binary file not shown.
Binary file removed sprites/elements/car.aseprite
Binary file not shown.
Binary file removed sprites/elements/chest.aseprite
Binary file not shown.
Binary file removed sprites/elements/element.aseprite
Binary file not shown.
Binary file removed sprites/elements/emerald.aseprite
Binary file not shown.
Binary file removed sprites/elements/hat.aseprite
Binary file not shown.
Binary file removed sprites/elements/heart.aseprite
Binary file not shown.
Binary file modified sprites/elements/ice.aseprite
Binary file not shown.
Binary file modified sprites/elements/key.aseprite
Binary file not shown.
Binary file removed sprites/elements/leaf.aseprite
Binary file not shown.
Binary file removed sprites/elements/magic.aseprite
Binary file not shown.
Binary file modified sprites/elements/map.aseprite
Binary file not shown.
Binary file removed sprites/elements/marker.aseprite
Binary file not shown.
Binary file removed sprites/elements/metal.aseprite
Binary file not shown.
Binary file removed sprites/elements/music.aseprite
Binary file not shown.
Binary file removed sprites/elements/potion.aseprite
Binary file not shown.
Binary file removed sprites/elements/sand.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/apple.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/armor.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/ball.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/berry.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/boat.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/book.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/boots.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/car.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/chest.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/element.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/emerald.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/hat.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/heart.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/leaf.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/magic.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/marker.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/metal.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/music.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/potion.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/sand.aseprite
Binary file not shown.
Binary file added sprites/elements/substitute/wand.aseprite
Binary file not shown.
Binary file modified sprites/elements/sword.aseprite
Binary file not shown.
Binary file removed sprites/elements/wand.aseprite
Binary file not shown.
2 changes: 1 addition & 1 deletion src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ body {
margin: 0;
overflow: hidden;

>* {
> * {
grid-area: 1 / 1 / 1 / 1;
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/lib/Drawer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@
res = res || isExhausted(a.name) - isExhausted(b.name);
}

return (
res ||
a.elem_id.kind - b.elem_id.kind ||
a.elem_id.id - b.elem_id.id
);
return res || a.elem_id.kind - b.elem_id.kind || a.elem_id.id - b.elem_id.id;
});

if (search_term === "") return table;
Expand Down
5 changes: 1 addition & 4 deletions src/lib/Playfield.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
*/
export function handle_dropped(mounted) {
Array.from(mounted)
.toSorted(
([_a, a], [_b, b]) =>
Number(a.get_z_index()) - Number(b.get_z_index()),
)
.toSorted(([_a, a], [_b, b]) => Number(a.get_z_index()) - Number(b.get_z_index()))
.forEach(([_num, ele], idx) => ele.set_z_index(String(idx + 1)));
}
</script>
Expand Down
154 changes: 96 additions & 58 deletions src/lib/machine-learning/iconml.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,80 +7,118 @@ import { getElementData } from "../stores/apclient.svelte.js";
/**
* @param {string} game
* @param {string} name
* @returns {string}
*/
export function iconForLocation(game, name) {
const kind = "item";
return iconForText(`[game=${game}] ${name}`);
return iconForText(`[game=${game}][kind=${kind}] ${name}`);
}

/**
* @param {string} game
* @param {string} name
* @returns {string}
*/
export function iconForItem(game, name) {
const kind = "location";
return iconForText(`[game=${game}] ${name}`);
return iconForText(`[game=${game}][kind=${kind}] ${name}`);
}

/**
* @param {string} name
* @returns {string}
*/
export function iconForIntermediate(name) {
return iconForText(name);
}

const colors = [
"lightblue",
"turqoise",
"green",
"lime",
"yellow",
"orange",
"warmred",
"red",
"magenta",
"purple",
"indigo",
"blue",
"white",
];

const substituteIcons = [
"apple",
"armor",
"ball",
"berry",
"boat",
"book",
"boots",
"car",
"chest",
"element",
"emerald",
"hat",
"heart",
"leaf",
"magic",
"marker",
"metal",
"music",
"potion",
"sand",
"wand",
];

const icons = [
"bow",
"cave",
"coin",
"desert",
"egg",
"fire",
"gun",
"hammer",
"hills",
"hourglass",
"house",
"ice",
"island",
"key",
"map",
"money",
"mountains",
"piece",
"planet",
"quest",
"ring",
"rock",
"shop",
"sign",
"skull",
"spear",
"sword",
"tree",
"upgrade",
"void",
"water",
];

const combinedIcons = [
...icons,
...substituteIcons.flatMap((value) => colors.map((color) => `${value}-${color}`)),
];

/**
* @param {String} text
* @returns {String}
*/
function iconForText(text) {
//const res = predictIcon(get(model), text, { returnTopK: 1 });

const icons = [
"apple",
"armor",
"ball",
"berry",
"boat",
"book",
"boots",
"bow",
"car",
"cave",
"chest",
"coin",
"desert",
"egg",
"element",
"emerald",
"fire",
"gun",
"hammer",
"hat",
"heart",
"hills",
"hourglass",
"house",
"ice",
"island",
"key",
"leaf",
"magic",
"map",
"marker",
"metal",
"money",
"mountains",
"music",
"piece",
"planet",
"potion",
"quest",
"ring",
"rock",
"sand",
"shop",
"sign",
"skull",
"spear",
"sword",
"tree",
"upgrade",
"void",
"wand",
"water"
];
const buffer = new Uint32Array(md5.arrayBuffer(text));
const res = icons[buffer[buffer.length - 1] % icons.length];
const res = combinedIcons[buffer[buffer.length - 1] % combinedIcons.length];

const iconKey = res;
return iconKey;
Expand Down
27 changes: 19 additions & 8 deletions src/lib/stores/apclient.svelte.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { derived, get, readable, writable } from "svelte/store";
import { Client } from "archipelago.js";
import { createSubscriber, SvelteMap, SvelteSet } from "svelte/reactivity";
import { element_to_name, parse_element } from "../../utils";
import { iconForItem, iconForLocation } from "../machine-learning/iconml";
import { iconForIntermediate, iconForItem, iconForLocation } from "../machine-learning/iconml";
import { draw } from "svelte/transition";
import { INTERMEDIATE_AMOUNT, LOCATION_AMOUNT, NON_ELEMENT_ITEMS } from "../../consts";
import { get_name, init_naming } from "./names.js";
Expand Down Expand Up @@ -228,8 +228,14 @@ export async function initElementStores() {
for (const item of await scoutedLocations) {
if (!elementData.has(item.locationName)) {
const elem_id = parse_element(item.locationName);
const loc = elem_id.kind === ElementKind.INTERMEDIATE ? get_name() : item.name;
const icon_name = iconForLocation(item.game, loc);
let loc, icon_name;
if (elem_id.kind === ElementKind.INTERMEDIATE) {
loc = get_name();
icon_name = iconForIntermediate(loc);
} else {
loc = item.name;
icon_name = iconForLocation(item.game, loc);
}
elementData.set(item.locationName, {
elem_id,
name: item.locationName,
Expand Down Expand Up @@ -341,11 +347,16 @@ function extendReceivedElements(items) {
}

let elem_id = parse_element(item.name);
const loc =
elem_id.kind === ElementKind.INTERMEDIATE || item.locationGame === "Archipelago"
? get_name()
: item.locationName;
let icon_name = iconForItem(item.game, loc);

let loc, icon_name;
if (elem_id.kind === ElementKind.INTERMEDIATE || item.locationGame === "Archipelago") {
loc = get_name();
icon_name = iconForIntermediate(loc);
} else {
loc = item.locationName;
icon_name = iconForLocation(item.game, loc);
}

receivedElements.add(item.name);

if (elementData.has(item.name)) {
Expand Down
7 changes: 2 additions & 5 deletions src/lib/stores/toast.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { get, writable } from "svelte/store";
import { apclient, getElementData } from "./apclient.svelte";
import { iconForItem, iconForLocation } from "../machine-learning/iconml";
import { writable } from "svelte/store";
import { getElementData } from "./apclient.svelte";
import { NON_ELEMENT_ITEMS } from "../../consts";

/**
Expand All @@ -14,8 +13,6 @@ import { NON_ELEMENT_ITEMS } from "../../consts";

export const toast_queue = writable([]);

const initialized = writable(false);

/**
* @param {Item[]} items
*/
Expand Down