needle
This commit is contained in:
parent
752330bdf5
commit
b3fa0917f3
@ -1,6 +1,6 @@
|
|||||||
<label>needle weapon</label>
|
<label>needle weapon</label>
|
||||||
|
|
||||||
<Arcs selected={arcs} on:click_arc={({ detail }) => click_arc(detail)} />
|
<Arcs selected={[arc]} on:click_arc={({ detail }) => click_arc(detail)} />
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte";
|
import { getContext } from "svelte";
|
||||||
@ -9,18 +9,13 @@
|
|||||||
|
|
||||||
const all_arcs = ["FS", "F", "FP", "AP", "A", "AS"];
|
const all_arcs = ["FS", "F", "FP", "AP", "A", "AS"];
|
||||||
|
|
||||||
export let arcs = ["F"];
|
export let arc = "F";
|
||||||
|
|
||||||
const click_arc = (arc) => {
|
|
||||||
console.log(arc);
|
|
||||||
return;
|
|
||||||
if (arcs[0] === arc) return;
|
|
||||||
arcs = [arc];
|
|
||||||
};
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
$: dispatch("change", { arcs });
|
const click_arc = (arc) => {
|
||||||
|
dispatch("change",{arc});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -8,7 +8,8 @@ export const weaponTypes = [
|
|||||||
{ name: 'submunition pack', type: 'submunition', reqs: { mass:1, cost:3 }},
|
{ name: 'submunition pack', type: 'submunition', reqs: { mass:1, cost:3 }},
|
||||||
{ name: 'point defence system', type: 'pds', reqs: {mass:1,cost:3}},
|
{ name: 'point defence system', type: 'pds', reqs: {mass:1,cost:3}},
|
||||||
{ name: 'scattergun', type: 'scattergun', reqs: { mass:1,cost:4 }},
|
{ name: 'scattergun', type: 'scattergun', reqs: { mass:1,cost:4 }},
|
||||||
{ name: 'needle weapon', type: 'needle', reqs: { mass: 2, cost: 6 }},
|
{ name: 'needle weapon', type: 'needle', reqs: { mass: 2, cost: 6 },
|
||||||
|
initial: { arc: 'F' }},
|
||||||
];
|
];
|
||||||
|
|
||||||
const dux = new Updux({
|
const dux = new Updux({
|
||||||
@ -16,12 +17,17 @@ const dux = new Updux({
|
|||||||
actions: {
|
actions: {
|
||||||
addWeapon: null,
|
addWeapon: null,
|
||||||
removeWeapon: null,
|
removeWeapon: null,
|
||||||
|
setWeapon: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dux.setMutation('setWeapon', ({id,...rest}) =>
|
||||||
|
u.map( u.if( (w) => w.id === id, { ...rest }))
|
||||||
|
);
|
||||||
|
|
||||||
dux.setMutation('removeWeapon', id => state => [
|
dux.setMutation('removeWeapon', id => state => [
|
||||||
...state.filter( (w) => w.id !== id )
|
...state.filter( (w) => w.id !== id )
|
||||||
])
|
]);
|
||||||
|
|
||||||
dux.setMutation('addWeapon', type => state => {
|
dux.setMutation('addWeapon', type => state => {
|
||||||
return [
|
return [
|
||||||
@ -30,6 +36,7 @@ dux.setMutation('addWeapon', type => state => {
|
|||||||
id: state.length === 0 ? 1 : state[state.length -1]+1,
|
id: state.length === 0 ? 1 : state[state.length -1]+1,
|
||||||
type,
|
type,
|
||||||
reqs: weaponReqs({type}),
|
reqs: weaponReqs({type}),
|
||||||
|
...weaponTypes.find(w => w.type === type ).initial,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user