def door_stats(num_rooms, iqr): n = num_rooms # TODO: this number is probably wrong, but it's the number that got me # closest to the actual time shown on the screen in my most recent # run. t = n * 120 best = FrameCount(t) p25 = FrameCount(t) p50 = FrameCount(t) p75 = FrameCount(t) p90 = FrameCount(t) save = p75 - p25 if iqr else p50 - best most_recent = FrameCount(t) save_most_recent = max(most_recent - p50, FrameCount(0)) return TransitionStats(room=Room(None, 'Uncounted door time'), n='', best=best, p25=p25, p50=p50, p75=p75, p90=p90, save=save, most_recent=most_recent, save_most_recent=save_most_recent, items='', beams='')
def bulck_update(self, params, start, finish): params['property_id'] = self.hotel_ids[start:finish] res1 = requests.get(url=self.base_url + 'properties/availability', headers=self.headers, params=params) print res1.text all_rooms = json.loads(res1.text) for rooms_info in all_rooms: property_id = rooms_info['property_id'] if property_id not in self.avail_rooms: self.avail_rooms[property_id] = [] for data in rooms_info['rooms']: available_nums = data['rates'][0]['available_rooms'] room = Room(id=data['id'], room_name=data['room_name'].encode( 'ascii', 'ignore'), available_nums=available_nums) self.avail_rooms[property_id].append(room) self.hotel_ids = self.avail_rooms.keys() print 'new_hotel_ids:----------------------------' print self.hotel_ids print '--------------------------------------------------------------------------------------------------------------' print '--------------------------------------------------------------------------------------------------------------' print '--------------------------------------------------------------------------------------------------------------'
def __init__(self): # Log attribute self.start_time = time.strftime(r"%y-%m-%d %H.%M.%S") self.log("Inicializando servidor...") # Diccionario a contener los sockets de los clients self.host = PARAMETROS["host"] self.port = PARAMETROS["port"] self.server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Other attributes self.sockets = dict() self.rooms = [ Room(nombre=f"Sala {i}") for i in range(PARAMETROS["rooms_number"]) ] self.usuarios = { usuario.username: usuario for usuario in Usuario.get_usuarios() } self.server_socket.bind((self.host, self.port)) self.log("Dirección y puerto enlazados..") self.server_socket.listen() self.log(f"Servidor escuchando en {self.host}:{self.port}...") thread = threading.Thread(target=self.login_thread, daemon=True) thread.start() self.log("Servidor aceptando conexiones...")
def __init__(self, fileName): # iterate through the rooms in the database, creating an object for each room. self.rooms = {} for element in self.getElements(fileName, "room"): obj = Room() obj.id = element.get("id") obj.x = element.get("x") obj.y = element.get("y") obj.z = element.get("z") obj.region = element.get("region") obj.terrain = element.get("terrain", "UNDEFINED") obj.name = element.findtext("roomname") obj.desc = element.findtext("desc") obj.note = element.findtext("note") obj.exits = [] for x in element.findall("./exits/exit"): newExit = Exit() newExit.dir = self.directionNames[x.get("dir")] newExit.to = x.get("to") newExit.door = x.get("door") obj.exits.append(newExit) obj.exits.sort( key=lambda k: self.directionNames.values().index(k.dir)) obj.setCost(obj.terrain) # Add a reference to the room object to our self.rooms dict, using the room ID as the key. self.rooms[obj.id] = obj
def main() : e = league.Engine("Spook City") e.init_pygame() timer = pygame.time.set_timer(pygame.USEREVENT + 1, 1000 // league.Settings.gameTimeFactor) count = 0 p = Player(1, 400, 300) spawner = EnemySpawner(e,p) crate = createInteract(e,p) spawner.createEnemy(2,128,128) crate.createLanternContainer(2,128,300) crate.createBeartrapContainer(2,256,300) mapRenderer = MapRenderer("first room", e) world_size = mapRenderer.renderBackground() p.world_size = world_size mapRenderer.renderForeGround() d = Door(2, 300, 4, 300, 416, "second room", e) e.light_points = p.raycast_points e.player = p overlay = Overlay(p) e.overlay = overlay e.objects.append(p) e.objects.append(overlay) e.objects.append(d) # any objects to be created on the fly p.items = e.dynamic_instances p.interactables.add(d) # add all drawables e.drawables.add(p) e.drawables.add(d) mapRenderer.renderForeGround() p.resetx = 300 p.resety = 416 bgm = BackgroundMusic("lavender town") bgm.start_music() # add all impassable sprites to classes which need them for impassable in mapRenderer.getAllImpassables(): p.blocks.add(impassable) # create room object in engine e.room = Room(p, e, overlay) p.room = e.room e.key_events[pygame.K_a] = p.move_left e.key_events[pygame.K_d] = p.move_right e.key_events[pygame.K_w] = p.move_up e.key_events[pygame.K_s] = p.move_down e.key_events[pygame.K_e] = p.interact e.key_events[pygame.K_SPACE] = p.use_active_item e.key_events[pygame.K_ESCAPE] = e.stop e.events[pygame.QUIT] = e.stop e.run()
def play_game(p_level): p_room = Room(p_level) print("You are about to play in maze craze level - {}".format(p_level)) maze_disp = p_room.maze_size() for i in maze_disp: print("\t\t\t" + "\t".join(i)) print("." * 80) print("Press e for entering the maze") print("Press i for checking the inventory") print("Press x for exiting the game") while my_inventory.moves > 0: user = input(" > ") if user == "e": p_step = p_room.maze_setup() p_room.display_maze(p_step) while True: print("\n") print( " \033[3;32;40m Your score is {} \033[m". format(my_inventory.score)) print("." * 80) print( "Moves :r - right\tl - left\tu - up\td - down \t x - exit") print("." * 80) p_input = input("> ") if p_input == "r" or p_input == "l" or p_input == "u" or p_input == "d": p_step, p_stage = p_room.move(p_step, p_input) if p_stage: os.system("clear") print("\033[3;30;43m Level up.\033[m") player1.play_level = p_level player1.player_score = my_inventory.score player1.player_log() p_level = p_level + 1 play_game(p_level) else: p_room.display_maze(p_step) elif p_input == "x": sys.exit(0) elif p_input == "i": print(my_inventory) else: print("Give correct choice") elif user == "i": print(my_inventory) elif user == "x": print("Exiting the game.") sys.exit() else: print("\033[3;32;46m Please enter the right choice.\033[m") os.system("clear") print("\033[3;32;47m Sorry you dont have moves.\033[m") sys.exit()
def make_rooms(self): room_size = c.SCREEN_SIZE wall_size = c.TILE_SIZE self.rooms = {} for room_number in self.floor.rooms_on_floor: exits = self.floor.floor_dict[room_number] self.rooms[room_number] = Room(room_number, (0, 0), exits, room_size, wall_size, self, self.player)
def build_parts(self, **kw): # menus = OrthoView("menus",[], _vport=(0,0,1024,768)) # with menus.compile_style(): # glDisable(GL_LIGHTING) sv = SceneView("scene", [], _vport=(0.0, 128, 1.0, 1.0), _ClearColor=(0.3, 0.3, 0.3, 1.0), _perspective_angle=30.0) hroom = Room("Room", self.room + ".txt") outdoors = "outdoors" in hroom.flags ppos = hroom.gates.get(self.start, (0, 0, 0)) sv.append(hroom) self.camera = sv.camera self.player = Player((ppos[0], ppos[1], 0), ppos[2], 1.2, self.camera) with sv.compile_style(): glEnable(GL_LIGHTING) lighting.two_side(True) lighting.local_viewer(True) lighting.light_position(self.light, (hroom.width / 2, hroom.height / 2, 2, 1)) lighting.light_colour(self.light, (1, 1, 0.9, 1)) lighting.light_switch(self.light, True) lighting.light_attenuation(self.light, (0, ) if (outdoors) else (0.01, )) self.append(sv) ov = OrthoView("itembar", [], _vport=(0.0, 0.0, 1.0, 128), _ClearColor=(0.1, 0, 0, 1.0), _left=0, _right=1024, _top=128, _bottom=0) speechport = OrthoView("speech", [], _ClearColor=None, _left=0, _right=1024, _top=768, _bottom=0) with ov.compile_style(): glDisable(GL_LIGHTING) with speechport.compile_style(): glDisable(GL_LIGHTING) self.append(ov) self.append(speechport) tpanel = LabelPanel("text", hroom.name, _text_width=1000, _pos=(512, 48, 0)) ov.append(tpanel)
def format(self): """Format the reservation.""" DFMT = "%m-%d-%Y " TFMT = "%I:%M%p" st = self.starttime.strftime(DFMT+TFMT) en = self.endtime.strftime(DFMT+TFMT) # If on the same day, print the date once if self.starttime.date() == self.endtime.date(): en = self.endtime.strftime(TFMT) rv = '%s to %s: ' % (st, en) if hasattr(self, 'displayname'): # room info loaded from rooms import Room rv += Room(**self.__dict__).display else: rv += '%s %s' % (self.building, self.roomnum) return rv
def read_room(infileobj): new_room = Room() new_room.name = read_qstring(infileobj) new_room.desc = read_qstring(infileobj) new_room.dynamicDesc = read_qstring(infileobj) new_room.id = str(read_uint32(infileobj)) new_room.note = read_qstring(infileobj) new_room.terrain = terrain_type[read_uint8(infileobj)] new_room.light = light_type[read_uint8(infileobj)] new_room.align = align_type[read_uint8(infileobj)] new_room.portable = portable_type[read_uint8(infileobj)] new_room.ridable = ridable_type[read_uint8(infileobj)] new_room.mobFlags = mobflags.bits_to_flag_set(read_uint16(infileobj)) new_room.loadFlags = loadflags.bits_to_flag_set(read_uint16(infileobj)) new_room.updated = bool(read_uint8(infileobj)) new_room.x = read_int32(infileobj) new_room.y = read_int32(infileobj) new_room.z = read_int32(infileobj) new_room.exits = read_exits(infileobj) #[x for x in read_exits(infileobj)] return new_room
def rooms(self): """ Returns a list of room device objects. Args: None Returns: `list` of rooms.Room objects. """ roomsList = [] queryStr = "{0}/User?expand=appliance%2Cdevice&user_id={1}".format( REST_URL, self.__userObj.userId) log(queryStr) response = requests.get(queryStr, headers=self.__headers, verify=False) for device in response.json()["devices"]: roomObj = Room(device, self.__headers) roomsList.append(roomObj) return roomsList
def setup_room(gamesettings): room = Room(gamesettings) room.wall_sprite = arcade.Sprite("graphics/trees/Flowered_Tree.png", gamesettings.SPRITE_SCALING * 2) """ Set up the game and initialize the variables. """ room.draw_top_wall([]) room.draw_bottom_wall([]) room.draw_left_wall([2, 3]) room.draw_right_wall([1, 2]) wall = arcade.Sprite(":resources:images/tiles/boxCrate_double.png", gamesettings.SPRITE_SCALING) wall.left = 7 * gamesettings.SPRITE_SIZE wall.bottom = 5 * gamesettings.SPRITE_SIZE room.wall_list.append(wall) # Load the background image for this level. room.background = arcade.load_texture("graphics/rooms/home.png") return room
def display(self): if self.currentRoom == None: self.currentRoom = Room() self.drawWall(self.currentRoom.w, self.chars["hwall"], 1) self.drawWall(self.currentRoom.w, self.chars["hwall"], 0) for y in range(self.currentRoom.h - 3): self.win.move(self.midpointy - int(self.currentRoom.h / 2) + y + 2, self.midpointx - int(self.currentRoom.w / 2)) for x in range(self.currentRoom.w): if x == 0: self.win.addstr(self.chars["vwall"]) elif x == self.currentRoom.w - 1: self.win.addstr(self.chars["vwall"]) else: self.win.addstr(self.chars["floor"]) # Draw Player self.win.move(self.posy, self.posx) self.win.addstr(self.chars["player"]) self.win.move(self.posy, self.posx) self.win.refresh()
def ceres_cutscene_stats(id, attempts, iqr): n = len(attempts.attempts) best = FrameCount(2951) p25 = FrameCount(2951) p50 = FrameCount(2951) p75 = FrameCount(2951) p90 = FrameCount(2951) save = p75 - p25 if iqr else p50 - best most_recent = FrameCount(2951) save_most_recent = max(most_recent - p50, FrameCount(0)) items = id.items beams = id.beams return TransitionStats(room=Room(None, 'Ceres Cutscene'), n=n, best=best, p25=p25, p50=p50, p75=p75, p90=p90, save=save, most_recent=most_recent, save_most_recent=save_most_recent, items=items, beams=beams)
def make_room(lvl): r = Room(lvl) return r
('go to', '- go to "Room name" - you\'ll go through the exit that connects the current room with the "Room name" and will execute the \'location\' command. Each time you move, you lose health.'), ('items', '- items - prints out a list of items in the backpack'), ('pick up', '- pick up "item name" - you will pick up the item and execute the \'items\' command'), ('drop', '- drop "item name" - you will drop or unequip the item and execute the \'items\' command'), ('unlock', '- unlock "exit name" - unlocks the exit if you have the respective key'), ('eat', '- eat "item name" - you will eat the food, restore health and execute the \'items\' command'), ('equip', '- equip "item name" - you will equip the item and will be able to cause more damage to monsters'), ('monsters', '- monsters - prints out a list of alive monsters in the room'), ('attack', '- attack "monster name" - you will attack the monster'), ('quit', '- quit - exits the game'), ] ) ROOMS = { 'dark_room': Room(name='Dark room', exits=[Exit(name='Wooden door', goes_to=None, is_locked=False)], monsters=None, items=[Food(name='Half-rotten apple', weight=1, health_points=1)]), 'long_hall': Room(name='Long hall', exits=[ Exit(name='Wooden door', goes_to=None, is_locked=False), Exit(name='Prison cell door', goes_to=None, is_locked=True), Exit(name='Rusty iron gate', goes_to=None, is_locked=True) ], monsters=[ Monster(name='Venomous spider', health=5, damage=1) ], items=[Key(name='Prison key', weight=1, unlocks_door=None)]), 'prison_cell': Room(name='Prison cell', exits=[Exit(name='Prison cell door', goes_to=None, is_locked=False)], monsters=[ Monster(name='Frenzied boar', health=6, damage=2),
def generate_rooms(self, num_rooms): # generate a random graph of rooms self.rooms = {} if num_rooms < 1: print("Must create at least 1 room") return None # the coordinates of our room. We start from (0,0) xy = [0,0] # keep track of which grid spots are occupied self.occupied = set() #create a set that will hold the IDS of the rooms vaild connections available valid_rooms = set() # Create n rooms for i in range(0, num_rooms): # Create n rooms. new_room = Room(f"Room {i}", "You are standing in an empty room.") self.rooms[i] = new_room # if it's not the first room if i > 0: # our first room is always vaild valid_rooms.add(i) self.occupied.add(str(xy)) else: #if it's not the first room, then connect to the previous room in a random direction random_dir = None # in case we run into a room with no valid connections, keep looping # until we find a room with a valid connection open # note that there will always be a valid room available while random_dir is None: # get a room that we think is vaild connecting_room = valid_rooms.pop() # get the coordinates of that room xy = self.rooms[connecting_room].xy #see if we can get a random direction fromt that room random_dir = self.get_randomDirection(self.rooms[connecting_room], xy) # if the room is valid, or not None, then we put it back in our set of vaild rooms if random_dir is not None: valid_rooms.add(connecting_room) # if it's not vaild, then we don't put it in vaild_rooms # move on to the next room xy = self.update_coordinates(xy, random_dir) self.rooms[connecting_room].connecting_rooms(random_dir, new_room) ################### WIP # connect to the previous room in a random direction random_dir = self.get_randomDirection(self.rooms[i-1]) if random_dir is not None: self.rooms[i-1].connect_rooms(random_dir, new_room) # # Hard-code a single room connection. # # You should replace this with procedural connection code. # if numRooms > 1: # self.rooms[0].connectRooms("n", self.rooms[1]) # Set the starting room to the first room. Change this if you want a new starting room. self.starting_room = self.rooms[0] return self.rooms
#### ========================================= THE ADVENTURE GAME ========================================= # ========= Imports ========= from rooms import Room # ========= Make Rooms ========= outside = Room("Outside Cave Entrance", "North of you, the cave mount beckons") foyer = Room( "Foyer", """Dim light filters in from the south. Dusty passages run north and east.""" ) overlook = Room( "Grand Overlook", """A steep cliff appears before you, falling into the darkness. Ahead to the north, a light flickers in the distance, but there is no way across the chasm.""" ) narrow = Room( "Narrow Passage", """The narrow passage bends here from west to north. The smell of gold permeates the air.""" ) treasure = Room( "Treasure Chamber", """You've found the long-lost treasure chamber! Sadly, it has already been completely emptied by earlier adventurers. The only exit is to the south.""" ) # ========= Link Rooms ========= outside.n_to = foyer foyer.s_to = outside foyer.n_to = overlook
# Create bookings collection # mydb.create_collection("bookings") roomsCollection = mydb.get_collection("rooms") userCollection = mydb.get_collection("users") bookingCollection = mydb.get_collection("bookings") fromDate = "2020, 10, 15" toDate = "2020, 10, 25" # USER user1 = User("Habiba", "Thailand", "BB45ER", "FEMALE") # ROOM room1 = Room("Male Dorm", "MALE", 4) room2 = Room("Female Dorm", "FEMALE", 4) room3 = Room("Double Room", "DOUBLE", 1) room4 = Room("Single Room", "SINGLE", 2) # BOOKING booking1 = Booking(fromDate, toDate, room1, user1) # roomDb1 = {"name": room1.name, "roomType": room1.roomType, # "quantity": room1.quantity} # roomDb2 = {"name": room2.name, "roomType": room2.roomType, # "quantity": room2.quantity} # roomDb3 = {"name": room3.name, "roomType": room3.roomType, # "quantity": room3.quantity} # roomDb4 = {"name": room4.name, "roomType": room4.roomType, # "quantity": room4.quantity}
from rooms import Room kitchen = Room("Kitchen", "This is the kitchen.") livingRoom = Room("Living Room", "There's a dusty sofa here.") bedroom = Room("Bedroom", "There is a creepy doll here.") bathroom = Room("Bathroom", "There is blood in the tub") closet = Room("Closet", "There is a body in the closet") rooms = [] rooms.append(kitchen) rooms.append(livingRoom) rooms.append(bedroom) rooms.append(bathroom) rooms.append(closet) for room in rooms: print(room)
def add_sections_to_rooms(buildings, filename, intersession=False, only_active=True, debug=False, include_all_rooms=False): with open(filename, 'rt', encoding='utf8') as csvfile: reader = csv.reader(csvfile) next(reader, None) # skip the header date_format = "%m/%d/%y" n_prev = 5 prev_rows = [None] * n_prev i_prev = 0 alphabetic_zero_regex = re.compile(r"^[A-Z]0") for row in reader: if len(row) > 22: subject = row[1] number = row[2] title = row[5] primary_instructor = row[6] instructor_id = row[7] status = row[8] campus = row[9] start_date_str = row[16] end_date_str = row[17] building_code = row[18] room_number = row[19] meeting_days = row[20].split('/') start_time = row[21] end_time = row[22] if ~intersession and campus == "Intersession": if debug: print("Intersession class excluded", row) continue if only_active and status != "Active": if debug: print("Not Active class excluded", row) continue if len(start_date_str) < 1: if debug: print("ERROR: Start date invalid XXXX ", row) end_date = datetime.strptime(end_date_str, date_format) start_date = datetime.strptime(start_date_str, date_format) enrollment_cap = int('0' + row[11]) # default to zero actual_enrollment = int('0' + row[12]) # default to zero # Replace ...'s with values from previous row if CRN is the same cur_crn = row[4] if "..." in { title, primary_instructor, instructor_id, status, campus }: for prev_row in prev_rows: if prev_row is None: continue prev_crn = prev_row[4] if prev_crn == cur_crn: title = prev_row[5] primary_instructor = prev_row[6] instructor_id = prev_row[7] status = prev_row[8] campus = prev_row[9] prev_rows[i_prev] = row i_prev = (i_prev + 1) % n_prev building = get_building_by_code(buildings, building_code) if building is not None: if building_code == "SEC": # For sarkeys numbering, remove padded zero # M0204 -> M204 if alphabetic_zero_regex.match( room_number) is not None: room_number = room_number[0] + room_number[2:] room = building.get_room(room_number) if room is None and include_all_rooms: room = Room(building, room_number, 1) building.add_room(room) if room is not None: section = Section(subject, number, title, instructor_id, building, room, start_time, end_time, meeting_days, campus, enrollment_cap, actual_enrollment, start_date, end_date) room.addSection(section, debug=debug) else: if debug: print( "Building {} Room {} not found in centrally scheduled rooms" .format(building_code, room_number)) else: if debug: print( "Building {} not found in centrally scheduled rooms" .format(building_code)) return buildings
from rooms import Room import maze my_rooms = [] my_rooms.append(Room("This room is the entrance.")) my_rooms.append(Room("This room has a table. Maybe a dining room?")) my_rooms.append(Room("This room is exit. Good Job!")) my_rooms[0].setNorth(my_rooms[1]) my_rooms[1].setSouth(my_rooms[0]) my_rooms[1].setEast(my_rooms[2]) my_rooms[2].setWest(my_rooms[1]) my_maze = maze.MyMaze(my_rooms[0], my_rooms[2]) print(my_rooms[0]) user_input = input("Enter direction to move north west east south./n") def TestVar(user_input): if user_input.lower() == "west": test_var = my_maze.moveWest() elif user_input.lower() == "north": test_var = my_maze.moveNorth() elif user_input.lower() == "south": test_var = my_maze.moveSouth() elif user_input.lower() == "east": test_var = my_maze.moveEast()
def setUp(self): self.room = Room("statehouse") self.person = Person() self.amity = Amity() self.amity.reallocate_person(1, "statehouse")
from rooms import Room #from item import Item from character import Enemy #knife = Item("knife") #knife.set_idescription("used to cut") kitchen = Room("Kitchen") kitchen.set_description("A place to cook and a place to experiment") dininghall = Room("dininghall") dininghall.set_description("very symmetrical place to eat") #cleats = Item("cleats") #cleats.set_idescription("used to dance") ballroom = Room("ballroom") ballroom.set_description("A free breathable space for one to fly") #forks = Item("forks") #forks.set_idescription("used to eat") ''' knife.location(forks,"south") forks.location(knife,"north") forks.location(cleats,"west") cleats.location(forks,"east") ''' kitchen.link_room(dininghall, "south") dininghall.link_room(kitchen, "north") dininghall.link_room(ballroom, "west") ballroom.link_room(dininghall, "east") #dininghall.get_details() #kitchen.get_details()