diff --git a/.histoire/dist/histoire.json b/.histoire/dist/histoire.json index b5418fc..0c78028 100644 --- a/.histoire/dist/histoire.json +++ b/.histoire/dist/histoire.json @@ -349,6 +349,34 @@ ], "virtual": false, "markdownFile": null + }, + { + "id": "src-routes-export-print-printship-weapons-torpedo-index-story-svelte", + "title": "Torpedo", + "group": null, + "layout": { + "type": "single", + "iframe": true + }, + "icon": null, + "iconColor": null, + "docsOnly": false, + "variants": [ + { + "id": "_default", + "title": "default" + } + ], + "relativePath": "src/routes/export/print/PrintShip/Weapons/Torpedo/index.story.svelte", + "supportPluginId": "svelte3", + "treePath": [ + "Export", + "PrintShip", + "Weapons", + "Torpedo" + ], + "virtual": false, + "markdownFile": null } ], "markdownFiles": [] diff --git a/.histoire/screenshots/src-routes-export-print-printship-index-story-svelte-_default-1280x800.png b/.histoire/screenshots/src-routes-export-print-printship-index-story-svelte-_default-1280x800.png index fd07540..fd2f151 100644 Binary files a/.histoire/screenshots/src-routes-export-print-printship-index-story-svelte-_default-1280x800.png and b/.histoire/screenshots/src-routes-export-print-printship-index-story-svelte-_default-1280x800.png differ diff --git a/.histoire/screenshots/src-routes-export-print-printship-weapons-torpedo-index-story-svelte-_default-1280x800.png b/.histoire/screenshots/src-routes-export-print-printship-weapons-torpedo-index-story-svelte-_default-1280x800.png new file mode 100644 index 0000000..7c99f16 Binary files /dev/null and b/.histoire/screenshots/src-routes-export-print-printship-weapons-torpedo-index-story-svelte-_default-1280x800.png differ diff --git a/Taskfile.yml b/Taskfile.yml index ab27475..20f8bfe 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -17,7 +17,7 @@ tasks: deps: - histoire:build cmds: - - vitest run -u src + - vitest run -u src check: deps: @@ -28,6 +28,7 @@ tasks: histoire:build: sources: - src/lib/components/** + - src/routes/** generates: - .histoire/screenshots/** cmds: diff --git a/misc/SSD Icons/new3.svg b/misc/SSD Icons/torpedo.svg similarity index 100% rename from misc/SSD Icons/new3.svg rename to misc/SSD Icons/torpedo.svg diff --git a/src/lib/components/ShipEdit/Weaponry/Weapon/Arc.svelte b/src/lib/components/ShipEdit/Weaponry/Weapon/Arc.svelte index 47a73a0..555740d 100644 --- a/src/lib/components/ShipEdit/Weaponry/Weapon/Arc.svelte +++ b/src/lib/components/ShipEdit/Weaponry/Weapon/Arc.svelte @@ -1,5 +1,5 @@ - + + + diff --git a/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte b/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte index 77fbb26..ad06add 100644 --- a/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte +++ b/src/lib/components/ShipEdit/Weaponry/Weapon/index.svelte @@ -18,6 +18,7 @@ import Scattergun from "./Scattergun.svelte"; import Needle from "./Needle.svelte"; import Graser from "./Graser/index.svelte"; + import Torpedo from "./Torpedo/index.svelte"; const component = { beam: Beam, @@ -26,6 +27,7 @@ scattergun: Scattergun, needle: Needle, graser: Graser, + torpedo: Torpedo, }; export let reqs = {}; diff --git a/src/lib/components/__image_snapshots__/screenshots-test-ts-src-lib-components-screenshots-test-ts-image-snapshot-14-snap.png b/src/lib/components/__image_snapshots__/screenshots-test-ts-src-lib-components-screenshots-test-ts-image-snapshot-14-snap.png index fd07540..fd2f151 100644 Binary files a/src/lib/components/__image_snapshots__/screenshots-test-ts-src-lib-components-screenshots-test-ts-image-snapshot-14-snap.png and b/src/lib/components/__image_snapshots__/screenshots-test-ts-src-lib-components-screenshots-test-ts-image-snapshot-14-snap.png differ diff --git a/src/lib/components/__image_snapshots__/screenshots-test-ts-src-lib-components-screenshots-test-ts-image-snapshot-18-snap.png b/src/lib/components/__image_snapshots__/screenshots-test-ts-src-lib-components-screenshots-test-ts-image-snapshot-18-snap.png new file mode 100644 index 0000000..7c99f16 Binary files /dev/null and b/src/lib/components/__image_snapshots__/screenshots-test-ts-src-lib-components-screenshots-test-ts-image-snapshot-18-snap.png differ diff --git a/src/lib/store/ship/weaponry/rules.ts b/src/lib/store/ship/weaponry/rules.ts index 3c3d024..99c4e4d 100644 --- a/src/lib/store/ship/weaponry/rules.ts +++ b/src/lib/store/ship/weaponry/rules.ts @@ -33,7 +33,20 @@ type Graser = { arcs: Arc[]; }; -export type Weapon = Beam | Submunition | PDS | Scattergun | Needle | Graser; +type Torpedo = { + type: "torpedo"; + weaponClass: 1 | 2 | 3 | 4; + arcs: Arc[]; +}; + +export type Weapon = + | Beam + | Submunition + | PDS + | Scattergun + | Needle + | Graser + | Torpedo; export const weaponTypes = [ { @@ -67,6 +80,20 @@ export const weaponTypes = [ }, ], }, + { + type: "torpedo", + name: "torpedo", + reqs: torpedoReqs, + initial: { + type: "torpedo", + weaponClass: 1, + arcs: ["F"], + } as any as Torpedo, + options: { + maxClass: 4, + nbrArcs: [1, 2, 3, "broadside"], + }, + }, { type: "submunition", name: "submunition pack", @@ -153,7 +180,7 @@ function beamReqs({ weaponClass, arcs }: Beam) { }; } -function graserReqs({ weaponClass, arcs }: Beam) { +function graserReqs({ weaponClass, arcs }: Graser) { let mass: number; if (weaponClass === 1) { @@ -185,3 +212,20 @@ function graserReqs({ weaponClass, arcs }: Beam) { cost: 4 * mass, }; } + +function torpedoReqs({ weaponClass, arcs }: Torpedo): Reqs { + let mass: number = 4; + + if (isBroadside(arcs)) { + mass += 2; + } else { + mass += arcs.length - 1; + } + + mass = mass * Math.pow(2, weaponClass - 1); + + return { + mass, + cost: 3 * mass, + }; +} diff --git a/src/routes/export/print/PrintShip/Identification.svelte b/src/routes/export/print/PrintShip/Identification.svelte index c9a7087..0abe34f 100644 --- a/src/routes/export/print/PrintShip/Identification.svelte +++ b/src/routes/export/print/PrintShip/Identification.svelte @@ -10,15 +10,14 @@ {shipType}
- {cost} paid   {mass} weight + {reqs.cost} paid   {reqs.mass} weight
diff --git a/src/routes/export/print/PrintShip/Weapons/printComps.js b/src/routes/export/print/PrintShip/Weapons/printComps.js index af00c95..2f82b89 100644 --- a/src/routes/export/print/PrintShip/Weapons/printComps.js +++ b/src/routes/export/print/PrintShip/Weapons/printComps.js @@ -4,8 +4,10 @@ import PDS from "./PDS.svelte"; import Scattergun from "./Scattergun.svelte"; import Needlebeam from "./Needlebeam.svelte"; import Graser from "./Graser/index.svelte"; +import Torpedo from "./Torpedo/index.svelte"; export default { + torpedo: Torpedo, graser: Graser, beam: Beam, submunition: Submunition,