From 996da7831792da5bc509bee3e3afb673e26f205a Mon Sep 17 00:00:00 2001 From: Shane B Date: Mon, 7 Aug 2023 11:40:35 -0400 Subject: [PATCH 1/6] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 029b656..1d5cde5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Wormroller (To be renamed maybe?) -This is a simple app built with Vue on Vite to help plan rolling off wormholes in Eve Online. +The repo for http://wormroller.dotlag.info. + +This is just a calculator built on Vue to help simplify the process of rolling wormholes in Eve Online. ## Documentation From 3eda5228b25a219b26949ddcec3cbbdf27761156 Mon Sep 17 00:00:00 2001 From: Shane B Date: Mon, 7 Aug 2023 14:35:10 -0400 Subject: [PATCH 2/6] Create LICENSE.md --- LICENSE.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..a25cb58 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Shane B. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From bbaa190ceb917bc8de5717960398c382749d8a50 Mon Sep 17 00:00:00 2001 From: Shane B Date: Mon, 7 Aug 2023 14:37:54 -0400 Subject: [PATCH 3/6] Create .vercelignore So that the site doesn't redeploy when I update the readme. --- .vercelignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .vercelignore diff --git a/.vercelignore b/.vercelignore new file mode 100644 index 0000000..412392d --- /dev/null +++ b/.vercelignore @@ -0,0 +1,2 @@ +*.md +.gitignore From d13399965c0211397841d2961386c16228bd3b94 Mon Sep 17 00:00:00 2001 From: Shane Bell Date: Fri, 18 Aug 2023 10:40:53 -0400 Subject: [PATCH 4/6] Breaking: saving an edited ship breaks the ship select. --- package-lock.json | 9 ++++ package.json | 1 + src/App.vue | 93 +++++++++++++++++++++++------------------ src/components/Ship.vue | 18 ++++++-- src/main.js | 16 +++++-- src/stores/ship.js | 65 ++++++++++++++++++++++++++++ src/stores/solver.js | 4 +- src/style.css | 4 ++ 8 files changed, 161 insertions(+), 49 deletions(-) create mode 100644 src/stores/ship.js diff --git a/package-lock.json b/package-lock.json index f284104..46fa957 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@fortawesome/vue-fontawesome": "^3.0.3", "@vueuse/core": "^10.3.0", "pinia": "^2.1.4", + "pinia-plugin-persistedstate": "^3.2.0", "vue": "^3.3.4", "vuedraggable": "^4.1.0" }, @@ -1449,6 +1450,14 @@ } } }, + "node_modules/pinia-plugin-persistedstate": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-3.2.0.tgz", + "integrity": "sha512-tZbNGf2vjAQcIm7alK40sE51Qu/m9oWr+rEgNm/2AWr1huFxj72CjvpQcIQzMknDBJEkQznCLAGtJTIcLKrKdw==", + "peerDependencies": { + "pinia": "^2.0.0" + } + }, "node_modules/pinia/node_modules/vue-demi": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.14.5.tgz", diff --git a/package.json b/package.json index 29ecdee..2f4bf92 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@fortawesome/vue-fontawesome": "^3.0.3", "@vueuse/core": "^10.3.0", "pinia": "^2.1.4", + "pinia-plugin-persistedstate": "^3.2.0", "vue": "^3.3.4", "vuedraggable": "^4.1.0" }, diff --git a/src/App.vue b/src/App.vue index cbc5a8c..235e169 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,13 +3,16 @@ import { ref, watch, computed } from "vue"; import draggable from "vuedraggable"; import { useSolverStore } from "./stores/solver"; +import { useShipStore } from "./stores/ship"; import Toggle from "./components/Toggle.vue"; import RadioGroup from "./components/RadioGroup.vue"; import Ship from "./components/Ship.vue"; -const store = useSolverStore(); -const { wormholes, stages, solver, getJumpStyles } = store; +const solverStore = useSolverStore(); +const { wormholes, stages, solver, getJumpStyles } = solverStore; +const shipStore = useShipStore(); +const { addShip } = shipStore; const displayTons = ref(true); const rollFast = ref(true); @@ -19,15 +22,11 @@ const displayMass = (value) => { return (value / (displayTons.value ? 1000 : 1)).toLocaleString(); }; -const randomInt = (min, max) => { - return Math.floor(Math.random() * (max - min + 1)) + min; -}; - const swapShips = (ev) => { - if (ev.newIdx >= 0 && ev.newIdx < store.ships.length) { - let a = store.ships[Math.min(ev.oldIdx, ev.newIdx)]; - let b = store.ships[Math.max(ev.oldIdx, ev.newIdx)]; - store.ships.splice(Math.min(ev.oldIdx, ev.newIdx), 2, b, a); + if (ev.newIdx >= 0 && ev.newIdx < solverStore.ships.length) { + let a = solverStore.ships[Math.min(ev.oldIdx, ev.newIdx)]; + let b = solverStore.ships[Math.max(ev.oldIdx, ev.newIdx)]; + solverStore.ships.splice(Math.min(ev.oldIdx, ev.newIdx), 2, b, a); } }; @@ -38,7 +37,11 @@ const copyShip = (ship) => { }; watch( - [store.ships, () => store.selectedStage.name, () => store.selectedWH.type], + [ + solverStore.ships, + () => solverStore.selectedStage.name, + () => solverStore.selectedWH.type, + ], () => { solver(rollFast); } @@ -48,7 +51,7 @@ watch( -
+
-

