mirror of https://github.com/aotds/aotds-docks.git
15 changed files with 227 additions and 243 deletions
@ -1,30 +1,28 @@
@@ -1,30 +1,28 @@
|
||||
<ShipItem {cost} {mass}> |
||||
<Field label="cargo"> |
||||
<input type="number" min="0" bind:value={space}/> |
||||
<input type="number" min="0" bind:value={space} /> |
||||
</Field> |
||||
</ShipItem> |
||||
|
||||
<script> |
||||
import get from 'lodash/get.js'; |
||||
import ShipItem from '$lib/components/ShipItem/index.svelte'; |
||||
import Field from '$lib/components/Field/index.svelte'; |
||||
import dux from '$lib/dux/cargo'; |
||||
<script> |
||||
import ShipItem from "$lib/components/ShipItem/index.svelte"; |
||||
import Field from "$lib/components/Field/index.svelte"; |
||||
|
||||
import {getContext, createEventDispatcher} from 'svelte'; |
||||
import { getContext } from "svelte"; |
||||
|
||||
const ship = getContext('ship'); |
||||
export let ship = getContext("ship"); |
||||
|
||||
export let space = 0; |
||||
export let cost = 0; |
||||
export let mass = 0; |
||||
|
||||
const dispatch = createEventDispatcher(); |
||||
$: dispatch( 'set_cargo', dux.actions.set_cargo( space ) ); |
||||
$: ship?.dispatch_action("set_cargo", space); |
||||
|
||||
</script> |
||||
</script> |
||||
|
||||
<style> |
||||
<style> |
||||
input { |
||||
width: 5em; |
||||
} |
||||
</style> |
||||
|
||||
</style> |
||||
|
@ -1,111 +1,106 @@
@@ -1,111 +1,106 @@
|
||||
<label>beam</label> |
||||
|
||||
<Field label="beam class"> |
||||
<select bind:value={weapon_class}> |
||||
<option>1</option> |
||||
<option>2</option> |
||||
<option>3</option> |
||||
<option>4</option> |
||||
</select> |
||||
<select bind:value={weapon_class}> |
||||
<option>1</option> |
||||
<option>2</option> |
||||
<option>3</option> |
||||
<option>4</option> |
||||
</select> |
||||
</Field> |
||||
|
||||
<Field label="arcs"> |
||||
<select bind:value={nbr_arcs}> |
||||
{#each arc_options[weapon_class]||[] as nbr_arcs (nbr_arcs)} |
||||
<option>{nbr_arcs}</option> |
||||
{/each} |
||||
</select> |
||||
<select bind:value={nbr_arcs}> |
||||
{#each arc_options[weapon_class] || [] as nbr_arcs (nbr_arcs)} |
||||
<option>{nbr_arcs}</option> |
||||
{/each} |
||||
</select> |
||||
</Field> |
||||
|
||||
<Arcs selected={arcs} on:click_arc={({detail}) => click_arc(detail)} /> |
||||
<Arcs selected={arcs} on:click_arc={({ detail }) => click_arc(detail)} /> |
||||
|
||||
<script> |
||||
import {getContext } from 'svelte'; |
||||
import Arc from '../../Weapons/Arc.svelte'; |
||||
import Arcs from '../Arcs/index.svelte'; |
||||
import { weapon_cost_mass } from '$lib/dux/weapons/rules'; |
||||
import _ from 'lodash'; |
||||
import ShipItem from '$lib/components/ShipItem/index.svelte'; |
||||
import Field from '$lib/components/Field/index.svelte'; |
||||
import dux from '$lib/dux'; |
||||
import { createEventDispatcher } from 'svelte'; |
||||
|
||||
const all_arcs = [ 'FS', 'F', 'FP', 'AP', 'A', 'AS' ]; |
||||
|
||||
export let weapon_type; |
||||
export let id; |
||||
export let weapon_class = 1; |
||||
export let arcs = ['F']; |
||||
export let ship_change = getContext('ship_change') || ( () => {} ); |
||||
|
||||
let arc_options = { |
||||
1: [ 6], |
||||
2: [ 3, 6 ], |
||||
3: [ 1, 2, 3, 4, 5, 6, 'broadside' ], |
||||
4: [ 1, 2, 3, 4, 5, 6, 'broadside' ] |
||||
}; |
||||
|
||||
let nbr_arcs = 6; |
||||
$: nbr_arcs = arc_options[weapon_class][0]; |
||||
|
||||
$: console.log({arcs,nbr_arcs}) |
||||
|
||||
$: if ( arcs.length !== nbr_arcs ) { |
||||
if( nbr_arcs === 'broadside' ) { |
||||
arcs = all_arcs.filter( arc => arc.length === 1 ) |
||||
} |
||||
else{ |
||||
|
||||
let first_index = all_arcs.findIndex( arc => arcs[0] ); |
||||
if( first_index === -1 ) first_index = 0; |
||||
|
||||
const new_arcs = []; |
||||
|
||||
_.range(nbr_arcs).forEach( i => { |
||||
new_arcs.push( all_arcs[first_index] ) |
||||
first_index = ( first_index + 1 ) % all_arcs.length; |
||||
}); |
||||
|
||||
arcs = new_arcs; |
||||
} |
||||
import { getContext } from "svelte"; |
||||
import Arc from "../../Weapons/Arc.svelte"; |
||||
import Arcs from "../Arcs/index.svelte"; |
||||
import { weapon_cost_mass } from "$lib/dux/weapons/rules"; |
||||
import _ from "lodash"; |
||||
import ShipItem from "$lib/components/ShipItem/index.svelte"; |
||||
import Field from "$lib/components/Field/index.svelte"; |
||||
import dux from "$lib/dux"; |
||||
import { createEventDispatcher } from "svelte"; |
||||
|
||||
const all_arcs = ["FS", "F", "FP", "AP", "A", "AS"]; |
||||
|
||||
export let weapon_class = 1; |
||||
export let arcs = ["F"]; |
||||
export let id; |
||||
|
||||
let arc_options = { |
||||
1: [6], |
||||
2: [3, 6], |
||||
3: [1, 2, 3, 4, 5, 6, "broadside"], |
||||
4: [1, 2, 3, 4, 5, 6, "broadside"], |
||||
}; |
||||
|
||||
let nbr_arcs = 6; |
||||
$: nbr_arcs = arc_options[weapon_class][0]; |
||||
|
||||
$: console.log({ arcs, nbr_arcs }); |
||||
|
||||
$: if (arcs.length !== nbr_arcs) { |
||||
if (nbr_arcs === "broadside") { |
||||
arcs = all_arcs.filter((arc) => arc.length === 1); |
||||
} else { |
||||
let first_index = all_arcs.findIndex((arc) => arcs[0]); |
||||
if (first_index === -1) first_index = 0; |
||||
|
||||
const new_arcs = []; |
||||
|
||||
_.range(nbr_arcs).forEach((i) => { |
||||
new_arcs.push(all_arcs[first_index]); |
||||
first_index = (first_index + 1) % all_arcs.length; |
||||
}); |
||||
|
||||
arcs = new_arcs; |
||||
} |
||||
} |
||||
|
||||
const click_arc = (first_arc) => { |
||||
if( nbr_arcs === 'broadside' ) return; |
||||
const click_arc = (first_arc) => { |
||||
if (nbr_arcs === "broadside") return; |
||||
|
||||
let first_index = all_arcs.findIndex( arc => arc === first_arc ); |
||||
let first_index = all_arcs.findIndex((arc) => arc === first_arc); |
||||
|
||||
const new_arcs = []; |
||||
const new_arcs = []; |
||||
|
||||
_.range(nbr_arcs).forEach( i => { |
||||
new_arcs.push( all_arcs[first_index] ); |
||||
first_index = ( first_index + 1 ) % all_arcs.length; |
||||
}); |
||||
_.range(nbr_arcs).forEach((i) => { |
||||
new_arcs.push(all_arcs[first_index]); |
||||
first_index = (first_index + 1) % all_arcs.length; |
||||
}); |
||||
|
||||
arcs = new_arcs; |
||||
arcs = new_arcs; |
||||
}; |
||||
|
||||
} |
||||
let i = 1; |
||||
$: if (weapon_class) i = 1; |
||||
|
||||
let i = 1; |
||||
$: if(weapon_class) i = 1; |
||||
let cache = ""; |
||||
$: cache = arcs.join(":"); |
||||
|
||||
let cache = ''; |
||||
$: cache = arcs.join(":"); |
||||
const dispatch = createEventDispatcher(); |
||||
|
||||
const dispatch = createEventDispatcher(); |
||||
$: dispatch("change", { |
||||
weapon_class, |
||||
arcs: cache.split(":"), |
||||
}); |
||||
|
||||
$: dispatch( 'change', { |
||||
weapon_class, |
||||
arcs: cache.split(":"), |
||||
}) |
||||
</script> |
||||
|
||||
<style> |
||||
.arc { |
||||
.arc { |
||||
display: flex; |
||||
flex-direction: column; |
||||
margin-right: 1em; |
||||
} |
||||
|
||||
</style> |
||||
} |
||||
|
||||
</style> |
||||
|
@ -1,24 +1,27 @@
@@ -1,24 +1,27 @@
|
||||
|
||||
<Field label="weapon type"> |
||||
<select bind:value={weapon_type}> |
||||
<select bind:value={weapon_type}> |
||||
<option>beam</option> |
||||
<option value="submunition">submunition pack</option> |
||||
<option value="pds">point defence system</option> |
||||
<option>scattergun</option> |
||||
<option value="needle">needle weapon</option> |
||||
</select> |
||||
|
||||
<input type="button" value="add weapon" class="button small blue" on:click={ add_weapon }/> |
||||
</select> |
||||
|
||||
<input |
||||
type="button" |
||||
value="add weapon" |
||||
class="button small blue" |
||||
on:click={add_weapon} |
||||
/> |
||||
</Field> |
||||
|
||||
<script> |
||||
import Field from '../../Field/index.svelte'; |
||||
import {getContext } from 'svelte'; |
||||
import dux from '../../../dux'; |
||||
import { getContext } from "svelte"; |
||||
import Field from "../../Field/index.svelte"; |
||||
|
||||
export let weapon_type = "beam"; |
||||
export let ship_change = getContext('ship_change') || ( () => {} ); |
||||
export let ship = getContext("ship"); |
||||
|
||||
const add_weapon = () => ship?.dispatch_action("add_weapon", weapon_type); |
||||
|
||||
const add_weapon = () => ship_change( dux.actions.add_weapon(weapon_type) ); |
||||
</script> |
||||
|
Loading…
Reference in new issue