From 922a15bf597ae3dc651d52ed79b0c8f4eca41dca Mon Sep 17 00:00:00 2001 From: luxick Date: Thu, 6 Aug 2015 12:45:55 +0200 Subject: [PATCH] new overview for mayors --- config.py | 8 ++++---- mayorgotchi.py | 34 ++++++++++++++++++++++++++++++++++ test.py | 3 ++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index 3a17f3e..74f694e 100644 --- a/config.py +++ b/config.py @@ -1,9 +1,9 @@ #!/usr/bin/python # The lenght of one game cycle in milliseconds -ticklenght = 0.1 +ticklenght = 0.05 # Number of Tamagotchis to be created at the start of the simulation -startnr = 50 +startnr = 100 # The amount of points a Tamagotchi loses per tick decayaspeed = 1 # If the hunger stat falls below this level Tamagotchis can be fed @@ -22,8 +22,8 @@ min_decay = 1 max_decay = 3 # These two define how long it takes a Tamagotchi to perform work (preparing food/washing someone/playing with someone) # The value is choosen randomly between these two. Obviously a lower number is better. -min_workpower = 1 -max_workpower = 3 +min_workpower = 3 +max_workpower = 6 # This defines the bounds of how much a Tamagotchi can recover when eating/sleeping/playing etc. min_recovery = 10 max_recovery = 20 diff --git a/mayorgotchi.py b/mayorgotchi.py index 23d18f7..8cd286c 100644 --- a/mayorgotchi.py +++ b/mayorgotchi.py @@ -29,6 +29,40 @@ 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 94db8ac..6315322 100644 --- a/test.py +++ b/test.py @@ -27,7 +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_status(show_pct)) + screen.addstr(mayor.give_overview()) ticks += 1 screen.clrtobot()