コード例 #1
0
    def test_visit_room_without_description(self):
        name = "name"
        room = Room(name)

        visit_description = room.Visit()

        self.assertIn(name, visit_description)
コード例 #2
0
ファイル: Map.py プロジェクト: carlosbarcelos/TextAdventure
def toMap(mapJSON, resources):
    # Add the explicity rooms
    map = {}
    for name, details in mapJSON.items():
        map[name] = Room(name, details, resources)

    # Find the coordinates of the implicit, empty rooms
    filledCoords = []
    maxX = 0
    maxY = 0
    for roomName in map:
        coord = map[roomName].coordinates
        if coord[0] > maxX: maxX = coord[0]  # Find the maximum X coordinate
        if coord[1] > maxY: maxY = coord[1]  # Find the maximum Y coordinate
        filledCoords.append(coord)

    # Add the implicit, empty rooms
    emptyDesc = {
        'title': 'empty',
        'description': 'empty',
        'connections': {},
        'area': 'empty',
        'icon': '|||',
        'coordinates': [],
        'visited': True
    }
    for i in range(maxX + 1):
        for j in range(maxY + 1):
            if [i, j] not in filledCoords:
                emptyDesc['coordinates'] = [i, j]
                map[f'empty_{i}_{j}'] = Room('empty', emptyDesc, resources)

    return map
コード例 #3
0
    def test_visit_room_first_time(self):
        name = "name"
        description = "description"
        room = Room(name, description)

        first_visit_description = room.Visit()

        self.assertIn(name, first_visit_description)
        self.assertIn(description, first_visit_description)
コード例 #4
0
    def test_visit_room_second_time(self):
        name = "name"
        description = "description"
        room = Room(name, description)

        room.Visit()
        second_visit_description = room.Visit()

        self.assertIn(name, second_visit_description)
        self.assertNotIn(description, second_visit_description)
コード例 #5
0
 def __init__(self, dict):
     self.__room = Room(dict["room_num"], dict["clean_rating"],
                        dict["electrical_appliance"], dict["sex"])
     self.__inventory = Inventory(dict["inventory_name"], dict["name"],
                                  dict["surname"], dict["patronymic"],
                                  dict["amount"], dict["num_in_queue"])
     self.__student = Student(dict["name"], dict["surname"],
                              dict["patronymic"], dict["bd"], dict["email"],
                              dict["faculty"], dict["course"],
                              dict["room_num"], dict["phone_number"],
                              dict["sex"])
コード例 #6
0
ファイル: test_room.py プロジェクト: Sh1n/sbit_exercise
def test_room_with_two_adjacent_rooms_should_return_correct_number_of_ids():
    objectDef = {
        'id': 1,
        'name': 'valid',
        'north': 3,
        'south': 4,
        'objects': []
    }
    room = Room(objectDef)
    assert len(room.getAvailableRooms()) == 2
    assert 4 in room.getAvailableRooms()
    assert 3 in room.getAvailableRooms()
コード例 #7
0
ファイル: main.py プロジェクト: rulepack/course-scheduler
def main(cmdArguments):
    if len(cmdArguments) <= 0:
        raise ValueError("Usage: python main.py <inputfile>")

    slots = []
    rooms = []
    courses = []
    instructors = []

    with open(cmdArguments[0]) as fp:
        for line in fp:
            if line.startswith("#"):
                # ignore comments in input file
                continue

            lineSections = line.split("=")
            if lineSections[0].strip() == "Slot":
                slots.append(Slot(lineSections[1]))
            elif lineSections[0].strip() == "Room":
                rooms.append(Room(lineSections[1]))
            elif lineSections[0].strip() == "Course":
                courses.append(Course(lineSections[1]))
            elif lineSections[0].strip() == "Instructor":
                instructors.append(Instructor(lineSections[1]))

    algo = GeneticAlgorithm(slots, rooms, courses, instructors)
    algo.initChromosomes(100)
    algo.execute()
コード例 #8
0
ファイル: test_room.py プロジェクト: Sh1n/sbit_exercise
def test_get_contained_items_should_return_correct_overlapping_set():
    objectDef = {
        'id': 1,
        'name': 'valid',
        'objects': [{
            'name': 'Knife'
        }, {
            'name': 'Pillow'
        }, {
            'name': 'Fork'
        }]
    }
    room = Room(objectDef)
    containedItems = room.getContainedItems(['Fork', 'Knife'])
    assert len(containedItems) == 2
    assert 'Fork' in containedItems
    assert 'Knife' in containedItems
