mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 06:13:55 -07:00
Up to now `eslint-plugin-brace-rules` was used to enforce a common brace style for JavaScript code. This plugin was however updated the last time over 9 years ago and will be incompatible with ESLint v10, as that [removes `context.getSourceCode()`][1], the plugin relies on. To keep the eslint config working with ESLint v10, this replaces `eslint-plugin-brace-rules` with the [`@stylistic/brace-style`][2] rule from `@stylistic/eslint-plugin`, a package we already use. While `@stylistic/brace-style` doesn't offer an option to format braces in exactly the same way as before, the "allman" style seems to be the one closest to the existing code. [1]: https://eslint.org/blog/2025/11/eslint-v10.0.0-alpha.0-released/#removed-deprecated-rule-context-members [2]: https://eslint.style/rules/brace-style
71 lines
1.7 KiB
JavaScript
71 lines
1.7 KiB
JavaScript
Engine.GetTemplate = (path) =>
|
|
{
|
|
return {
|
|
"Identity": {
|
|
"GenericName": null,
|
|
"Icon": null,
|
|
"History": null
|
|
}
|
|
};
|
|
};
|
|
|
|
Engine.LoadLibrary("rmgen");
|
|
|
|
export function* generateMap()
|
|
{
|
|
g_MapSettings = { "Size": 512 };
|
|
globalThis.g_Map = new RandomMap(0, "blackness");
|
|
|
|
yield 50;
|
|
|
|
// Test that that it checks by value, not by reference
|
|
{
|
|
const tileClass = new TileClass(2);
|
|
const reference1 = new Vector2D(1, 1);
|
|
const reference2 = new Vector2D(1, 1);
|
|
tileClass.add(reference1);
|
|
TS_ASSERT(tileClass.has(reference2));
|
|
}
|
|
|
|
// Test out-of-bounds
|
|
{
|
|
const tileClass = new TileClass(32);
|
|
|
|
const absentPoints = [
|
|
new Vector2D(0, 0),
|
|
new Vector2D(0, 1),
|
|
new Vector2D(1, 0),
|
|
new Vector2D(-1, -1),
|
|
new Vector2D(2048, 0),
|
|
new Vector2D(0, NaN),
|
|
new Vector2D(0, Infinity)
|
|
];
|
|
|
|
for (const point of absentPoints)
|
|
TS_ASSERT(!tileClass.has(point));
|
|
}
|
|
|
|
// Test getters
|
|
{
|
|
const tileClass = new TileClass(88);
|
|
|
|
const point = new Vector2D(5, 5);
|
|
tileClass.add(point);
|
|
|
|
const pointBorder = new Vector2D(1, 9);
|
|
tileClass.add(pointBorder);
|
|
|
|
TS_ASSERT_EQUALS(tileClass.countMembersInRadius(point, 0), 1);
|
|
TS_ASSERT_EQUALS(tileClass.countMembersInRadius(point, 1), 1);
|
|
TS_ASSERT_EQUALS(tileClass.countMembersInRadius(point, 100), 2);
|
|
|
|
TS_ASSERT_EQUALS(tileClass.countNonMembersInRadius(point, 1), 4);
|
|
TS_ASSERT_EQUALS(tileClass.countNonMembersInRadius(point, 2), 12);
|
|
TS_ASSERT_EQUALS(tileClass.countNonMembersInRadius(point, 3), 28);
|
|
|
|
// Points not on the map are not counted.
|
|
TS_ASSERT_EQUALS(tileClass.countNonMembersInRadius(pointBorder, 1), 4);
|
|
TS_ASSERT_EQUALS(tileClass.countNonMembersInRadius(pointBorder, 2), 11);
|
|
TS_ASSERT_EQUALS(tileClass.countNonMembersInRadius(pointBorder, 3), 22);
|
|
}
|
|
}
|