add terenkill and youlgrinner

This commit is contained in:
Alberto Xamin 2023-03-11 22:51:34 +02:00
parent e4f9cfc886
commit d3a056cc6a
No known key found for this signature in database
GPG Key ID: 5ABFCD8A22EA6F5D
5 changed files with 51 additions and 5 deletions

View File

@ -84,8 +84,8 @@ def all_characters() -> List[Character]:
# GreygoryDeckard(), # GreygoryDeckard(),
JohnPain(), JohnPain(),
# LeeVanKliff(), # LeeVanKliff(),
# TerenKill(), TerenKill(),
# YoulGrinner(), YoulGrinner(),
] ]
for c in cards: for c in cards:
c.expansion_icon = '🎪' c.expansion_icon = '🎪'

View File

@ -265,6 +265,12 @@ class Player:
if isinstance(self.gold_rush_equipment[i], grc.Zaino): if isinstance(self.gold_rush_equipment[i], grc.Zaino):
self.gold_rush_equipment[i].play_card(self, None) self.gold_rush_equipment[i].play_card(self, None)
return # play card will notify the player return # play card will notify the player
if self.character.check(self.game, chw.TerenKill):
picked: cs.Card = self.game.deck.pick_and_scrap()
G.sio.emit('chat_message', room=self.game.name, data=f'_flipped|{self.name}|{picked.name}|{picked.num_suit()}')
if not picked.check_suit(self.game, [cs.Suit.SPADES]):
self.lives = 1
self.game.deck.draw(True, player=self)
if self.character.check(self.game, chars.SidKetchum) and len(self.hand) > 1 and self.lives == 0: if self.character.check(self.game, chars.SidKetchum) and len(self.hand) > 1 and self.lives == 0:
if self.game.players[self.game.turn] != self: if self.game.players[self.game.turn] != self:
self.game.players[self.game.turn].pending_action = PendingAction.WAIT self.game.players[self.game.turn].pending_action = PendingAction.WAIT
@ -573,6 +579,12 @@ class Player:
self.notify_self() self.notify_self()
else: else:
self.pending_action = PendingAction.PLAY self.pending_action = PendingAction.PLAY
if self.character.check(self.game, chw.YoulGrinner):
hsize = len(self.hand)
for p in self.game.get_alive_players():
if p != self and len(p.hand) > hsize:
G.sio.emit('card_drawn', room=self.game.name, data={'player': self.name, 'pile': p.name})
self.hand.append(p.hand.pop(randint(0, len(p.hand)-1)))
num = 2 if not self.character.check(self.game, chd.BillNoface) else self.max_lives-self.lives+1 num = 2 if not self.character.check(self.game, chd.BillNoface) else self.max_lives-self.lives+1
if self.character.check(self.game, chd.PixiePete): num += 1 if self.character.check(self.game, chd.PixiePete): num += 1
if self.character.check(self.game, tvosch.TucoFranziskaner) and not any((True for c in self.equipment if not c.usable_next_turn)): num += 2 if self.character.check(self.game, tvosch.TucoFranziskaner) and not any((True for c in self.equipment if not c.usable_next_turn)): num += 2

View File

@ -7,7 +7,7 @@ from globals import G
G.sio = DummySocket() G.sio = DummySocket()
def started_game(expansions, players=4): def started_game(expansions, players=4, character=Character('test_char', 4)):
g = Game('test') g = Game('test')
g.expansions = expansions g.expansions = expansions
ps = [Player(f'p{i}', f'p{i}') for i in range(players)] ps = [Player(f'p{i}', f'p{i}') for i in range(players)]
@ -15,7 +15,7 @@ def started_game(expansions, players=4):
g.add_player(p) g.add_player(p)
g.start_game() g.start_game()
for p in ps: for p in ps:
p.available_characters = [Character('test_char', 4)] p.available_characters = [character]
p.set_character(p.available_characters[0].name) p.set_character(p.available_characters[0].name)
return g return g

View File

@ -0,0 +1,34 @@
from tests import started_game, set_events, current_player, next_player, current_player_with_cards
from bang.expansions.wild_west_show.characters import *
from bang.cards import Card, Suit
import bang.roles as roles
from bang.players import PendingAction
# test TerenKill
def test_TerenKill():
g = started_game(['wild_west_show'], 4, TerenKill())
p = current_player_with_cards(g, [])
p.lives = 0
g.deck.cards = [Card(Suit.HEARTS, 'card', 0), Card(Suit.HEARTS, 'card', 0)]
p.notify_self()
assert p.lives == 1
assert len(p.hand) == 1
p.lives = 0
g.deck.cards = [Card(Suit.SPADES, 'card', 0), Card(Suit.HEARTS, 'card', 0)]
p.notify_self()
assert p.lives == 0
# test YoulGrinner
def test_YoulGrinner():
g = started_game(['wild_west_show'], 4, YoulGrinner())
p = current_player(g)
p.hand = []
p.draw('')
assert len(p.hand) == 5
for pl in g.players:
if pl != p:
assert len(pl.hand) == 3

View File

@ -58,7 +58,7 @@ def test_LadyRosaDelTexas():
p = current_player_with_cards(g, [Card(0,'card',0)]*4) p = current_player_with_cards(g, [Card(0,'card',0)]*4)
t = g.turn t = g.turn
p.draw('event') p.draw('event')
assert g.turn == t+1 assert g.turn == (t+1)%len(g.players)
# test MissSusanna # test MissSusanna
def test_miss_suzanna(): def test_miss_suzanna():