コード例 #9
0
ファイル: test_room.py プロジェクト: Sh1n/sbit_exercise
def test_clean_room_with_two_adjacent_rooms_should_correctly_clear_pointers():
    objectDef = {
        'id': 1,
        'name': 'valid',
        'north': 3,
        'south': 4,
        'objects': []
    }
    room = Room(objectDef)
    room.cleanRooms()
    assert room.hasNorthRoom() == False
    assert room.hasSouthRoom() == False
コード例 #10
0
ファイル: test_room.py プロジェクト: Sh1n/sbit_exercise
def test_constructor_without_id_definition_should_raise_exception():
    objectDef = {}
    with pytest.raises(ValueError) as e_info:
        room = Room(objectDef)
    assert 'Room definition should contain attribute id' == str(e_info.value)
コード例 #11
0
ファイル: test_room.py プロジェクト: Sh1n/sbit_exercise
def test_constructor_with_not_well_formed_objects_list_should_return_empty_room(
):
    objectDef = {'id': 1, 'name': 'name', 'objects': ['invalid']}
    room = Room(objectDef)
    assert len(room.getObjects()) == 0
コード例 #12
0
ファイル: test_room.py プロジェクト: Sh1n/sbit_exercise
def test_constructor_with_invalid_objects_list_should_raise_exception():
    objectDef = {'id': 1, 'name': 'name', 'objects': 'invalid'}
    with pytest.raises(ValueError) as e_info:
        room = Room(objectDef)
    assert 'Room\'s definition of contained objects should be a list' == str(
        e_info.value)
コード例 #13
0
ファイル: test_room.py プロジェクト: Sh1n/sbit_exercise
def test_constructor_with_not_numeric_id_definition_should_raise_exception():
    objectDef = {'id': 'invalid'}
    with pytest.raises(ValueError) as e_info:
        room = Room(objectDef)
    assert 'Room identifier should be numeric' == str(e_info.value)
コード例 #14
0
ファイル: World.py プロジェクト: nehoraigold/gunslinger
 def load_board_from_csv(
         csv_file_path: str) -> typing.Dict[typing.Tuple[int, int], Room]:
     return {(i, j): Room(cell)
             for j, row in enumerate(utils.LoadCSV(csv_file_path))
             for i, cell in enumerate(row)}
コード例 #15
0
    def test_describe_room(self):
        name = "name"
        description = "description"
        room = Room(name, description)

        self.assertTrue(description in room.Describe())
コード例 #16
0
class StudentFacade:
    def __init__(self, dict):
        self.__room = Room(dict["room_num"], dict["clean_rating"],
                           dict["electrical_appliance"], dict["sex"])
        self.__inventory = Inventory(dict["inventory_name"], dict["name"],
                                     dict["surname"], dict["patronymic"],
                                     dict["amount"], dict["num_in_queue"])
        self.__student = Student(dict["name"], dict["surname"],
                                 dict["patronymic"], dict["bd"], dict["email"],
                                 dict["faculty"], dict["course"],
                                 dict["room_num"], dict["phone_number"],
                                 dict["sex"])

    def getStudentAmount(self):
        return self.__student.studentCount()

    def addStudent(self):
        # TODO write student to room
        stId = self.__student.addStudent()
        self.__room.addStudentToRoom(stId)

    def getRoom(self):
        self.__room.getRoom()

    def setRoom(self):
        self.__room.setRoom()

    # How did this occur here
    def getInventory(self):
        pass

    def getStudent(self):
        return self.__student.get()

    def updateStudent(self, array):
        self.__student.updateStudent()

    def removeStudent(self):
        self.__room.deleteStudentFromRoom(self.getStudent()["id"])
        self.__student.deleteStudent()

    def getAllRooms(self):
        rooms = self.__room.getAllRooms()
        res = []
        for room in rooms:
            temp = {"room_num": room['room'], "students": []}
            for i in room['students']:
                buff = self.__student.getStudentByID(i['stId'])
                temp["students"].append(buff["surname"] + " " + buff["name"] +
                                        " " + buff["patronymic"])
            res.append(temp)
        return res

    def getRoom(self):
        if self.__student.get()["room"] is not (None or ""):
            return self.__student.get()["room"]
        else:
            return "Not Found"

    def getAllStudent(self):
        return self.__student.getAllStudent()

    def getAmount(self):
        return self.__student.getAmount()