| 1 | import test from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | import { GroundType, isGroundPassable, isWadeGround, isWaterGround, isLiquidWaterGround, isWadeGroundInSeason } from "../../shared/definitions/tiles.js"; |
| 4 | import { SeasonId, resolveSeasonalVisualState } from "../../shared/world/season.js"; |
| 5 | import { createEmptyChunkData, isChunkTilePassable, setGround } from "../src/world/chunkData.js"; |
| 6 | |
| 7 | test("deep water ground is impassable; shallow water is passable and wadeable", () => |
| 8 | { |
| 9 | assert.equal(isGroundPassable(GroundType.water), true); |
| 10 | assert.equal(isGroundPassable(GroundType.deepWater), false); |
| 11 | assert.equal(isWadeGround(GroundType.water), true); |
| 12 | assert.equal(isWadeGround(GroundType.deepWater), false); |
| 13 | assert.equal(isWaterGround(GroundType.water), true); |
| 14 | assert.equal(isWaterGround(GroundType.deepWater), true); |
| 15 | |
| 16 | const data = createEmptyChunkData(); |
| 17 | setGround(data, 1, 1, GroundType.water); |
| 18 | setGround(data, 2, 2, GroundType.deepWater); |
| 19 | assert.equal(isChunkTilePassable(data, 1, 1), true); |
| 20 | assert.equal(isChunkTilePassable(data, 2, 2), false); |
| 21 | }); |
| 22 | |
| 23 | test("shallow water freezes in winter: no wade, not liquid for coast foam", () => |
| 24 | { |
| 25 | assert.equal(isLiquidWaterGround(GroundType.water, SeasonId.summer), true); |
| 26 | assert.equal(isLiquidWaterGround(GroundType.water, SeasonId.winter), false); |
| 27 | assert.equal(isLiquidWaterGround(GroundType.deepWater, SeasonId.winter), true); |
| 28 | assert.equal(isWadeGroundInSeason(GroundType.water, SeasonId.summer), true); |
| 29 | assert.equal(isWadeGroundInSeason(GroundType.water, SeasonId.winter), false); |
| 30 | assert.equal( |
| 31 | resolveSeasonalVisualState(["water", "water-winter"], "water", SeasonId.winter), |
| 32 | "water-winter" |
| 33 | ); |
| 34 | assert.equal( |
| 35 | resolveSeasonalVisualState(["water", "water-winter"], "water", SeasonId.summer), |
| 36 | "water" |
| 37 | ); |
| 38 | }); |