Skip to content

Commit 59ad20e

Browse files
committed
Fix units being able to enter and leave Space via paths in the Spaceship biome.
GitOrigin-RevId: db7cb03ebbce1658e572ee7001ff1e6388afb2a2
1 parent 102e409 commit 59ad20e

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

athena/Radius.tsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import FastPriorityQueue from 'fastpriorityqueue';
22
import { Skill } from './info/Skill.tsx';
3-
import { Bridge, TileInfo, TileTypes, TransitionCost } from './info/Tile.tsx';
3+
import {
4+
Bridge,
5+
Space,
6+
TileInfo,
7+
TileTypes,
8+
TransitionCost,
9+
} from './info/Tile.tsx';
410
import { UnitInfo } from './info/Unit.tsx';
511
import canAccessBridge from './lib/canAccessBridge.tsx';
612
import canLoad from './lib/canLoad.tsx';
@@ -86,8 +92,9 @@ export const MoveConfiguration = {
8692
if (maybeCancelTransitionCost) {
8793
return (parentCost === TransitionCost.Cancel &&
8894
currentCost === TransitionCost.Cancel) ||
89-
parent.group === Bridge.group ||
90-
current.group === Bridge.group
95+
(parent.group === Bridge.group && current.group === Bridge.group) ||
96+
(parent.group === Bridge.group && current !== Space) ||
97+
(current.group === Bridge.group && parent !== Space)
9198
? 0
9299
: Number.POSITIVE_INFINITY;
93100
}

athena/__tests__/Radius.test.tsx

+34
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import isPresent from '@deities/hephaestus/isPresent.tsx';
22
import { expect, test } from 'vitest';
33
import startMap from '../../hermes/map-fixtures/they-are-close-to-home.tsx';
44
import { Skill } from '../info/Skill.tsx';
5+
import { Path, Space } from '../info/Tile.tsx';
56
import {
67
Battleship,
78
Flamethrower,
89
Humvee,
10+
Jetpack,
911
PatrolShip,
1012
XFighter,
1113
} from '../info/Unit.tsx';
@@ -1852,6 +1854,38 @@ test('correctly cancels transition costs in the Space biome', () => {
18521854
`);
18531855
});
18541856

1857+
test('cannot enter or exit a Spaceship without a bridge', () => {
1858+
const vecA = vec(1, 2);
1859+
const vecB = vec(1, 1);
1860+
const unitA = Jetpack.create(1);
1861+
const map = MapData.createMap({
1862+
config: {
1863+
biome: 4,
1864+
},
1865+
map: [
1866+
Space.id,
1867+
Space.id,
1868+
Space.id,
1869+
Path.id,
1870+
Space.id,
1871+
Space.id,
1872+
Space.id,
1873+
Space.id,
1874+
Space.id,
1875+
],
1876+
size: {
1877+
height: 3,
1878+
width: 3,
1879+
},
1880+
});
1881+
1882+
expect(
1883+
Array.from(moveable(map, unitA, vecA).keys()).sort(),
1884+
).toMatchInlineSnapshot(`[]`);
1885+
1886+
expect(moveable(map, unitA, vecB).has(vecA)).toBeFalsy();
1887+
});
1888+
18551889
test('Naval units cannot access bridges unless they are below a Sea tile', () => {
18561890
const map = radiusTestMap.copy({
18571891
buildings: radiusTestMap.buildings.deleteAll(

0 commit comments

Comments
 (0)