curses UI improvements

This commit is contained in:
luxick
2015-08-25 16:34:16 +02:00
parent e82f89d689
commit 0d22dc1251
6 changed files with 13 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# The lenght of one game cycle in milliseconds
ticklenght = 0.005

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from config import *
from mayorgotchi import Mayorgotchi
@@ -19,7 +20,7 @@ class Kinggotchi:
result = 'I am Kinggotchi '+str(self.name)+'.\nIn my Kingdom live '+str(self.all_tamagotchis())+' Tamagotichs.\nIn my Kingdom '+str(self.all_dead())+' Tamagotchis have died so far.\n\nThese are the '+str(len(self.myvillages))+' Villages in my Kingdom:\n'
for n in self.myvillages:
result += '-------------------------------------------------------------------------------\n'
# result += '-----------------------------------------------------------------------------------------\n'
result += n.give_overview()
return result

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from tamagotchi import Tamagotchi
import names
@@ -21,7 +22,7 @@ class Mayorgotchi:
self.mygotchis.remove(n)
def give_status(self,show_pct):
result = 'I am Mayorgotchi ' + self.name + '.\nIn my Village '+str(self.graveyard)+' Tamagotchis died so far.\nThese are the '+str(len(self.mygotchis))+' Tamagotchis living in my Village:\n\n'
result = 'I am Mayorgotchi ' + self.name + '.\nIn my Village live '+str(len(self.mygotchis))+' Tamagotchis.\nIn my Village '+str(self.graveyard)+' Tamagotchis died so far.\n\n'
for n in self.mygotchis:
if show_pct:
result += n.status_pct()
@@ -30,10 +31,9 @@ class Mayorgotchi:
return result
def give_overview(self):
result = 'I am Mayorgotchi ' + self.name + '.\nThere are ' + str(len(self.mygotchis)) + ' Tamagotchis in my Village\nThere are ' + str(self.graveyard) + ' Tamagotchis in the graveyard.\nOccupation in my Village:\n'
tmp = self.get_status_list()
result += 'Idle:{0:5} Eating:{1:5} Sleeping:{2:5} Bathing:{3:5} Playing:{4:5} Working:{5:5}\n'.format(str(len(tmp[0])), str(len(tmp[1])), str(len(tmp[2])), str(len(tmp[3])), str(len(tmp[4])), str(len(tmp[5])))
result = ''
tmp = self.get_status_list()
result += 'Village of Mayor {0:10} Population:{1:5} Dead:{2:5} Idle:{3:5} Eating:{4:5} Sleeping:{5:5} Bathing:{6:5} Playing:{7:5} Working:{8:5}\n'.format(self.name,str(len(self.mygotchis)),str(self.graveyard),str(len(tmp[0])), str(len(tmp[1])), str(len(tmp[2])), str(len(tmp[3])), str(len(tmp[4])), str(len(tmp[5])))
return result
def get_status_list(self):

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
class Tamagotchi:
status = ''

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from mayorgotchi import Mayorgotchi
from kinggotchi import Kinggotchi
@@ -37,10 +38,10 @@ while True:
win.addstr(0,0,'Tamagotchi Colony (alpha) - currently at tick '+str(ticks)+'.\n')
if kingdomview:
win.addstr(2,0,'[q]:exit [p]:pause [v]:switch between Kingdom/Village view\n')
win.addstr(2,0,'[q]:Exit [p]:Pause [v]: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(2,0,'[q]:Exit [p]:Pause [v]:Kingdom View [n/m]:Previous/Next Village\n')
win.addstr(4,0,king.myvillages[villagenr].give_status(percentage))
king.step()

View File

@@ -1,4 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from tamagotchi import Tamagotchi
import random