main
Yanick Champoux 2020-07-26 12:02:15 -04:00
parent 6deb92f9df
commit 1dd6be4b1a
5 changed files with 61 additions and 1 deletions

View File

@ -3,7 +3,9 @@
import shipStore from './stores/ship';
import ShipItem from './components/ShipItem/index.svelte';
import ShipCost from './components/ShipCost.svelte';
import Field from './components/Field/index.svelte';
import Hull from './components/Hull.svelte';
import Identification from './components/Identification.svelte';
import Firecons from './components/Firecons.svelte';
@ -11,6 +13,7 @@
import Propulsion from './components/Propulsion/index.svelte';
import Section from '~C/Section';
import Weapon from '~C/Weapon';
import Cargo from '~C/Cargo/index.svelte';
const ship = shipStore();
@ -78,6 +81,10 @@
</Section>
<Section label="misc">
<Cargo {...$ship.cargo} />
</Section>
</main>
<style>

View File

@ -0,0 +1,29 @@
<ShipItem {cost} {mass}>
<Field label="cargo">
<input type="number" min="0" bind:value={space}/>
</Field>
</ShipItem>
<script>
import get from 'lodash/get';
import ShipItem from '~C/ShipItem/index.svelte';
import Field from '~C/Field/index.svelte';
import {getContext} from 'svelte';
const ship = getContext('ship');
export let space = 0;
export let cost = 0;
export let mass = 0;
export let set_cargo = get(ship,'dispatch.set_cargo',() => {});
$: set_cargo( space );
</script>
<style>
input {
width: 5em;
}
</style>

22
src/dux/cargo/index.js Normal file
View File

@ -0,0 +1,22 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import { createSelector } from "reselect";
const dux = new Updux({
initial: {
space: 0,
cost: 0,
mass: 0,
},
});
const set_cargo = action('set_cargo',payload());
dux.addMutation(set_cargo, space => () => ({
space,
cost: 0,
mass: space,
}));
export default dux.asDux;

View File

@ -10,6 +10,7 @@ import { calc_ftl_reqs } from "./ftl/rules";
import { calc_ship_req } from "./utils";
import { candidate_ship_types } from './ship_types';
import structure from './structure';
import cargo from './cargo';
const set_ship_mass = action("set_ship_mass", payload());
const set_name = action("set_name", payload());
@ -33,7 +34,7 @@ const initial = {
};
const dux = new Updux({
subduxes: { ftl, engine, weaponry, structure },
subduxes: { ftl, engine, weaponry, structure, cargo },
initial
});

View File

@ -31,6 +31,7 @@ module.exports = {
options: {
emitCss: true,
hotReload: true,
dev: true,
},
},
},