cargo
This commit is contained in:
parent
6deb92f9df
commit
1dd6be4b1a
@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
import shipStore from './stores/ship';
|
import shipStore from './stores/ship';
|
||||||
|
|
||||||
|
import ShipItem from './components/ShipItem/index.svelte';
|
||||||
import ShipCost from './components/ShipCost.svelte';
|
import ShipCost from './components/ShipCost.svelte';
|
||||||
|
import Field from './components/Field/index.svelte';
|
||||||
import Hull from './components/Hull.svelte';
|
import Hull from './components/Hull.svelte';
|
||||||
import Identification from './components/Identification.svelte';
|
import Identification from './components/Identification.svelte';
|
||||||
import Firecons from './components/Firecons.svelte';
|
import Firecons from './components/Firecons.svelte';
|
||||||
@ -11,6 +13,7 @@
|
|||||||
import Propulsion from './components/Propulsion/index.svelte';
|
import Propulsion from './components/Propulsion/index.svelte';
|
||||||
import Section from '~C/Section';
|
import Section from '~C/Section';
|
||||||
import Weapon from '~C/Weapon';
|
import Weapon from '~C/Weapon';
|
||||||
|
import Cargo from '~C/Cargo/index.svelte';
|
||||||
|
|
||||||
const ship = shipStore();
|
const ship = shipStore();
|
||||||
|
|
||||||
@ -78,6 +81,10 @@
|
|||||||
|
|
||||||
</Section>
|
</Section>
|
||||||
|
|
||||||
|
<Section label="misc">
|
||||||
|
<Cargo {...$ship.cargo} />
|
||||||
|
</Section>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
29
src/components/Cargo/index.svelte
Normal file
29
src/components/Cargo/index.svelte
Normal 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
22
src/dux/cargo/index.js
Normal 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;
|
@ -10,6 +10,7 @@ import { calc_ftl_reqs } from "./ftl/rules";
|
|||||||
import { calc_ship_req } from "./utils";
|
import { calc_ship_req } from "./utils";
|
||||||
import { candidate_ship_types } from './ship_types';
|
import { candidate_ship_types } from './ship_types';
|
||||||
import structure from './structure';
|
import structure from './structure';
|
||||||
|
import cargo from './cargo';
|
||||||
|
|
||||||
const set_ship_mass = action("set_ship_mass", payload());
|
const set_ship_mass = action("set_ship_mass", payload());
|
||||||
const set_name = action("set_name", payload());
|
const set_name = action("set_name", payload());
|
||||||
@ -33,7 +34,7 @@ const initial = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const dux = new Updux({
|
const dux = new Updux({
|
||||||
subduxes: { ftl, engine, weaponry, structure },
|
subduxes: { ftl, engine, weaponry, structure, cargo },
|
||||||
initial
|
initial
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ module.exports = {
|
|||||||
options: {
|
options: {
|
||||||
emitCss: true,
|
emitCss: true,
|
||||||
hotReload: true,
|
hotReload: true,
|
||||||
|
dev: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user