-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunciones.py
52 lines (46 loc) · 1.57 KB
/
funciones.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from clases import *
from time import sleep
from random import randint
def menu():
print('HUNDIR LA FLOTA')
print('Elige la opción:')
print('a - Jugar.')
print('h - Imprime este menú.')
print('exit - Salir del juego')
def juego():
tablero_jugador = Tablero('Rai',10,1,2,3,4)
tablero_maquina = Tablero('Rai',10,1,2,3,4)
tablero_jugador.colocar_barcos()
tablero_maquina.colocar_barcos()
while 'O' in tablero_jugador.tablero_barcos and 'O' in tablero_maquina.tablero_barcos:
print('Tu turno:')
print(tablero_maquina.tablero_visible)
print('Dime tus disparos:')
y = int(input('Fila: '))
x = int(input('Columna: '))
tablero_maquina.recibir_disparo(x, y)
print(tablero_maquina.tablero_visible)
sleep(3)
print('Turno de la máquina:')
print(tablero_jugador.tablero_barcos)
print('Pensando disparos disparos.')
sleep(2)
a = randint(0,9)
b = randint(0,9)
tablero_jugador.recibir_disparo(a, b)
print(tablero_jugador.tablero_barcos)
print(f'Disparos de la máquina: [{a}][{b}]')
sleep(4)
print('GAME OVER')
def main():
menu()
opt = input('\nEscribe tu opción: ')
while opt != 'exit':
if opt == 'a':
juego()
elif opt == 'h':
menu()
opt = input('\nEscribe tu opción: ')
else:
print('Opción no válida. Pulsa h para obtener ayuda.')
opt = input('\nEscribe tu opción: ')