Ships

+

Ships

diff --git a/src/components/Ship.vue b/src/components/Ship.vue index 09028cc..8d8e08b 100644 --- a/src/components/Ship.vue +++ b/src/components/Ship.vue @@ -15,7 +15,13 @@ const { useTons: Boolean, ship: Object, }); -defineEmits(["change:ship", "change:shipIdx", "delete:ship", "copy:ship"]); +defineEmits([ + "change:ship", + "change:shipIdx", + "delete:ship", + "copy:ship", + "save:ship", +]); const updateShipProperty = (key, val) => { let updatedShip = ship; @@ -90,13 +96,19 @@ const updateShipProperty = (key, val) => { class="rounded-full font-regular w-1/4" @click="$emit('copy:ship')" > - Copy + + +
diff --git a/src/main.js b/src/main.js index 3f383de..3dd453b 100644 --- a/src/main.js +++ b/src/main.js @@ -2,6 +2,7 @@ import { createApp } from 'vue' import './style.css' import App from './App.vue' import { createPinia } from 'pinia' +import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'; /* import the fontawesome core */ import { library } from '@fortawesome/fontawesome-svg-core' @@ -16,7 +17,10 @@ import { faArrowDown, faFire, faSnowflake, - faTag + faTag, + faX, + faCopy, + faFloppyDisk, } from '@fortawesome/free-solid-svg-icons' /* add icons to the library */ @@ -26,10 +30,16 @@ library.add( faArrowDown, faFire, faSnowflake, - faTag + faTag, + faX, + faCopy, + faFloppyDisk, ) +const pinia = createPinia() + .use(piniaPluginPersistedstate) + createApp(App) - .use(createPinia()) + .use(pinia) .component('font-awesome-icon', FontAwesomeIcon) .mount('#app') diff --git a/src/stores/ship.js b/src/stores/ship.js new file mode 100644 index 0000000..c7beffe --- /dev/null +++ b/src/stores/ship.js @@ -0,0 +1,65 @@ +import { defineStore } from "pinia"; +import { ref, computed } from "vue"; + +export const useShipStore = defineStore("ships", () => { + const randomInt = (min, max) => { + return Math.floor(Math.random() * (max - min + 1)) + min; + }; + + const savedShips = ref([ + { + name: "174/274 Praxis", + cold: 174_000_000, + hot: 274_000_000, + isThreader: false, + }, { + name: "196/296 Megathron", + cold: 196_000_000, + hot: 296_000_000, + isThreader: false, + }, + ]); + const selectedShip = ref(savedShips.value[0]); + + const addShip = (shipsList) => { + shipsList.push({ + ...selectedShip.value, + id: randomInt(0, 100_000_000), + color: { + h: randomInt(0, 360), + s: randomInt(42, 98), + l: randomInt(40, 90), + }, + }); + } + + const saveShip = (ship) => { + console.log(selectedShip.value); + const oldShip = savedShips.value.findIndex(i => i.name === ship.name); + if (oldShip >= 0) { + savedShips.value.splice(oldShip, 1, { + name: ship.name, + cold: ship.cold, + hot: ship.hot, + isThreader: ship.isThreader + }) + } else { + savedShips.value.push({ + name: ship.name, + cold: ship.cold, + hot: ship.hot, + isThreader: ship.isThreader + }) + } + console.log(selectedShip.value); + } + + return { + savedShips, + selectedShip, + addShip, + saveShip + } +}, { + persist: true +}) \ No newline at end of file diff --git a/src/stores/solver.js b/src/stores/solver.js index 71fb9d0..3469d99 100644 --- a/src/stores/solver.js +++ b/src/stores/solver.js @@ -7,6 +7,7 @@ export const useSolverStore = defineStore('solver', () => { const selectedWH = ref(wormholes[0]); const selectedStage = ref(stages[0]); + const plan = ref([]); const url = computed(() => new URL(window.location)); if (url.value.search) { @@ -23,7 +24,6 @@ export const useSolverStore = defineStore('solver', () => { })); const ships = ref([]); - const plan = ref([]); const totalPlanMass = computed(() => plan.value.reduce((prevTotal, jump) => { return prevTotal + jump.mass @@ -133,6 +133,6 @@ export const useSolverStore = defineStore('solver', () => { plan, solver, resetApp, - getJumpStyles + getJumpStyles, } }) diff --git a/src/style.css b/src/style.css index 61b003b..b711808 100644 --- a/src/style.css +++ b/src/style.css @@ -60,6 +60,10 @@ button { @apply bg-red-700 hover:bg-red-500 border-red-800 hover:border-red-600; } +.save { + @apply bg-teal-700 hover:bg-teal-500 border-teal-800 hover:border-teal-600; +} + select { @apply col-span-1 bg-gray-700 w-fit; } From 5359129101ea778c8e3c849b445ab4477ed9e5b4 Mon Sep 17 00:00:00 2001 From: Shane Bell Date: Sat, 23 Sep 2023 12:09:54 -0400 Subject: [PATCH 5/6] BREAKING: ship edit interface. --- src/App.vue | 30 +++----- src/components/RollerControls.vue | 115 ++++++++++++++++++++++++++++++ src/components/Ship.vue | 30 +++----- src/stores/ship.js | 35 +++++---- 4 files changed, 151 insertions(+), 59 deletions(-) create mode 100644 src/components/RollerControls.vue diff --git a/src/App.vue b/src/App.vue index 235e169..d597bce 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,5 @@ + + diff --git a/src/components/Ship.vue b/src/components/Ship.vue index 8d8e08b..96c9dcd 100644 --- a/src/components/Ship.vue +++ b/src/components/Ship.vue @@ -3,8 +3,10 @@ import ColorPicker from "./ColorPicker.vue"; import Toggle from "./Toggle.vue"; import { useSolverStore } from "../stores/solver"; +import { useShipStore } from "../stores/ship"; const store = useSolverStore(); +const { updateShipProperty } = useShipStore(); const { useTons = false, @@ -22,16 +24,6 @@ defineEmits([ "copy:ship", "save:ship", ]); - -const updateShipProperty = (key, val) => { - let updatedShip = ship; - if (["hot", "cold"].includes(key)) { - updatedShip[key] = val * (useTons ? 1 : 1000); - } else { - updatedShip[key] = val; - } - return updatedShip; -};