Add forest types
This commit is contained in:
parent
9b56235de8
commit
780458f88f
2 changed files with 78 additions and 12 deletions
|
@ -49,8 +49,32 @@ export const BIG_BEACH: LobeGeneratorConstructor = (
|
|||
};
|
||||
};
|
||||
|
||||
/** form forested zone */
|
||||
export const FOREST_LOBE: LobeGeneratorConstructor =
|
||||
/** form forested zone wherever available */
|
||||
export const SCATTERED_FOREST: LobeGeneratorConstructor =
|
||||
(islands: IslandGrid, basePos: number) => () => {
|
||||
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
|
||||
|
||||
// grow shore
|
||||
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER);
|
||||
islands.dropWithin(shoreTiles);
|
||||
|
||||
// seed beach
|
||||
const beachTiles = islandTiles.filter((pos) => islands.data[pos] == BEACH);
|
||||
islands.dropWithin(beachTiles);
|
||||
islands.dropWithin(beachTiles);
|
||||
|
||||
// expand forest
|
||||
const forestLobe = islands.floodSearch(basePos, (tile) => tile > WATER);
|
||||
const forestTiles = forestLobe.filter(
|
||||
(pos) => islands.data[pos] == LIGHT_FOREST
|
||||
);
|
||||
islands.dropWithin(forestTiles);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/** form forested zone that tries to grow as one mass */
|
||||
export const CONTIGUOUS_FOREST: LobeGeneratorConstructor =
|
||||
(islands: IslandGrid, basePos: number) => () => {
|
||||
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
|
||||
|
||||
|
@ -62,20 +86,48 @@ export const FOREST_LOBE: LobeGeneratorConstructor =
|
|||
const beachTiles = islandTiles.filter((pos) => islands.data[pos] == BEACH);
|
||||
islands.dropWithin(beachTiles);
|
||||
|
||||
// expand forest
|
||||
// locate & expand central forest edge
|
||||
const forestLobe = islands.floodSearch(basePos, (tile) => tile > BEACH);
|
||||
const forestTiles = forestLobe.filter(
|
||||
(pos) => islands.data[pos] == LIGHT_FOREST
|
||||
);
|
||||
islands.dropWithin(forestTiles);
|
||||
islands.dropWithin(forestTiles);
|
||||
islands.dropWithin(forestTiles);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/** form forested zone that can raise additional peaks */
|
||||
export const HILLY_FOREST: LobeGeneratorConstructor =
|
||||
(islands: IslandGrid, basePos: number) => () => {
|
||||
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
|
||||
|
||||
// grow shore
|
||||
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER);
|
||||
islands.dropWithin(shoreTiles);
|
||||
|
||||
// seed beach
|
||||
const beachTiles = islandTiles.filter((pos) => islands.data[pos] == BEACH);
|
||||
islands.dropWithin(beachTiles);
|
||||
|
||||
// locate central forest
|
||||
const centralForest = islands.floodSearch(basePos, (tile) => tile > BEACH);
|
||||
islands.dropWithin(centralForest);
|
||||
|
||||
// expand edge
|
||||
const edgeTiles = centralForest.filter(
|
||||
(pos) => islands.data[pos] == LIGHT_FOREST
|
||||
);
|
||||
islands.dropWithin(edgeTiles);
|
||||
|
||||
const hillTiles = centralForest.filter(
|
||||
(pos) => islands.data[pos] >= MOUNTAIN
|
||||
);
|
||||
return hillTiles.length > 0;
|
||||
};
|
||||
|
||||
/** form low-lying beach with eroded sections */
|
||||
export const ERODED_LOBE: LobeGeneratorConstructor =
|
||||
export const ERODED_BEACH: LobeGeneratorConstructor =
|
||||
(islands: IslandGrid, basePos: number) => () => {
|
||||
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
|
||||
|
||||
|
@ -97,11 +149,20 @@ export const NO_ISLAND: LobeGeneratorConstructor =
|
|||
return true;
|
||||
};
|
||||
|
||||
export const BIG_ISLANDS = [BIG_MOUNTAIN, BIG_BEACH];
|
||||
export const BIG_ISLANDS = [BIG_MOUNTAIN, BIG_BEACH, HILLY_FOREST];
|
||||
export const ROCKY_ISLANDS = [BIG_MOUNTAIN, HILLY_FOREST];
|
||||
export const GREEN_ISLANDS = [
|
||||
SCATTERED_FOREST,
|
||||
CONTIGUOUS_FOREST,
|
||||
HILLY_FOREST,
|
||||
];
|
||||
export const SMALL_ISLANDS = [SMALL_BEACH, SCATTERED_FOREST, ERODED_BEACH];
|
||||
export const ALL_ISLANDS = [
|
||||
BIG_MOUNTAIN,
|
||||
SMALL_BEACH,
|
||||
BIG_BEACH,
|
||||
FOREST_LOBE,
|
||||
ERODED_LOBE,
|
||||
SCATTERED_FOREST,
|
||||
CONTIGUOUS_FOREST,
|
||||
HILLY_FOREST,
|
||||
ERODED_BEACH,
|
||||
];
|
||||
|
|
|
@ -3,8 +3,11 @@ import { BEACH, ICECAP } from "./data";
|
|||
import {
|
||||
ALL_ISLANDS,
|
||||
BIG_ISLANDS,
|
||||
GREEN_ISLANDS,
|
||||
LobeGenerator,
|
||||
NO_ISLAND,
|
||||
ROCKY_ISLANDS,
|
||||
SMALL_ISLANDS,
|
||||
} from "./generators";
|
||||
|
||||
export class IslandGrid {
|
||||
|
@ -21,16 +24,18 @@ export class IslandGrid {
|
|||
|
||||
const islandBag = this.shuffle([
|
||||
this.choose(BIG_ISLANDS),
|
||||
this.choose(BIG_ISLANDS),
|
||||
this.choose(ALL_ISLANDS),
|
||||
this.choose(ALL_ISLANDS),
|
||||
this.choose(ALL_ISLANDS),
|
||||
this.choose(ROCKY_ISLANDS),
|
||||
this.choose(GREEN_ISLANDS),
|
||||
this.choose(SMALL_ISLANDS),
|
||||
this.choose(SMALL_ISLANDS),
|
||||
this.choose(SMALL_ISLANDS),
|
||||
this.choose(ALL_ISLANDS),
|
||||
NO_ISLAND,
|
||||
NO_ISLAND,
|
||||
NO_ISLAND,
|
||||
NO_ISLAND,
|
||||
NO_ISLAND,
|
||||
NO_ISLAND,
|
||||
]);
|
||||
|
||||
const islandCount = islandBag.length;
|
||||
|
|
Loading…
Add table
Reference in a new issue