adfc component
This commit is contained in:
parent
161175c3c9
commit
55a9a17dc1
@ -1,17 +0,0 @@
|
||||
import Updux from "updux";
|
||||
import { action, payload } from "ts-action";
|
||||
import u from "@yanick/updeep";
|
||||
|
||||
const dux = new Updux({
|
||||
initial: {
|
||||
rating: 0,
|
||||
cost: 0,
|
||||
mass: 0,
|
||||
},
|
||||
})
|
||||
|
||||
dux.addMutation( action( 'set_adfc', payload() ), rating =>
|
||||
u.update({ rating, mass: 2 * rating, cost: 8 * rating })
|
||||
);
|
||||
|
||||
export default dux.asDux;
|
18
src/lib/components/ShipEdit/Weaponry/ADFC.svelte
Normal file
18
src/lib/components/ShipEdit/Weaponry/ADFC.svelte
Normal file
@ -0,0 +1,18 @@
|
||||
<ShipItem {...reqs}>
|
||||
<Field label="ADFC">
|
||||
<input type="number" class="short" bind:value={rating} />
|
||||
</Field>
|
||||
</ShipItem>
|
||||
|
||||
<script>
|
||||
import { getContext } from 'svelte';
|
||||
import ShipItem from "$lib/components/ShipItem/index.svelte";
|
||||
import Field from "$lib/components/Field/index.svelte";
|
||||
|
||||
export let rating = 0;
|
||||
export let reqs = {};
|
||||
|
||||
const { dispatch } = getContext('ship');
|
||||
|
||||
$: dispatch.setADFC(rating);
|
||||
</script>
|
@ -1,14 +1,21 @@
|
||||
<Section label="weaponry">
|
||||
<Firecons {...firecons} />
|
||||
|
||||
<ADFC {...adfc} />
|
||||
</Section>
|
||||
|
||||
<script>
|
||||
import { getContext } from 'svelte';
|
||||
|
||||
import Section from "$lib/components/Section/index.svelte";
|
||||
import ShipItem from '$lib/components/ShipItem/index.svelte';
|
||||
import Field from '$lib/components/Field/index.svelte';
|
||||
|
||||
import Firecons from './Firecons.svelte';
|
||||
import ADFC from './ADFC.svelte';
|
||||
|
||||
export let firecons = {};
|
||||
|
||||
export let adfc = {};
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -9,8 +9,10 @@ const dux = new Updux({
|
||||
stations: 0,
|
||||
reqs,
|
||||
},
|
||||
adfc: { rating: 0, reqs },
|
||||
},
|
||||
actions: {
|
||||
setADFC: null,
|
||||
setFirecons: null,
|
||||
},
|
||||
});
|
||||
@ -26,5 +28,16 @@ dux.setMutation("setFirecons", (stations) =>
|
||||
},
|
||||
})
|
||||
);
|
||||
dux.setMutation("setADFC", (rating) =>
|
||||
u({
|
||||
adfc: {
|
||||
rating,
|
||||
reqs: {
|
||||
cost: 8 * rating,
|
||||
mass: 2 * rating,
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
export default dux;
|
||||
|
Loading…
Reference in New Issue
Block a user