More & better forced connection detection

This commit is contained in:
aerinon
2020-03-03 08:25:52 -07:00
parent 83a9c4bdcf
commit 5aef551f7c
4 changed files with 99 additions and 52 deletions

View File

@@ -1024,6 +1024,30 @@ class Direction(Enum):
Up = 4
Down = 5
@unique
class Hook(Enum):
North = 0
West = 1
South = 2
East = 3
Stairs = 4
hook_dir_map = {
Direction.North: Hook.North,
Direction.South: Hook.South,
Direction.West: Hook.West,
Direction.East: Hook.East,
}
def hook_from_door(door):
if door.type == DoorType.SpiralStairs:
return Hook.Stairs
if door.type == DoorType.Normal:
return hook_dir_map[door.direction]
return None
class Polarity:
def __init__(self):
@@ -1282,6 +1306,13 @@ class Sector(object):
magnitude[idx] = magnitude[idx] + 1
return magnitude
def hook_magnitude(self):
magnitude = [0] * len(Hook)
for door in self.outstanding_doors:
idx = hook_from_door(door).value
magnitude[idx] = magnitude[idx] + 1
return magnitude
def outflow(self):
outflow = 0
for door in self.outstanding_doors: