Browse Source

enter sveltekit

main
Yanick Champoux 2 years ago
parent
commit
702fefcd09
  1. 15
      .eslintrc.cjs
  2. 11
      .gitignore
  3. 1
      .node-version
  4. 1
      .npmrc
  5. 4
      .prettierignore
  6. 6
      .prettierrc
  7. 44
      docs/index.html
  8. 9
      jsconfig.json
  9. 168
      package.json
  10. 63
      package.yml
  11. 11705
      public/bulma/bulma-rtl.css
  12. 1
      public/bulma/bulma-rtl.css.map
  13. 1
      public/bulma/bulma-rtl.min.css
  14. 11705
      public/bulma/bulma.css
  15. 1
      public/bulma/bulma.css.map
  16. 1
      public/bulma/bulma.min.css
  17. BIN
      public/favicon.ico
  18. 36
      public/index.html
  19. 102
      rollup.config.js
  20. 16
      src/app.html
  21. 20
      src/components/App.svelte
  22. 10
      src/components/Carrier/Squadron/index.svelte
  23. 14
      src/components/Carrier/index.svelte
  24. 5
      src/components/Engine/index.svelte
  25. 4
      src/components/Firecons.svelte
  26. 6
      src/components/Hull/Armour/Layer/index.svelte
  27. 6
      src/components/Hull/Armour/index.svelte
  28. 8
      src/components/Hull/Cargo/index.svelte
  29. 6
      src/components/Hull/Screens/index.svelte
  30. 8
      src/components/Hull/Streamlining/index.svelte
  31. 14
      src/components/Hull/index.svelte
  32. 2
      src/components/Output/Print/Hull/Integrity/index.svelte
  33. 4
      src/components/Output/Print/Hull/index.svelte
  34. 4
      src/components/Output/Print/Identification/index.svelte
  35. 4
      src/components/Output/Print/Systems/index.svelte
  36. 2
      src/components/Output/Print/Weapons/Beam/index.svelte
  37. 2
      src/components/Output/Print/Weapons/index.svelte
  38. 10
      src/components/Output/Print/index.svelte
  39. 4
      src/components/ShipSpecs/Identification.svelte
  40. 2
      src/components/ShipSpecs/ShipCost.svelte
  41. 15
      src/components/Weapon/Beam/index.svelte
  42. 6
      src/components/Weapon/Needle/index.svelte
  43. 6
      src/components/Weapon/Submunition/index.svelte
  44. 17
      src/components/Weapon/index.svelte
  45. 8
      src/components/Weaponry/ADFC/index.svelte
  46. 4
      src/components/Weaponry/AddWeapon/index.svelte
  47. 1
      src/components/Weapons/Add.svelte
  48. 2
      src/dux/cargo/index.js
  49. 16
      src/dux/carrier/index.js
  50. 6
      src/dux/engine/index.js
  51. 12
      src/dux/ftl/index.js
  52. 6
      src/dux/index.js
  53. 6
      src/dux/streamlining/index.js
  54. 4
      src/dux/structure/armour/index.js
  55. 2
      src/dux/structure/index.js
  56. 6
      src/dux/structure/screens/index.js
  57. 19
      src/dux/utils.js
  58. 6
      src/dux/weaponry/adfc/index.js
  59. 2
      src/dux/weaponry/index.js
  60. 2
      src/dux/weaponry/weapons/index.js
  61. 3
      src/global.d.ts
  62. 6
      src/routes/index.svelte
  63. 15
      src/stores/ship.js
  64. 20
      svelte.config.js
  65. 86
      webpack.config.js

15
.eslintrc.cjs

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'prettier'],
plugins: ['svelte3'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2019
},
env: {
browser: true,
es2017: true,
node: true
}
};

11
.gitignore vendored

@ -1,5 +1,8 @@ @@ -1,5 +1,8 @@
.DS_Store
node_modules
.nyc_output
pnpm-lock.yaml
public/build
public/bundle.*
/.svelte
/build
/functions
.svelte-kit/
.vercel_build_output/
package-lock.json

1
.node-version

@ -0,0 +1 @@ @@ -0,0 +1 @@
15.14.0

1
.npmrc

@ -0,0 +1 @@ @@ -0,0 +1 @@
engine-strict=true

