Seasons based on a calendar
This commit is contained in:
+30
-4
@@ -1,6 +1,14 @@
|
||||
// biomes are data, worldgen/biomes/<name>.json in a mod. see common/worldgen/biomes.ts
|
||||
import { assert, assertEquals } from "@std/assert";
|
||||
import { biome_from_json, biome_ids, get_biome, validate_biome } from "$/common/worldgen/biomes.ts";
|
||||
import { CYCLE_TICKS } from "$/common/time.ts";
|
||||
import {
|
||||
biome_from_json,
|
||||
biome_ids,
|
||||
biome_season,
|
||||
calendar_season,
|
||||
get_biome,
|
||||
validate_biome,
|
||||
} from "$/common/worldgen/biomes.ts";
|
||||
import { test_game } from "./helpers.ts";
|
||||
|
||||
const PLAIN = { id: "my_mod:flat", surface: { top: "bworld:grass", filler: "bworld:dirt", filler_depth: 3 } };
|
||||
@@ -12,11 +20,29 @@ Deno.test("the bworld mod registers every biome the overworld picks", async () =
|
||||
assertEquals(get_biome("bworld:river")?.surface.underwater_top, "bworld:sand");
|
||||
});
|
||||
|
||||
Deno.test("a biome is in spring unless it says otherwise", async () => {
|
||||
Deno.test("seasons last 49 days, starting with spring on day 1 and changing at 06:00", () => {
|
||||
assertEquals(calendar_season(0), "spring");
|
||||
assertEquals(calendar_season(48), "spring");
|
||||
assertEquals(calendar_season(49), "summer");
|
||||
assertEquals(calendar_season(97), "summer");
|
||||
assertEquals(calendar_season(98), "autumn");
|
||||
assertEquals(calendar_season(147), "winter");
|
||||
assertEquals(calendar_season(195), "winter");
|
||||
assertEquals(calendar_season(196), "spring");
|
||||
});
|
||||
|
||||
Deno.test("a biome follows the calendar unless it says otherwise", async () => {
|
||||
await test_game("mods");
|
||||
assertEquals(get_biome("bworld:plains")?.season, "spring");
|
||||
assertEquals(biome_from_json(PLAIN).season, "spring");
|
||||
assertEquals(get_biome("bworld:plains")?.season, undefined);
|
||||
assertEquals(biome_from_json(PLAIN).season, undefined);
|
||||
assertEquals(biome_from_json({ ...PLAIN, season: "winter" }).season, "winter");
|
||||
// 06:00 of day 50
|
||||
const day_50 = 49 * CYCLE_TICKS;
|
||||
assertEquals(biome_season("bworld:plains", 0), "spring");
|
||||
assertEquals(biome_season("bworld:plains", day_50 - 1), "spring");
|
||||
assertEquals(biome_season("bworld:plains", day_50), "summer");
|
||||
assertEquals(biome_season("bworld:snowy_plains", day_50), "winter");
|
||||
assertEquals(biome_season("my_mod:removed", day_50), "summer");
|
||||
});
|
||||
|
||||
Deno.test("a biome's surface defaults: underwater is its filler, cliffs aren't bare", () => {
|
||||
|
||||
Reference in New Issue
Block a user