add print cargo

This commit is contained in:
Yanick Champoux 2023-04-30 12:08:42 -04:00
parent 406d8dc6e3
commit 288fc0a907
6 changed files with 174 additions and 111 deletions

View File

@ -0,0 +1,33 @@
{#if space}
<div class="grid">
<div class="s2">cargo</div>
<div class="s10">
{#each Array.from({ length: space }) as _, i (i)}
<div class="cell" />
{/each}
</div>
</div>
{/if}
<script>
export let space;
</script>
<style>
.cell {
display: inline-block;
margin-right: 0.5em;
margin-top: 0.5em;
width: 1.5em;
height: 1.5em;
border: 1px solid black;
}
div.s2 {
margin-top: 0.5em;
text-align: right;
}
div.m9 {
display: flex;
flex-wrap: wrap;
}
</style>

View File

@ -1 +0,0 @@
Yo!

View File

@ -4,116 +4,9 @@
<script> <script>
import PrintShip from "./index.svelte"; import PrintShip from "./index.svelte";
import { weaponTypes } from "$lib/store/ship/weaponry/rules"; import sampleShip from "./sample-ship.ts";
export let Hst; export let Hst;
const weapons = weaponTypes.map(({ initial: specs }, id) => ({ const ship = sampleShip;
id: id + 1,
specs,
}));
const ship = {
schemaVersion: "1",
identification: {
shipType: "Scout",
shipClass: "Bonobo",
isCarrier: false,
reqs: {
mass: 10,
cost: 10,
usedMass: 4,
},
},
structure: {
streamlining: {
type: "none",
reqs: {
cost: 0,
mass: 0,
},
},
cargo: {
space: 0,
reqs: {
cost: 0,
mass: 0,
},
},
hull: {
rating: 10,
min: 1,
max: 10,
reqs: {
cost: 0,
mass: 0,
},
},
screens: {
standard: 2,
advanced: 1,
reqs: {
cost: 0,
mass: 0,
},
},
armor: {
reqs: {
cost: 0,
mass: 0,
},
layers: [3, 2],
},
carrier: {
nbrBays: 0,
squadrons: [],
reqs: {
cost: 0,
mass: 0,
},
},
},
propulsion: {
ftl: {
reqs: {
cost: 2,
mass: 1,
},
type: "standard",
},
drive: {
rating: 1,
advanced: false,
reqs: {
cost: 2,
mass: 1,
},
},
},
carrier: {
nbrBays: 0,
squadrons: [],
reqs: {
cost: 0,
mass: 0,
},
},
weaponry: {
adfc: {
rating: 0,
reqs: {
cost: 0,
mass: 0,
},
},
firecons: {
stations: 0,
reqs: {
cost: 0,
mass: 0,
},
},
weapons,
},
};
</script> </script>

View File

@ -9,7 +9,7 @@
<div class="s6"> <div class="s6">
<Armor layers={structure?.armor?.layers} /> <Armor layers={structure?.armor?.layers} />
<Hull <Hull
shipMass={identification.reqs.mass} shipMass={identification.reqs?.mass}
advanced={false} advanced={false}
rating={structure.hull?.rating} rating={structure.hull?.rating}
/> />
@ -22,6 +22,8 @@
</div> </div>
<MainSystems {...propulsion} /> <MainSystems {...propulsion} />
<Cargo {...cargo} />
</div> </div>
<script> <script>
@ -32,12 +34,15 @@
import Screens from "./Screens/index.svelte"; import Screens from "./Screens/index.svelte";
import Firecons from "./Firecons/index.svelte"; import Firecons from "./Firecons/index.svelte";
import Weapons from "./Weapons/index.svelte"; import Weapons from "./Weapons/index.svelte";
import Cargo from "./Cargo.svelte";
export let identification = {}; export let identification = {};
export let propulsion = {}; export let propulsion = {};
export let structure = {}; export let structure = {};
export let weaponry = {}; export let weaponry = {};
$: cargo = structure.cargo ?? {};
$: screens = structure?.screens ?? {}; $: screens = structure?.screens ?? {};
$: firecons = weaponry?.firecons ?? {}; $: firecons = weaponry?.firecons ?? {};
$: weapons = weaponry?.weapons ?? []; $: weapons = weaponry?.weapons ?? [];

View File

@ -0,0 +1,23 @@
import { render } from "@testing-library/svelte";
import PrintShip from "./index.svelte";
describe("cargo", () => {
test("with", () => {
const { getByText } = render(PrintShip, {
props: {
structure: { cargo: { space: 10 } },
},
});
expect(getByText("cargo")).toBeTruthy();
});
test("without", () => {
const { queryByText } = render(PrintShip, {
props: {
structure: { cargo: { space: 0 } },
},
});
expect(queryByText("cargo")).toBeFalsy();
});
});

View File

@ -0,0 +1,110 @@
import { weaponTypes } from "$lib/store/ship/weaponry/rules";
const weapons = weaponTypes.map(({ initial: specs }, id) => ({
id: id + 1,
specs,
}));
export default {
schemaVersion: "1",
identification: {
shipType: "Scout",
shipClass: "Bonobo",
isCarrier: false,
reqs: {
mass: 10,
cost: 10,
usedMass: 4,
},
},
structure: {
streamlining: {
type: "none",
reqs: {
cost: 0,
mass: 0,
},
},
cargo: {
space: 20,
reqs: {
cost: 0,
mass: 0,
},
},
hull: {
rating: 10,
min: 1,
max: 10,
reqs: {
cost: 0,
mass: 0,
},
},
screens: {
standard: 2,
advanced: 1,
reqs: {
cost: 0,
mass: 0,
},
},
armor: {
reqs: {
cost: 0,
mass: 0,
},
layers: [3, 2],
},
carrier: {
nbrBays: 0,
squadrons: [],
reqs: {
cost: 0,
mass: 0,
},
},
},
propulsion: {
ftl: {
reqs: {
cost: 2,
mass: 1,
},
type: "standard",
},
drive: {
rating: 1,
advanced: false,
reqs: {
cost: 2,
mass: 1,
},
},
},
carrier: {
nbrBays: 0,
squadrons: [],
reqs: {
cost: 0,
mass: 0,
},
},
weaponry: {
adfc: {
rating: 0,
reqs: {
cost: 0,
mass: 0,
},
},
firecons: {
stations: 0,
reqs: {
cost: 0,
mass: 0,
},
},
weapons,
},
};