From 8bed89b6dccf6ea0ff1974c1c619666267e9053a Mon Sep 17 00:00:00 2001 From: Adrian Gaudebert Date: Tue, 19 Nov 2024 17:52:05 +0100 Subject: [PATCH] Force the player to clear an oasis before they can pillage it. --- src/board/OasisRegionPanel.svelte | 26 +++++++++++++++++++++++ src/board/Worldmap.svelte | 5 +++++ src/missions.ts | 35 +++++++++++++++++++++++++++++++ src/moves/clear.ts | 28 +++++++++++++++++++++++++ src/moves/index.ts | 2 ++ src/moves/pillage.ts | 6 ++++-- src/types.ts | 6 ++++-- src/utils.ts | 2 +- src/village.ts | 8 ++++--- 9 files changed, 110 insertions(+), 8 deletions(-) create mode 100644 src/moves/clear.ts diff --git a/src/board/OasisRegionPanel.svelte b/src/board/OasisRegionPanel.svelte index d4bd4cb..4eefeed 100644 --- a/src/board/OasisRegionPanel.svelte +++ b/src/board/OasisRegionPanel.svelte @@ -26,6 +26,12 @@ } + function clear() { + if (!region) return; + moves.clear(region.id, numberOfUnits); + } + + function toggleMissionRepeat() { if (!region) return; moves.toggleMissionRepeat(region.id); @@ -49,14 +55,34 @@ + { #if region.state.cleared } +

Region cleared

+ { :else } +

Defensive strength: { region.strength }

+ { /if } { #if region.state.mission }

{ region.state.mission.unitCount } soldiers are on a mission here.

Remaining: { Math.ceil(region.state.mission.remainingTime / 1000) }

+ { #if region.state.mission.type === 'pillage' } + { /if } +
+ { :else if !region.state.cleared } +
+ + { numberOfUnits } + +
{ :else }
diff --git a/src/board/Worldmap.svelte b/src/board/Worldmap.svelte index 1eddf67..5597257 100644 --- a/src/board/Worldmap.svelte +++ b/src/board/Worldmap.svelte @@ -16,6 +16,7 @@ class:empty={ region.type === WORLDMAP_TYPES.EMPTY } class:bourgade={ region.type === WORLDMAP_TYPES.BOURGADE } class:oasis={ region.type === WORLDMAP_TYPES.OASIS } + class:cleared={ region.type === WORLDMAP_TYPES.OASIS && region.state.cleared } > { #if region.type === WORLDMAP_TYPES.BOURGADE }