def test_insert_child_with_parent_v5(zork_v5_obj_table: ZMachineObjectTable): # Take machine out of Machine room and put in West of House zork_v5_obj_table.insert_child(215, 68) west_of_house_tree = zork_v5_obj_table.obj_tree(68) assert len(west_of_house_tree['children']) == 3 assert west_of_house_tree['children'][0]['number'] == 215 machine_room_tree = zork_v5_obj_table.obj_tree(93) assert len(machine_room_tree['children']) == 1 assert machine_room_tree['children'][0]['number'] == 105
def test_insert_child_with_parent_v3(zork_v3_obj_table: ZMachineObjectTable): # Take machine out of Machine room and put in West of House zork_v3_obj_table.insert_child(158, 180) west_of_house_tree = zork_v3_obj_table.obj_tree(180) assert len(west_of_house_tree['children']) == 3 assert west_of_house_tree['children'][0]['number'] == 158 machine_room_tree = zork_v3_obj_table.obj_tree(157) assert len(machine_room_tree['children']) == 1 assert machine_room_tree['children'][0]['number'] == 112
def test_insert_child_without_parent_v5( zork_v5_obj_table: ZMachineObjectTable): zork_v5_obj_table.insert_child(46, 68) west_of_house_tree = zork_v5_obj_table.obj_tree(68) assert len(west_of_house_tree['children']) == 3 assert west_of_house_tree['children'][0]['number'] == 46
def main(argv): header, data = header_and_data(argv[1]) obj_table = ZMachineObjectTable(data, header) for i in range(1, 223): if obj_table.object(i).parent == 0: obj_tree = obj_table.obj_tree(i) print_obj_tree(obj_tree) return 0
def test_remove_obj_from_parent_last_child_v5( zork_v5_obj_table: ZMachineObjectTable): zork_v5_obj_table.remove_obj_from_parent(127) west_of_house_tree = zork_v5_obj_table.obj_tree(68) assert len(west_of_house_tree['children']) == 1 assert west_of_house_tree['children'][0]['number'] == 239 door_obj = zork_v5_obj_table.object(127) assert door_obj.parent == 0 assert door_obj.sibling == 0
def test_remove_obj_from_parent_last_child_v3( zork_v3_obj_table: ZMachineObjectTable): zork_v3_obj_table.remove_obj_from_parent(160) west_of_house_tree = zork_v3_obj_table.obj_tree(180) assert len(west_of_house_tree['children']) == 1 assert west_of_house_tree['children'][0]['number'] == 181 small_mailbox_obj = zork_v3_obj_table.object(160) assert small_mailbox_obj.parent == 0 assert small_mailbox_obj.sibling == 0
def test_remove_obj_from_parent_first_child_v5( zork_v5_obj_table: ZMachineObjectTable): zork_v5_obj_table.remove_obj_from_parent(239) west_of_house_tree = zork_v5_obj_table.obj_tree(68) assert len(west_of_house_tree['children']) == 1 assert west_of_house_tree['children'][0]['number'] == 127 small_mailbox_obj = zork_v5_obj_table.object(239) assert small_mailbox_obj.parent == 0, 'object should no longer have a parent' assert small_mailbox_obj.sibling == 0, 'object should no longer have a sibling'
def test_remove_obj_from_parent_first_child_v3( zork_v3_obj_table: ZMachineObjectTable): zork_v3_obj_table.remove_obj_from_parent(181) west_of_house_tree = zork_v3_obj_table.obj_tree(180) assert len(west_of_house_tree['children']) == 1 assert west_of_house_tree['children'][0]['number'] == 160 door_obj = zork_v3_obj_table.object(181) assert door_obj.parent == 0, 'object should no longer have a parent' assert door_obj.sibling == 0, 'object should no longer have a sibling'
def test_remove_obj_from_parent_middle_child_v5( zork_v5_obj_table: ZMachineObjectTable): zork_v5_obj_table.remove_obj_from_parent(203) maintenance_room_tree = zork_v5_obj_table.obj_tree(233) assert len(maintenance_room_tree['children']) == 8 assert maintenance_room_tree['children'][0]['number'] == 245 assert maintenance_room_tree['children'][1]['number'] == 120 tube_obj = zork_v5_obj_table.object(203) assert tube_obj.parent == 0 assert tube_obj.sibling == 0
def test_remove_obj_from_parent_middle_child_v3( zork_v3_obj_table: ZMachineObjectTable): zork_v3_obj_table.remove_obj_from_parent(91) maintenance_room_tree = zork_v3_obj_table.obj_tree(199) assert len(maintenance_room_tree['children']) == 8 assert maintenance_room_tree['children'][0]['number'] == 200 assert maintenance_room_tree['children'][1]['number'] == 99 wrench_obj = zork_v3_obj_table.object(91) assert wrench_obj.parent == 0 assert wrench_obj.sibling == 0