Make wet-sand shoreline width a graphics setting (default 60%).
Players can pick Off / 30% / 60% / 100% under Settings; changing it rebakes chunk atlases.
@@ -54,6 +54,15 @@
54
54
<button type="button" data-graphics-key="softTerrain" data-graphics-value="off">Off</button>
55
55
</div>
56
56
</section>
57
<section class="settings-group">
58
<h3>Wet sand</h3>
59
<div class="settings-options">
60
<button type="button" data-graphics-key="wetSand" data-graphics-value="0">Off</button>
61
<button type="button" data-graphics-key="wetSand" data-graphics-value="30">30%</button>
62
<button type="button" data-graphics-key="wetSand" data-graphics-value="60">60%</button>
63
<button type="button" data-graphics-key="wetSand" data-graphics-value="100">100%</button>
64
</div>
65
</section>
57
66
<section class="settings-group">
58
67
<h3>Autorun</h3>
59
68
<div class="settings-options">
@@ -54,6 +54,15 @@54
<button type="button" data-graphics-key="softTerrain" data-graphics-value="off">Off</button>54
<button type="button" data-graphics-key="softTerrain" data-graphics-value="off">Off</button>55
</div>55
</div>56
</section>56
</section>57
<section class="settings-group">58
<h3>Wet sand</h3>59
<div class="settings-options">60
<button type="button" data-graphics-key="wetSand" data-graphics-value="0">Off</button>61
<button type="button" data-graphics-key="wetSand" data-graphics-value="30">30%</button>62
<button type="button" data-graphics-key="wetSand" data-graphics-value="60">60%</button>63
<button type="button" data-graphics-key="wetSand" data-graphics-value="100">100%</button>64
</div>65
</section>57
<section class="settings-group">66
<section class="settings-group">58
<h3>Autorun</h3>67
<h3>Autorun</h3>59
<div class="settings-options">68
<div class="settings-options">@@ -3,6 +3,7 @@ import {
3
3
LightingMode,
4
4
BloomMode,
5
5
AutorunMode,
6
WetSandBand,
6
7
loadGraphicsSettings,
7
8
saveGraphicsSettings,
8
9
normalizeGraphicsSettings
@@ -119,4 +120,4 @@ export function initGraphicsSettings ({ onChange, onSuppressWorldClick })
119
120
};
120
121
}
121
122
122
export { ViewDistance, LightingMode, BloomMode, AutorunMode };
123
export { ViewDistance, LightingMode, BloomMode, AutorunMode, WetSandBand };
@@ -3,6 +3,7 @@ import {3
LightingMode,3
LightingMode,4
BloomMode,4
BloomMode,5
AutorunMode,5
AutorunMode,6
WetSandBand,6
loadGraphicsSettings,7
loadGraphicsSettings,7
saveGraphicsSettings,8
saveGraphicsSettings,8
normalizeGraphicsSettings9
normalizeGraphicsSettings@@ -119,4 +120,4 @@ export function initGraphicsSettings ({ onChange, onSuppressWorldClick })119
};120
};120
}121
}121
122
122
export { ViewDistance, LightingMode, BloomMode, AutorunMode };123
export { ViewDistance, LightingMode, BloomMode, AutorunMode, WetSandBand };@@ -17,6 +17,7 @@ import {
17
17
mixSoftTerrainPixel
18
18
} from "/shared/render/softTerrain.js";
19
19
import {
20
WET_SAND_BAND_FRACTION,
20
21
WET_SAND_NEIGHBOR_DIRS,
21
22
wetSandWetness,
22
23
mixWetSandPixel
@@ -34,6 +35,7 @@ import { computeChunkAtlasKeys } from "/shared/render/chunkAtlasKeys.js";
34
35
* preview?: object | null,
35
36
* season?: string,
36
37
* softTerrain?: boolean,
38
* wetSandBandFraction?: number,
37
39
* resolveGround?: (tileX: number, tileY: number) => object | number | null,
38
40
* cache?: ReturnType<typeof import("./chunkAtlasCache.js").createChunkAtlasCache>
39
41
* }} options
@@ -45,6 +47,7 @@ export function bakeChunkAtlases ({
45
47
preview = null,
46
48
season = SeasonId.summer,
47
49
softTerrain = false,
50
wetSandBandFraction = WET_SAND_BAND_FRACTION,
48
51
resolveGround = null,
49
52
cache = null
50
53
})
@@ -62,6 +65,7 @@ export function bakeChunkAtlases ({
62
65
preview,
63
66
season,
64
67
softTerrain,
68
wetSandBandFraction,
65
69
resolveGround
66
70
});
67
71
const bakeCtx = {
@@ -71,6 +75,7 @@ export function bakeChunkAtlases ({
71
75
preview,
72
76
season,
73
77
softTerrain,
78
wetSandBandFraction,
74
79
resolveGround
75
80
};
76
81
@@ -195,6 +200,7 @@ function bakeGroundCanvas ({
195
200
preview,
196
201
season,
197
202
softTerrain,
203
wetSandBandFraction = WET_SAND_BAND_FRACTION,
198
204
resolveGround
199
205
})
200
206
{
@@ -207,6 +213,7 @@ function bakeGroundCanvas ({
207
213
const pixelCache = new Map();
208
214
const baseTileX = snapshot.chunkX * CHUNK_SIZE;
209
215
const baseTileY = snapshot.chunkY * CHUNK_SIZE;
216
const wetBand = Math.max(0, Number(wetSandBandFraction) || 0);
210
217
211
218
for (let localY = 0; localY < CHUNK_SIZE; localY++)
212
219
{
@@ -221,7 +228,7 @@ function bakeGroundCanvas ({
221
228
const groundMeta = groundCatalogMeta(catalog, groundEntry);
222
229
if (!isBakeable(images[groundName], groundMeta))
223
230
{ continue; }
224
const wetShore = isWetShoreGround(groundEntry);
231
const wetShore = wetBand > 0 && isWetShoreGround(groundEntry);
225
232
const blendable = softTerrain && isGroundBlendable(groundEntry);
226
233
if (wetShore || blendable)
227
234
{
@@ -238,7 +245,7 @@ function bakeGroundCanvas ({
238
245
season,
239
246
resolveGround,
240
247
pixelCache,
241
{ softTerrain: blendable, wetShore }
248
{ softTerrain: blendable, wetShore, wetSandBandFraction: wetBand }
242
249
);
243
250
}
244
251
else
@@ -436,7 +443,7 @@ function blitBlendedGround (
436
443
season,
437
444
resolveGround,
438
445
pixelCache,
439
{ softTerrain = false, wetShore = false } = {}
446
{ softTerrain = false, wetShore = false, wetSandBandFraction = WET_SAND_BAND_FRACTION } = {}
440
447
)
441
448
{
442
449
const dryPixels = spritePixels(images[groundName], pixelCache);
@@ -446,8 +453,9 @@ function blitBlendedGround (
446
453
return;
447
454
}
448
455
456
const wetBand = Math.max(0, Number(wetSandBandFraction) || 0);
449
457
const waterDirs = [];
450
if (wetShore)
458
if (wetShore && wetBand > 0)
451
459
{
452
460
for (const { ndx, ndy } of WET_SAND_NEIGHBOR_DIRS)
453
461
{
@@ -511,7 +519,7 @@ function blitBlendedGround (
511
519
let self = readPixel(dryPixels, px, py);
512
520
if (wetPixels && waterDirs.length)
513
521
{
514
const wetness = wetSandWetness(px, py, waterDirs, SPRITE_SIZE_PX);
522
const wetness = wetSandWetness(px, py, waterDirs, SPRITE_SIZE_PX, wetBand);
515
523
if (wetness > 0)
516
524
{ self = mixWetSandPixel(self, readPixel(wetPixels, px, py), wetness); }
517
525
}
@@ -17,6 +17,7 @@ import {17
mixSoftTerrainPixel17
mixSoftTerrainPixel18
} from "/shared/render/softTerrain.js";18
} from "/shared/render/softTerrain.js";19
import {19
import {20
WET_SAND_BAND_FRACTION,20
WET_SAND_NEIGHBOR_DIRS,21
WET_SAND_NEIGHBOR_DIRS,21
wetSandWetness,22
wetSandWetness,22
mixWetSandPixel23
mixWetSandPixel@@ -34,6 +35,7 @@ import { computeChunkAtlasKeys } from "/shared/render/chunkAtlasKeys.js";34
* preview?: object | null,35
* preview?: object | null,35
* season?: string,36
* season?: string,36
* softTerrain?: boolean,37
* softTerrain?: boolean,38
* wetSandBandFraction?: number,37
* resolveGround?: (tileX: number, tileY: number) => object | number | null,39
* resolveGround?: (tileX: number, tileY: number) => object | number | null,38
* cache?: ReturnType<typeof import("./chunkAtlasCache.js").createChunkAtlasCache>40
* cache?: ReturnType<typeof import("./chunkAtlasCache.js").createChunkAtlasCache>39
* }} options41
* }} options@@ -45,6 +47,7 @@ export function bakeChunkAtlases ({45
preview = null,47
preview = null,46
season = SeasonId.summer,48
season = SeasonId.summer,47
softTerrain = false,49
softTerrain = false,50
wetSandBandFraction = WET_SAND_BAND_FRACTION,48
resolveGround = null,51
resolveGround = null,49
cache = null52
cache = null50
})53
})@@ -62,6 +65,7 @@ export function bakeChunkAtlases ({62
preview,65
preview,63
season,66
season,64
softTerrain,67
softTerrain,68
wetSandBandFraction,65
resolveGround69
resolveGround66
});70
});67
const bakeCtx = {71
const bakeCtx = {@@ -71,6 +75,7 @@ export function bakeChunkAtlases ({71
preview,75
preview,72
season,76
season,73
softTerrain,77
softTerrain,78
wetSandBandFraction,74
resolveGround79
resolveGround75
};80
};76
81
@@ -195,6 +200,7 @@ function bakeGroundCanvas ({195
preview,200
preview,196
season,201
season,197
softTerrain,202
softTerrain,203
wetSandBandFraction = WET_SAND_BAND_FRACTION,198
resolveGround204
resolveGround199
})205
})200
{206
{@@ -207,6 +213,7 @@ function bakeGroundCanvas ({207
const pixelCache = new Map();213
const pixelCache = new Map();208
const baseTileX = snapshot.chunkX * CHUNK_SIZE;214
const baseTileX = snapshot.chunkX * CHUNK_SIZE;209
const baseTileY = snapshot.chunkY * CHUNK_SIZE;215
const baseTileY = snapshot.chunkY * CHUNK_SIZE;216
const wetBand = Math.max(0, Number(wetSandBandFraction) || 0);210
217
211
for (let localY = 0; localY < CHUNK_SIZE; localY++)218
for (let localY = 0; localY < CHUNK_SIZE; localY++)212
{219
{@@ -221,7 +228,7 @@ function bakeGroundCanvas ({221
const groundMeta = groundCatalogMeta(catalog, groundEntry);228
const groundMeta = groundCatalogMeta(catalog, groundEntry);222
if (!isBakeable(images[groundName], groundMeta))229
if (!isBakeable(images[groundName], groundMeta))223
{ continue; }230
{ continue; }224
const wetShore = isWetShoreGround(groundEntry);231
const wetShore = wetBand > 0 && isWetShoreGround(groundEntry);225
const blendable = softTerrain && isGroundBlendable(groundEntry);232
const blendable = softTerrain && isGroundBlendable(groundEntry);226
if (wetShore || blendable)233
if (wetShore || blendable)227
{234
{@@ -238,7 +245,7 @@ function bakeGroundCanvas ({238
season,245
season,239
resolveGround,246
resolveGround,240
pixelCache,247
pixelCache,241
{ softTerrain: blendable, wetShore }248
{ softTerrain: blendable, wetShore, wetSandBandFraction: wetBand }242
);249
);243
}250
}244
else251
else@@ -436,7 +443,7 @@ function blitBlendedGround (436
season,443
season,437
resolveGround,444
resolveGround,438
pixelCache,445
pixelCache,439
{ softTerrain = false, wetShore = false } = {}446
{ softTerrain = false, wetShore = false, wetSandBandFraction = WET_SAND_BAND_FRACTION } = {}440
)447
)441
{448
{442
const dryPixels = spritePixels(images[groundName], pixelCache);449
const dryPixels = spritePixels(images[groundName], pixelCache);@@ -446,8 +453,9 @@ function blitBlendedGround (446
return;453
return;447
}454
}448
455
456
const wetBand = Math.max(0, Number(wetSandBandFraction) || 0);449
const waterDirs = [];457
const waterDirs = [];450
if (wetShore)458
if (wetShore && wetBand > 0)451
{459
{452
for (const { ndx, ndy } of WET_SAND_NEIGHBOR_DIRS)460
for (const { ndx, ndy } of WET_SAND_NEIGHBOR_DIRS)453
{461
{@@ -511,7 +519,7 @@ function blitBlendedGround (511
let self = readPixel(dryPixels, px, py);519
let self = readPixel(dryPixels, px, py);512
if (wetPixels && waterDirs.length)520
if (wetPixels && waterDirs.length)513
{521
{514
const wetness = wetSandWetness(px, py, waterDirs, SPRITE_SIZE_PX);522
const wetness = wetSandWetness(px, py, waterDirs, SPRITE_SIZE_PX, wetBand);515
if (wetness > 0)523
if (wetness > 0)516
{ self = mixWetSandPixel(self, readPixel(wetPixels, px, py), wetness); }524
{ self = mixWetSandPixel(self, readPixel(wetPixels, px, py), wetness); }517
}525
}@@ -501,6 +501,8 @@ export class WorldView
501
501
this.bloomEnabled = true;
502
502
/** Soft edge blend for blendable grounds (grass, dirt, …). */
503
503
this.softTerrain = false;
504
/** Wet sand shoreline width as a 0–1 tile fraction (graphics setting). */
505
this.wetSandBandFraction = 0.6;
504
506
this.settings = { ...DEFAULT_WORLD_SETTINGS };
505
507
this.worldHour = 12;
506
508
/** Calendar season for seasonal ground/block visuals (`spring` / `summer` / `fall` / `winter`). */
@@ -532,8 +534,8 @@ export class WorldView
532
534
}
533
535
534
536
/**
535
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain).
536
* @param {{ lighting?: string, bloom?: string, softTerrain?: string }} prefs
537
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain, wet sand).
538
* @param {{ lighting?: string, bloom?: string, softTerrain?: string, wetSand?: string }} prefs
537
539
*/
538
540
setGraphicsPrefs (prefs)
539
541
{
@@ -550,15 +552,30 @@ export class WorldView
550
552
else
551
553
{ this.bloomEnabled = enabled; }
552
554
}
555
let rebake = false;
553
556
if (prefs?.softTerrain === "on" || prefs?.softTerrain === "off")
554
557
{
555
558
const enabled = prefs.softTerrain === "on";
556
559
if (enabled !== this.softTerrain)
557
560
{
558
561
this.softTerrain = enabled;
559
this.#rebakeAllChunks();
562
rebake = true;
560
563
}
561
564
}
565
if (prefs?.wetSand != null)
566
{
567
const pct = Number(prefs.wetSand);
568
const next = !Number.isFinite(pct) || pct <= 0
569
? 0
570
: Math.min(1, pct / 100);
571
if (next !== this.wetSandBandFraction)
572
{
573
this.wetSandBandFraction = next;
574
rebake = true;
575
}
576
}
577
if (rebake)
578
{ this.#rebakeAllChunks(); }
562
579
}
563
580
564
581
/** Apply server (or local) calendar season; rebakes chunks when it changes. */
@@ -3721,6 +3738,7 @@ export class WorldView
3721
3738
preview: this.preview,
3722
3739
season: this.worldSeason,
3723
3740
softTerrain: this.softTerrain,
3741
wetSandBandFraction: this.wetSandBandFraction,
3724
3742
resolveGround: (tileX, tileY) => this.#groundAtTile(tileX, tileY),
3725
3743
cache: this.#atlasCache
3726
3744
});
@@ -501,6 +501,8 @@ export class WorldView501
this.bloomEnabled = true;501
this.bloomEnabled = true;502
/** Soft edge blend for blendable grounds (grass, dirt, …). */502
/** Soft edge blend for blendable grounds (grass, dirt, …). */503
this.softTerrain = false;503
this.softTerrain = false;504
/** Wet sand shoreline width as a 0–1 tile fraction (graphics setting). */505
this.wetSandBandFraction = 0.6;504
this.settings = { ...DEFAULT_WORLD_SETTINGS };506
this.settings = { ...DEFAULT_WORLD_SETTINGS };505
this.worldHour = 12;507
this.worldHour = 12;506
/** Calendar season for seasonal ground/block visuals (`spring` / `summer` / `fall` / `winter`). */508
/** Calendar season for seasonal ground/block visuals (`spring` / `summer` / `fall` / `winter`). */@@ -532,8 +534,8 @@ export class WorldView532
}534
}533
535
534
/**536
/**535
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain).537
* Client graphics prefs (lighting Soft/Simple, bloom On/Off, soft terrain, wet sand).536
* @param {{ lighting?: string, bloom?: string, softTerrain?: string }} prefs538
* @param {{ lighting?: string, bloom?: string, softTerrain?: string, wetSand?: string }} prefs537
*/539
*/538
setGraphicsPrefs (prefs)540
setGraphicsPrefs (prefs)539
{541
{@@ -550,15 +552,30 @@ export class WorldView550
else552
else551
{ this.bloomEnabled = enabled; }553
{ this.bloomEnabled = enabled; }552
}554
}555
let rebake = false;553
if (prefs?.softTerrain === "on" || prefs?.softTerrain === "off")556
if (prefs?.softTerrain === "on" || prefs?.softTerrain === "off")554
{557
{555
const enabled = prefs.softTerrain === "on";558
const enabled = prefs.softTerrain === "on";556
if (enabled !== this.softTerrain)559
if (enabled !== this.softTerrain)557
{560
{558
this.softTerrain = enabled;561
this.softTerrain = enabled;559
this.#rebakeAllChunks();562
rebake = true;560
}563
}561
}564
}565
if (prefs?.wetSand != null)566
{567
const pct = Number(prefs.wetSand);568
const next = !Number.isFinite(pct) || pct <= 0569
? 0570
: Math.min(1, pct / 100);571
if (next !== this.wetSandBandFraction)572
{573
this.wetSandBandFraction = next;574
rebake = true;575
}576
}577
if (rebake)578
{ this.#rebakeAllChunks(); }562
}579
}563
580
564
/** Apply server (or local) calendar season; rebakes chunks when it changes. */581
/** Apply server (or local) calendar season; rebakes chunks when it changes. */@@ -3721,6 +3738,7 @@ export class WorldView3721
preview: this.preview,3738
preview: this.preview,3722
season: this.worldSeason,3739
season: this.worldSeason,3723
softTerrain: this.softTerrain,3740
softTerrain: this.softTerrain,3741
wetSandBandFraction: this.wetSandBandFraction,3724
resolveGround: (tileX, tileY) => this.#groundAtTile(tileX, tileY),3742
resolveGround: (tileX, tileY) => this.#groundAtTile(tileX, tileY),3725
cache: this.#atlasCache3743
cache: this.#atlasCache3726
});3744
});@@ -131,6 +131,38 @@ test("wet sand border fingerprint differs for liquid water neighbors", () =>
131
131
}
132
132
});
133
133
// Frozen shallow water should not wet the shoreline; deep still does.
134
assert.equal(winterShallow.groundKey.includes("wet:flat"), true);
134
assert.equal(winterShallow.groundKey.includes("wet:flat") || winterShallow.groundKey.includes("wetBand:0.6"), true);
135
assert.ok(winterShallow.groundKey.includes("wet:flat"));
135
136
assert.notEqual(winterShallow.groundKey, winterDeep.groundKey);
136
137
});
138
139
test("wet sand band fraction is part of the ground atlas key", () =>
140
{
141
const catalogSand = {
142
grounds: { sand: { states: ["sand", "sand-wet"] } },
143
blocks: {}
144
};
145
const snapshot = {
146
chunkX: 0,
147
chunkY: 0,
148
grounds: Array.from({ length: CHUNK_SIZE * CHUNK_SIZE }, () => ({ typeId: GroundType.sand })),
149
blocks: Array.from({ length: CHUNK_SIZE * CHUNK_SIZE }, () => null)
150
};
151
const medium = computeChunkAtlasKeys({
152
snapshot,
153
catalog: catalogSand,
154
season: "summer",
155
wetSandBandFraction: 0.6,
156
resolveGround: () => ({ typeId: GroundType.sand })
157
});
158
const off = computeChunkAtlasKeys({
159
snapshot,
160
catalog: catalogSand,
161
season: "summer",
162
wetSandBandFraction: 0,
163
resolveGround: () => ({ typeId: GroundType.sand })
164
});
165
assert.notEqual(medium.groundKey, off.groundKey);
166
assert.ok(medium.groundKey.includes("wetBand:0.6"));
167
assert.ok(off.groundKey.includes("wetBand:0"));
168
});
@@ -131,6 +131,38 @@ test("wet sand border fingerprint differs for liquid water neighbors", () =>131
}131
}132
});132
});133
// Frozen shallow water should not wet the shoreline; deep still does.133
// Frozen shallow water should not wet the shoreline; deep still does.134
assert.equal(winterShallow.groundKey.includes("wet:flat"), true);134
assert.equal(winterShallow.groundKey.includes("wet:flat") || winterShallow.groundKey.includes("wetBand:0.6"), true);135
assert.ok(winterShallow.groundKey.includes("wet:flat"));135
assert.notEqual(winterShallow.groundKey, winterDeep.groundKey);136
assert.notEqual(winterShallow.groundKey, winterDeep.groundKey);136
});137
});138
139
test("wet sand band fraction is part of the ground atlas key", () =>140
{141
const catalogSand = {142
grounds: { sand: { states: ["sand", "sand-wet"] } },143
blocks: {}144
};145
const snapshot = {146
chunkX: 0,147
chunkY: 0,148
grounds: Array.from({ length: CHUNK_SIZE * CHUNK_SIZE }, () => ({ typeId: GroundType.sand })),149
blocks: Array.from({ length: CHUNK_SIZE * CHUNK_SIZE }, () => null)150
};151
const medium = computeChunkAtlasKeys({152
snapshot,153
catalog: catalogSand,154
season: "summer",155
wetSandBandFraction: 0.6,156
resolveGround: () => ({ typeId: GroundType.sand })157
});158
const off = computeChunkAtlasKeys({159
snapshot,160
catalog: catalogSand,161
season: "summer",162
wetSandBandFraction: 0,163
resolveGround: () => ({ typeId: GroundType.sand })164
});165
assert.notEqual(medium.groundKey, off.groundKey);166
assert.ok(medium.groundKey.includes("wetBand:0.6"));167
assert.ok(off.groundKey.includes("wetBand:0"));168
});@@ -14,6 +14,12 @@ import {
14
14
isLiquidWaterGround
15
15
} from "../../shared/definitions/tiles.js";
16
16
import { SeasonId } from "../../shared/world/season.js";
17
import {
18
DEFAULT_GRAPHICS_SETTINGS,
19
WetSandBand,
20
wetSandBandFraction,
21
normalizeGraphicsSettings
22
} from "../../shared/graphics/settings.js";
17
23
18
24
test("sand is blendable wet-shore ground with year-round sprites", () =>
19
25
{
@@ -27,13 +33,21 @@ test("sand is blendable wet-shore ground with year-round sprites", () =>
27
33
assert.equal(sand.water, false);
28
34
});
29
35
30
test("wet sand band is 30% of the tile", () =>
36
test("wet sand band defaults to 60% and is a graphics setting", () =>
31
37
{
32
assert.equal(WET_SAND_BAND_FRACTION, 0.3);
38
assert.equal(WET_SAND_BAND_FRACTION, 0.6);
33
39
assert.equal(WET_SAND_NEIGHBOR_DIRS.length, 8);
40
assert.equal(DEFAULT_GRAPHICS_SETTINGS.wetSand, WetSandBand.medium);
41
assert.equal(wetSandBandFraction(WetSandBand.medium), 0.6);
42
assert.equal(wetSandBandFraction(WetSandBand.off), 0);
43
assert.equal(wetSandBandFraction(WetSandBand.narrow), 0.3);
44
assert.equal(wetSandBandFraction(WetSandBand.wide), 1);
45
assert.equal(normalizeGraphicsSettings({}).wetSand, "60");
46
assert.equal(normalizeGraphicsSettings({ wetSand: "30" }).wetSand, "30");
47
assert.equal(normalizeGraphicsSettings({ wetSand: "nope" }).wetSand, "60");
34
48
});
35
49
36
test("east water: edge fully wet, beyond 30% dry", () =>
50
test("east water: edge fully wet, beyond band dry", () =>
37
51
{
38
52
const band = WET_SAND_BAND_FRACTION * 16;
39
53
assert.equal(wetSandBlendWeight(15, 8, 1, 0), 1);
@@ -41,13 +55,16 @@ test("east water: edge fully wet, beyond 30% dry", () =>
41
55
assert.ok(wetSandBlendWeight(14, 8, 1, 0) < 1);
42
56
assert.equal(wetSandBlendWeight(15 - Math.ceil(band), 8, 1, 0), 0);
43
57
assert.equal(wetSandBlendWeight(0, 8, 1, 0), 0);
58
assert.equal(wetSandBlendWeight(10, 8, 1, 0, 16, 0), 0);
59
assert.equal(wetSandBlendWeight(0, 8, 1, 0, 16, 1), 1 / 16);
44
60
});
45
61
46
62
test("southeast water wets the corner fan", () =>
47
63
{
48
64
assert.equal(wetSandEdgeDistance(15, 15, 1, 1), 0);
49
65
assert.equal(wetSandBlendWeight(15, 15, 1, 1), 1);
50
assert.equal(wetSandBlendWeight(15, 8, 1, 1), 0);
66
// Far from the SE corner along the east edge stays dry under the default 60% band.
67
assert.equal(wetSandBlendWeight(15, 0, 1, 1), 0);
51
68
assert.ok(wetSandBlendWeight(14, 14, 1, 1) > 0);
52
69
});
53
70
@@ -14,6 +14,12 @@ import {14
isLiquidWaterGround14
isLiquidWaterGround15
} from "../../shared/definitions/tiles.js";15
} from "../../shared/definitions/tiles.js";16
import { SeasonId } from "../../shared/world/season.js";16
import { SeasonId } from "../../shared/world/season.js";17
import {18
DEFAULT_GRAPHICS_SETTINGS,19
WetSandBand,20
wetSandBandFraction,21
normalizeGraphicsSettings22
} from "../../shared/graphics/settings.js";17
23
18
test("sand is blendable wet-shore ground with year-round sprites", () =>24
test("sand is blendable wet-shore ground with year-round sprites", () =>19
{25
{@@ -27,13 +33,21 @@ test("sand is blendable wet-shore ground with year-round sprites", () =>27
assert.equal(sand.water, false);33
assert.equal(sand.water, false);28
});34
});29
35
30
test("wet sand band is 30% of the tile", () =>36
test("wet sand band defaults to 60% and is a graphics setting", () =>31
{37
{32
assert.equal(WET_SAND_BAND_FRACTION, 0.3);38
assert.equal(WET_SAND_BAND_FRACTION, 0.6);33
assert.equal(WET_SAND_NEIGHBOR_DIRS.length, 8);39
assert.equal(WET_SAND_NEIGHBOR_DIRS.length, 8);40
assert.equal(DEFAULT_GRAPHICS_SETTINGS.wetSand, WetSandBand.medium);41
assert.equal(wetSandBandFraction(WetSandBand.medium), 0.6);42
assert.equal(wetSandBandFraction(WetSandBand.off), 0);43
assert.equal(wetSandBandFraction(WetSandBand.narrow), 0.3);44
assert.equal(wetSandBandFraction(WetSandBand.wide), 1);45
assert.equal(normalizeGraphicsSettings({}).wetSand, "60");46
assert.equal(normalizeGraphicsSettings({ wetSand: "30" }).wetSand, "30");47
assert.equal(normalizeGraphicsSettings({ wetSand: "nope" }).wetSand, "60");34
});48
});35
49
36
test("east water: edge fully wet, beyond 30% dry", () =>50
test("east water: edge fully wet, beyond band dry", () =>37
{51
{38
const band = WET_SAND_BAND_FRACTION * 16;52
const band = WET_SAND_BAND_FRACTION * 16;39
assert.equal(wetSandBlendWeight(15, 8, 1, 0), 1);53
assert.equal(wetSandBlendWeight(15, 8, 1, 0), 1);@@ -41,13 +55,16 @@ test("east water: edge fully wet, beyond 30% dry", () =>41
assert.ok(wetSandBlendWeight(14, 8, 1, 0) < 1);55
assert.ok(wetSandBlendWeight(14, 8, 1, 0) < 1);42
assert.equal(wetSandBlendWeight(15 - Math.ceil(band), 8, 1, 0), 0);56
assert.equal(wetSandBlendWeight(15 - Math.ceil(band), 8, 1, 0), 0);43
assert.equal(wetSandBlendWeight(0, 8, 1, 0), 0);57
assert.equal(wetSandBlendWeight(0, 8, 1, 0), 0);58
assert.equal(wetSandBlendWeight(10, 8, 1, 0, 16, 0), 0);59
assert.equal(wetSandBlendWeight(0, 8, 1, 0, 16, 1), 1 / 16);44
});60
});45
61
46
test("southeast water wets the corner fan", () =>62
test("southeast water wets the corner fan", () =>47
{63
{48
assert.equal(wetSandEdgeDistance(15, 15, 1, 1), 0);64
assert.equal(wetSandEdgeDistance(15, 15, 1, 1), 0);49
assert.equal(wetSandBlendWeight(15, 15, 1, 1), 1);65
assert.equal(wetSandBlendWeight(15, 15, 1, 1), 1);50
assert.equal(wetSandBlendWeight(15, 8, 1, 1), 0);66
// Far from the SE corner along the east edge stays dry under the default 60% band.67
assert.equal(wetSandBlendWeight(15, 0, 1, 1), 0);51
assert.ok(wetSandBlendWeight(14, 14, 1, 1) > 0);68
assert.ok(wetSandBlendWeight(14, 14, 1, 1) > 0);52
});69
});53
70