This commit is contained in:
Yanick Champoux 2020-07-27 14:14:05 -04:00
parent 103b1a2bd1
commit 809572006f
4 changed files with 48 additions and 0 deletions

View File

@ -16,6 +16,7 @@
import Cargo from '~C/Cargo/index.svelte';
import Streamlining from '~C/Streamlining/index.svelte';
import Carrier from '~C/Carrier';
import ADFC from '~C/Weaponry/ADFC';
const ship = shipStore();
@ -79,6 +80,8 @@
<Firecons { ... $ship.weaponry.firecons }
on:change_firecons={ change_firecons }/>
<ADFC {...$ship.weaponry.adfc } />
<input type="button" value="add weapon" on:click={add_weapon}/>
{#each weapons as weapon (weapon.id)}

View File

@ -0,0 +1,26 @@
<ShipItem {cost} {mass}>
<Field label="ADFC">
<input type="number" bind:value={rating} />
</Field>
</ShipItem>
<script>
import get from 'lodash/get';
import ShipItem from '~C/ShipItem/index.svelte';
import Field from '~C/Field/index.svelte';
import dux from '~/dux';
import {getContext } from 'svelte';
export let rating = 0;
export let cost = 0;
export let mass = 0;
export let ship_change = getContext('ship_change') || ( () => {} );
$: ship_change( dux.actions.set_adfc(rating));
</script>
<style>
div { display: flex }
</style>

View File

@ -0,0 +1,17 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
const dux = new Updux({
initial: {
rating: 0,
cost: 0,
mass: 0,
},
})
dux.addMutation( action( 'set_adfc', payload() ), rating =>
u({ rating, mass: 2 * rating, cost: 8 * rating })
);
export default dux.asDux;

View File

@ -4,6 +4,7 @@ import u from "updeep";
import { createSelector } from "reselect";
import weapons from './weapons';
import adfc from './adfc';
const dux = new Updux({
initial: {
@ -13,6 +14,7 @@ const dux = new Updux({
},
subduxes: {
weapons,
adfc,
}
})