Add a worldmap showing some oasis regions.

This commit is contained in:
Adrian 2024-11-07 11:18:49 +01:00
parent 9639ff1368
commit 149a6b47f9
8 changed files with 126 additions and 2 deletions

View File

@ -0,0 +1 @@
<svg style="height: 512px; width: 512px;" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g class="" style="" transform="translate(0,0)"><path d="M253.47 17.406C123.76 17.406 18.437 122.76 18.437 252.47c0 129.707 105.324 235.06 235.03 235.06 129.707 0 235.063-105.353 235.063-235.06 0-129.71-105.355-235.064-235.06-235.064zM367.874 68.75c61.246 38.19 101.97 106.14 101.97 183.72 0 17.143-1.993 33.823-5.75 49.81l-34.25-18.06 22 54.874c-9.454 21.647-22.362 41.432-38 58.687l-43.158-30.936-64.625 47.72-61.656 6.967-13.906-41.78-49.72 26.844-68.093-18.938 9.157 36.594c-28.41-21.793-51.23-50.466-66-83.563L81.25 304.47l32.25 17.124 59.22-9.875 2.843-40.908-37.344-1.718 4.905-17.844 30.78-25.313-25.093-15.625 67.22-38.593-45.345-29.657-66.625 40.187-49.437-15.28c13.812-32.14 35.21-60.22 61.906-82.064l-3.75 44.375 43.376-34.124 72 22.22-22.5-27.407L233 75.562l26.813 28.468 71 9.845-3.5-34.47 41.468 12.657-.905-23.312zm1.156 120.03L278 199.47l28.906 43.218 3.156 64.468L339.25 321l11.438-28.375 62.656 48.656L395.78 294l6.408-48.344-43.75-22.72 10.593-34.155zM221 192.438l-31.594 21.188 36.47 14.78 16.686-14.78L221 192.437zm22.188 144.688l18.687 52.594 19.78-42.564-38.467-10.03z" fill="#ffffff" fill-opacity="1"></path></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -0,0 +1,25 @@
<script lang="ts">
import type { OasisType } from "../types";
export let region: OasisType;
</script>
<div>
<h2>
<img src="/img/icons/{ region.resource }.png" alt="{ region.resource }">
Oasis
(→ { region.distance })
</h2>
<div>
<button>Pillage</button>
<button>Conquer</button>
</div>
</div>
<style>
h2 {
align-items: center;
display: flex;
gap: 0.4em;
}
</style>

27
src/board/Worldmap.svelte Normal file
View File

@ -0,0 +1,27 @@
<script lang="ts">
import village from "../village";
import OasisRegion from "./OasisRegion.svelte";
</script>
<section class="worldmap">
{ #each $village.worldmap as region }
<div class="region">
{ #if region.type === 'oasis' }
<OasisRegion { region } />
{ /if }
</div>
{ /each }
</section>
<style>
.worldmap {
display: flex;
justify-content: space-between;
}
.region {
border: 1px solid white;
padding: 1em;
}
</style>

22
src/data/worldmap.ts Normal file
View File

@ -0,0 +1,22 @@
export default [
{
type: 'oasis',
resource: 'food',
distance: 1,
},
{
type: 'oasis',
resource: 'wood',
distance: 1,
},
{
type: 'oasis',
resource: 'stone',
distance: 1,
},
{
type: 'oasis',
resource: 'iron',
distance: 1,
},
];

View File

@ -3,6 +3,7 @@
import Outside from "../board/Outside.svelte"; import Outside from "../board/Outside.svelte";
import Village from "../board/Village.svelte"; import Village from "../board/Village.svelte";
import Worldmap from "../board/Worldmap.svelte";
import gameTab from "../stores/gameTab"; import gameTab from "../stores/gameTab";
import type { GameTab } from "../types"; import type { GameTab } from "../types";
import update from "../update"; import update from "../update";
@ -44,6 +45,8 @@
<Village /> <Village />
{ :else if $gameTab === 'resources' } { :else if $gameTab === 'resources' }
<Outside /> <Outside />
{ :else if $gameTab === 'world' }
<Worldmap />
{ /if } { /if }
</div> </div>
</section> </section>

View File

@ -19,6 +19,13 @@
<img src="/img/icons/field.svg" alt=""> <img src="/img/icons/field.svg" alt="">
<span>Resources</span> <span>Resources</span>
</button> </button>
<button
class="invisible"
on:click={ () => setTab('world') }
>
<img src="/img/icons/world.svg" alt="">
<span>Worldmap</span>
</button>
</nav> </nav>
<style> <style>

View File

@ -1,7 +1,7 @@
import type { Hex } from "./hexgrid"; import type { Hex } from "./hexgrid";
export type GameTab = 'village' | 'resources'; export type GameTab = 'village' | 'resources' | 'world';
export interface CostType { export interface CostType {
@ -62,3 +62,28 @@ export interface UnitType {
culturePerMinute?: number; culturePerMinute?: number;
} }
} }
interface BaseRegionType {
distance: number;
state: {
mission?: {
type: string;
};
};
}
export interface OasisType extends BaseRegionType {
type: 'oasis';
resource: keyof CostType;
}
export interface BourgadeType extends BaseRegionType {
type: 'bourgade';
distance: number;
}
export type RegionType = OasisType | BourgadeType;

View File

@ -1,8 +1,9 @@
import { writable } from "svelte/store"; import { writable } from "svelte/store";
import { createBuilding } from "./create"; import { createBuilding } from "./create";
import worldmap from "./data/worldmap";
import { getTilesAtDistance, Hex } from "./hexgrid"; import { getTilesAtDistance, Hex } from "./hexgrid";
import type { BuildingType, ResourcesType } from "./types"; import type { BuildingType, RegionType, ResourcesType } from "./types";
import { getKeysAsNumbers, shuffle } from "./utils"; import { getKeysAsNumbers, shuffle } from "./utils";
@ -21,6 +22,7 @@ export interface VillageState {
resources: ResourcesType; resources: ResourcesType;
villageTiles: Board; villageTiles: Board;
outsideTiles: Board; outsideTiles: Board;
worldmap: RegionType[];
victory: boolean; victory: boolean;
} }
@ -63,6 +65,17 @@ function getInitialOutsideBoard() {
} }
function getInitialWorldmap(): RegionType[] {
return worldmap.map(r => {
const region = r as RegionType;
return {
...region,
state: {},
};
});
}
function getInitialState() { function getInitialState() {
const state: VillageState = { const state: VillageState = {
buildings: [], buildings: [],
@ -76,6 +89,7 @@ function getInitialState() {
}, },
villageTiles: getInitialVillageBoard(), villageTiles: getInitialVillageBoard(),
outsideTiles: getInitialOutsideBoard(), outsideTiles: getInitialOutsideBoard(),
worldmap: getInitialWorldmap(),
victory: false, victory: false,
}; };