Merge branch 'docks49-cargo-print'
This commit is contained in:
commit
41b9c447c7
33
src/routes/export/print/PrintShip/Cargo.svelte
Normal file
33
src/routes/export/print/PrintShip/Cargo.svelte
Normal 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>
|
@ -1 +0,0 @@
|
||||
Yo!
|
@ -4,116 +4,9 @@
|
||||
|
||||
<script>
|
||||
import PrintShip from "./index.svelte";
|
||||
import { weaponTypes } from "$lib/store/ship/weaponry/rules";
|
||||
import sampleShip from "./sample-ship.ts";
|
||||
|
||||
export let Hst;
|
||||
|
||||
const weapons = weaponTypes.map(({ initial: specs }, id) => ({
|
||||
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,
|
||||
},
|
||||
};
|
||||
const ship = sampleShip;
|
||||
</script>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<div class="s6">
|
||||
<Armor layers={structure?.armor?.layers} />
|
||||
<Hull
|
||||
shipMass={identification.reqs.mass}
|
||||
shipMass={identification.reqs?.mass}
|
||||
advanced={false}
|
||||
rating={structure.hull?.rating}
|
||||
/>
|
||||
@ -22,6 +22,8 @@
|
||||
</div>
|
||||
|
||||
<MainSystems {...propulsion} />
|
||||
|
||||
<Cargo {...cargo} />
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@ -32,12 +34,15 @@
|
||||
import Screens from "./Screens/index.svelte";
|
||||
import Firecons from "./Firecons/index.svelte";
|
||||
import Weapons from "./Weapons/index.svelte";
|
||||
import Cargo from "./Cargo.svelte";
|
||||
|
||||
export let identification = {};
|
||||
export let propulsion = {};
|
||||
export let structure = {};
|
||||
export let weaponry = {};
|
||||
|
||||
$: cargo = structure.cargo ?? {};
|
||||
|
||||
$: screens = structure?.screens ?? {};
|
||||
$: firecons = weaponry?.firecons ?? {};
|
||||
$: weapons = weaponry?.weapons ?? [];
|
||||
|
23
src/routes/export/print/PrintShip/index.test.ts
Normal file
23
src/routes/export/print/PrintShip/index.test.ts
Normal 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();
|
||||
});
|
||||
});
|
110
src/routes/export/print/PrintShip/sample-ship.ts
Normal file
110
src/routes/export/print/PrintShip/sample-ship.ts
Normal 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,
|
||||
},
|
||||
};
|
Loading…
Reference in New Issue
Block a user