4
.prettierignore

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
.svelte/**
static/**
build/**
node_modules/**

6
.prettierrc

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100
}

44
docs/index.html

@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="./" >
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<title>Svelte app</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='./global.css'>
<link rel='stylesheet' href='./bundle.css'>
<!--
<link rel='stylesheet' href='/materialize/materialize.css'>
<script src="/materialize/materialize.js"></script>
-->
<script>
process = { env: { NODE_ENV: 'production' } };
</script>
<script defer src='./bundle.js'></script>
<style>
.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}
@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}
</style>
</head>
<body>
<!-- github ribbon from https://tholman.com/github-corners/ -->
<a href="https://github.com/yanick/aotds-shipyard"
class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>
<div id="app"></div>
</body>
</html>

9
jsconfig.json

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"$lib/*": ["src/lib/*"]
}
},
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"]
}

168
package.json

@ -1,139 +1,33 @@ @@ -1,139 +1,33 @@
{
"author": "Yanick Champoux <yanick@babyl.ca>",
"dependencies": {
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/node": "^7.10.1",
"@material/animation": "^7.0.0",
"@material/base": "^7.0.0",
"@material/density": "^7.0.0",
"@material/feature-targeting": "^7.0.0",
"@material/floating-label": "^7.0.0",
"@material/line-ripple": "^7.0.0",
"@material/notched-outline": "^7.0.0",
"@material/ripple": "^7.0.0",
"@material/rtl": "^7.0.0",
"@material/shape": "^7.0.0",
"@material/textfield": "^6.0.0",
"@material/theme": "^7.0.0",
"@material/typography": "^7.0.0",
"@smui/floating-label": "^1.0.0-beta.21",
"@smui/line-ripple": "^1.0.0-beta.21",
"@smui/notched-outline": "^1.0.0-beta.21",
"@smui/textfield": "^1.0.0-beta.21",
"@storybook/svelte": "^5.3.19",
"babel-loader": "^8.1.0",
"css-loader": "^3.6.0",
"dart-sass": "^1.25.0",
"lodash": "^4.17.15",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.14.1",
"prettier": "2.0.5",
"prettier-plugin-svelte": "1.1.0",
"redux": "^4.0.5",
"reselect": "^4.0.0",
"rollup-plugin-css-only": "^2.1.0",
"rollup-plugin-postcss": "^3.1.2",
"rollup-plugin-scss": "^2.5.0",
"sass": "^1.26.9",
"sass-loader": "^8.0.2",
"sirv-cli": "^0.4.4",
"style-loader": "^1.2.1",
"svelte-loader": "^2.13.6",
"svelte3-redux": "^0.3.0",
"ts-action": "^11.0.0",
"updeep": "^1.2.0",
"updux": "^2.1.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-dev-server": "^3.11.0"
},
"description": "Full Thrust ship builder",
"devDependencies": {
"@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-commonjs": "^12.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@storybook/addon-actions": "^5.3.19",
"eslint": "7.4.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-lodash": "^7.1.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-svelte3": "2.7.3",
"eslint-plugin-you-dont-need-lodash-underscore": "^6.10.0",
"file-loader": "^6.0.0",
"npm-run-all": "^4.1.5",
"rollup": "^2.3.4",
"rollup-plugin-livereload": "^1.0.0",
"rollup-plugin-svelte": "^5.0.3",
"rollup-plugin-terser": "^5.1.2",
"svelte": "^3.0.0",
"svelte-material-ui": "^1.0.0-beta.21",
"svg-inline-loader": "^0.8.2",
"tap": "^14.10.7"
},
"eslintConfig": {
"env": {
"amd": true,
"browser": true,
"es6": true,
"node": true
},
"extends": [
"prettier",
"eslint:recommended",
"plugin:you-dont-need-lodash-underscore/compatible",
"plugin:lodash/recommended"
],
"ignorePatterns": [
"src/node_modules"
],
"overrides": [
{
"files": [
"*.svelte"
],
"processor": "svelte3/svelte3"
}
],
"parserOptions": {
"ecmaFeatures": {
"modules": true
},
"ecmaVersion": "2020",
"sourceType": "module"
},
"plugins": [
"svelte3"
],
"rules": {
"lodash/prefer-lodash-method": "off"
}
},
"keywords": [
"game"
],
"license": "ISC",
"main": "index.js",
"name": "aotds-docks",
"prettier": {
"svelteSortOrder": "markup-scripts-styles",
"svelteStrictMode": false
},
"scripts": {
"build": "NODE_ENV=production webpack",
"lint": "npm-run-all --parallel \"lint:prettier -- {@}\" \"lint:eslint -- {@}\" --",
"lint:eslint": "./scripts/eslint",
"lint:eslint:fix": "npm run lint:eslint -- --fix",
"lint:fix": "npm-run-all \"lint:eslint:fix -- {@}\" \"lint:prettier:fix -- {@}\" --",
"lint:prettier": "./scripts/prettier",
"lint:prettier:fix": "npm run lint:prettier -- --fix",
"package": "./scripts/merge_package.pl",
"start": "webpack-dev-server --open --content-base public",
"test": "tap 'src/**test.js' --no-coverage"
},
"tap": {
"coverage": false
},
"version": "0.0.1"
"name": "~TODO~",
"version": "0.0.1",
"scripts": {
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"lint": "prettier --check . && eslint --ignore-path .gitignore .",
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/kit": "^1.0.0-next.107",
"eslint": "^7.22.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-svelte3": "^3.2.0",
"prettier": "~2.2.1",
"prettier-plugin-svelte": "^2.2.0",
"svelte": "^3.34.0",
"vite": "^2.2.3"
},
"type": "module",
"dependencies": {
"@sveltejs/adapter-node": "^1.0.0-next.18",
"@sveltejs/adapter-static": "^1.0.0-next.9",
"@yanick/updeep": "link:/home/yanick/work/javascript/updeep",
"bulma": "^0.9.2",
"lodash": "^4.17.21",
"redux": "^4.1.0",
"reselect": "^4.0.0",
"ts-action": "^11.0.0",
"updux": "link:/home/yanick/work/javascript/updux/"
}
}

63
package.yml

@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
---
_merge:
- version
- dependencies
- devDependencies
name: aotds-docks
description: Full Thrust ship builder
author: 'Yanick Champoux <yanick@babyl.ca>'
scripts:
build: NODE_ENV=production webpack
start: webpack-dev-server --open --content-base public
package: ./scripts/merge_package.pl
test: tap 'src/**test.js' --no-coverage
"lint:prettier": ./scripts/prettier
"lint:eslint": ./scripts/eslint
lint: npm-run-all --parallel "lint:prettier -- {@}" "lint:eslint -- {@}" --
"lint:prettier:fix": npm run lint:prettier -- --fix
"lint:eslint:fix": npm run lint:eslint -- --fix
"lint:fix": npm-run-all "lint:eslint:fix -- {@}" "lint:prettier:fix -- {@}" --
eslintConfig:
env:
amd: true
browser: true
es6: true
node: true
extends:
- prettier
- eslint:recommended
- plugin:you-dont-need-lodash-underscore/compatible
- plugin:lodash/recommended
ignorePatterns:
- src/node_modules
overrides:
- files:
- '*.svelte'
processor: svelte3/svelte3
parserOptions:
ecmaFeatures:
modules: true
ecmaVersion: '2020'
sourceType: module
plugins:
- svelte3
rules:
lodash/prefer-lodash-method: off
keywords: [ game ]
license: ISC
main: index.js
prettier:
svelteSortOrder: markup-scripts-styles
svelteStrictMode: false
tap:
coverage: false

11705
public/bulma/bulma-rtl.css

File diff suppressed because it is too large Load Diff

1
public/bulma/bulma-rtl.css.map

File diff suppressed because one or more lines are too long

1
public/bulma/bulma-rtl.min.css vendored

File diff suppressed because one or more lines are too long

11705
public/bulma/bulma.css vendored

File diff suppressed because it is too large Load Diff

1
public/bulma/bulma.css.map

File diff suppressed because one or more lines are too long

1
public/bulma/bulma.min.css vendored

File diff suppressed because one or more lines are too long

BIN
public/favicon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

36
public/index.html

@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'>
<title>The Docks</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono">
<link rel="stylesheet" href="./fonts/faktos.css">
<link rel="stylesheet" href="./fonts/dosis/dosis.css">
<link rel='icon' type='image/png' href='/favicon.png'>
<link rel='stylesheet' href='./global.css'>
<link rel='stylesheet' href='./css/buttons.css'>
<link rel='stylesheet' href='./bundle.css'>
<link rel="stylesheet" href="print.css">
<!--
<link rel='stylesheet' href='/materialize/materialize.css'>
<script src="/materialize/materialize.js"></script>
-->
<script>
process = { env: { NODE_ENV: 'production' } };
</script>
<script defer src='./bundle.js'></script>
</head>
<body>
</body>
</html>

102
rollup.config.js

@ -1,102 +0,0 @@ @@ -1,102 +0,0 @@
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import alias from '@rollup/plugin-alias';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import css from 'rollup-plugin-css-only';
import postcss from 'rollup-plugin-postcss';
import path from 'path';
const postcssOptions = () => ({
extensions: ['.scss', '.sass'],
extract: false,
minimize: true,
use: [
['sass', {
includePaths: [
'./sass',
'./node_modules',
// This is only needed because we're using a local module. :-/
// Normally, you would not need this line.
path.resolve(__dirname, '..', 'node_modules')
]
}]
]
});
const production = !process.env.ROLLUP_WATCH;
export default {
input: 'src/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
alias({
entries: [
{ find: '~', replacement: './src' },
]
}),
// scss(),
css({ output: 'public/build/import-bundle.css' }),
svelte({
// enable run-time checks when not in production
dev: !production,
// we'll extract any component CSS out into
// a separate file - better for performance
css: css => {
css.write('public/build/bundle.css');
}
}),
postcss(postcssOptions()),
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload('public'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false,
chokidar: {
usePolling: true
}
}
};
function serve() {
let started = false;
return {
writeBundle() {
if (!started) {
started = true;
require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
}
}
};
}

16
src/app.html

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/bulma/bulma.css" />
<link rel="stylesheet" href="/fonts/faktos.css">
<link rel="stylesheet" href="/fonts/dosis/dosis.css">
<link rel='stylesheet' href='/global.css'>
%svelte.head%
</head>
<body>
<div id="svelte">%svelte.body%</div>
</body>
</html>

20
src/components/App.svelte

@ -78,23 +78,23 @@ @@ -78,23 +78,23 @@
<script>
import { setContext } from "svelte";
import Header from './Header';
import shipStore from "~/stores/ship";
import Header from './Header.svelte';
import shipStore from "../stores/ship";
import OutputJson from './Output/Json.svelte';
import Print from './Output/Print';
import Print from './Output/Print/index.svelte';
import ShipSpecs from './ShipSpecs/index.svelte';
import Notes from './Notes';
import Notes from './Notes.svelte';
import ShipItem from "./ShipItem/index.svelte";
import Field from "./Field/index.svelte";
import Hull from "./Hull";
import Hull from "./Hull/index.svelte";
import Firecons from "./Firecons.svelte";
import Propulsion from "./Propulsion/index.svelte";
import Section from "~C/Section";
import Weapon from "~C/Weapon";
import Carrier from "~C/Carrier";
import ADFC from "~C/Weaponry/ADFC";
import AddWeapon from "~C/Weaponry/AddWeapon";
import Section from "./Section/index.svelte";
import Weapon from "./Weapon/index.svelte";
import Carrier from "./Carrier/index.svelte";
import ADFC from "./Weaponry/ADFC/index.svelte";
import AddWeapon from "./Weaponry/AddWeapon/index.svelte";
const ship = shipStore();

10
src/components/Carrier/Squadron/index.svelte

@ -11,11 +11,11 @@ @@ -11,11 +11,11 @@
<script>
import {getContext } from 'svelte';
import Section from "~C/Section/index.svelte";
import Field from "~C/Field/index.svelte";
import ShipItem from "~C/ShipItem/index.svelte";
import dux from '~/dux/carrier';
import squadron_types from '~/dux/carrier/squadron_types';
import Section from "$lib/components/Section/index.svelte";
import Field from "$lib/components/Field/index.svelte";
import ShipItem from "$lib/components/ShipItem/index.svelte";
import dux from '$lib/dux/carrier';
import squadron_types from '$lib/dux/carrier/squadron_types';
const types = squadron_types.map( ({type}) => type );

14
src/components/Carrier/index.svelte

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
</ShipItem>
{#each squadrons as squad (squad.id)}
<Squadron {...squad} />
<Squadron {...squad} />
{/each}
</Section>
@ -14,13 +14,13 @@ @@ -14,13 +14,13 @@
<script>
import {getContext } from 'svelte';
import Section from "~C/Section/index.svelte";
import Field from "~C/Field/index.svelte";
import ShipItem from "~C/ShipItem/index.svelte";
import Squadron from './Squadron';
import dux from '~/dux/carrier';
import Section from "../Section/index.svelte";
import Field from "../Field/index.svelte";
import ShipItem from "../ShipItem/index.svelte";
import Squadron from './Squadron/index.svelte';
import dux from '../../dux/carrier';
export let bays = 0;
export let bays = 0;
export let squadrons = [];
export let cost = 0;
export let mass = 0;

5
src/components/Engine/index.svelte

@ -13,10 +13,11 @@ @@ -13,10 +13,11 @@
<script>
import Field from '~C/Field';
import ShipItem from '~C/ShipItem';
import { createEventDispatcher } from 'svelte';
import Field from '$lib/components/Field/index.svelte';
import ShipItem from '$lib/components/ShipItem/index.svelte';
export let cost;
export let mass;
export let advanced = false;

4
src/components/Firecons.svelte

@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
<script>
import { createEventDispatcher } from 'svelte';
import ShipItem from '~C/ShipItem';
import Field from '~C/Field';
import ShipItem from './ShipItem/index.svelte';
import Field from './Field/index.svelte';
export let nbr, cost, mass = (0,0,0);

6
src/components/Hull/Armour/Layer/index.svelte

@ -6,10 +6,10 @@ @@ -6,10 +6,10 @@
<script>
import { createEventDispatcher} from 'svelte';
import dux from '~/dux/structure/armour';
import dux from '$lib/dux/structure/armour';
import ShipItem from '~C/ShipItem/index.svelte';
import Field from '~C/Field/index.svelte';
import ShipItem from '$lib/components/ShipItem/index.svelte';
import Field from '$lib/components/Field/index.svelte';
export let layer = 1;
export let rating = 0;

6
src/components/Hull/Armour/index.svelte

@ -22,10 +22,10 @@ @@ -22,10 +22,10 @@
<script>
import { createEventDispatcher} from 'svelte';
import ShipItem from '~C/ShipItem/index.svelte';
import Field from '~C/Field/index.svelte';
import ShipItem from '$lib/components/ShipItem/index.svelte';
import Field from '$lib/components/Field/index.svelte';
import Layer from './Layer/index.svelte';
import dux from '~/dux/structure/armour';
import dux from '$lib/dux/structure/armour';
import _ from 'lodash';
export let armour = [];

8
src/components/Hull/Cargo/index.svelte

@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
</ShipItem>
<script>
import get from 'lodash/get';
import ShipItem from '~C/ShipItem/index.svelte';
import Field from '~C/Field/index.svelte';
import dux from '~/dux/cargo';
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';
import {getContext, createEventDispatcher} from 'svelte';

6
src/components/Hull/Screens/index.svelte

@ -15,9 +15,9 @@ @@ -15,9 +15,9 @@
<script>
import { createEventDispatcher } from 'svelte';
import Section from '~C/Section';
import Field from '~C/Field';
import ShipItem from '~C/ShipItem';
import Section from '$lib/components/Section/index.svelte';
import Field from '$lib/components/Field/index.svelte';
import ShipItem from '../../ShipItem/index.svelte';
export let cost = 0;
export let mass = 0;

8
src/components/Hull/Streamlining/index.svelte

@ -16,10 +16,10 @@ @@ -16,10 +16,10 @@
</ShipItem>
<script>
import get from 'lodash/get';
import ShipItem from '~C/ShipItem/index.svelte';
import Field from '~C/Field/index.svelte';
import dux from '~/dux/streamlining';
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/streamlining';
import {getContext } from 'svelte';

14
src/components/Hull/index.svelte

@ -21,13 +21,13 @@ @@ -21,13 +21,13 @@
<script>
import { createEventDispatcher } from 'svelte';
import Section from '~C/Section';
import Field from '~C/Field';
import ShipItem from '~C/ShipItem';
import Screens from './Screens';
import Armour from './Armour';
import Cargo from './Cargo';
import Streamlining from './Streamlining';
import Section from '../Section/index.svelte';
import Field from '../Field/index.svelte';
import ShipItem from '../ShipItem/index.svelte';
import Screens from './Screens/index.svelte';
import Armour from './Armour/index.svelte';
import Cargo from './Cargo/index.svelte';
import Streamlining from './Streamlining/index.svelte';
export let cost, mass, ship_mass, rating, screens, armour = (
0, 0, 10, 1, [], []

2
src/components/Output/Print/Hull/Integrity/index.svelte

@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
</div>
<script>
import { ceil } from '~/dux/utils';
import { ceil } from '$lib/dux/utils';
export let ship_mass = 0;
export let rating = 0;

4
src/components/Output/Print/Hull/index.svelte

@ -8,8 +8,8 @@ @@ -8,8 +8,8 @@
</div>
<script>
import Integrity from './Integrity';
import Armour from './Armour';
import Integrity from './Integrity/index.svelte';
import Armour from './Armour/index.svelte';
export let structure = {};
export let ship_mass = 0;

4
src/components/Output/Print/Identification/index.svelte

@ -10,8 +10,8 @@ @@ -10,8 +10,8 @@
</div>
<script>
import Cost from '~C/Cost';
import Mass from '~C/Mass';
import Cost from '../../../Cost.svelte';
import Mass from '$lib/components/Mass.svelte';
export let ship_class;
export let ship_type;

4
src/components/Output/Print/Systems/index.svelte

@ -5,8 +5,8 @@ @@ -5,8 +5,8 @@
</div>
<script>
import Firecons from './Firecons';
import Screens from './Screens';
import Firecons from './Firecons/index.svelte';
import Screens from './Screens/index.svelte';
export let firecons = 0;
export let screens = {};

2
src/components/Output/Print/Weapons/Beam/index.svelte

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
</div>
<script>
import Arcs from '~C/Weapon/Arcs';
import Arcs from '$lib/components/Weapon/Arcs/index.svelte';
export let weapon_class = 1;
export let arcs = [];
</script>

2
src/components/Output/Print/Weapons/index.svelte

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
</div>
<script>
import Beam from './Beam';
import Beam from './Beam/index.svelte';
export let weapons = [];
let beams = [];

10
src/components/Output/Print/index.svelte

@ -23,11 +23,11 @@ @@ -23,11 +23,11 @@
<script>
import _ from 'lodash';
import Identification from './Identification';
import MainSystems from './MainSystems';
import Hull from './Hull';
import Weapons from './Weapons';
import Systems from './Systems';
import Identification from './Identification/index.svelte';
import MainSystems from './MainSystems/index.svelte';
import Hull from './Hull/index.svelte';
import Weapons from './Weapons/index.svelte';
import Systems from './Systems/index.svelte';
export let ship;

4
src/components/ShipSpecs/Identification.svelte

@ -14,8 +14,8 @@ @@ -14,8 +14,8 @@
<script>
import { getContext } from 'svelte';
import Field from '~C/Field';
import { candidate_ship_types } from '~/dux/ship_types';
import Field from '$lib/components/Field/index.svelte';
import { candidate_ship_types } from '../../dux/ship_types';
export let ship = getContext('ship');
let general;

2
src/components/ShipSpecs/ShipCost.svelte

@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
<script>
import { getContext } from "svelte";
import Field from "~C/Field";
import Field from "$lib/components/Field/index.svelte";
export let ship = getContext("ship");

15
src/components/Weapon/Beam/index.svelte

@ -22,15 +22,14 @@ @@ -22,15 +22,14 @@
<script>
import {getContext } from 'svelte';
import Arc from '../../Weapons/Arc.svelte';
import Arcs from '../Arcs';
import { weapon_cost_mass } from '~/dux/weapons/rules';
import fp from 'lodash/fp';
import Arcs from '../Arcs/index.svelte';
import { weapon_cost_mass } from '$lib/dux/weapons/rules';
import _ from 'lodash';
import ShipItem from '~C/ShipItem';
import Field from '~C/Field';
import dux from '~/dux';
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;
@ -84,7 +83,7 @@ @@ -84,7 +83,7 @@
});
arcs = new_arcs;
}
let i = 1;

6
src/components/Weapon/Needle/index.svelte

@ -3,10 +3,10 @@ @@ -3,10 +3,10 @@
<script>
import {getContext } from 'svelte';
import Arcs from '../Arcs';
import dux from '~/dux';
import Arcs from '../Arcs/index.svelte';
import dux from '$lib/dux';
import { createEventDispatcher } from 'svelte';
const all_arcs = [ 'FS', 'F', 'FP', 'AP', 'A', 'AS' ];
export let arcs = ['F'];

6
src/components/Weapon/Submunition/index.svelte

@ -3,10 +3,10 @@ @@ -3,10 +3,10 @@
<script>
import {getContext } from 'svelte';
import Arcs from '../Arcs';
import dux from '~/dux';
import Arcs from '../Arcs/index.svelte';
import dux from '$lib/dux';
import { createEventDispatcher } from 'svelte';
const all_arcs = [ 'FS', 'F', 'FP', 'AP', 'A', 'AS' ];
export let arcs = ['F'];

17
src/components/Weapon/index.svelte

@ -16,17 +16,16 @@ @@ -16,17 +16,16 @@
import Arc from '../Weapons/Arc.svelte';
import { weapon_cost_mass } from '../../dux/weapons/rules.js';
import fp from 'lodash/fp';
import _ from 'lodash';
import { createEventDispatcher } from 'svelte';
import ShipItem from '~C/ShipItem';
import Field from '~C/Field';
import Beam from './Beam';
import Submunition from './Submunition';
import PointDefenceSystem from './PointDefenceSystem';
import Scattergun from './Scattergun';
import Needle from './Needle';
import dux from '~/dux';
import ShipItem from '../ShipItem/index.svelte';
import Field from '../Field/index.svelte';
import Beam from './Beam/index.svelte';
import Submunition from './Submunition/index.svelte';
import PointDefenceSystem from './PointDefenceSystem/index.svelte';
import Scattergun from './Scattergun/index.svelte';
import Needle from './Needle/index.svelte';
import dux from '../../dux';
const weapon_component = {
beam: Beam,

8
src/components/Weaponry/ADFC/index.svelte

@ -6,10 +6,10 @@ @@ -6,10 +6,10 @@
<script>
import get from "lodash/get";
import ShipItem from "~C/ShipItem/index.svelte";
import Field from "~C/Field/index.svelte";
import dux from "~/dux";
import get from "lodash/get.js";
import ShipItem from "../../ShipItem/index.svelte";
import Field from "../../Field/index.svelte";
import dux from "../../../dux";
import { getContext } from "svelte";

4
src/components/Weaponry/AddWeapon/index.svelte

@ -13,9 +13,9 @@ @@ -13,9 +13,9 @@
</Field>
<script>
import Field from '~C/Field';
import Field from '../../Field/index.svelte';
import {getContext } from 'svelte';
import dux from '~/dux';
import dux from '../../../dux';
export let weapon_type = "beam";
export let ship_change = getContext('ship_change') || ( () => {} );

1
src/components/Weapons/Add.svelte

@ -50,7 +50,6 @@ @@ -50,7 +50,6 @@
'FS', 'F', 'FP', 'AP', 'A', 'AS'
];
import fp from 'lodash/fp';
import _ from 'lodash';
import { createEventDispatcher } from 'svelte';

2
src/dux/cargo/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
const dux = new Updux({

16
src/dux/carrier/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import _ from 'lodash';
import { createSelector } from "reselect";
@ -19,27 +19,27 @@ const dux = new Updux({ @@ -19,27 +19,27 @@ const dux = new Updux({
const set_squadron = action('set_squadron',payload());
dux.addMutation(set_squadron, ({id,type}) => u({ squadrons: u.map(
dux.addMutation(set_squadron, ({id,type}) => u.update({ squadrons: u.map(
u.if(_.matches({id}), u({type, cost: 6 * _.find(squadron_types,{type}).cost, mass: 6 }))
)}));
const set_carrier_bays = action('set_carrier_bays', payload() );
dux.addMutation( set_carrier_bays, bays => state => {
state = u({
bays,
state = u.update({
bays,
mass: 1.5*6*bays,
cost: 3 * 1.5 * 6 * bays,
})(state);
if( state.squadrons.length > bays ) {
state = u({
state = u.update({
squadrons: squadrons => squadrons.slice(0,bays)
}, state)
}, state)
}
if( state.squadrons.length < bays ) {
state = u({
state = u.update({
squadrons: squadrons => [ ...squadrons, ..._.times(
bays - state.squadrons.length, i => ({
id: 1 + i + state.squadrons.length,
@ -47,7 +47,7 @@ dux.addMutation( set_carrier_bays, bays => state => { @@ -47,7 +47,7 @@ dux.addMutation( set_carrier_bays, bays => state => {
mass: 6,
type: squadron_types[0].type,
})
)] }, state)
)] }, state)
}
return state;

6
src/dux/engine/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from 'updux';
import { action, payload } from 'ts-action';
import u from 'updeep';
import u from "@yanick/updeep";
import { createSelector } from 'reselect';
const set_engine = action('set_engine',payload());
@ -14,8 +14,8 @@ const dux = new Updux({ @@ -14,8 +14,8 @@ const dux = new Updux({
}
});
dux.addMutation(set_engine, engine => u(engine));
dux.addMutation(set_drive_reqs, rate => u(rate));
dux.addMutation(set_engine, engine => u.update(engine));
dux.addMutation(set_drive_reqs, rate => u.update(rate));
export function calc_drive_reqs(ship_mass,rating,advanced=false) {
const mass = Math.ceil(rating * 0.05 * ship_mass);

12
src/dux/ftl/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from 'updux';
import Updux from "updux";
import { action, payload } from 'ts-action';
import u from 'updeep';
import u from "@yanick/updeep";
import { createSelector } from 'reselect';
import { calc_ftl_reqs } from './rules';
@ -9,15 +9,17 @@ const set_ftl = action('set_ftl',payload()); @@ -9,15 +9,17 @@ const set_ftl = action('set_ftl',payload());
const set_ftl_reqs = action('set_ftl_reqs', payload() );
console.log(Updux);
const dux = new Updux({
initial: {
mass: 0,
cost: 0,
type: 'none'
type: 'none'
}
});
dux.addMutation(set_ftl, type => u({type}));
dux.addMutation(set_ftl_reqs, reqs => u(reqs) );
dux.addMutation(set_ftl, type => u.update({type}));
dux.addMutation(set_ftl_reqs, reqs => u.update(reqs) );
export default dux.asDux;

6
src/dux/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
import ftl from "./ftl";
@ -13,7 +13,7 @@ import structure from './structure'; @@ -13,7 +13,7 @@ import structure from './structure';
import cargo from './cargo';
import streamlining from './streamlining';
import carrier from './carrier';
import { ceil } from '~/dux/utils';
import { ceil } from './utils';
const set_ship_mass = action("set_ship_mass", payload());
const set_name = action("set_name", payload());
@ -36,6 +36,8 @@ const initial = { @@ -36,6 +36,8 @@ const initial = {
},
};
console.log(Updux);
const dux = new Updux({
subduxes: { ftl, engine, weaponry, structure, cargo, streamlining, carrier },
initial

6
src/dux/streamlining/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
const dux = new Updux({
@ -13,10 +13,10 @@ const dux = new Updux({ @@ -13,10 +13,10 @@ const dux = new Updux({
const set_streamlining = action('set_streamlining',payload());
dux.addMutation(set_streamlining, type => u({type}) );
dux.addMutation(set_streamlining, type => u.update({type}) );
const set_streamlining_cost_mass = action('set_streamlining_cost_mass',payload());
dux.addMutation( set_streamlining_cost_mass, reqs => u(reqs) );
dux.addMutation( set_streamlining_cost_mass, reqs => u.update(reqs) );
export default dux.asDux;

4
src/dux/structure/armour/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
import _ from 'lodash';
@ -29,7 +29,7 @@ dux.addMutation( @@ -29,7 +29,7 @@ dux.addMutation(
rating,
cost: 2 * layer * rating,
mass: 2 * rating,
}))
}))
)
);

2
src/dux/structure/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
import screens from './screens';

6
src/dux/structure/screens/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
const dux = new Updux({
@ -10,9 +10,9 @@ const dux = new Updux({ @@ -10,9 +10,9 @@ const dux = new Updux({
});
const set_screens = action('set_screens', payload() );
dux.addMutation(set_screens, payload => u(payload) );
dux.addMutation(set_screens, payload => u.update(payload) );
const set_screens_reqs = action('set_screens_reqs', payload() );
dux.addMutation(set_screens_reqs, payload => u(payload) );
dux.addMutation(set_screens_reqs, payload => u.update(payload) );
export default dux.asDux;

19
src/dux/utils.js

@ -1,7 +1,12 @@ @@ -1,7 +1,12 @@
import fp from 'lodash/fp';
import flow from 'lodash/fp/flow.js';
import sumBy from 'lodash/fp/sumBy.js';
import pick from 'lodash/fp/pick.js';
import filter from 'lodash/fp/filter.js';
import flattenDeep from 'lodash/fp/flattenDeep.js';
import has from 'lodash/fp/has.js';
const expand_cost_mass = (obj={}) => ([
fp.pick(['cost','mass'],obj),
pick(['cost','mass'],obj),
...Object.values(obj || {}).filter( val => typeof val === 'object' ).map(
val => expand_cost_mass(val)
)
@ -14,18 +19,18 @@ export function calc_ship_req(ship) { @@ -14,18 +19,18 @@ export function calc_ship_req(ship) {
//if(!general) general = {};
const items = fp.flow(
const items = flow(
expand_cost_mass,
fp.flattenDeep,
fp.filter(fp.has('cost'))
flattenDeep,
filter(has('cost'))
)({
...rest,
cost: general.mass, mass: 0
})
return {
mass: fp.sumBy('mass',items),
cost: fp.sumBy('cost',items),
mass: sumBy('mass',items),
cost: sumBy('cost',items),
}
}

6
src/dux/weaponry/adfc/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
const dux = new Updux({
initial: {
@ -10,8 +10,8 @@ const dux = new Updux({ @@ -10,8 +10,8 @@ const dux = new Updux({
},
})
dux.addMutation( action( 'set_adfc', payload() ), rating =>
u({ rating, mass: 2 * rating, cost: 8 * rating })
dux.addMutation( action( 'set_adfc', payload() ), rating =>
u.update({ rating, mass: 2 * rating, cost: 8 * rating })
);
export default dux.asDux;

2
src/dux/weaponry/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
import weapons from './weapons';

2
src/dux/weaponry/weapons/index.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import Updux from "updux";
import { action, payload } from "ts-action";
import u from "updeep";
import u from "@yanick/updeep";
import { createSelector } from "reselect";
import { weapon_cost_mass } from "../../weapons/rules";

3
src/global.d.ts vendored

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
/// <reference types="@sveltejs/kit" />
/// <reference types="svelte" />
/// <reference types="vite/client" />

6
src/routes/index.svelte

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
<App />
<script>
import App from '../components/App.svelte';
</script>

15
src/stores/ship.js

@ -1,15 +1,22 @@ @@ -1,15 +1,22 @@
import { browser } from '$app/env';
import { readable } from "svelte/store";
import { compose, applyMiddleware } from "redux";
import { calc_ship_req } from "../dux/utils";
const composeEnhancers =
(window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose;
let composeEnhancers = compose;
if(browser) {
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
}
import shipDux from "../dux";
export default () => {
let saved = window && window.localStorage.getItem('aotds-shipyard');
let saved;
if(browser) saved = window.localStorage.getItem('aotds-shipyard');
if( saved ) {
saved = JSON.parse(saved);
}