File tree 2 files changed +44
-3
lines changed
2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 1
1
import FastPriorityQueue from 'fastpriorityqueue' ;
2
2
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' ;
4
10
import { UnitInfo } from './info/Unit.tsx' ;
5
11
import canAccessBridge from './lib/canAccessBridge.tsx' ;
6
12
import canLoad from './lib/canLoad.tsx' ;
@@ -86,8 +92,9 @@ export const MoveConfiguration = {
86
92
if ( maybeCancelTransitionCost ) {
87
93
return ( parentCost === TransitionCost . Cancel &&
88
94
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 )
91
98
? 0
92
99
: Number . POSITIVE_INFINITY ;
93
100
}
Original file line number Diff line number Diff line change @@ -2,10 +2,12 @@ import isPresent from '@deities/hephaestus/isPresent.tsx';
2
2
import { expect , test } from 'vitest' ;
3
3
import startMap from '../../hermes/map-fixtures/they-are-close-to-home.tsx' ;
4
4
import { Skill } from '../info/Skill.tsx' ;
5
+ import { Path , Space } from '../info/Tile.tsx' ;
5
6
import {
6
7
Battleship ,
7
8
Flamethrower ,
8
9
Humvee ,
10
+ Jetpack ,
9
11
PatrolShip ,
10
12
XFighter ,
11
13
} from '../info/Unit.tsx' ;
@@ -1852,6 +1854,38 @@ test('correctly cancels transition costs in the Space biome', () => {
1852
1854
` ) ;
1853
1855
} ) ;
1854
1856
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
+
1855
1889
test ( 'Naval units cannot access bridges unless they are below a Sea tile' , ( ) => {
1856
1890
const map = radiusTestMap . copy ( {
1857
1891
buildings : radiusTestMap . buildings . deleteAll (
You can’t perform that action at this time.
0 commit comments