adfc component

This commit is contained in:
Yanick Champoux 2022-03-06 14:49:20 -05:00
parent 161175c3c9
commit 55a9a17dc1
4 changed files with 39 additions and 18 deletions

View File

@ -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;

View 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>

View File

@ -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>

View File

@ -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;