Merge pull request #357 from garylin2099/werewolf_game

Werewolf game
This commit is contained in:
garylin2099 2023-09-23 22:23:52 +08:00 committed by GitHub
commit cf365c8e82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 464 additions and 24 deletions

View file

@ -137,6 +137,11 @@ class Role:
"""Get the role description (position)"""
return self._setting.profile
@property
def name(self):
"""Get the role name"""
return self._setting.name
def _get_prefix(self):
"""Get the role prefix"""
if self._setting.desc:
@ -185,9 +190,13 @@ class Role:
observed = self._rc.env.memory.get_by_actions(self._rc.watch)
self._rc.news = self._rc.memory.remember(observed) # remember recent exact or similar memories
self._rc.news = self._rc.memory.find_news(observed) # find news (previously unseen messages) from observed messages
for i in env_msgs:
if i.restricted_to != "" and self.profile not in i.restricted_to and self.name not in i.restricted_to:
# if the msg is not send to the whole audience ("") nor this role (self.profile or self.name),
# then this role should not be able to receive it and record it into its memory
continue
self.recv(i)
news_text = [f"{i.role}: {i.content[:20]}..." for i in self._rc.news]