visible players fix
This commit is contained in:
parent
768415d2ed
commit
f4a5f2d015
2
game.py
2
game.py
@ -48,7 +48,7 @@ class Game:
|
|||||||
def get_visible_players(self, player):
|
def get_visible_players(self, player):
|
||||||
i = self.players.index(player)
|
i = self.players.index(player)
|
||||||
sight = player.get_sight()
|
sight = player.get_sight()
|
||||||
return [self.players[j] for j in range(len(self.players)) if i != j and min(abs(i-j)-1, abs(i-len(self.players)-j))+players[j].get_visibility() <= sight]
|
return [self.players[j] for j in range(len(self.players)) if i != j and min(abs(i-j)-1, abs(i-len(self.players)-j))+self.players[j].get_visibility() <= sight]
|
||||||
|
|
||||||
def play_turn(self):
|
def play_turn(self):
|
||||||
self.players[self.turn].play_turn()
|
self.players[self.turn].play_turn()
|
||||||
|
@ -23,7 +23,7 @@ class Player:
|
|||||||
|
|
||||||
def set_role(self, role: roles.Role):
|
def set_role(self, role: roles.Role):
|
||||||
self.role = role
|
self.role = role
|
||||||
print(f'I {self.id} am a {role.name}')
|
print(f'I {self.id} am a {role.name}, my goal is "{role.goal}"')
|
||||||
|
|
||||||
def set_character(self, character: characters.Character):
|
def set_character(self, character: characters.Character):
|
||||||
self.available_characters = []
|
self.available_characters = []
|
||||||
@ -46,6 +46,7 @@ class Player:
|
|||||||
self.has_played_bang = False
|
self.has_played_bang = False
|
||||||
print(f'I {self.id} was notified that it is my turn')
|
print(f'I {self.id} was notified that it is my turn')
|
||||||
print(f'lives: {self.lives}/{self.max_lives} hand: {[str(c) for c in self.hand]}')
|
print(f'lives: {self.lives}/{self.max_lives} hand: {[str(c) for c in self.hand]}')
|
||||||
|
print(f'I {self.id} can see {[p.get_public_description() for p in self.game.get_visible_players(self)]}')
|
||||||
|
|
||||||
def get_playable_cards(self):
|
def get_playable_cards(self):
|
||||||
playable_cards = []
|
playable_cards = []
|
||||||
@ -59,6 +60,11 @@ class Player:
|
|||||||
playable_cards.append(i)
|
playable_cards.append(i)
|
||||||
return playable_cards
|
return playable_cards
|
||||||
|
|
||||||
|
def get_public_description(self):
|
||||||
|
s = f"{self.id} {'Sheriff ⭐️' if type(self.role) == roles.Sheriff else ''} ({self.lives}/{self.max_lives} ⁍) {len(self.hand)} Cards in hand, "
|
||||||
|
s += f"equipment {[str(c) for c in self.equipment]}"
|
||||||
|
return s
|
||||||
|
|
||||||
def play_card(self, hand_index: int, againts=None):
|
def play_card(self, hand_index: int, againts=None):
|
||||||
if not (0 <= hand_index < len(self.hand)):
|
if not (0 <= hand_index < len(self.hand)):
|
||||||
print('illegal')
|
print('illegal')
|
||||||
|
Loading…
Reference in New Issue
Block a user