hull integrity

This commit is contained in:
Yanick Champoux 2020-07-29 15:56:19 -04:00
parent 7ad0491b70
commit 02fd6dd1c5
5 changed files with 159 additions and 12 deletions

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
viewBox="0 0 170.3 161.89999"
enable-background="new 0 0 960 560"
xml:space="preserve"
sodipodi:docname="crew-star.svg"
width="170.3"
height="161.89999"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"><metadata
id="metadata13"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs11">
</defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="957"
id="namedview9"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="0.36770833"
inkscape:cx="314"
inkscape:cy="98.2"
inkscape:window-x="0"
inkscape:window-y="34"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" />
<polygon
id="polygon4"
points="303.8,378.2 251.2,340 198.5,378.2 218.6,316.4 166,278.1 231.1,278.1 251.2,216.3 271.3,278.1 336.3,278.1 283.7,316.4 "
transform="translate(-166,-216.3)" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 960 560" enable-background="new 0 0 960 560" xml:space="preserve">
<g>
<rect x="436.1" y="101.1" fill="none" stroke="#000000" stroke-width="15.485" stroke-miterlimit="10" width="357.9" height="357.9"/>
<polygon points="251.2,216.3 271.3,278.1 336.3,278.1 283.7,316.4 303.8,378.2 251.2,340 198.5,378.2 218.6,316.4 166,278.1
231.1,278.1 "/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 746 B

View File

@ -0,0 +1,72 @@
<div>
{#each rows as row (row)}
<div class="row">
{#each row as item (item)}
<div class="cell">
{#if item}
<img src="icons/crew-star.svg" alt="crew loss threshold" />
{/if}
</div>
{/each}
</div>
{/each}
</div>
<script>
import { ceil } from '~/dux/utils';
export let ship_mass = 0;
export let rating = 0;
export let advanced = false;
let nbr_rows;
$: nbr_rows = advanced ? 3 : 4;
let cells;
$: cells = Array(rating).fill(false);
let dcp;
$: dcp= ceil(ship_mass/20);
$: cells = divide(cells, dcp).map(
g => {
g[g.length-1] = true;
return g;
}
).flat();
function divide(list, divider) {
if( divider <= 1 ) return [ list ];
let div = list.length / divider;
const mod = list.length % divider;
if(mod) div++;
return [
list.slice(0,div),
...divide( list.slice(div), divider-1 )
]
}
let rows = [];
$: rows = divide( cells, nbr_rows );
</script>
<style>
.row {
}
.cell {
display: inline-block;
margin-right: 0.5em;
width: 1em;
height: 1em;
border: 1px solid black;
}
img {
width: 1em;
}
</style>

View File

@ -0,0 +1,23 @@
import Component from '.';
export default {
title: "printouts/hull/integrity"
};
export const basic = () => ({
Component,
props: {
ship_mass: 50,
rating: 14,
advanced: false,
}
});
export const advanced = () => ({
Component,
props: {
ship_mass: 50,
rating: 14,
advanced: true,
}
});

View File

@ -1,9 +1,15 @@
<div>
<Identification {...ship.general} />
<Integrity
rating={ship.structure.hull.rating}
advanced={ship.structure.hull.advanced}
ship_mass={ship.general.mass}
/>
</div>
<script>
import Identification from './Identification';
import Integrity from './Hull/Integrity';
export let ship;
</script>