From b7d0fea9993fab1ee921d1b01e3a7609bf7f9275 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Sun, 7 Apr 2024 00:41:19 -0500 Subject: [PATCH] appease tsc --- starkingdoms-client/src/hub.ts | 4 +- starkingdoms-client/src/pages/Play.svelte | 4 +- .../src/pages/ShipEditor.svelte | 59 ++++++++++--------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/starkingdoms-client/src/hub.ts b/starkingdoms-client/src/hub.ts index 9c7e9d27d535f97dba0b89a1c434e96887fb70f7..2a372b21f9dd72a92584f7dc9e68e457e2c1b358 100644 --- a/starkingdoms-client/src/hub.ts +++ b/starkingdoms-client/src/hub.ts @@ -19,7 +19,6 @@ import { global } from "./globals.ts"; import { startRender } from "./rendering.ts"; import { ButtonType } from "./protocol.ts"; import type Chatbox from "./components/Chatbox.svelte"; -import type Button from "./components/ui/Button.svelte"; import { part_texture_url } from "./textures.js"; import * as PIXI from "pixi.js"; @@ -47,7 +46,6 @@ export async function hub_connect( x_pos: HTMLSpanElement, y_pos: HTMLSpanElement, energy: HTMLDivElement, - beam_out_button: Button, ): Promise { logger("connecting to client hub at " + url); @@ -73,7 +71,7 @@ export async function hub_connect( let save = window.localStorage.getItem("save"); if (save !== null) { - save = save.trim(); + save = save.trim(); } let packet: Packet = { t: PacketType.ClientLogin, diff --git a/starkingdoms-client/src/pages/Play.svelte b/starkingdoms-client/src/pages/Play.svelte index 86da2bdf243dcb2ea1443588a17328ff3fcd4e96..49c2ef375a5997059c43f0dfee0643f9e9c0369c 100644 --- a/starkingdoms-client/src/pages/Play.svelte +++ b/starkingdoms-client/src/pages/Play.svelte @@ -25,7 +25,6 @@ //let antialiasing: boolean = false; let chatbox: Chatbox; - let beam_out_button: Button; const logger = createDebug("main"); logger( @@ -108,7 +107,6 @@ x_pos, y_pos, energy, - beam_out_button, ); }); @@ -167,7 +165,7 @@ - diff --git a/starkingdoms-client/src/pages/ShipEditor.svelte b/starkingdoms-client/src/pages/ShipEditor.svelte index 33970600072067592d0fb2fc2c31c2f8fbe33507..1b38964b3a9299438ad8b1a6ab48c3f83340e21c 100644 --- a/starkingdoms-client/src/pages/ShipEditor.svelte +++ b/starkingdoms-client/src/pages/ShipEditor.svelte @@ -263,8 +263,8 @@ available: existing_part_count.available + 1, }); - let x_dir = Math.round(Math.cos((rotation+1)*Math.PI/2)); - let y_dir = Math.round(Math.sin((rotation+1)*Math.PI/2)); + let x_dir = Math.round(Math.cos(((rotation + 1) * Math.PI) / 2)); + let y_dir = Math.round(Math.sin(((rotation + 1) * Math.PI) / 2)); if (children[0] !== null) { place(x, y + y_dir, children[0], (rotation + 2) % 4); } @@ -298,41 +298,44 @@ }, 5000); } - function save_recursive(x: number, y: number/*, a_rotation: number*/) { + function save_recursive(x: number, y: number /*, a_rotation: number*/) { let [part_type, rotation] = grid.get(x)!.get(y)!; let children = [null, null, null, null]; - let x_dir = Math.round(Math.cos((rotation+1)*Math.PI/2)); - let y_dir = Math.round(Math.sin((rotation+1)*Math.PI/2)); + let x_dir = Math.round(Math.cos(((rotation + 1) * Math.PI) / 2)); + let y_dir = Math.round(Math.sin(((rotation + 1) * Math.PI) / 2)); console.log(x_dir + ", " + y_dir + "(" + rotation + ")"); console.log(grid.get(x)?.get(y + y_dir)); if (part_type == PartType.Hearty) { - if (grid.get(x + 1)?.get(y)?.[1] == 1) { - // right - children[1] = save_recursive(x + 1, y, 1); - } - if (grid.get(x - 1)?.get(y)?.[1] == 3) { - // left - children[3] = save_recursive(x - 1, y, 3); - } - if (grid.get(x)?.get(y - 1)?.[1] == 0) { - // up - children[2] = save_recursive(x, y - 1, 0); - } - if (grid.get(x)?.get(y + 1)?.[1] == 2) { - // down - children[0] = save_recursive(x, y + 1, 2); - } - return { part_type: part_type, children: children }; - } else if (part_type == PartType.Cargo || part_type == PartType.LandingThruster) { - return { part_type: part_type, children: children }; + if (grid.get(x + 1)?.get(y)?.[1] == 1) { + // right + children[1] = save_recursive(x + 1, y, 1); + } + if (grid.get(x - 1)?.get(y)?.[1] == 3) { + // left + children[3] = save_recursive(x - 1, y, 3); + } + if (grid.get(x)?.get(y - 1)?.[1] == 0) { + // up + children[2] = save_recursive(x, y - 1, 0); + } + if (grid.get(x)?.get(y + 1)?.[1] == 2) { + // down + children[0] = save_recursive(x, y + 1, 2); + } + return { part_type: part_type, children: children }; + } else if ( + part_type == PartType.Cargo || + part_type == PartType.LandingThruster + ) { + return { part_type: part_type, children: children }; } - if (grid.get(x + x_dir)?.get(y)?.[1] == (rotation+3)%4) { + if (grid.get(x + x_dir)?.get(y)?.[1] == (rotation + 3) % 4) { // left - children[3] = save_recursive(x + x_dir, y, rotation+3); + children[3] = save_recursive(x + x_dir, y, rotation + 3); } - if (grid.get(x - x_dir)?.get(y)?.[1] == (rotation+1)%4) { + if (grid.get(x - x_dir)?.get(y)?.[1] == (rotation + 1) % 4) { // right - children[1] = save_recursive(x - x_dir, y, rotation+1); + children[1] = save_recursive(x - x_dir, y, rotation + 1); } /*if (grid.get(x)?.get(y - y_dir)?.[1] == rotation) { // down