def homepage(): win = GraphWin("Chess", 400, 400) win.setCoords(0, 0, 400, 400) win.setBackground("systemhighlight") ext = exitbutton(win) game = Button(win, Point(325, 75), 100, 50, "TBD") game1 = Button(win, Point(325, 135), 100, 50, "Checkers") game2 = Button(win, Point(325, 195), 100, 50, "Chess") game3 = Button(win, Point(325, 255), 100, 50, "Tictactoe") game4 = Button(win, Point(325, 315), 100, 50, "Hangman") game4.activate("red") game3.activate("orange") game2.deactivate() game1.deactivate() game.deactivate() buttonlist = [game, game1, game2, game3, game4, ext] while 1 == 1: p = win.getMouse() if buttonlist[5].clicked(p) == True: win.close() quit() elif buttonlist[4].clicked(p) == True: win.close() hangman.main() elif buttonlist[3].clicked(p) == True: win.close() Tictactoe.ticmain() elif buttonlist[2].clicked(p) == True: win.close() elif buttonlist[1].clicked(p) == True: win.close() elif buttonlist[0].clicked(p) == True: win.close()
def main(args): dicc = {'ahorcado': [], 'ta-te-ti': [], 'otello': []} sigo_jugando = True archivo = open("jueguitosjson.txt", "x") while sigo_jugando: nombre = input("INGRESA TU NOMBRE") print(''' Elegí con qué juego querés jugar: 1.- Ahorcado 2.- Ta-TE-TI 3.- Otello 4.- Salir''') opcion = input() if opcion == '1': hangman.main() elif opcion == '2': tictactoeModificado.main() elif opcion == '3': reversegam.main() elif opcion == '4': sigo_jugando = False if (opcion != '4'): dicc = guardarj(nombre,opcion,dicc) json.dump(dicc, archivo) archivo.close()
def main(args): print('Ingrese el nombre del jugador') nom=input() jugador={"Nombre":nom} sigo_jugando = True while sigo_jugando: print(''' Elegí con qué juego querés jugar: 1.- Ahorcado 2.- Ta-TE-TI 3.- Otello 4.- Salir''') opcion = input() if opcion == '1': hangman.main() guardar(jugador,"Ahorcado") elif opcion == '2': tictactoeModificado.main() guardar(jugador,"Tateti") elif opcion == '3': reversegam.main() guardar(jugador,"Reverse") elif opcion == '4': sigo_jugando = False dato=open('dato.txt','a') json.dump(jugador,dato)
def main(args): sg.theme('DarkBrown4') opciones=['Ahorcado','TA-TE-TI','Otello'] layout=[[sg.Text('ingrese su nombre:')], [sg.Input(key='nombre')], [sg.Text('elija el juego que quiera jugar')], [sg.Listbox(opciones,size=(20,10),key='opcion')], [sg.Button('jugar'),sg.Button('dejar de jugar')]] window=sg.Window('juegos',layout) while True: event,values=window.read() if event == 'dejar de jugar': break if event == 'jugar': nombre=values['nombre'] juego=values['opcion'] print(juego) if juego[0] =='Ahorcado': hangman.main() elif juego[0] == 'TA-TE-TI': tictactoeModificado.main() elif juego[0] == 'Otello': reversegam.main() guardar_datos(archivo,nombre,juego[0]) window.close()
def elijoJuego(jugador): layout = [[ sg.Button('Ahorcado!'), sg.Button('Ta-Te-Ti!'), sg.Button('Reverse!') ], [sg.Exit()]] window = sg.Window('Juegos!').Layout(layout).Finalize() while True: event, values = window.Read() if event is None or event == 'Exit': break elif event == 'Ahorcado!': modificoJugador(jugador, event) hangman.main() window.Close() break elif event == 'Ta-Te-Ti!': modificoJugador(jugador, event) tictactoeModificado.main() window.Close() break elif event == 'Reverse!': modificoJugador(jugador, event) reversegam.main() window.Close() break
def main(args): sg.theme("Dark Amber") juegos = ["Ahorcado", "Ta_TE-TI", "Otello"] dic, arch = CargarArchivo() nombre = IngresoJugador() menu = SetearMenu() sigo_jugando = True while sigo_jugando: opcion, values = menu.read() if opcion == '4': break now = datetime.now() date_time = now.strftime("%m/%d/%Y, %H:%M:%S") num = int(opcion) - 1 dic[date_time] = (nombre, juegos[num]) if opcion == '1': hangman.main() elif opcion == '2': tictactoeModificado.main() elif opcion == '3': reversegam.main() else: print("forced close") break menu.close() json.dump(dic, arch) arch.close()
def main(args): sigo_jugando = True while sigo_jugando: print(''' Elegí con qué juego querés jugar: 1.- Ahorcado 2.- Ta-TE-TI 3.- Otello 4.- Salir''') opcion = input() if opcion == '1': hangman.main() juego='Ahorcado' elif opcion == '2': tictactoeModificado.main() juego='Ta-TE-TI' elif opcion == '3': reversegam.main() juego='Otello' elif opcion == '4': sigo_jugando = False return juego
def interfaz(): sg.theme("DarkAmber") layout =[ [sg.Text('Ingrese nombre del jugador: '), sg.InputText(size=(8, 0))], [sg.Text('Selecciona el juego:'), sg.Combo(values=JuegosValidos, size=(10, 10), readonly=True, key='lista_juegos')], [sg.Submit(), sg.Cancel()] ] window = sg.Window('Juegos', layout, size=(300, 120)) while True: event, values = window.read() if event is 'Submit': juego = values['lista_juegos'] # valor seleccionado del combo if juego in JuegosValidos: GuardarAJSON(values[0], juego) if juego == 'Ahorcado': hangman.main() elif juego == 'TA-TE-TI': tictactoeModificado.main() elif juego == 'Otello': reversegam.main() if event in (None, 'Cancel'): break window.close()
def elegir_juego(eleccion): if eleccion == 'Ahorcado': hangman.main() elif eleccion == 'Ta-Te-Ti': tictactoeModificado.main() elif eleccion == 'Otello': reversegam.main()
def main(args): sigo_jugando = True while sigo_jugando: layout = [[sg.Text('Nombre de jugador:'), sg.InputText()], [sg.Text('Elegí con qué juego querés jugar:')], [ sg.Button('Ahorcado'), sg.Button('Ta-Te-Ti'), sg.Button('Otello') ], [sg.Button('Salir')]] window = sg.Window("Ventana").Layout(layout) event, values = window.Read() window.Close() guardarDatos(values[0], event) if event == 'Ahorcado': hangman.main() elif event == 'Ta-Te-Ti': tictactoeModificado.main() elif event == 'Otello': reversegam.main() elif event == 'Salir': sigo_jugando = False
def main(args): n = input('Nombre: ') e = input('Edad: ') j = [] sigo_jugando = True while sigo_jugando: print(''' Elegí con qué juego querés jugar: 1.- Ahorcado 2.- Ta-TE-TI 3.- Otello 4.- Salir''') opcion = input() if opcion == '1': hangman.main() elif opcion == '2': tictactoeModificado.main() elif opcion == '3': reversegam.main() elif opcion == '4': sigo_jugando = False if opcion in ('1', '2', '3'): j.append(opcion) else: print('No') info_player(n, e, j)
def main(args): # Instanciacion de variables sigo_jugando = True while sigo_jugando: #Creacion de la UI layout = [[sg.Text("Ingrese su nombre")], [sg.InputText(key="name")], [sg.Text("Elegí con qué juego querés jugar:")], [sg.Text("1.- Ahorcado")], [sg.Text("2.- Ta-TE-TI")], [sg.Text("3.- Otello")], [sg.Text("4.- Salir")], [sg.InputText(key="selection")], [sg.Submit()] ] event,values = window = sg.Window("Juegos",layout).read(close=True) #Sentencia que se usa para cerrar la ventana cuando se hace click en la "X" if event in (None, 'Quit'): break #Traer los valores ingresados nombre = values["name"] opcion = values["selection"] if(opcion != "4"): juego(nombre,opcion) if opcion == '1': hangman.main() elif opcion == '2': tictactoeModificado.main() elif opcion == '3': reversegam.main() elif opcion == '4': sigo_jugando = False
def main(args): sigo_jugando = True #Almaceno en data lo retornado por la funcion(un diccionario) data=cargarInfo() while sigo_jugando: print(''' Elegí una opcion : 1.- AHORCADO 2.- Ta-TE-TI 3.- REVERSE 4.- Salir del menu o mostrar jugadores ''') opcion = input() if opcion == '1': juego = 'AHORCADO' # Agrega un jugador en el archivo cargarJson(data,juego) hangman.main() elif opcion == '2': juego='TA-TE-TI' # Agrega un jugador en el archivo cargarJson(data, juego) tictactoeModificado.main() elif opcion == '3': juego='REVERSE' # Agrega un jugador en el archivo cargarJson(data, juego) reversegam.main() elif opcion == '4': print('Quiere ver el listado de los usuarios que jugaron? si/no') op=input().lower() if op=='si' or op=='s': mostrarContenido(data) #Escribo en el json escriboJson(data) sigo_jugando = False
def main(): def title(): clear() print("\t\t_______Game Vault______\n\n") def clear(): os.system('cls') def delay(): time.sleep(1) status = True while (status != False): title() print("The available games are:") print("\n1.Hangman\n2.Luckydraw\n3.Quiz") ch = int(input("\n\nEnter your selection..\n\t\t:")) delay() if (ch == 1): hangman.main() elif (ch == 2): LuckyDraw.main() else: Quiz.main() title() c = input("Do you want to play another game?(y/n)\n\t\t:") c = c.lower() if c == 'y': status = True else: status = False clear() print("\t\tThank you for visiting!!!!") delay()
def main(args): if (not os.path.isfile("registro.txt")): archivo=open("registro.txt", "w") j=[] json.dump(j,archivo) archivo.close() sg.theme('DarkAmber') layout = [[sg.Text("Escriba su nombre "),sg.InputText("")],[sg.Text("Elegi a que queres jugar: "),sg.Combo(["Ahorcado","Ta-Te-Ti","Otello"])],[sg.Ok(),sg.Button("Salir")]] window = sg.Window('Juegos en Python', layout) while True: evento, valores = window.read() if evento == "Salir": break else: if (evento=="Ok") and (not(valores[0] == "" or valores[0]=="Olvido el nombre!")): nombre=valores[0] if valores[1]=="Ahorcado": hangman.main() registrar(nombre,"Ahorcado") if valores[1]=="Ta-Te-Ti": tictactoeModificado.main() registrar(nombre,"Ta-TE-TI") if valores[1]=="Otello": reversegam.main() registrar(nombre,"Otello") else: layout[0][1]("Olvido el nombre!") window.Close()
def ventanaEleccionJuego(jugador): layout = [[ sg.Button("Ahorcado"), sg.Button("TaTeTi"), sg.Button("Reverse") ], [sg.Exit()]] window = sg.Window('JUEGOS').Layout(layout).Finalize() while True: event, values = window.Read( ) #QUISE USAR KEYS PARA NO TENER QUE PASAR "event" A "MODIFICAR()", PERO EL PROGRAMA SE TRABA if event is None or event == 'Exit': break elif event == "Ahorcado": modificar(jugador, event) window.Close() hangman.main() break elif event == "TaTeTi": modificar(jugador, event) window.Close() tictactoe.main() break elif event == "Reverse": modificar(jugador, event) window.Close() reversegam.main() break
def main(): #init pygame.init() width = 640 height = 480 s = pygame.display.set_mode((width, height)) # s for screen pygame.display.set_caption("Spielmenue") FPS = 30 # game loop running = True while running: # event loop for event in pygame.event.get(): # exit if event.type == pygame.QUIT: running = False pygame.quit() exit(0) # keys pressed keys = pygame.key.get_pressed() if keys[K_RIGHT]: hangman.main() # refresh window s.fill(white) # print menu text # update and tick the Clock pygame.display.update()
def main(args): name = input('Ingrese su nombre: ') dicc = defaultdict(list) window = sg.Window('Steam', layout) # Event Loop to process "events" and get the "values" of the inputs while True: event, values = window.read() if event in (None, 'Salir'): # if user closes window or clicks cancel break elif event in "Jugar": eleccion = values['-JUEGO-'][0] if eleccion == "Ahorcado": juego = "Ahorcado" dicc = identificador(dicc, name, juego) hangman.main() elif eleccion == "TA-TE-TI": juego = "Ta-Te-Ti" dicc = identificador(dicc, name, juego) tictactoeModificado.main() elif eleccion == "Otello": juego = "Otello" dicc = identificador(dicc, name, juego) reversegam.main() with open("jugadores.json", 'a') as file: json.dump(dicc, file, indent=2) window.close()
def test_multiple_char_input(self): """Test error message when user inputs multiple characters.""" self.randint.return_value = 0 self.input.side_effect = ["a", "nt", "n", "t", ] + ["n"] hangman.main() self.print.assert_any_call('Please enter a single letter.')
def test_numeric_input(self): """Test error message when user inputs numbers.""" self.randint.return_value = 0 self.input.side_effect = list("a2nt" "n") hangman.main() self.print.assert_any_call('Please enter a LETTER.')
def test_lose(self): """Test user lose scenario.""" self.randint.return_value = 0 self.input.side_effect = list("bcdefg" "n") hangman.main() self.print.assert_any_call('You have run out of guesses!')
def main(args): opcion = values['lista'][0] if opcion == 'Ahorcado': hangman.main() elif opcion == 'Ta-Te-Ti': tictactoeModificado.main() elif opcion == 'Otello': reversegam.main()
def test_out_of_order(self): """Test win scenario with out of order input of letters.""" self.randint.return_value = 0 self.input.side_effect = list("tan" "n") hangman.main() self.print.assert_any_call('Yes! The secret word is "ant"! ' 'You have won!')
def test_same_letter_twice(self): """Test error message when user enters same letter twice.""" self.randint.return_value = 0 self.input.side_effect = list("anntn") hangman.main() self.print.assert_any_call("You have already guessed that letter. " "Choose again.")
def test_win(self): """Test user win scenario.""" self.randint.return_value = 0 self.input.side_effect = list("ant" "n") hangman.main() self.print.assert_any_call('Yes! The secret word is "ant"! ' 'You have won!')
def main(args): sg.ChangeLookAndFeel("SandyBeach") usuarios = {} layout1 = [[sg.Text('Ingrese sus datos: ')], [ sg.Text('Username'), sg.InputText("jaja", size=(10, 0), key='_NAME_') ], [ sg.Text('Cantidad de jugadores: '), sg.Text(len(usuarios.keys()), key='_COUNT_') ], [sg.Button('Aceptar'), sg.Button('Cerrar')]] window = sg.Window('Juegos GUI').Layout(layout1) name = '' sigo_jugando = True event, values = window.Read() if event is None or event == 'Cerrar': sigo_jugando = False if event == 'Aceptar': name = values['_NAME_'] usuarios[name] = {} print('name ', name) print('values ', values) window.Close() layout2 = [ [sg.Text('Elija el juego, ' + name + ': ')], [sg.Button('Ahorcado', key='_HANG_')], [sg.Button('TA-TE-TI', key='_TA_')], [sg.Button('Otello', key='_OT_')], [sg.Button('Salir')], ] window2 = sg.Window('Juegos GUI').Layout(layout2) while sigo_jugando: # Event Loop event, values2 = window2.Read() if event is None or event == 'Salir': sigo_jugando = False break if event == '_HANG_': window2.Close() hangman.main() elif event == '_TA_': window2.Close() tictactoeModificado.main() elif event == '_OT_': window2.Close() reversegam.main() window2 = sg.Window('Juegos GUI').Layout(layout2) window2.Close() print('values ', values) print('values2 ', values2)
def main(args): sg.ChangeLookAndFeel('Dark Blue') # Add some color for fun # 1- the layout layout = [ [sg.Text('Menu', size=(0, 0), font=("Helvetica", 25))], [sg.Image(r'C:\Users\Criatian\Desktop\juego\juegos/img.png')], [sg.Text('ingrese el nombre del jugador :'), sg.Input(key='nombre')], [sg.Text('seleccione un juego')], [ sg.Radio('ahorcado! ', "RADIO1", default=False), sg.Radio('tateti!', "RADIO1"), sg.Radio('otello!', "RADIO1") ], #[sg.Listbox(values =[], key='datos', size=(60,10))], ### consultar el uso de values [sg.Button('Jugar'), sg.Button('Salir')] ] ## # 2 - the window window = sg.Window('Juegos', layout) window.Finalize() event, values = window.Read() # layout = [[sg.Image(r'C:\Users\Criatian\Desktop\Python\Practica 4/img.png')], # [sg.Listbox(values =[], key='datos', size=(60,10))], ### consultar el uso de values # [sg.Button('Añadir'), sg.Button('Guardar')]] # window = sg.Window('JUEGOS', default_element_size=(10, 0)).Layout(layout) # # # 3 - the event loop # event, values = window.read() print(values) sigo_jugando = True while sigo_jugando: # print(''' # Elegí con qué juego querés jugar: # 1.- Ahorcado # 2.- Ta-TE-TI # 3.- Otello # 4.- Salir''') #opcion = values['nombre'] #input() if values[1]: hangman.main() elif values[2]: tictactoeModificado.main() elif values[3]: reversegam.main() elif event is 'Salir': sigo_jugando = False window.close()
def test_two_game(self): """Test two winning game plays.""" self.randint.side_effect = [0, 1] self.input.side_effect = list("ant" "y" "babon" "n") hangman.main() self.print.assert_any_call('Yes! The secret word is "ant"! ' 'You have won!') self.print.assert_any_call('Yes! The secret word is "baboon"! ' 'You have won!')
def main(args): sg.theme('BluePurple') games = ['Ahorcado', 'TA-TE-TI', 'Otello'] players = dict() msj = 'Vuelva a la ventana grafica' # abro ventana principal window = ventana_principal() while True: event, values = window.read() if event is None: break if event is 'play' and values['name'] != '': juego = -1 name = values['name'] if name not in players.keys(): # caso jugador nuevo players[name] = [] # abro ventana de juegos window2 = ventana_juegos(games) while True: event, values = window2.read() if event in (None, 'Salir'): break if event in games: if event not in players[ name]: # no repito los mismos juegos players[name].append(event) juego = games.index(event) sg.PopupOK('Juegue en la terminal', text_color='white', button_color=('white', 'pink')) break window2.close() if juego == 0: hangman.main() print(msj) elif juego == 1: tictactoeModificado.main() print(msj) elif juego == 2: reversegam.main() print(msj) window.close() guardarJugadores(players)
def lanzar_juego(event): #lanzo el juego correspondiente a cada evento if event == '_HANG_': #print(event) hangman.main() elif event == '_TA_': #print(event) tictactoeModificado.main() elif event == '_OT_': #print(event) reversegam.main()
def main(args): log = 'log.txt' #print('existe? ',os.path.isfile(log)) existe = os.path.isfile(log) if existe: #si existe lo abro, y cargo la lista archivo = open(log, "r") datos = json.load(archivo) else: archivo = open(log, "w") # si no existe lo creo datos = [] # ~ datos = [ # ~ {'nombre': 'Tony Stark', 'fecha': time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())}, # ~ {'nombre': 'Bruce Wayne', 'fecha': time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())}] archivo.close() #cierro para despues reescribirlo name = input('\n Ingresá tu nombre, maestre: ') sigo_jugando = True while sigo_jugando: print(''' Elegí con qué juego querés jugar: 1.- Ahorcado 2.- Ta-TE-TI 3.- Otello 4.- Salir''') opcion = input() if opcion == '1': hangman.main() juego = "Ahorcado" elif opcion == '2': tictactoeModificado.main() juego = "Ta-TE-TI" elif opcion == '3': reversegam.main() juego = "Otello" elif opcion == '4': sigo_jugando = False #anexo los datos nuevos datos.append({'nombre': name, 'juego': juego, 'fecha': time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())}) archivo = open(log, "w") #sobreescribo el archivo json.dump(datos, archivo) archivo.close() # puedo abrir el archivo y leer los datos: archivo = open(log, "r") datos = json.load(archivo) print(json.dumps(datos, sort_keys=True, indent=4)) #dumps la S es de STRING archivo.close()
def menu(): sigo_jugando=True while sigo_jugando: if not(values['_numero_']=='4'): if (values['_numero_']=='1'): hangman.main() if (values['_numero_']=='2'): tictactoeModificado.main() elif (values['_numero_']=='3'): reversegam.main() else: sigo_jugando = False menu()
def test_main(): def new_play(self): self.boolean = False with patch.object(Game, 'play', new_play): result = main() assert result
def main(): jugador = {} nombre = input('Ingrese su nombre ') if existejugador(nombre): jugador= quieroMiJugador(nombre) else: agregarJugador(nombre) jugador= quieroMiJugador(nombre) sigo_jugando = True while sigo_jugando: print(''' ¿Qué deseas hacer? 1.- Ahorcado 2.- Ta-TE-TI 3.- Otello 4.- Mostrar tu puntaje 5.- Mostrar todos los puntajes 0.- Guardar y salir''') opcion = input() if opcion == '1': jugador['hangman'] = hangman.main(jugador['hangman']) if opcion == '2': jugador['tictactoe'] = tictactoeModificado.main(jugador['tictactoe']) elif opcion == '3': jugador['reversegam'] = reversegam.main(jugador['reversegam']) elif opcion == '4': mostrarMisPuntajes(jugador) elif opcion == '5': MostrarPuntajes() elif opcion == '0': actualizarPuntajes(jugador) sigo_jugando = False
def test_for_Win_main(): input_values = ['e', 'l', 'p', 'h', 'a', 'n', 't'] output = [] def mock_input(s): output.append(s) return input_values.pop(0) hangman.input = mock_input hangman.print = lambda s: output.append(s) hangman.main("elephant") assert output[1] == "Number of tries left: 10" assert output[3] == "Enter your guess: " assert output[4] == "e*e*****" assert output[35] == "Congratulations! You WON."
def test_for_Lose_main(): input_values = ['k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k', 'k'] output = [] def mock_input(s): output.append(s) return input_values.pop(0) hangman.input = mock_input hangman.print = lambda s: output.append(s) hangman.main("elephant") assert output[1] == "Number of tries left: 10" assert output[4] == "Wrong Guess:" assert output[50] == "Too bad! The secret word was elephant"
def main(args): opciones={1: 'Ahorcado', 2: 'TA-TE-TI', 3: 'Otello'} while True: datos=menu() os.system('cls') opcion = datos['opcion'] if opcion!=0: ar=open('user(_)data.JSON', 'a') ar.write('El usuario \'{}\' jugo: {}\n'.format(str(datos['usuario']), opciones[opcion])) ar.close() if opcion == 1: hangman.main() elif opcion == 2: tictactoeModificado.main() elif opcion == 3: reversegam.main() elif opcion == 0: break