Fix skins not loading on connection

This commit is contained in:
2026-10-02 13:26:00 -03:00
parent cd07d441b2
commit 7b3cdd925e
2 changed files with 16 additions and 1 deletions
+7 -1
View File
@@ -1,5 +1,6 @@
import { assertEquals } from "@std/assert";
import { encode_skin } from "$/server/game/skins.ts";
import { PROTOCOL_VERSION } from "$/common/protocol.ts";
import { test_game } from "./helpers.ts";
const SKIN = Deno.readFileSync("assets/sprites/skin_template.png");
@@ -29,7 +30,12 @@ Deno.test("/skin downloads a png, tells everyone and is saved with the player",
// players joining later get it with the rest of alice's info, and it's still there after a restart
const loaded = await test_game("mods", t.game.save());
loaded.join(1, "alice");
// alice gets it too, for her own hand
loaded.game.on_connect(1);
loaded.send(1, { type: "hello", name: "alice", protocol: PROTOCOL_VERSION });
loaded.send(1, { type: "ready" });
const own = loaded.take(1).find((m) => m.type === "player_skin");
assertEquals([own?.id, own?.skin], [loaded.game.players()[0].id, skin]);
const join = loaded.join(2, "bob");
assertEquals(join.players.find((p: { name: string }) => p.name === "alice").skin, skin);
});