From aa172606c57d485ab7fd616e463d1800108d8437 Mon Sep 17 00:00:00 2001 From: luxick Date: Sun, 23 Aug 2015 14:50:46 +0200 Subject: [PATCH] no more washing and playing when not idle --- config.py | 2 +- mayorgotchi.py | 47 ++++++++--------------------------------------- test.py | 4 ++-- 3 files changed, 11 insertions(+), 42 deletions(-) diff --git a/config.py b/config.py index 74f694e..a7c7610 100644 --- a/config.py +++ b/config.py @@ -3,7 +3,7 @@ # The lenght of one game cycle in milliseconds ticklenght = 0.05 # Number of Tamagotchis to be created at the start of the simulation -startnr = 100 +startnr = 50 # The amount of points a Tamagotchi loses per tick decayaspeed = 1 # If the hunger stat falls below this level Tamagotchis can be fed diff --git a/mayorgotchi.py b/mayorgotchi.py index 8cd286c..3b13980 100644 --- a/mayorgotchi.py +++ b/mayorgotchi.py @@ -29,40 +29,6 @@ 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: @@ -82,8 +48,9 @@ class Mayorgotchi: def get_dirty(self): dirties = [] for n in self.mygotchis: - if n.hygiene[0] <= washing_point: - dirties.append(n) + if n.status is 'Idle': + if n.hygiene[0] <= washing_point: + dirties.append(n) if len(dirties) > 0: return dirties[random.randrange(0,len(dirties),1)] else: @@ -91,10 +58,10 @@ class Mayorgotchi: def get_unhappy(self): unhappies = [] - result = [] for n in self.mygotchis: - if n.happiness[0] <= play_point: - unhappies.append(n) + if n.status is 'Idle': + if n.happiness[0] <= play_point: + unhappies.append(n) if len(unhappies) > 0: return unhappies[random.randrange(0,len(unhappies), 1)] else: @@ -120,6 +87,8 @@ class Mayorgotchi: for n in self.mygotchis: n.step() self.remove_corpses() + + self.order_feed() self.order_wash() self.order_play() diff --git a/test.py b/test.py index 6315322..7058644 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()