This commit is contained in:
Yanick Champoux 2020-07-27 15:26:07 -04:00
parent 6932a7cca1
commit 13df19ccfa
2 changed files with 10 additions and 13 deletions

View File

@ -36,7 +36,6 @@
const change_hull = ({detail}) => ship.dispatch.set_hull(detail);
const change_firecons = ({detail}) => ship.dispatch.set_firecons(detail);
const change_weapon = ({detail}) => ship.dispatch.set_weapon(detail);
const remove_weapon = ({detail}) => ship.dispatch.remove_weapon(detail);
let weapons = [];
$: console.log(weapons);
@ -86,7 +85,7 @@
{#each weapons as weapon (weapon.id)}
<Weapon {...weapon} on:change_weapon={change_weapon}
on:remove_weapon={remove_weapon} />
/>
{/each}

View File

@ -41,6 +41,8 @@
</ShipItem>
<script>
import {getContext } from 'svelte';
import Arc from '../Weapons/Arc.svelte';
import { weapon_cost_mass } from '../../dux/weapons/rules.js';
import fp from 'lodash/fp';
@ -48,6 +50,8 @@
import { createEventDispatcher } from 'svelte';
import ShipItem from '~C/ShipItem';
import Field from '~C/Field';
import dux from '~/dux';
const all_arcs = [ 'FS', 'F', 'FP', 'AP', 'A', 'AS' ];
@ -57,6 +61,7 @@
export let arcs = [];
export let cost;
export let mass;
export let ship_change = getContext('ship_change') || ( () => {} );
let arc_options = {
1: [ 6],
@ -110,21 +115,14 @@
let i = 1;
$: if(weapon_class) i = 1;
$: console.log( "id", id);
$: console.log( "weapon_class", weapon_class);
$: console.log( "weapon_type", weapon_type);
$: console.log( "arcs", arcs);
const dispatch = createEventDispatcher();
let cache = '';
$: cache = arcs.join(":");
$: {
//console.log( { id, weapon_class, weapon_type, arcs: cache.split(":") });
dispatch( 'change_weapon', { id, weapon_class, weapon_type, arcs:
cache.split(":") });
}
const remove = () => ship_change( dux.actions.remove_weapon(id) );
const remove = () => dispatch( 'remove_weapon', id );
$: ship_change( dux.actions.set_weapon({
id, weapon_class, weapon_type, arcs: cache.split(":")
}));
</script>