forked from Bitcoindefi/OpenAO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsafeZone.ts
More file actions
52 lines (38 loc) · 1.29 KB
/
Copy pathsafeZone.ts
File metadata and controls
52 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import type { Position } from "./types/runtime";
export {};
const vars = require("./vars");
const mapInstanceManager = require("./mapInstanceManager");
function resolveZoneMapId(mapId: number | undefined): number | undefined {
if (!mapId) {
return mapId;
}
return mapInstanceManager.isInstanceMap(mapId) ? (mapInstanceManager.getBaseMapId(mapId) ?? mapId) : mapId;
}
export function isSafeZonePosition(mapId: number | undefined, pos: Position | undefined): boolean {
if (!mapId || !pos) {
return false;
}
const zoneMapId = resolveZoneMapId(mapId);
if (!zoneMapId) {
return false;
}
return vars.mapData[zoneMapId]?.pk === 1 || vars.mapa[zoneMapId]?.[pos.y]?.[pos.x]?.trigger === 6;
}
export function isUnsafeArenaPosition(mapId: number | undefined, pos: Position | undefined): boolean {
if (!mapId || !pos) {
return false;
}
const zoneMapId = resolveZoneMapId(mapId);
if (!zoneMapId) {
return false;
}
return vars.mapa[zoneMapId]?.[pos.y]?.[pos.x]?.trigger === 6;
}
export function getSafeZoneFlag(mapId: number | undefined, pos: Position | undefined): 0 | 1 {
return isSafeZonePosition(mapId, pos) ? 1 : 0;
}
module.exports = {
getSafeZoneFlag,
isSafeZonePosition,
isUnsafeArenaPosition,
};