Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Battaglia Navale A Linea di Comando
- #Cesta Luca
- import sys
- import os
- import locale
- import time
- def clearscreen():
- if sys.platform[0:3]=='win':
- clear='cls'
- else:
- clear='clear'
- os.system(clear)
- def lingua():
- if locale.getdefaultlocale()[0]=='it_IT':
- file=open('lingua','w')
- file.write('ita')
- elif locale.getdefaultlocale()[0]=='en_GB' or 'en_US':
- file=open('lingua','w')
- file.write('eng')
- else:
- linguamanuale(lang)
- def linguamanuale():
- while (1):
- lingua= input(' Choose your language: \n Scegli la tua lingua: \n ENG/ITA \n ')
- if lingua.lower()=='ita':
- file=open('lingua','w')
- file.write('ita')
- break
- elif lingua.lower()=='eng':
- file=open('lingua','w')
- file.write('eng')
- break
- else:
- clearscreen()
- print(' Scelta non valida. \n Invalid choice.')
- def animling():
- for i in range(100):
- if i==50:
- lingua()
- print(" Getting your language: ", i+1,"% / Ottenendo la tua lingua: ", i+1,"%", end="\r")
- time.sleep(0.05)
- clearscreen()
- file=open('lingua')
- if file.read()=='ita':
- print("\n Successo!\n ")
- time.sleep(0.05)
- input(" Premi invio per continuare...")
- else:
- input("\n Done!\n")
- time.sleep(0.05)
- input(" Press enter to continue...")
- def letturanomegiocatore():
- file=open('lingua')
- file2=open('giocatore','w')
- if file.read()=='ita':
- nome=input(" Ciao! sembra che ancora non ci siamo presentati, io sono Alfred, il computer, giochero' con te nei momenti di noia! \n Tu, invece, chi sei? \n ")
- else:
- nome=input(" Hi! It seems that we have not yet submitted, I am Alfred, the computer, I will play with you in moments of boredom \n You, however, who are You? \n ")
- file2.write(nome)
- def esci():
- exit()
- def main():
- clearscreen()
- try:
- file=open('lingua')
- if file.read()=='':
- animling()
- except FileNotFoundError:
- animling()
- clearscreen()
- try:
- file2=open('giocatore')
- if file2.read()=='':
- letturanomegiocatore()
- except FileNotFoundError:
- letturanomegiocatore()
- clearscreen()
- file2=open('giocatore')
- nome=file2.read()
- while(1):
- print(" Ciao ",nome, " sei pronto per giocare?\n")
- sceltamenu=input(" Scegli cosa vuoi fare:\n 1. Nuova partita.\n 2. Opzioni.\n 3. Esci.\n")
- if sceltamenu==1:
- partita()
- break
- elif sceltamenu==2:
- opzioni()
- break
- elif sceltamenu==3:
- esci()
- break
- else:
- input(" Scelta non valida, premi invio per continuare.")
- clearscreen()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement