(cycloper: Creature, G: Game)
| 989 | } |
| 990 | |
| 991 | function getRiotShieldPlacementRange(cycloper: Creature, G: Game) { |
| 992 | const baseRange = 3; |
| 993 | const canRelayThroughWalls = isRiotShieldUpgraded(cycloper); |
| 994 | const relayCount = canRelayThroughWalls |
| 995 | ? cycloper.player.creatures.filter( |
| 996 | (candidate) => |
| 997 | candidate instanceof Creature && |
| 998 | !candidate.dead && |
| 999 | isCycloperRelayWall(candidate, cycloper), |
| 1000 | ).length |
| 1001 | : 0; |
| 1002 | const scanDistance = baseRange + relayCount; |
| 1003 | const origin = getCycloperOrigin(cycloper); |
| 1004 | if (!origin) { |
| 1005 | return []; |
| 1006 | } |
| 1007 | const result: Hex[] = []; |
| 1008 | const seen = new Set<string>(); |
| 1009 | |
| 1010 | for (const direction of [0, 1, 2, 3, 4, 5]) { |
| 1011 | const line = G.grid.getHexLine(origin.x, origin.y, direction, cycloper.player.flipped); |
| 1012 | let effectiveDistance = 0; |
| 1013 | let scannedSteps = 0; |
| 1014 | |
| 1015 | for (const hex of line) { |
| 1016 | if (hex.creature === cycloper) { |
| 1017 | continue; |
| 1018 | } |
| 1019 | |
| 1020 | scannedSteps++; |
| 1021 | if (scannedSteps > scanDistance) { |
| 1022 | break; |
| 1023 | } |
| 1024 | |
| 1025 | const creature = hex.creature; |
| 1026 | const isAlliedWallHex = |
| 1027 | creature instanceof Creature && isAcrylicWall(creature) && creature.team === cycloper.team; |
| 1028 | const isDamagedWallHex = isDamagedAlliedAcrylicWall(creature, cycloper); |
| 1029 | const isRelayWallHex = canRelayThroughWalls && isAlliedWallHex; |
| 1030 | |
| 1031 | if (!isRelayWallHex) { |
| 1032 | effectiveDistance++; |
| 1033 | } |
| 1034 | |
| 1035 | if (effectiveDistance > baseRange) { |
| 1036 | break; |
| 1037 | } |
| 1038 | |
| 1039 | if (!creature || isDamagedWallHex) { |
| 1040 | const key = `${hex.x},${hex.y}`; |
| 1041 | if (!seen.has(key)) { |
| 1042 | seen.add(key); |
| 1043 | result.push(hex); |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | if (creature instanceof Creature && !isAlliedWallHex) { |
| 1048 | break; |
no test coverage detected