This commit is contained in:
Yanick Champoux 2022-03-06 14:10:44 -05:00
parent c8454ed792
commit f207fa3d3c
4 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,5 @@
const ship_types = [ const ship_types = [
{ name: "Scout", mass: [4, 10], abbrev: "SC" }, { name: "Scout", mass: [0, 10], abbrev: "SC" },
{ name: "Courier", mass: [4, 10], abbrev: "SC" }, { name: "Courier", mass: [4, 10], abbrev: "SC" },
{ name: "Corvette", mass: [8, 16], abbrev: "CT" }, { name: "Corvette", mass: [8, 16], abbrev: "CT" },
{ name: "Frigate", mass: [14, 28], abbrev: "FF" }, { name: "Frigate", mass: [14, 28], abbrev: "FF" },
@ -14,7 +14,7 @@ const ship_types = [
{ name: "Heavy Battleship", mass: [120, 160], abbrev: "BDN" }, { name: "Heavy Battleship", mass: [120, 160], abbrev: "BDN" },
{ name: "Dreadnought", mass: [140, 180], abbrev: "DN" }, { name: "Dreadnought", mass: [140, 180], abbrev: "DN" },
{ name: "Superdreadnought", mass: [160, 300], abbrev: "SDN" }, { name: "Superdreadnought", mass: [160, 300], abbrev: "SDN" },
{ name: "Escort Carrier", mass: [60, 140], abbrev: "CVE", carrier: true }, { name: "Escort Carrier", mass: [0, 140], abbrev: "CVE", carrier: true },
{ name: "Light Carrier", mass: [120, 180], abbrev: "CVL", carrier: true }, { name: "Light Carrier", mass: [120, 180], abbrev: "CVL", carrier: true },
{ name: "Heavy Carrier", mass: [160, 300], abbrev: "CVH", carrier: true }, { name: "Heavy Carrier", mass: [160, 300], abbrev: "CVH", carrier: true },
{ name: "Attack Carrier", mass: [150, 300], abbrev: "CVA", carrier: true }, { name: "Attack Carrier", mass: [150, 300], abbrev: "CVA", carrier: true },

View File

@ -8,6 +8,8 @@
<Structure {...$shipState.structure} /> <Structure {...$shipState.structure} />
<Carrier {...$shipState.carrier} />
<script> <script>
import { getContext } from "svelte"; import { getContext } from "svelte";
@ -15,6 +17,7 @@
import ShipCost from "./ShipCost.svelte"; import ShipCost from "./ShipCost.svelte";
import Propulsion from "./Propulsion/index.svelte"; import Propulsion from "./Propulsion/index.svelte";
import Structure from "./Structure/index.svelte"; import Structure from "./Structure/index.svelte";
import Carrier from "./Carrier/index.svelte";
const { state: shipState } = getContext("ship"); const { state: shipState } = getContext("ship");
</script> </script>

View File

@ -1,10 +1,13 @@
import { Updux } from "updux"; import { Updux } from "updux";
import u from "updeep"; import u from "updeep";
import carrier from './carrier.js';
const dux = new Updux({ const dux = new Updux({
actions: { actions: {
setShipType: null, setShipType: null,
setShipClass: null, setShipClass: null,
setCarrierBays: carrier.actions.setCarrierBays,
}, },
initial: { initial: {
shipType: "", shipType: "",
@ -16,5 +19,8 @@ const dux = new Updux({
dux.setMutation("setShipType", (shipType) => u({ shipType })); dux.setMutation("setShipType", (shipType) => u({ shipType }));
dux.setMutation("setShipClass", (shipClass) => u({ shipClass })); dux.setMutation("setShipClass", (shipClass) => u({ shipClass }));
dux.setMutation('setCarrierBays', (bays) => u({
isCarrier: bays > 0,
}))
export default dux; export default dux;

View File

@ -6,13 +6,14 @@ import identification from "./identification.js";
import { calculateDriveReqs } from './propulsion/drive.js'; import { calculateDriveReqs } from './propulsion/drive.js';
import { ftlReqsReaction } from './propulsion/ftl.js'; import { ftlReqsReaction } from './propulsion/ftl.js';
import structure from './structure/index.js'; import structure from './structure/index.js';
import carrier from './carrier.js';
import { screenReqsReaction, screensReqsReaction } from './structure/screens.js' import { screenReqsReaction, screensReqsReaction } from './structure/screens.js'
const dux = new Updux({ const dux = new Updux({
subduxes: { subduxes: {
identification, identification,
propulsion, propulsion,
structure structure, carrier
}, },
initial: { initial: {
reqs: { cost: 0, mass: 10, usedMass: 0 }, reqs: { cost: 0, mass: 10, usedMass: 0 },