class HallTest(unittest.TestCase): def setUp(self): self.hall = Hall() def test_new_instance(self): self.assertTrue(self.hall, Hall) def test_valid_members(self): places = [ [' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'], ['1 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['2 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['3 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['4 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['5 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['6 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['7 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['8 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['9 ', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['10', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'] ] self.assertEqual(self.hall.places, places) def test_set_busy_seat(self): self.hall.set_busy_seat(5, 5) self.assertEqual(self.hall.places[5][5], 'X')
def init_rooms(self, frame): study = Study(frame) study.grid(row=0, column=0) hall = Hall(frame) hall.grid(row=0, column=9) lounge = Lounge(frame) lounge.grid(row=0, column=17) library = Library(frame) library.grid(row=6, column=0) stairs = Stairs(frame) stairs.grid(row=8, column=9) dining_room = DiningRoom(frame) dining_room.grid(row=9, column=16) billiard_room = BilliardRoom(frame) billiard_room.grid(row=12, column=0) conservatory = Conservatory(frame) conservatory.grid(row=19, column=0) ball_room = BallRoom(frame) ball_room.grid(row=17, column=8) kitchen = Kitchen(frame) kitchen.grid(row=18, column=18)
def make_reservation(database): print("Step 1:") name = CommandIO.input_name() tickets = CommandIO.input_tickets() print("Step 2:") CommandIO.show_movies(database) movie_id = CommandIO.input_movie_id() print("Step 3:") is_seats = False while not is_seats: CommandIO.show_movie_projections(database, movie_id) projection_id = CommandIO.input_projection_id() is_seats = CommandIO.check_seats(database, projection_id, tickets) busy_seats = database.get_non_available_seats(projection_id) new_hall = Hall() CommandIO.append_busy_seats(new_hall, busy_seats) new_hall.print_places() print("Step 4: ") choosen_seats = CommandIO.choose_seats(busy_seats, tickets) CommandIO.append_busy_seats(new_hall, choosen_seats) CommandIO.print_movie_name(database, movie_id) CommandIO.print_projection_info(database, projection_id, choosen_seats) print("Step 5:") CommandIO.finalize(database, name, projection_id, choosen_seats)
def seedHall(self): foundSeed = False for i in range(self.mapBorder, self.width - self.mapBorder, 2): for j in range(self.mapBorder, self.height - self.mapBorder, 2): if self.tiles[i][j] == 0 and foundSeed == False: cid = len(self.halls) + 1 self.halls.append(Hall(cid)) self.tiles[i][j] = -cid self.ci = i self.cj = j foundSeed = True return foundSeed
def test_create_hall(self): # Given root = tk.Tk() # When hall = Hall(root) tk.mainloop() # Then # I see the hall self.assertEqual(True, False)
def enter(): global boy, hall, block, block1, block2, block3 count = 0 boy = Boy() hall = Hall() block = Block(258, 97, 258, 97) block1 = Block(245, 570, 245, 180) block2 = Block(937, 611, 270, 215) block3 = Block(945, 106, 228, 70) game_world.add_object(hall, 0) game_world.add_object(block, 0) game_world.add_object(block1, 0) game_world.add_object(block2, 0) game_world.add_object(block3, 0) game_world.add_object(boy, 1)
def main(): width = 1024 height = 768 pygame.init() screen = pygame.display.set_mode((width + 80, height)) clock = pygame.time.Clock() lock_flag = [False, False, False] item_get = [False, False, False, False] item_use = [False, False, False, False] item_ctrl = Item_Base(screen, item_get, item_use, width, height) room_state = 0 next_room_state = 0 room_ctrl = [Hall(screen, lock_flag, item_get, item_use), Livingroom(screen, lock_flag, item_get, item_use), Privateroom(screen, lock_flag, item_get, item_use), Ending(screen, lock_flag, item_get, item_use)] while True: """ マウスカーソル位置 """ x, y = pygame.mouse.get_pos() room_ctrl[room_state].pos_event(x, y) """ クリックイベント,キーイベント """ for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: if x < width: room_ctrl[room_state].click_event(x, y) else: item_ctrl.click_event(int(y / 64)) if event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: room_state = (room_state - 1) % -3 elif event.key == pygame.K_RIGHT: room_state = (room_state + 1) % 3 elif event.key == pygame.K_a: lock_flag[0] = not lock_flag[0] elif event.key == pygame.K_b: lock_flag[1] = not lock_flag[1] elif event.key == pygame.K_c: lock_flag[2] = not lock_flag[2] elif event.key == pygame.K_0: item_get[0] = not item_get[0] item_use[0] = False elif event.key == pygame.K_1: item_get[1] = not item_get[1] item_use[1] = False elif event.key == pygame.K_2: item_get[2] = not item_get[2] item_use[2] = False elif event.key == pygame.K_3: item_get[3] = not item_get[3] item_use[3] = False if event.type == pygame.QUIT: pygame.quit() sys.exit() """ 処理 """ room_ctrl[room_state].do() item_ctrl.do() """ 描画 """ screen.fill((0, 0, 0)) room_ctrl[room_state].draw() item_ctrl.draw() pygame.display.update() """ 部屋移動 """ next_room_state = room_ctrl[room_state].next_state() if room_state != next_room_state: surface = pygame.Surface((width, height), pygame.SRCALPHA) alpha = 0 for i in range(12): screen.fill((0,0,0)) surface.fill((0, 0, 0, alpha)) room_ctrl[room_state].draw() item_ctrl.do() item_ctrl.draw() screen.blit(surface, (0, 0)) pygame.display.update() clock.tick(30) alpha = alpha + 20 room_state = next_room_state for i in range(12): screen.fill((0,0,0)) surface.fill((0, 0, 0, alpha)) room_ctrl[room_state].draw() item_ctrl.do() item_ctrl.draw() screen.blit(surface, (0, 0)) pygame.display.update() clock.tick(30) alpha = alpha - 20 clock.tick(30)
def setUp(self): self.hall = Hall()
if key.type == 'normal': key.items.append('key') break # Item distribution for item in items: while max_items[item] > used[item]: act = random.choice(normal_rooms) if act.type == 'normal': act.items.append(item) used[item] += 1 # Getting halls ready for room in rooms[1::2]: meta = (room.x1, room.y1, room.x2, room.y2) hall = Hall(*meta) map = hall.findmode(map.copy()) halls.append(hall) # Stage 2.5: Generating map # Map generation for room in normal_rooms: map = room.fill(map.copy()) for hall in halls: out = hall.generate(map.copy()) if type(out) is not int: map = out else: map = hall.findmode(map.copy(), False)
def do_add(self, name_of_hall, capacity): new_hall = Hall(name_of_hall, capacity) self.manager.transition = SlideTransition(direction="left") self.manager.current = 'connected' halls.append(new_hall)
def build(self): manager = ScreenManager() manager.add_widget(Login(name='login')) manager.add_widget(Connected(name='connected')) manager.add_widget(AddAPlay(name='add_a_play_screen')) manager.add_widget(DeleteAPlay(name='delete_a_play_screen')) manager.add_widget(AddAHall(name='add_a_hall_screen')) return manager if __name__ == '__main__': LoginApp().run() hall = Hall("Hall 1", 300) hall2 = Hall("Hall 2", 500) jamesbond = Play() jamesbond.set_name("James Bond") schedule = Week_Schedule() lotr = Play() lotr.set_name("Lord of the Rings") schedule.set_play_date(jamesbond, "Monday", hall, ["12,30", "14,40", "16.30"]) schedule.set_play_date(jamesbond, "Monday", hall2, "17.00") schedule.set_play_date(jamesbond, "Tuesday", hall2, "17.00") schedule.set_play_date(lotr, "Sunday", hall2, "13.00") schedule.find_day_for_play(lotr.name) schedule.find_day_for_play(jamesbond.name)
sys.exit(1) else: HOST = sys.argv[1] address = (HOST, PORT) server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) #the line above creates a connection using the python library "socket" #the first argument defines the protocol family, here AF_INET is the IPv4 protocol, and is considered the default for this library #the second argument here defines the type of connection, here SOCK_STREAM is used to create a TCP connection. server.bind(address) #binds the address given when running the program to the socket server.listen(MAXUSERS) #socket is now listening for connections made to the binded address, as long as the max amount of users has not been met print("Server has started with ip and port of", address) hallway = Hall() while True: client, address = server.accept() client.send('NICKNAME'.encode(bufferSize)) nickname = client.recv(1024).decode(bufferSize) user = Player(client, nickname) print("{} joined the server".format(user.name)) #server.sendall("{} joined The Server".format(user.name).encode()) serveT = threading.Thread(target=sendM, args=(user, )) serveT.start()