new: face expression when a new unit is detected depends on the units bond level

This commit is contained in:
Simone Margaritelli 2019-10-24 13:02:50 +02:00
parent f00c861844
commit 032e183ff7
3 changed files with 7 additions and 1 deletions

View File

@ -55,6 +55,9 @@ class Peer(object):
def first_encounter(self):
return self.encounters == 1
def is_good_friend(self, config):
return self.encounters >= config['personality']['bond_encounters_factor']
def face(self):
return self.adv.get('face', faces.FRIEND)

View File

@ -202,9 +202,10 @@ class View(object):
self.update()
def on_new_peer(self, peer):
self.set('face', faces.FRIEND)
self.set('face', faces.FRIEND if peer.is_good_friend(self._config) else faces.EXCITED)
self.set('status', self._voice.on_new_peer(peer))
self.update()
time.sleep(3)
def on_lost_peer(self, peer):
self.set('face', faces.LONELY)

View File

@ -75,6 +75,8 @@ class Voice:
self._('Hello {name}! Nice to meet you.').format(name=peer.name())])
else:
return random.choice([
self._('Yo {name}! Sup?').format(name=peer.name()),
self._('Hey {name} how are you doing?').format(name=peer.name()),
self._('Unit {name} is nearby!').format(name=peer.name())])
def on_lost_peer(self, peer):