Пример #1
0
 def __init__(self, name, station):
     Door.__init__(self, name, station)
     self.truck_list = []
     self.behaviour_list = ['empty', 'waiting', 'loading', 'waiting2']
     self.function_list = [self.empty, self.waiting, self.loading, self.waiting]
     self.good_times = []
     self.door_name = name
     self.waiting_name = 'waiting_to_deploy'
Пример #2
0
def test_facing_other__vertical():
    r1 = Room(0, 0, 3, 3)
    d1 = Door(r1, 1, 2)

    r2 = Room(0, 5, 4, 3)
    d2 = Door(r2, 1, 5)
    d3 = Door(r2, 2, 5)
    assert d1.facing_other(d2)  # Lined up vertically
    assert d2.facing_other(d1)  # Lined up vertically
    assert d1.facing_other(d3)  # Off by one
    assert d3.facing_other(d1)  # Off by one
Пример #3
0
def test_facing_other__horizontal():
    r1 = Room(0, 0, 3, 3)
    d1 = Door(r1, 2, 1)

    r2 = Room(5, 0, 3, 4)
    d2 = Door(r2, 5, 1)
    d3 = Door(r2, 5, 2)
    assert d1.facing_other(d2)  # Lined up horizontally
    assert d2.facing_other(d1)  # Lined up horizontally
    assert d1.facing_other(d3)  # Off by one
    assert d3.facing_other(d1)  # Off by one
Пример #4
0
 def __init__(self, name, station, door_list):
     Door.__init__(self, name, station)
     self.truck_list = []
     self.behaviour_list = ['empty', 'waiting_to_load', 'start_loading', 'must_load', 'loading', "waiting"]
     self.function_list = [self.empty, self.waiting_to_load, self.start_loading, self.must_load, self.loading, self.waiting]
     self.next_truck_number = 0
     self.waiting_name = 'waiting_to_load'
     self.good_ready = False
     self.current_goods = []
     self.goods = GoodStore()
     self.transfer_amounts = {}
     self.door_list = door_list
     self.critic = False
Пример #5
0
def test_facing_other__facing_away_horizontally():
    r1 = Room(0, 0, 3, 3)
    d1 = Door(r1, 0, 1)  # Facing west

    r2 = Room(5, 0, 3, 4)
    d2 = Door(r2, 7, 1)  # Facing east
    assert d1.facing_other(d2) is False  # Lined up horizontally
    assert d2.facing_other(d1) is False  # Lined up horizontally
Пример #6
0
def test_facing_other__facing_away_vertically():
    r1 = Room(0, 0, 3, 3)
    d1 = Door(r1, 1, 0)  # Facing N

    r2 = Room(0, 5, 4, 3)
    d2 = Door(r2, 1, 7)  # Facing S
    assert d1.facing_other(d2) is False  # Lined up vertically
    assert d2.facing_other(d1) is False  # Lined up vertically
Пример #7
0
def load_door(door, from_save, gap_x, gap_y):
    # Static data
    x = int(door.find('position/x').text) * TILE_SIZE + gap_x
    y = int(door.find('position/y').text) * TILE_SIZE + gap_y
    pos = (x, y)
    sprite = door.find('sprite').text.strip()

    # Dynamic data
    pick_lock_initiated = False
    if from_save:
        pick_lock_initiated = door.find('pick_lock_initiated') is not None

    loaded_door = Door(pos, sprite, pick_lock_initiated)
    return loaded_door
Пример #8
0
def test_facing_other__doors_lined_up_vertically():
    # These doors do not share the same y-axis, there is 1 space between them,
    # but we need at least 2 spaces for them to be facing eachother.
    r1 = Room(0, 0, 3, 3)
    d1 = Door(r1, 1, 2)  # Facing south

    r2 = Room(4, 3, 3, 3)
    d2 = Door(r2, 5, 3)  # Facing north
    assert d1.facing_other(d2)
    assert d2.facing_other(d1)
Пример #9
0
def test_facing_other__doors_lined_up_horizontally():
    # These doors do not share the same x-axis, there is 1 space between them,
    # but we need at least 2 spaces for them to be facing eachother.
    r1 = Room(0, 0, 3, 3)
    d1 = Door(r1, 2, 1)  # Facing east

    r2 = Room(3, 4, 3, 3)
    d2 = Door(r2, 3, 5)  # Facing west
    assert d1.facing_other(d2)
    assert d2.facing_other(d1)
Пример #10
0
 def get_all_possible_doors(self):
     """Returns a list of all the possible door locations in the room."""
     walls = self.perimeter().difference(self.corners())
     return [Door(self, x, y) for x, y in walls]
Пример #11
0
def test_init__room():
    r = Room(0, 0, 3, 3)
    d = Door(r, 1, 0)
    assert d.room == r
Пример #12
0
def test_facing_other__same_room():
    r = Room(0, 0, 3, 3)
    d1 = Door(r, 1, 0)
    d2 = Door(r, 2, 1)
    assert d1.facing_other(d2) is False
Пример #13
0
def test_init__not_in_its_room_raises_exception():
    r = Room(0, 0, 3, 3)
    with pytest.raises(ValueError):
        Door(r, 100, 1000)
Пример #14
0
def test_init__invalid_location__raises_exception():
    r = Room(0, 0, 3, 3)
    with pytest.raises(ValueError):
        Door(r, 0, 0)
Пример #15
0
def test_init__coords():
    r = Room(0, 0, 3, 3)
    d = Door(r, 1, 0)
    assert d.x == 1
    assert d.y == 0