def game(): """Game Loop and Setup""" # Item test_item1 = item.Item("candle", "It lights the way.") test_item2 = item.Item("rope", "It is long and sturdy.") test_item3 = item.Item("chalice", "It is a dull copper.") # Create room object t_room1 = room.Room("R1", "D1", test_item1) t_room2 = room.Room("R2", "D2", test_item2) t_room3 = room.Room("R3", "D3", test_item3) # Room adds go as: North South East West t_room1.connect_rooms(t_room2, None, None, None) t_room2.connect_rooms(None, t_room1, None, t_room3) t_room3.connect_rooms(None, None, t_room2, None) """ Map: 3 - 2 | 1 """ current_room = t_room1 game_loop = True character = player.Player(input("Your name? "), [], 10, 10, 5, 5) print("Start the game, {}!".format(character.name)) while game_loop: user_input = input(">").lower() if user_input in ["end", "stop", "quit", "bye", "exit"]: game_loop = False elif user_input == "test": print(current_room) elif user_input == "menu": character.navigate_menu() elif user_input == "inspect": current_room.inspect_room() elif user_input == "get": character.add_to_backpack(current_room) elif user_input == "move": temp_room = current_room.move_rooms(input("N, S, E, W? ")[0]) if temp_room is None: print("There is no room there!") else: current_room = temp_room else: print("Invalid input.") print("Game over.")
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists r = room.Room('lonelyfire', roomPath) r.set_description( 'abandoned fire', 'You find yourself in a small chamber. On the the floor are several pieces of burnt wood arranged in a rough circle, as well as \ a series of charcoal paintings on the walls. One of the pieces of wood looks sturdy enough to take. The cave continues to the northwest.' ) r.add_adjectives('dark') r.add_exit('northwest', 'domains.school.forest.oil_pool') r.add_exit('south', 'domains.school.forest.forest_cave_entry') burnt_log = scenery.Scenery( 'log', 'burnt log', 'This log is large enough to have come from a tree, and it\'s sharp edges suggest that it was cut.' ) burnt_log.add_response( ['take', 'get'], 'The log begins to crumble in your hands when you try to take it.') burnt_log.add_adjectives('burnt', 'old', 'large', 'cut') burnt_log.move_to(r, True) log = gametools.clone('domains.school.forest.log') log.move_to(r, True) return r
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists forest_two = room.Room('forest', roomPath) forest_two.set_description( 'nice forest', 'This is an ancient forest with towering trees. They must be hundreds of years old at least.' ) forest_two.add_exit('west', 'domains.school.forest.forest1') forest_two.add_exit('east', 'domains.school.forest.field') forest_two.add_adjectives('ancient', 'towering', 'nice') pine_two = scenery.Scenery( 'pine', 'old, sturdy pine tree', 'This pine tree has clearly been here for quite a while. It seems strong and has some low branches you think you can reach.' ) pine_two.add_names('pine', 'tree') pine_two.add_adjectives( 'old', 'sturdy', ) pine_two.add_response( ['climb'], "Unfortunately, the lower branches are not as strong as the sturdy trunk, and you can't seem to get a hold of the higher ones.", emit_message='%s reaches for the lower branches, but they break off.') forest_two.insert(pine_two) return forest_two
def __init__(self, parent: app.App): self.app = parent # TODO: there will be many, dynamically loaded rooms. self.test_room = room.Room(self) logger.info(f"New level created: {self}")
def finalize(self, output_directory, preview=False): """Run the final process on the real room""" if self.room is None: self.room = room.Room(self.level_directory, self.values.room_id, self.selector) self.room.load(state.LevelState.DressingPersonalized) self.room.finalize(output_directory, preview)
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists dark_forest = room.Room('darkforest', roomPath) dark_forest.set_description( 'scary, dark forest', 'This is a scary, dark forest that you want to leave...soon!') dark_forest.add_exit("south", "domains.school.forest.forest3") dark_forest.add_exit("north", "domains.school.forest.gloomy_forest") dead_tree = scenery.Scenery( 'dead_tree', 'big dead tree', 'This dead tree is big and bare with no bark. At the bottom of it there is a rat hole. ' ) dead_tree.add_names('tree') dead_tree.add_adjectives('dead') dead_tree.add_response([ 'climb' ], 'When you try to climb the tree, the branch you grab on to breaks off with an eerie snap.' ) dark_forest.insert(dead_tree) rat = gametools.clone('domains.school.forest.rat') rat.move_to(dark_forest) return dark_forest
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists firepit_room = room.Room('fireQuest1', roomPath) firepit_room.indoor = True firepit_room.set_description( 'large room with a firepit in the middle', 'This large domed room has paintings ' 'of dancing flames on the walls. It has a firepit in the center, currently unlit and filled with sturdy oak ' 'branches. The doorway through which you entered is to the northwest. ' ) firepit_room.add_exit('northwest', 'domains.school.elementQuest.path_choice') firepit_room.add_exit('southeast', 'domains.school.elementQuest.tapestries') global firepit firepit = scenery.Scenery( 'firepit', 'copper firepit', 'This copper firepit is filled with sturdy oak branches. It is unlit.') firepit.actions.append( room.Action(light_firepit, ['light', 'hold', 'touch', 'put'], True, False)) firepit.actions.append(room.Action(take, ['take', 'get'], True, False)) firepit.lit = False firepit_room.insert(firepit) return firepit_room
def build_house(self): names = ['Weatherby', 'Hill House', 'Northshire Cottage', 'Donnovar Manor', 'Trillhelm', "Joe's Shack", 'An abandoned mill', 'Greyview', 'Elsinor Cottage', 'Overgrown ruins', 'A store house', 'A workshop', 'A barn', 'A house', 'A cottage'] n = random.choice(names) while n in self.areas: n = random.choice(names) self.houses[n] = {} xr = random.randint(1,2) yr = random.randint(1,2) xc = self.r() yc = self.r() close = self.closest_road_coord((xc, yc)) while close[0] < 9: xc = self.r() yc = self.r() close = self.closest_road_coord((xc, yc)) nl = yc + yr sl = yc - yr el = xc + xr wl = xc - xr x = wl y = sl while x <= el: while y <= nl: c = (x, y) r = room.Room( c, 'house', n ) self.all_rooms[c] = r self.houses[n][c] = r y += 1 y = sl x += 1 print(" > %s has been built with %s rooms" % (n, len(self.houses[n]) ) ) self.build_path((xc, yc), close[1], "Path to %s" % n)
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists r = room.Room('empty_room', roomPath) r.set_description('empty void', 'You find yourself in an empty void with a translucent floor. ' 'You see four mirrors, one north, one south, one east, and one west.') human = mirror.Mirror('a human, smiling back at you', 'domains.character_creation.gender', species='human') human.add_adjectives('north', 'human') r.insert(human) elf = mirror.Mirror('an elf, smiling back at you', 'domains.character_creation.gender', species='elf') elf.add_adjectives('south', 'elf') r.insert(elf) dwarf = mirror.Mirror('a dwarf, smiling back at you', 'domains.character_creation.gender', species='dwarf') dwarf.add_adjectives('east', 'dwarf') r.insert(dwarf) gnome = mirror.Mirror('a gnome, smiling back at you', 'domains.character_creation.gender', species='gnome') gnome.add_adjectives('west', 'gnome') r.insert(gnome) return r
def explore_start(): state.player = player.Ranger() state.player.x = 40 state.player.y = 6 pytality.term.clear() x = state.width - 80 g.buffer = pytality.buffer.Buffer(x=x, width=state.width - x, height=0) g.text = pytality.buffer.PlainText( "YOU ARE A %s" % state.player.title, x=0, y=state.height/2, center_to=g.buffer.width, fg=pytality.colors.BLUE ) g.stat_bar = pytality.buffer.Box( width=g.buffer.width, height=6, padding_x=2, padding_y=1, draw_left=False, draw_top=False, children = [ pytality.buffer.RichText("<GREEN>Health:</> %s", y=0), pytality.buffer.RichText("<YELLOW>Stamina:</> %s", y=2) ] ) g.room_container = pytality.buffer.Buffer(x=0, width=g.buffer.width, height=state.height - g.stat_bar.height, y=g.stat_bar.height) g.buffer.children += [g.text, g.stat_bar, g.room_container] for i in range(10): message.add("hoo boy!") set_room(room.Room(room.layout))
def setUp(self): ''' create instance of Movie class ''' self.room = room.Room(ROOM_NAME, ROOM_SIZE) # change number of occupated places self.room.occupated_places = OCCUPATED_PLACES # reserve one place in cinema room self.room._Room__seating[1][1] = ROOM_SEATING[1][1]
def get_room(self, db, roomid): cur = db.execute('select room_id, name from rooms where room_id = ?', [roomid]) rooms = cur.fetchall() rm = rooms[0] cur = db.execute( 'select room_roomgroup.roomgroup_id, room_roomgroup.room_id, roomgroups.roomgroup_name from room_roomgroup natural join roomgroups where room_roomgroup.room_id =?', [roomid]) roomgrouprows = cur.fetchall() roomgroups = [] for row in roomgrouprows: rmgrp = roomgroup.Roomgroup(row['roomgroup_id'], row['roomgroup_name']) roomgroups.append(rmgrp) cur = db.execute('select * from room_device where room_id = ?', [roomid]) devicerows = cur.fetchall() devices = [] df = devicefactory.DeviceFactory() for row in devicerows: deviceid = row['device_id'] device = df.get_device(db, deviceid) devices.append(device) return room.Room(rm['room_id'], rm['name'], roomgroups, devices)
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists r = room.Room('tapestries', roomPath) r.indoor = True r.set_description('room with many tapestries hanging', 'This smaller circular room has many tapestries hanging around it.') r.add_exit('northwest', 'domains.school.elementQuest.firepit') r.add_exit('south', 'domains.school.elementQuest.shaft_of_sunlight') cloth = gametools.clone('domains.school.elementQuest.cloth') r.insert(cloth) tapestry1 = scenery.Scenery('tapestry', 'tapestry decorated with dancing flames', 'This tapestry has a fire with dancing flames woven into it. It almost seems as if the fire on it was actually burning.') tapestry1.add_response(['take', 'get'], 'You feel as if this tapestry should not be taken...as if you would be taking a piece of the room.') tapestry1.add_adjectives('dancing', 'flames') r.insert(tapestry1) tapestry2 = scenery.Scenery('tapestry', 'tapestry decorated with burning embers', 'This tapestry has the burning embers of a fire woven into it. It almost seems as if they were actual coals.') tapestry2.add_response(['take', 'get'], 'You feel as if this tapestry should not be taken...as if you would be taking a piece of the room.') tapestry2.add_adjectives('burning', 'embers') r.insert(tapestry2) return r
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists bedroom = room.Room('bedroom', roomPath) bedroom.indoor = True bedroom.set_description( 'dusty bedroom', 'The bare board walls of this bedroom are dusty. A musty smell fills the air.' ) bedroom.add_exit('northwest', 'domains.school.forest.hallway') bed = scenery.Scenery( 'bed', 'decrepit old bed', 'This decrepit bed supports a bare stained mattress and is covered with a thick layer of dust.' ) bed.add_adjectives('old', 'decrepit') bed.add_response([ 'sleep' ], 'You briefly consider sleeping on the dusty, soiled mattress but quickly think better of it.', True, True) bed.add_response( ['make'], 'You look around for sheets or blankets but see nothing suitable with which to make the bed.', emit_message='%s looks around the room.') bedroom.insert(bed) sword = gametools.clone('domains.school.forest.sword') bedroom.insert(sword) leather_suit = gametools.clone('domains.school.forest.leather_suit') bedroom.insert(leather_suit) return bedroom
def testSleep(self): self.testMember.asleep = True roomTwo = room.Room("testRoomTwo") roomTwo.stand.append((4,5)) self.testRoom.connectToRoom(roomTwo) with self.assertRaises(client_action.ActionError): self.testMember.move(roomTwo)
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists bathroom = room.Room('bathroom', pref_id=roomPath, indoor=True) bathroom.set_description( 'modern bathroom', 'This small bathroom has a bathtub, a shower, and a sink.') bathroom.add_exit('east', 'home.alex.house.lr31795') bathroom.add_adjectives('modern') bathtub = gametools.clone('home.alex.house.bathtub') bathtub.move_to(bathroom, True) sink = gametools.clone('home.alex.house.sink') sink.move_to(bathroom, True) toilet = scenery.Scenery('toilet', 'ordinary toilet', 'This is an ordinary toilet.') toilet.add_response(['flush'], 'You flush the toilet.') toilet.move_to(bathroom, True) cabinet = gametools.clone('home.alex.house.cabinets') cabinet.move_to(bathroom, True) return bathroom
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists r = room.Room('sunlit room', roomPath) r.indoor = True r.set_description( 'small sunlit room', 'This circular room is lit by a shaft of sunlight in the center. The walls here are made of clay, baked like bricks by a fire.' ) r.add_names('room') r.add_adjectives('sunlit', 'circular', 'round') r.add_exit('north', 'domains.school.elementQuest.tapestries') r.add_exit('southwest', 'domains.school.elementQuest.potion_room') shaft = scenery.Scenery( 'shaft', 'shaft of sunlight', 'This shaft of sunlight glows down in the center of the room. Something about this shaft makes it very clear where the sun is shining and where it is not.' ) shaft.add_names('sunlight') shaft.add_response(['step'], 'You step into the shaft of sunlight. It is warm.') r.insert(shaft) return r
def map_burrow(self): "Decode the burrow information" # 1. Decode the hallway self.hallway = hallway.Hallway(text=self.text, part2=self.part2) # 2. For each doorway in the hall there is a room for doorway in self.hallway.doorways: # 3. Who wants to be in this room homeroom = AMPHIPODS[len(self.rooms)] # 4. But who is really in the room? contents = [] for line in self.text[2:]: if line[doorway + 1] != WALL: contents.append(line[doorway + 1]) # 5. Construct the room the_room = room.Room(doorway=doorway, homeroom=homeroom, contents=contents) # 6. Add it to the rooms self.rooms[doorway] = the_room # 7. Set the lengths self.hall_len = len(self.hallway.spaces) self.room_len = len(contents) self.poss_len = self.hall_len + len(self.rooms) * self.room_len
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists r = room.Room('gloomyforest', roomPath) r.set_description( 'gloomy forest', 'This is a very gloomy forest. Here the trail coming from the south fades away to the point that you can\'t see it anymore.' ) r.add_adjectives('gloomy') r.add_exit('south', 'domains.school.forest.dark_forest') r.add_exit('west', 'domains.school.forest.forest_cave_entry') witherd_boulder = scenery.Scenery( 'boulder', 'withered boulder', 'This withered boulder is covered in an ancient lichen.') witherd_boulder.add_response([ 'sit' ], 'You consider sitting on the boulder, but the forest surrounding you makes you feel like you should stay on your toes.' ) witherd_boulder.add_response(['move'], 'The boulder is too heavy to move.') r.insert(witherd_boulder) return r
def init_rooms(self): rooms = [] total = 0 t0 = time.time() for dirpath, dirnames, filenames in os.walk(self.data_path): for dirname in dirnames: zone_path = extract_zone_path(self.data_path, dirpath, dirname) self.create_zone(zone_path) for name in filenames: room_path = os.path.join(dirpath, name) this_zone = extract_zone_path_from_room( self.data_path, room_path) room_id = re.sub('[.].+$', '', name) fh = open(room_path, 'r') room_string = fh.read() path = '%s/%s' % ('/'.join(this_zone), room_id) rm = room.Room(self, room_id, path, room_string) self.insert_room(this_zone, rm) rooms.append(rm) fh.close() total += 1 for rm in rooms: rm.parse() t1 = time.time() print 'Initialized world consisting of %d rooms in %d seconds' % ( total, t1 - t0) #for testing rm = self.query_room('Sephix/Outside/Market/Vitenir\'s Arch') mob = warrior.OrcWarrior('orc-64', rm)
def join_room(self, user, money, betsize, beton): """ adds user to the room with the minimum number of people to prevent starvation increments the room size when we add a user such that we only have maximum self.cap (5 in this case) users in a room """ print("adding user " + user + " to a room") self.self_lock.acquire() idx = self.get_min_room() if idx != -1: rm = self.rooms[idx] rm[1] += 1 t = threading.Thread(target=rm[0].addToRoom, args=([user, money], )) t.start() self.users[user] = idx else: new_room = room.Room(self.game_map[self.name], self.room_msgs) t = threading.Thread(target=new_room.addToRoom, args=([user, money], )) t.start() self.rooms.append([new_room, 1]) self.users[user] = len(self.rooms) - 1 for rm in self.rooms: rm[0].printRoom() self.self_lock.release() print("release lock in join")
def build_path(self, s, e, n): c = s steps = [] #destination minus current v = [-1, -1] #default heads west and south if s[0] < e[0]: #head east v[0] = 1 if s[1] < e[1]: #head north v[1] = 1 xd = (v[0], 0) yd = (0, v[1]) xs = [xd] * abs(e[0] - s[0]) ys = [yd] * abs(e[1] - s[1]) steps = xs + ys random.shuffle(steps) while len(steps) > 0: c = (c[0] + steps[0][0], c[1] + steps[0][1]) #self.display_map(c) if c not in self.all_rooms: r = room.Room( c, 'path', n ) self.all_rooms[c] = r self.road_coord_list.append(c) steps.pop(0)
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists woods = room.Room('woods', pref_id=roomPath) woods.set_description( 'bright and cheerful woods', 'These woods have happy birdsongs and pretty trees. They are bright.') woods.add_exit('west', 'domains.school.forest.entryway') woods.add_exit('north', 'domains.school.forest.forest1') woods.add_exit('south', 'domains.school.forest.clearing') bag = gametools.clone('domains.school.forest.bag') woods.insert(bag) flashlight = gametools.clone('domains.school.forest.flashlight') woods.insert(flashlight) beech = scenery.Scenery( "beech", "old beech tree full of carvings", "This large old beech tree has been scarred with the reminders of many passers-by, who decided to immortalize their visit by carving their initials into the tree." ) beech.add_names("tree") beech.add_adjectives("old", "beech", "carved") beech.add_response([ "carve" ], "You think about carving your own initials into the tree, but an uneasy feeling--as if the forest itself is watching--makes you stop." ) woods.insert(beech) bird = gametools.clone('domains.school.forest.bird') woods.insert(bird) return woods
def setup_environments(): myenv = [] for room in home: e = env.Room(room) myenv.append(e) return myenv
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists magic_room = room.Room('magical room', roomPath, indoor=True) magic_room.set_description( 'magical room', 'This room has a lot of magical supplies. It also has a door on the west side of the room with a piece of paper above it.' ) magic_room.add_exit('north', 'home.alex.house.lr31795') magic_room.add_exit('west', 'woods') magic_room.add_names('room') magic_room.add_adjectives('magic', 'magical') paper = gametools.clone('home.alex.house.paper') magic_room.insert(paper, True) emerald = gametools.clone('home.alex.house.emerald') magic_room.insert(emerald, True) ruby = gametools.clone('home.alex.house.ruby') magic_room.insert(ruby, True) opal = gametools.clone('home.alex.house.opal') magic_room.insert(opal, True) return magic_room
def load(): roomPath = gametools.findGamePath(__file__) exists = room.check_loaded(roomPath) if exists: return exists gallery = room.Room('gallery', safe=True, pref_id=roomPath) gallery.indoor = True gallery.set_description( 'portrait gallery', "This grandiose portrait gallery overlooks the Great Hall through a pillared colonnade." ) gallery.add_exit('east', 'domains.school.school.landing') gallery.add_exit('north', 'domains.school.school.hmasters_office') gallery.add_exit('northeast', 'domains.school.school.hallway') portrait = scenery.Scenery( 'portrait', 'fancy portrait', 'This oil on canvas portrait is of a strange figure. He is dressed in dark colors and is against a dark background.' ) portrait.add_adjectives('fancy') portrait.add_response( 'take', 'You think about taking the portait for a moment, but then realize that it is the school\'s property and should not steal it.' ) gallery.insert(portrait, True) portrait_two = scenery.Scenery( 'portrait', 'light portait', 'This portrait is over a woman in a sky blue dress, with very long hair. She seems to be in front of a large lake, surrounded by a thick forest.' ) portrait_two.add_adjectives('light') portrait_two.add_response( 'take', 'You think about taking the portait for a moment, but then realize that it is the school\'s property and should not steal it.' ) gallery.insert(portrait_two, True) portrait_three = scenery.Scenery( 'portrait', 'bright portait', 'This portait is of a woman and a man in a blazing fire. They almost seem to be performing some sort of meditation exersise.' ) portrait_three.add_adjectives('bright') portrait_three.add_response( 'take', 'You think about taking the portait for a moment, but then realize that it is the school\'s property and should not steal it.' ) gallery.insert(portrait_three, True) portrait_four = scenery.Scenery( 'portrait', 'seethrough portait', 'This portait is very strange. It is made of glass. You can barely make out a figure in the center.' ) portrait_four.add_adjectives('seethrough', 'glass') portrait_four.add_response( 'take', 'You think about taking the portait for a moment, but then realize that it is the school\'s property and should not steal it.' ) gallery.insert(portrait_four, True) return gallery
def load(self): log.info(f"Loading area: {self.area_path}") with open(self.area_path, 'r') as thefile: data = thefile.read() # Load Header Data into this Area log.info(f"Loading area Header: {self.area_path}") for eachkey, eachvalue in json.loads(data).items(): setattr(self, eachkey, eachvalue) # Load each Room into this Area log.info(f"{self.name} : Loading area Rooms") roomfilepath = os.path.join(self.folder_path, f"rooms/*.json") filenames = glob.glob(roomfilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: room.Room(self, thefile.read()) # Load each Exit and attach it to a room log.info(f"{self.name} : Loading area Exits") exitfilepath = os.path.join(self.folder_path, f"exits/*.json") filenames = glob.glob(exitfilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: fullpath, direction_fn = eachfile.split('.')[0].split('-') roomvnum = fullpath.split('/')[-1:][0] attached_room = self.room_by_vnum(int(roomvnum)) if attached_room is None: log.warning( f"room_by_vnum_global failed in exit load: {roomvnum}") else: exits.Exit(attached_room, direction_fn, thefile.read()) # Load each Mobile in to the Indexes. log.info(f"{self.name} : Loading area Mobiles") mobilefilepath = os.path.join(self.folder_path, f"mobiles/*.json") filenames = glob.glob(mobilefilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: mobile.Mobile(self, thefile.read()) # Load each Object in to the Indexes. log.info(f"{self.name} : Loading area Objects") objectfilepath = os.path.join(self.folder_path, f"objects/*.json") filenames = glob.glob(objectfilepath) for eachfile in filenames: with open(eachfile, 'r') as thefile: objects.Object(self, thefile.read(), load_type="index") # Load the resets for this area. log.info(f"{self.name} : Loading area Resets") resetfilepath = os.path.join(self.folder_path, f"resets/resets.json") if os.path.exists(resetfilepath): with open(resetfilepath, 'r') as thefile: reset.Reset(self, thefile.read()) # Add this area to the area list. log.info(f"{self.name} : Appending to arealist.") arealist.append(self)
def test_text_init(self): "Test the Room object creation from text" # 1. Create Room object from text myobj = room.Room("aaaaa-bbb-z-y-x-123[abxyz]") # 2. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 26) self.assertEqual(myobj.name, "aaaaa-bbb-z-y-x") self.assertEqual(myobj.id, 123) self.assertEqual(myobj.checksum, "abxyz") self.assertEqual(myobj.valid, True) # 3. Create another Room object from text myobj = room.Room("a-b-c-d-e-f-g-h-987[abcde]") # 4. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 26) self.assertEqual(myobj.name, "a-b-c-d-e-f-g-h") self.assertEqual(myobj.id, 987) self.assertEqual(myobj.checksum, "abcde") self.assertEqual(myobj.valid, True) # 5. Create yet another Room object from text myobj = room.Room("not-a-real-room-404[oarel]") # 6. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 26) self.assertEqual(myobj.name, "not-a-real-room") self.assertEqual(myobj.id, 404) self.assertEqual(myobj.checksum, "oarel") self.assertEqual(myobj.valid, True) # 7. Create last Room object from text myobj = room.Room("totally-real-room-200[decoy]") # 8. Make sure it has the expected values self.assertEqual(myobj.part2, False) self.assertEqual(len(myobj.text), 28) self.assertEqual(myobj.name, "totally-real-room") self.assertEqual(myobj.id, 200) self.assertEqual(myobj.checksum, "decoy") self.assertEqual(myobj.valid, False)
def test_part_two(self): "Test part two example of Room object" # 1. Create Room object from text myobj = room.Room(part2=True, text=aoc_18.from_text(PART_TWO_TEXT)) # 2. Check the part two result self.assertEqual(myobj.part_two(verbose=False), PART_TWO_RESULT)
def dressing_instantiation(self): """Run the brick personalization process on the real room""" if self.room is None: self.room = room.Room(self.level_directory, self.values.room_id, self.selector) self.room.load(state.LevelState.Personalized) self.room.dressing_instantiation() self.state = state.LevelState.DressingInstantiated