print beam

This commit is contained in:
Yanick Champoux 2023-04-28 11:18:31 -04:00
parent c055b15c81
commit 8d1cd7533e
7 changed files with 83 additions and 16 deletions

View File

@ -0,0 +1,19 @@
<div>
{#each Array.from({ length: stations }) as firecon}
<img class="firecon" src="/icons/firecon.svg" alt="firecon" />
{/each}
</div>
<script>
export let stations = 0;
</script>
<style>
div {
display: flex;
gap: 0.5em;
}
img.firecon {
width: 1em;
}
</style>

View File

@ -1,11 +1,4 @@
<div <div>
style:transform={uiTransform}
use:movable={{
disabled: !isMovable,
ship,
system: ["weapon", id],
}}
>
<Arcs selected={arcs} size="40"> <Arcs selected={arcs} size="40">
<text x="50%" y="50%"> <text x="50%" y="50%">
{weaponClass} {weaponClass}
@ -14,20 +7,12 @@
</div> </div>
<script> <script>
import { getContext } from "svelte";
import { movable } from "../../movable.js";
import Arcs from "$lib/components/ShipEdit/Weaponry/Weapon/Arcs.svelte"; import Arcs from "$lib/components/ShipEdit/Weaponry/Weapon/Arcs.svelte";
export let weaponClass = 1; export let weaponClass = 1;
export let arcs = []; export let arcs = [];
export let uiTransform = "";
export let isMovable = false;
export let id = -1;
const ship = getContext("ship");
</script> </script>
<style> <style>
div :global(path) {
}
div :global(path:hover) { div :global(path:hover) {
fill: white; fill: white;
} }

View File

@ -0,0 +1,24 @@
<Hst.Story title="Export/PrintShip/Weapons">
<svelte:component this={weaponComp} {...initial} />
<svelte:fragment slot="controls">
<Hst.Select bind:value={type} {options} title="weapon type" />
</svelte:fragment>
</Hst.Story>
<script>
import printComps from "./printComps.js";
import { weaponTypes } from "$lib/store/ship/weaponry/rules.ts";
export let Hst;
const types = weaponTypes.map(({ type }) => type);
let type = types[0];
$: options = Object.fromEntries(types.map((t) => [t, t]));
console.log(type);
$: initial = types.find((t) => t.type === type)?.initial ?? {};
$: weaponComp = printComps[type];
</script>

View File

@ -0,0 +1,10 @@
<div>TODO</div>
<script>
</script>
<style>
div {
background-color: red;
}
</style>

View File

@ -0,0 +1,12 @@
import { render, fireEvent } from "@testing-library/svelte";
import "@testing-library/jest-dom";
import { weaponTypes } from "$lib/store/ship/weaponry/rules";
import printComp from "./printComp.js";
describe("all weapons have a print component", () => {
test.each(weaponTypes)("$type", ({ type, initial }) => {
expect(printComp).toHaveProperty(type);
render(printComp[type], { props: initial });
});
});

View File

@ -0,0 +1,5 @@
import Beam from "./Beam.svelte";
export default {
beam: Beam,
};

View File

@ -3,6 +3,8 @@
<div class="print-output"> <div class="print-output">
<Identification {...identification} /> <Identification {...identification} />
<Weapons {weapons} />
<div class="grid"> <div class="grid">
<div class="s6"> <div class="s6">
<Armor layers={structure?.armor?.layers} /> <Armor layers={structure?.armor?.layers} />
@ -15,6 +17,7 @@
<div class="s6"> <div class="s6">
<Screens {...screens} /> <Screens {...screens} />
<Firecons {...firecons} />
</div> </div>
</div> </div>
@ -27,12 +30,17 @@
import Hull from "./Hull/index.svelte"; import Hull from "./Hull/index.svelte";
import Armor from "./Armor/index.svelte"; import Armor from "./Armor/index.svelte";
import Screens from "./Screens/index.svelte"; import Screens from "./Screens/index.svelte";
import Firecons from "./Firecons/index.svelte";
import Weapons from "./Weapons/index.svelte";
export let identification = {}; export let identification = {};
export let propulsion = {}; export let propulsion = {};
export let structure = {}; export let structure = {};
export let weaponry = {};
$: screens = structure?.screens ?? {}; $: screens = structure?.screens ?? {};
$: firecons = weaponry?.firecons ?? {};
$: weapons = weaponry?.weapons ?? [];
</script> </script>
<style> <style>
@ -57,4 +65,8 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.s6 :global(> div) {
margin-bottom: 1em;
}
</style> </style>