MCPcopy
hub / github.com/FreezingMoon/AncientBeast / getTargetDistanceInDirection

Function getTargetDistanceInDirection

src/abilities/Cycloper.ts:929–954  ·  view source on GitHub ↗
(
	cycloper: Creature,
	target: Creature,
	direction: number | undefined,
	G: Game,
)

Source from the content-addressed store, hash-verified

927}
928
929function 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
956function hasRelayExtensionOnPath(
957 cycloper: Creature,

Callers 3

hasRelayExtensionOnPathFunction · 0.85
isApertureTargetInRangeFunction · 0.85

Calls 2

getCycloperOriginFunction · 0.85
getHexLineMethod · 0.80

Tested by

no test coverage detected