From f6d1abe23ad3b55b83d20fa0a746eb9b67f2ce48 Mon Sep 17 00:00:00 2001 From: luxick Date: Sun, 23 Aug 2015 15:03:45 +0200 Subject: [PATCH] reverted overview --- kinggotchi.py | 20 ++++++++++++++++++++ mayorgotchi.py | 33 +++++++++++++++++++++++++++++++++ test.py | 4 ++-- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 kinggotchi.py diff --git a/kinggotchi.py b/kinggotchi.py new file mode 100644 index 0000000..695f5eb --- /dev/null +++ b/kinggotchi.py @@ -0,0 +1,20 @@ +#!/usr/bin/python + +from config import * +from mayorgotchi import Mayorgotchi +import names +import random + +class Kinggotchi: + myvillages = [] + name = '' + + def __init__(self): + self.name = names.get_last_name() + + def add_village(self, mayor): + self.myvillages.append(mayor) + + def show_kingdom(self): + result = 'I am Kinggotchi '+str(self.name)+'.\nThese are the '+str(len(self.myvillages))+' Villages in my Kingdom:\n' + \ No newline at end of file diff --git a/mayorgotchi.py b/mayorgotchi.py index 3b13980..ca445ae 100644 --- a/mayorgotchi.py +++ b/mayorgotchi.py @@ -29,6 +29,39 @@ class Mayorgotchi: result += n.status_abs() 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]))) + + return result + def get_status_list(self): + # A list containing lists of Tamagotchis and thier statuses + # 0 = Idle + # 1 = Eating + # 2 = Sleeping + # 3 = Bathing + # 4 = Playing + # 5 = Working + result = [[] for x in xrange(6)] + + for n in self.mygotchis: + if n.status is 'Idle': + result[0].append(n) + if n.status is 'Eating': + result[1].append(n) + if n.status is 'Sleeping': + result[2].append(n) + if n.status is 'Bathing': + result[3].append(n) + if n.status is 'Playing': + result[4].append(n) + if n.status is 'Working': + result[5].append(n) + + return result + def get_free(self): freegotchis = [] for n in self.mygotchis: diff --git a/test.py b/test.py index 7058644..6315322 100644 --- a/test.py +++ b/test.py @@ -27,8 +27,8 @@ while True: mayor.step() screen.addstr('Simulation running. Press [q] to exit.\n') screen.addstr('----------------------After '+str(ticks)+' ticks------------------------------\n') - screen.addstr(mayor.give_status(show_pct)) - #screen.addstr(mayor.give_overview()) + #screen.addstr(mayor.give_status(show_pct)) + screen.addstr(mayor.give_overview()) ticks += 1 screen.clrtobot()