diff --git a/.prettierrc b/.prettierrc index 0fca9c1..d98e2e8 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,5 @@ { "singleQuote": true, "semi": true, - "printWidth": 200 + "printWidth": 120 } \ No newline at end of file diff --git a/public/icons/space/alien-bug.svg b/public/icons/space/alien-bug.svg deleted file mode 100644 index 956adce..0000000 --- a/public/icons/space/alien-bug.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/alien-egg.svg b/public/icons/space/alien-egg.svg deleted file mode 100644 index f42d2a9..0000000 --- a/public/icons/space/alien-egg.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/alien-skull.svg b/public/icons/space/alien-skull.svg deleted file mode 100644 index 0b1b8b8..0000000 --- a/public/icons/space/alien-skull.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/asteroid.svg b/public/icons/space/asteroid.svg deleted file mode 100644 index 0b5e269..0000000 --- a/public/icons/space/asteroid.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/astronaut-helmet.svg b/public/icons/space/astronaut-helmet.svg deleted file mode 100644 index 3b06369..0000000 --- a/public/icons/space/astronaut-helmet.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/black-hole-bolas.svg b/public/icons/space/black-hole-bolas.svg deleted file mode 100644 index 951dc05..0000000 --- a/public/icons/space/black-hole-bolas.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/bubble-field.svg b/public/icons/space/bubble-field.svg deleted file mode 100644 index a4cd1a8..0000000 --- a/public/icons/space/bubble-field.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/burning-meteor.svg b/public/icons/space/burning-meteor.svg deleted file mode 100644 index 674a180..0000000 --- a/public/icons/space/burning-meteor.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/death-star.svg b/public/icons/space/death-star.svg deleted file mode 100644 index db953a3..0000000 --- a/public/icons/space/death-star.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/distress-signal.svg b/public/icons/space/distress-signal.svg deleted file mode 100644 index 3a8c57f..0000000 --- a/public/icons/space/distress-signal.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/double-ringed-orb.svg b/public/icons/space/double-ringed-orb.svg deleted file mode 100644 index ab0d3a4..0000000 --- a/public/icons/space/double-ringed-orb.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/earth-africa-europe.svg b/public/icons/space/earth-africa-europe.svg deleted file mode 100644 index a24e1f6..0000000 --- a/public/icons/space/earth-africa-europe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/earth-america.svg b/public/icons/space/earth-america.svg deleted file mode 100644 index 401a598..0000000 --- a/public/icons/space/earth-america.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/earth-asia-oceania.svg b/public/icons/space/earth-asia-oceania.svg deleted file mode 100644 index 9691498..0000000 --- a/public/icons/space/earth-asia-oceania.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/eclipse.svg b/public/icons/space/eclipse.svg deleted file mode 100644 index 24d1341..0000000 --- a/public/icons/space/eclipse.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/exploding-planet.svg b/public/icons/space/exploding-planet.svg deleted file mode 100644 index f2d421e..0000000 --- a/public/icons/space/exploding-planet.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/explosion-rays.svg b/public/icons/space/explosion-rays.svg deleted file mode 100644 index eb2fac0..0000000 --- a/public/icons/space/explosion-rays.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/forward-field.svg b/public/icons/space/forward-field.svg deleted file mode 100644 index d7c398b..0000000 --- a/public/icons/space/forward-field.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/galaxy.svg b/public/icons/space/galaxy.svg deleted file mode 100644 index a790877..0000000 --- a/public/icons/space/galaxy.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/hypersonic-bolt.svg b/public/icons/space/hypersonic-bolt.svg deleted file mode 100644 index 346dcea..0000000 --- a/public/icons/space/hypersonic-bolt.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/interceptor-ship.svg b/public/icons/space/interceptor-ship.svg deleted file mode 100644 index 1687a2f..0000000 --- a/public/icons/space/interceptor-ship.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/jupiter.svg b/public/icons/space/jupiter.svg deleted file mode 100644 index d9c8c92..0000000 --- a/public/icons/space/jupiter.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/meteor-impact.svg b/public/icons/space/meteor-impact.svg deleted file mode 100644 index c940372..0000000 --- a/public/icons/space/meteor-impact.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/moon-orbit.svg b/public/icons/space/moon-orbit.svg deleted file mode 100644 index 98ed6ce..0000000 --- a/public/icons/space/moon-orbit.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/moon.svg b/public/icons/space/moon.svg deleted file mode 100644 index c413ed4..0000000 --- a/public/icons/space/moon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/nested-eclipses.svg b/public/icons/space/nested-eclipses.svg deleted file mode 100644 index 444d843..0000000 --- a/public/icons/space/nested-eclipses.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/orbit.svg b/public/icons/space/orbit.svg deleted file mode 100644 index 273d159..0000000 --- a/public/icons/space/orbit.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/orbital-rays.svg b/public/icons/space/orbital-rays.svg deleted file mode 100644 index e1e0933..0000000 --- a/public/icons/space/orbital-rays.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/planet-conquest.svg b/public/icons/space/planet-conquest.svg deleted file mode 100644 index f39c392..0000000 --- a/public/icons/space/planet-conquest.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/planet-core.svg b/public/icons/space/planet-core.svg deleted file mode 100644 index ab77a38..0000000 --- a/public/icons/space/planet-core.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/radar-dish.svg b/public/icons/space/radar-dish.svg deleted file mode 100644 index 59ddc54..0000000 --- a/public/icons/space/radar-dish.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/ringed-planet.svg b/public/icons/space/ringed-planet.svg deleted file mode 100644 index 99dc0e1..0000000 --- a/public/icons/space/ringed-planet.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/scout-ship.svg b/public/icons/space/scout-ship.svg deleted file mode 100644 index 0dac931..0000000 --- a/public/icons/space/scout-ship.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/solar-system.svg b/public/icons/space/solar-system.svg deleted file mode 100644 index d802ee0..0000000 --- a/public/icons/space/solar-system.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/spiky-field.svg b/public/icons/space/spiky-field.svg deleted file mode 100644 index 32e2f3b..0000000 --- a/public/icons/space/spiky-field.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/spoutnik.svg b/public/icons/space/spoutnik.svg deleted file mode 100644 index 16f459f..0000000 --- a/public/icons/space/spoutnik.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/star-cycle.svg b/public/icons/space/star-cycle.svg deleted file mode 100644 index 41bd1b5..0000000 --- a/public/icons/space/star-cycle.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/starfighter.svg b/public/icons/space/starfighter.svg deleted file mode 100644 index 117d888..0000000 --- a/public/icons/space/starfighter.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/stars.svg b/public/icons/space/stars.svg new file mode 100644 index 0000000..1f2ad72 --- /dev/null +++ b/public/icons/space/stars.svg @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/public/icons/space/strafe.svg b/public/icons/space/strafe.svg deleted file mode 100644 index 9b86e99..0000000 --- a/public/icons/space/strafe.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/transportation-rings.svg b/public/icons/space/transportation-rings.svg deleted file mode 100644 index 2b0ff73..0000000 --- a/public/icons/space/transportation-rings.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/vortex.svg b/public/icons/space/vortex.svg deleted file mode 100644 index 7b5f984..0000000 --- a/public/icons/space/vortex.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/public/icons/space/world.svg b/public/icons/space/world.svg deleted file mode 100644 index 8fa5c91..0000000 --- a/public/icons/space/world.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/components/Sector/HexCell.vue b/src/components/Sector/HexCell.vue index 0f3eeb4..a8400a9 100644 --- a/src/components/Sector/HexCell.vue +++ b/src/components/Sector/HexCell.vue @@ -1,12 +1,19 @@ - - + + + + diff --git a/src/components/Sector/HexMap.vue b/src/components/Sector/HexMap.vue index 6c2783a..2076cc2 100644 --- a/src/components/Sector/HexMap.vue +++ b/src/components/Sector/HexMap.vue @@ -4,7 +4,13 @@ - + + + @@ -12,20 +18,32 @@ - - Edit Cell + + Cell Details + + - Set Location - + Link location: + - - Mark as - + + + @@ -40,9 +58,10 @@ import { defineComponent, ref } from 'vue'; import { IHex } from '../models'; import HexCell from './HexCell.vue'; import LocationSelect from 'src/components/LocationSelect.vue'; +import Cell from './Cell.vue'; export default defineComponent({ - components: { HexCell, LocationSelect }, + components: { HexCell, LocationSelect, Cell }, name: 'HexMap', setup() { const campaign = useCampaign(); @@ -50,28 +69,23 @@ export default defineComponent({ const showDialog = ref(false); const selectedHex = ref(0); + const selectedCell = ref({ sector: 0, cell: 0, found: false }); + const clickHex = (o: IHex, i: number) => { selectedHex.value = i; + selectedCell.value = { sector: 0, cell: 0, found: false }; if (!o.isPassage && o.id === '') { campaign.data.sectors[config.data.sector].hexes[i].isPassage = true; return; } if (o.isPassage || o.id !== '') { + if (o.id !== '') { + selectedCell.value = campaign.getCellLocation(o.id); + } showDialog.value = true; } }; - const unlinkCell = (id: string) => { - campaign.data.sectors.forEach((s, sI) => { - s.hexes.forEach((h, hI) => { - if (h.id === id) { - campaign.data.sectors[sI].hexes[hI].id = ''; - return; - } - }); - }); - }; - const linkCell = (args: { sector: number; cell: number }) => { // Unmark as passage campaign.data.sectors[config.data.sector].hexes[selectedHex.value].isPassage = false; @@ -80,7 +94,8 @@ export default defineComponent({ const id = campaign.data.sectors[args.sector].cells[args.cell].id; // unlink cell from any other maps - unlinkCell(id); + campaign.unlinkCell(id); + selectedCell.value = campaign.getCellLocation(id); // Set cell id for item campaign.data.sectors[config.data.sector].hexes[selectedHex.value].id = id; @@ -91,6 +106,7 @@ export default defineComponent({ config, showDialog, selectedHex, + selectedCell, clickHex, linkCell, }; @@ -119,7 +135,7 @@ export default defineComponent({ display: inline-block; font-size: initial; clip-path: polygon(0% 25%, 0% 75%, 50% 100%, 100% 75%, 100% 25%, 50% 0%); - background: white; + background: black; margin-bottom: calc(var(--m) - var(--s) * 0.2885); } /*.container div:nth-child(odd) { @@ -133,6 +149,6 @@ export default defineComponent({ width: calc(var(--s) / 2 + var(--m)); float: left; height: 120%; - shape-outside: repeating-linear-gradient(#0000 0 calc(var(--f) - 3px), #000 0 var(--f)); + shape-outside: repeating-linear-gradient(#0000 0 calc(var(--f) - 1px), #000 0 var(--f)); } diff --git a/src/components/Sector/SCreature.vue b/src/components/Sector/SCreature.vue index 0d3c5ea..1b7360b 100644 --- a/src/components/Sector/SCreature.vue +++ b/src/components/Sector/SCreature.vue @@ -1,6 +1,6 @@ - + @@ -35,10 +35,11 @@ diff --git a/src/components/Sector/SStarship.vue b/src/components/Sector/SStarship.vue index ad796c6..ee34b5b 100644 --- a/src/components/Sector/SStarship.vue +++ b/src/components/Sector/SStarship.vue @@ -1,6 +1,6 @@ - + @@ -27,6 +27,7 @@ import { defineComponent, PropType, ref, watch } from 'vue'; import Controls from './Controls.vue'; import IInput from '../IInput.vue'; import { IStarship } from '../models'; +import { icon } from 'src/lib/icons'; export default defineComponent({ components: { IInput, Controls }, name: 'SStarship', @@ -57,6 +58,7 @@ export default defineComponent({ return { data, config, + icon, }; }, }); diff --git a/src/components/Sector/SVault.vue b/src/components/Sector/SVault.vue index 0b21539..e266998 100644 --- a/src/components/Sector/SVault.vue +++ b/src/components/Sector/SVault.vue @@ -1,6 +1,6 @@ - + @@ -31,6 +31,7 @@ import { defineComponent, ref, PropType, watch } from 'vue'; import Controls from './Controls.vue'; import IInput from '../IInput.vue'; import { IVault, ESLocation } from '../models'; +import { icon } from 'src/lib/icons'; export default defineComponent({ components: { IInput, Controls }, name: 'SVault', @@ -65,6 +66,7 @@ export default defineComponent({ data, config, ESLocation, + icon, }; }, }); diff --git a/src/components/models.ts b/src/components/models.ts index 5a0a79e..dbe79eb 100644 --- a/src/components/models.ts +++ b/src/components/models.ts @@ -252,7 +252,7 @@ export interface IStar { export interface IHex { id: string; // must correspond to a Cell.id - icon: string; + player: boolean; isPassage: boolean; } export interface ISectorCell { diff --git a/src/lib/campaign.ts b/src/lib/campaign.ts index 0f1ecef..d6427d8 100644 --- a/src/lib/campaign.ts +++ b/src/lib/campaign.ts @@ -244,7 +244,7 @@ export function NewCell(name?: string): ISectorCell { export function NewHex(id?: string): IHex { return { id: id ? id : '', - icon: '', + player: false, isPassage: false, }; } diff --git a/src/lib/icons.ts b/src/lib/icons.ts new file mode 100644 index 0000000..fb87a31 --- /dev/null +++ b/src/lib/icons.ts @@ -0,0 +1,37 @@ +export const icon = { + star: (): string => { + return 'img:icons/space/star-sattelites.svg'; + }, + + planet: (type: string): string => { + return `img:icons/planets/${type.toLowerCase()}.svg`; + }, + + settlement: (): string => { + return 'img:icons/space/settlement.svg'; + }, + + starship: (): string => { + return 'img:icons/space/spaceship.svg'; + }, + + derelict: (): string => { + return 'img:icons/space/derelict.svg'; + }, + + vault: (): string => { + return 'img:icons/space/spaceship.svg'; + }, + + creature: (form: string): string => { + return /(amoeba|amorphous|avian|beast|crustacean|fish|humanoid|insectoid|jellyfish|lizard|octopoid|plant|ray|snake|spider|starfish|worm)/i.test( + form + ) + ? `img:icons/life/${form.split(' ')[0].toLowerCase()}.svg` + : 'img:icons/life/floating-tentacles.svg'; + }, + + npc: (): string => { + return 'img:icons/life/character.svg'; + }, +}; diff --git a/src/pages/Sector.vue b/src/pages/Sector.vue index ccd5d86..4541427 100644 --- a/src/pages/Sector.vue +++ b/src/pages/Sector.vue @@ -182,6 +182,7 @@ export default defineComponent({ campaign.data.sectors[config.data.sector].cells.unshift(NewCell()); }; const removeCell = (index: number) => { + campaign.unlinkCell(campaign.data.sectors[config.data.sector].cells[index].id); campaign.data.sectors[config.data.sector].cells.splice(index, 1); }; diff --git a/src/store/campaign.ts b/src/store/campaign.ts index 497b4a4..83963a8 100644 --- a/src/store/campaign.ts +++ b/src/store/campaign.ts @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import { ICampaign, ICreature, IDerelict, INPC, IPlanet, ISettlement, IStar, IStarship, IVault } from 'components/models'; +import { ICampaign, ICreature, IDerelict, INPC, IPlanet, ISectorCell, ISettlement, IStar, IStarship, IVault } from 'components/models'; import { NewCampaign } from 'src/lib/campaign'; import { useConfig } from './config'; import { db } from 'src/lib/db'; @@ -14,6 +14,66 @@ export const useCampaign = defineStore({ }, actions: { + unsetPlayerLocation() { + let done = false; + this.data.sectors.forEach((s, sI) => { + s.hexes.forEach((h, hI) => { + if (h.player) { + this.data.sectors[sI].hexes[hI].player = false; + done = true; + return; + } + }); + if (done) return; + }); + }, + + unlinkCell(id: string) { + let found = false; + this.data.sectors.forEach((s, sI) => { + s.hexes.forEach((h, hI) => { + if (h.id === id) { + found = true; + this.data.sectors[sI].hexes[hI].id = ''; + return; + } + }); + if (found) return; + }); + }, + + // Returns a copy of a cell found by id string + getCell(id: string): ISectorCell { + let cell = {}; + let found = false; + this.data.sectors.forEach((s) => { + s.cells.forEach((c) => { + if (c.id === id) { + found = true; + cell = JSON.parse(JSON.stringify(c)) as ISectorCell; + return; + } + }); + if (found) return; + }); + return cell; + }, + + // returns the sector/cell numbers from an ID search + getCellLocation(id: string): { sector: number; cell: number; found: boolean } { + let out = { sector: 0, cell: 0, found: false }; + this.data.sectors.forEach((s, sI) => { + s.cells.forEach((c, cI) => { + if (c.id === id) { + out = { sector: sI, cell: cI, found: true }; + return; + } + }); + if (out.found) return; + }); + return out; + }, + moveStar(index: number, from: { sector: number; cell: number }, to: { sector: number; cell: number }) { const o = JSON.parse(JSON.stringify(this.data.sectors[from.sector].cells[from.cell].stars[index])) as IStar; this.data.sectors[to.sector].cells[to.cell].stars.unshift(o);