def test_game_already_active(): reset_data() user = auth_register('*****@*****.**', 'ilovecse', 'Jiaqi', 'Zhu') test_channel = channels_create(user['token'], 'test channel 1', True) start_game(user['token'], test_channel['channel_id']) with pytest.raises(AccessError): start_game(user['token'], test_channel['channel_id'])
def test_start_game_success(): reset_data() data = get_data() user = auth_register('*****@*****.**', 'ilovecse', 'Jiaqi', 'Zhu') test_channel = channels_create(user['token'], 'test channel 1', True) start_game(user['token'], test_channel['channel_id']) assert data['hangman'][0]['is_active'] is True
def make_choice_gui(): top = make_window(WINDOW1_WIDTH, WINDOW_HEIGHT1, WINDOW1_X, WINDOW1_Y, TITLE) make_button(top, "game_name", (150, 30), (NAME_WIDTH, NAME_HEIGHT)) for i in range(3): coord = (230, 180 + (i * 70)) size = (BUTTON1_WIDTH, BUTTON1_HEIGHT) text = BUTTON1_TEXT[i] btn = make_button(top, BUTTON1_IMAGE[i], coord, size) btn.config(text=text[1], fg=BUTTON1_COLOR[i], font=FONT_23) btn.config(command=lambda temp=text[0]: [top.destroy(), hangman.start_game(temp)]) top.mainloop()
def msg_send(): '''Send a message from authorised_user to the channel specified by channel_id''' payload = request.get_json() token = payload['token'] channel_id = int(payload['channel_id']) message = payload['message'] if channel_id is None: raise InputError(description='Empty channel id') if message is None: raise InputError(description='Cannot send empty message') data = get_data() if message == '/hangman': message = start_game(token, channel_id) token = data['users'][0]['token'] if message.split()[0] == '/guess': if message == '/guess': raise InputError(description='You must enter a letter or a word to guess.') guess = message.split()[1] message = check_word(token, guess, channel_id) token = data['users'][0]['token'] message_id = message_send(token, channel_id, message) return dumps(message_id)
from hangman import start_game import time print("WELCOME TO HANGMAN!") user_play = False while not user_play: user_input = input("Do you want to play? (Y/N) \n").upper() if user_input == 'Y': print("OKAY!! Generating word.... good luck!") time.sleep(1.5) start_game() else: print("Okay... Maybe next time :(") user_play = True