diff --git a/Naval Battle/NavalBattle.py b/Naval Battle/NavalBattle.py index 9eb01bf..908354a 100644 --- a/Naval Battle/NavalBattle.py +++ b/Naval Battle/NavalBattle.py @@ -128,12 +128,16 @@ if gmode == "single": if e2.pos() == e3.pos(): e3.goto(random.choice(posx), random.choice(posy)) #pass - + #vencer + if win == True: + tl.Terminator() + + while win == False: - e1_sunk = False - e2_sunk = False - e3_sunk = False tiro = tl.textinput("linha X do disparo","Em qual quadrante X devemos disparar a artilharia") + #vencer + if win == True: + break #acerto Submarino if (tiro_pos[tiro]) == e1.pos(): bullet.showturtle() @@ -141,7 +145,7 @@ if gmode == "single": print("Acerto!") bullet.write("U-boat Afundado\n Capitão!",False,align="center") bullet.hideturtle() - e1_sunk = True + e1.goto(-1000,-1000) #acerto Crusador elif (tiro_pos[tiro]) == e2.pos(): bullet.showturtle() @@ -149,7 +153,7 @@ if gmode == "single": print("Acerto!") bullet.write("Crusador Afundado\n Capitão!",False,align="center") bullet.hideturtle() - e2_sunk = True + e2.goto(-1000,-1000) #acerto Destroyer elif(tiro_pos[tiro]) == e3.pos(): bullet.showturtle() @@ -157,20 +161,20 @@ if gmode == "single": print("Acerto!") bullet.write("Destroyer Afundado\n Capitão!",False,align="center") bullet.hideturtle() - e3_sunk = True + e3.goto(-1000,-1000) #erro - elif (tiro_pos[tiro]) != e1.pos() or (tiro_pos[tiro]) != e2.pos() or (tiro_pos[tiro]) != e3.pos(): + elif (tiro_pos[tiro]) != e1.pos() and (tiro_pos[tiro]) != e2.pos() and (tiro_pos[tiro]) != e3.pos(): bullet.showturtle() bullet.goto(tiro_pos[tiro]) print("errou!") bullet.write("Erramos o alvo\n Capitão!",False,align="center") bullet.hideturtle() - continue + + #erro + if e1.pos() not in tiro_pos and e2.pos() not in tiro_pos and e3.pos() not in tiro_pos: + win = True + print("voçe ganhou") - elif e1_sunk == True and (e2_sunk == True) and (e3_sunk == True): - break - else: - print("Voçe ganhou!")