71 lines
2.2 KiB
Python
Executable File
71 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import curses
|
|
from finestra import Window
|
|
from mondo import Mondo
|
|
m =Mondo
|
|
nome="pippo"
|
|
def main(stdscr):
|
|
global nome
|
|
curses.curs_set(0)
|
|
|
|
# Disegna il bordo della finestra principale
|
|
stdscr.border()
|
|
|
|
# sh, sw = stdscr.getmaxyx()
|
|
# height = 10
|
|
# width = 30
|
|
# starty = int((sh - height) / 2)
|
|
# startx = int((sw - width) / 2)
|
|
|
|
# # Inizializza l'oggetto MyWindow con la finestra creata
|
|
# my_window = Window(height, width, starty, startx,"intro")
|
|
# my_window.addstr ("ciao, digita qui il nome del tuo personaggio")
|
|
# # Aggiorna lo schermo principale per visualizzare la finestra creata
|
|
stdscr.refresh()
|
|
# # Aggiorna la finestra creata per visualizzare il testo
|
|
# my_window.refresh()
|
|
# nome=my_window.add_input(5,2,10)
|
|
# #stdscr.getch()
|
|
# my_window.clear()
|
|
# my_window.refresh()
|
|
global m
|
|
m =Mondo("matteo")
|
|
finestre=[]
|
|
|
|
if __name__ == '__main__':
|
|
curses.wrapper(main)
|
|
uscita=False
|
|
gioco=Window(30,50,1,1,"Gioco")
|
|
racconto=Window(30,50,1,60,"Racconto")
|
|
finestre.append(gioco)
|
|
finestre.append(racconto)
|
|
racconto.addstr('racconto',1,1)
|
|
racconto.addstr('storia',5,1)
|
|
gioco.addstr("suggerimenti",7,0)
|
|
gioco.addstr('comandi',5,1)
|
|
racconto.addstr('errori',20,1)
|
|
while uscita==False:
|
|
#racconto.addstr(f"ciao {nome} ti trovi {m.descrizione_posizione()}")
|
|
racconto.label_caption('racconto',f"ciao {nome} ti trovi {m.descrizione_posizione()}")
|
|
|
|
gioco.label_caption('suggerimenti', m.stampa_comandi())
|
|
for fin in finestre:
|
|
fin.refresh()
|
|
risposta=gioco.add_input(3,3,30)
|
|
if risposta=="U" or risposta=="uscita":
|
|
uscita=True
|
|
racconto.label_caption('errori',"")
|
|
try:
|
|
valore_comandi=m.esegui_comandi(risposta)
|
|
gioco.label_caption('comandi',f"hai digitato { valore_comandi['comandi']}")
|
|
racconto.label_caption('storia',f"storia:\n{ valore_comandi['descrizione']}")
|
|
except KeyError:
|
|
racconto.label_caption('errori',f"chiave errata comando non valido")
|
|
except TypeError:
|
|
racconto.label_caption('errori',f"tipologia non valida risultato non valido")
|
|
|
|
|
|
|
|
curses.endwin()
|
|
|