From 756f2bc152fb7fd4b8b2b076e583156b2c87daf7 Mon Sep 17 00:00:00 2001 From: Adrian Gaudebert Date: Thu, 24 Oct 2024 16:24:39 +0200 Subject: [PATCH] Show a map of the outside of the village, with all the resource farms. --- src/board/BuildingTile.svelte | 1 + src/board/Outside.svelte | 48 ++++++++++++++++++++++++++++++++++ src/board/Village.svelte | 6 +---- src/buildings.ts | 33 ++++++++++++++++------- src/create.ts | 18 +++++++++++-- src/hud/BuildingCreator.svelte | 6 +++-- src/hud/Game.svelte | 19 ++++++++++---- src/hud/Navigation.svelte | 20 ++++++++++++++ src/moves/build.ts | 8 +++--- src/stores/gameTab.ts | 5 ++++ src/types.ts | 6 +++++ src/village.ts | 6 ++--- 12 files changed, 145 insertions(+), 31 deletions(-) create mode 100644 src/board/Outside.svelte create mode 100644 src/hud/Navigation.svelte create mode 100644 src/stores/gameTab.ts diff --git a/src/board/BuildingTile.svelte b/src/board/BuildingTile.svelte index db46fad..1465665 100644 --- a/src/board/BuildingTile.svelte +++ b/src/board/BuildingTile.svelte @@ -5,3 +5,4 @@

{ building.name }

+

{ building.level }

diff --git a/src/board/Outside.svelte b/src/board/Outside.svelte new file mode 100644 index 0000000..aa8839d --- /dev/null +++ b/src/board/Outside.svelte @@ -0,0 +1,48 @@ + + +
+
+ { #each getKeysAsNumbers($village.outsideTiles) as y } +
+ { #each getKeysAsNumbers($village.outsideTiles[y]) as x } + { #if $village.outsideTiles[y][x] >= 0 } + openBuildingPanel($village.outsideTiles[y][x]) } + > + + + { :else if $village.outsideTiles[y][x] === VILLAGE_TILE } + gameTab.set('village') } + /> + { /if } + { /each } +
+ { /each } +
+
+ + diff --git a/src/board/Village.svelte b/src/board/Village.svelte index 386d8fa..b5bbba0 100644 --- a/src/board/Village.svelte +++ b/src/board/Village.svelte @@ -1,6 +1,5 @@ { #if $showBuildingCreator !== null } @@ -29,10 +31,10 @@
- { #each Object.entries(buildings) as [type, building] } + { #each constructible as building }

{ building.name }

- +
{ /each }
diff --git a/src/hud/Game.svelte b/src/hud/Game.svelte index 8530829..64e81bb 100644 --- a/src/hud/Game.svelte +++ b/src/hud/Game.svelte @@ -6,6 +6,10 @@ import BuildingCreator from "./BuildingCreator.svelte"; import Resources from "./Resources.svelte"; import BuildingPanel from "./BuildingPanel.svelte"; + import Outside from "../board/Outside.svelte"; + import Navigation from "./Navigation.svelte"; + import type { GameTab } from "../types"; + import gameTab from "../stores/gameTab"; onMount(() => { @@ -21,14 +25,23 @@ cancelAnimationFrame(frame); } }); + + function setTab(newTab: GameTab) { + gameTab.set(newTab); + }
+
-
+
+ { #if $gameTab === 'village' } + { :else if $gameTab === 'resources' } + + { /if }
@@ -37,10 +50,6 @@