Changed numbers 0 and 1 to be represented in textform in order to improve readability

This commit is contained in:
BaerbelBox
2022-06-20 09:29:06 +02:00
parent 5fc98e574e
commit 8e665cd64f

View File

@@ -77,7 +77,7 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype):
def update_on_ping(self, data, connection: Connection): def update_on_ping(self, data, connection: Connection):
if self.active == 0: if self.active == 0:
return return
if 1 == randint(1,11): if 1 == randint(1,1):
if self.duck_alive == 0: if self.duck_alive == 0:
connection.send_channel("*. *. *. * <<w°)> *. *. * Quack!") connection.send_channel("*. *. *. * <<w°)> *. *. * Quack!")
self.duck_alive = 1 self.duck_alive = 1
@@ -112,9 +112,19 @@ class DuckObserver(PrivMsgObserverPrototype, PingObserverPrototype):
ducks_provider.save_or_replace(nick, living, dead) ducks_provider.save_or_replace(nick, living, dead)
def build_duck_string(self, nick: str): def build_duck_string(self, nick: str):
return nick + " hat schon " +str(self.getLiving(nick))+ " befreundete "+self.pluralEnte(self.getLiving(nick))+" und " + str(self.getDead(nick)) + " getötete "+self.pluralEnte(self.getDead(nick)) duckstring = ""
livingDucks = self.getLiving(nick)
def pluralEnte(self, enten:int): deadDucks = self.getDead(nick)
if enten == 1: if livingDucks > 1:
return "Ente" duckstring = duckstring + nick + " hat schon " +str(livingDucks)+ " befreundete Enten und "
return "Enten" elif livingDucks == 1:
duckstring = duckstring + nick + " hat schon eine befreunde Ente und "
elif livingDucks == 0:
duckstring = duckstring + nick + " hat noch keine befreundeten Enten und "
if deadDucks > 1:
duckstring = duckstring + str(deadDucks) + " getötete Enten"
elif deadDucks == 1:
duckstring = duckstring +"eine getötete Ente"
elif deadDucks == 0:
duckstring = duckstring+"keine getöteten Enten"
return duckstring