deactivated name generator for performance, added interactive view changing

This commit is contained in:
luxick
2015-08-25 13:25:48 +02:00
parent dd28c63582
commit e82f89d689
2 changed files with 26 additions and 5 deletions

28
test.py
View File

@@ -9,6 +9,9 @@ import curses
# Temporary test section # Temporary test section
ticks = 0 ticks = 0
kingdomview = True
villagenr = 0
percentage = True
def make_list(number): def make_list(number):
list = [] list = []
@@ -17,7 +20,7 @@ def make_list(number):
return list return list
king = Kinggotchi() king = Kinggotchi()
for n in range(0, 10): for n in range(0, 30):
king.add_village(Mayorgotchi(make_list(startnr))) king.add_village(Mayorgotchi(make_list(startnr)))
stdscr = curses.initscr() stdscr = curses.initscr()
@@ -31,9 +34,15 @@ win = curses.newpad(16383, width)
while True: while True:
win.move(0,0) win.move(0,0)
win.addstr(0,0,'Simulation running. Press [q] to exit.\n') win.addstr(0,0,'Tamagotchi Colony (alpha) - currently at tick '+str(ticks)+'.\n')
win.addstr(1,0,'----------------------After '+str(ticks)+' ticks------------------------------\n')
win.addstr(3,0,king.show_kingdom()) if kingdomview:
win.addstr(2,0,'[q]:exit [p]:pause [v]:switch between Kingdom/Village view\n')
win.addstr(4,0,king.show_kingdom())
else:
win.addstr(2,0,'[q]:exit [p]:pause [v]:switch between Kingdom/Village view [n/m]:previous/next Village\n')
win.addstr(4,0,king.myvillages[villagenr].give_status(percentage))
king.step() king.step()
ticks += 1 ticks += 1
win.clrtoeol() win.clrtoeol()
@@ -43,6 +52,17 @@ while True:
key = stdscr.getch() key = stdscr.getch()
if key == ord('q'): if key == ord('q'):
break break
elif key == ord('p'):
while True:
unpause_key =stdscr.getch()
if unpause_key == ord('p'):
break
elif key == ord('v'):
kingdomview = not kingdomview
elif key == ord('n'):
villagenr -= 1
elif key == ord('m'):
villagenr += 1
elif key < 0: elif key < 0:
time.sleep(ticklenght) time.sleep(ticklenght)

View File

@@ -8,7 +8,8 @@ from config import *
class Util: class Util:
def make_Tamagotchi(self): def make_Tamagotchi(self):
name = names.get_last_name() # name = names.get_last_name()
name = 'Gotchi'
hunger = random.randrange(min_stat,max_stat,1) hunger = random.randrange(min_stat,max_stat,1)
happiness = random.randrange(min_stat,max_stat,1) happiness = random.randrange(min_stat,max_stat,1)
hygiene = random.randrange(min_stat,max_stat,1) hygiene = random.randrange(min_stat,max_stat,1)