diff --git a/src/App.svelte b/src/App.svelte
index 941eac4..646fef4 100644
--- a/src/App.svelte
+++ b/src/App.svelte
@@ -9,7 +9,6 @@
import Hull from './components/Hull.svelte';
import Identification from './components/Identification.svelte';
import Firecons from './components/Firecons.svelte';
- import AddWeapon from './components/Weapons/Add.svelte';
import Propulsion from './components/Propulsion/index.svelte';
import Section from '~C/Section';
import Weapon from '~C/Weapon';
@@ -17,6 +16,7 @@
import Streamlining from '~C/Streamlining/index.svelte';
import Carrier from '~C/Carrier';
import ADFC from '~C/Weaponry/ADFC';
+ import AddWeapon from '~C/Weaponry/AddWeapon';
const ship = shipStore();
@@ -81,7 +81,7 @@
-
+
{#each weapons as weapon (weapon.id)}
diff --git a/src/components/Weapon/Arcs/index.svelte b/src/components/Weapon/Arcs/index.svelte
new file mode 100644
index 0000000..870835c
--- /dev/null
+++ b/src/components/Weapon/Arcs/index.svelte
@@ -0,0 +1,30 @@
+
+
+
+
+
+
diff --git a/src/components/Weapon/Beam/index.svelte b/src/components/Weapon/Beam/index.svelte
index 8e00819..a5ffca5 100644
--- a/src/components/Weapon/Beam/index.svelte
+++ b/src/components/Weapon/Beam/index.svelte
@@ -1,5 +1,6 @@
+
-
+
-
-
+ click_arc(detail)} />
+
+
+
diff --git a/src/components/Weapon/PointDefenceSystem/index.svelte b/src/components/Weapon/PointDefenceSystem/index.svelte
new file mode 100644
index 0000000..27f4aa9
--- /dev/null
+++ b/src/components/Weapon/PointDefenceSystem/index.svelte
@@ -0,0 +1,2 @@
+
+
diff --git a/src/components/Weapon/Scattergun/index.svelte b/src/components/Weapon/Scattergun/index.svelte
new file mode 100644
index 0000000..de8a6e0
--- /dev/null
+++ b/src/components/Weapon/Scattergun/index.svelte
@@ -0,0 +1,2 @@
+
+
diff --git a/src/components/Weapon/Submunition/index.svelte b/src/components/Weapon/Submunition/index.svelte
new file mode 100644
index 0000000..ff41ed5
--- /dev/null
+++ b/src/components/Weapon/Submunition/index.svelte
@@ -0,0 +1,37 @@
+
+ click_arc(detail)} />
+
+
+
+
+
diff --git a/src/components/Weapon/index.svelte b/src/components/Weapon/index.svelte
index aa97361..ed76f48 100644
--- a/src/components/Weapon/index.svelte
+++ b/src/components/Weapon/index.svelte
@@ -2,11 +2,6 @@
X
-
-
-
@@ -23,10 +18,18 @@
import ShipItem from '~C/ShipItem';
import Field from '~C/Field';
import Beam from './Beam';
+ import Submunition from './Submunition';
+ import PointDefenceSystem from './PointDefenceSystem';
+ import Scattergun from './Scattergun';
+ import Needle from './Needle';
import dux from '~/dux';
const weapon_component = {
beam: Beam,
+ 'submunition': Submunition,
+ 'pds': PointDefenceSystem,
+ scattergun: Scattergun,
+ needle: Needle,
};
export let weapon = {};
@@ -35,11 +38,11 @@
export let mass;
export let ship_change = getContext('ship_change') || ( () => {} );
- let weapon_type;
- $: weapon_type = weapon.weapon_type;
+ let weapon_type = weapon.weapon_type;
const remove = () => ship_change( dux.actions.remove_weapon(id) );
+
const update = ({detail}) => {
ship_change( dux.actions.set_weapon({
id, weapon_type, ...detail
diff --git a/src/components/Weaponry/AddWeapon/index.svelte b/src/components/Weaponry/AddWeapon/index.svelte
new file mode 100644
index 0000000..b880e92
--- /dev/null
+++ b/src/components/Weaponry/AddWeapon/index.svelte
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/dux/weaponry/weapons/index.js b/src/dux/weaponry/weapons/index.js
index c831760..896aad2 100644
--- a/src/dux/weaponry/weapons/index.js
+++ b/src/dux/weaponry/weapons/index.js
@@ -2,24 +2,43 @@ import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import { createSelector } from "reselect";
+import { weapon_cost_mass } from '../../weapons/rules';
-import weapon from './weapon';
-
-const add_weapon = action('add_weapon');
+const add_weapon = action('add_weapon', payload());
const remove_weapon = action('remove_weapon', payload());
+const uu = transform => state => transform(state)(state)
+
+const with_reqs = uu( weapon => u(weapon_cost_mass(weapon)));
+
const dux = new Updux({
initial: [],
- subduxes: { '*': weapon }
})
-dux.addMutation( add_weapon, () => state => {
+const weapon_initial = {
+ beam: { weapon_type: "beam", weapon_class: 1, arcs: ['F'] },
+ submunition: {
+ weapon_type: "submunition", arcs: ['F'] },
+ pds: { weapon_type: 'pds' },
+ scattergun: { weapon_type: 'scattergun' },
+ needle: { weapon_type: 'needle', arcs: ['F'] },
+};
+
+dux.addMutation( add_weapon, (type) => state => {
const id = 1 + Math.max( 0, ... state.map(({id})=>id) );
- return [ ...state, { ...weapon.initial, id }];
+ return [ ...state, { ...with_reqs(weapon_initial[type]), id }];
});
dux.addMutation( remove_weapon, id => state =>
state.filter( w => w.id !== id )
);
+const set_weapon = action('set_weapon',payload());
+
+dux.addMutation(
+ set_weapon, payload => u.map( u.if( _.matches({id: payload.id}),
+ state => with_reqs(u(payload,state)) )
+ )
+);
+
export default dux.asDux;
diff --git a/src/dux/weaponry/weapons/weapon/index.js b/src/dux/weaponry/weapons/weapon/index.js
deleted file mode 100644
index 849a495..0000000
--- a/src/dux/weaponry/weapons/weapon/index.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import Updux from "updux";
-import { action, payload } from "ts-action";
-import u from "updeep";
-import { createSelector } from "reselect";
-import { weapon_cost_mass } from '../../../weapons/rules';
-
-const uu = transform => state => transform(state)(state)
-
-const with_reqs = uu( weapon => u(weapon_cost_mass(weapon)));
-
-const initial = with_reqs({
- weapon_type: 'beam',
- weapon_class: 1,
- });
-
-console.log(initial);
-
-const dux = new Updux({
- initial
-});
-
-const set_weapon = action('set_weapon',payload());
-
-dux.addMutation(
- set_weapon, payload => u.if( s => s.id === payload.id,
- state => with_reqs(u(payload,state))
- )
-)
-
-export default dux.asDux;
diff --git a/src/dux/weapons/rules.js b/src/dux/weapons/rules.js
index f0fe61b..77d5c4d 100644
--- a/src/dux/weapons/rules.js
+++ b/src/dux/weapons/rules.js
@@ -7,6 +7,21 @@ export function weapon_cost_mass(weapon){
return beam_cost_mass(weapon);
}
+ if( weapon.weapon_type == 'submunition' ) {
+ return { mass: 1, cost: 3 };
+ }
+
+ if( weapon.weapon_type === 'pds' ) {
+ return { mass: 1, cost: 3 };
+ }
+
+ if( weapon.weapon_type === 'scattergun' ) {
+ return { mass: 1, cost: 4 };
+ }
+
+ if( weapon.weapon_type === 'needle' ) {
+ return { mass: 2, cost: 6 };
+ }
return { cost, mass };
}