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

View File

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