예제 #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
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: room.py 프로젝트: elunna/labhack
 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
파일: test_Door.py 프로젝트: elunna/labhack
def test_init__room():
    r = Room(0, 0, 3, 3)
    d = Door(r, 1, 0)
    assert d.room == r
예제 #12
0
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: test_Door.py 프로젝트: elunna/labhack
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
파일: test_Door.py 프로젝트: elunna/labhack
def test_init__invalid_location__raises_exception():
    r = Room(0, 0, 3, 3)
    with pytest.raises(ValueError):
        Door(r, 0, 0)
예제 #15
0
파일: test_Door.py 프로젝트: elunna/labhack
def test_init__coords():
    r = Room(0, 0, 3, 3)
    d = Door(r, 1, 0)
    assert d.x == 1
    assert d.y == 0