( cycloper: Creature, target: Creature, direction: number | undefined, G: Game, )
| 927 | } |
| 928 | |
| 929 | function getTargetDistanceInDirection( |
| 930 | cycloper: Creature, |
| 931 | target: Creature, |
| 932 | direction: number | undefined, |
| 933 | G: Game, |
| 934 | ) { |
| 935 | if (direction === undefined) { |
| 936 | return Number.POSITIVE_INFINITY; |
| 937 | } |
| 938 | |
| 939 | const origin = getCycloperOrigin(cycloper); |
| 940 | if (!origin) { |
| 941 | return Number.POSITIVE_INFINITY; |
| 942 | } |
| 943 | const line = G.grid.getHexLine(origin.x, origin.y, direction, cycloper.player.flipped); |
| 944 | |
| 945 | let distance = 0; |
| 946 | for (const hex of line) { |
| 947 | distance++; |
| 948 | if (hex.creature === target || target.hexagons.includes(hex)) { |
| 949 | return distance; |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | return Number.POSITIVE_INFINITY; |
| 954 | } |
| 955 | |
| 956 | function hasRelayExtensionOnPath( |
| 957 | cycloper: Creature, |
no test coverage detected