add cecchino

This commit is contained in:
Alberto Xamin 2020-12-20 22:58:17 +01:00
parent ee26ff5d01
commit 48f4605b0b
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
3 changed files with 30 additions and 5 deletions

View File

@ -13,10 +13,10 @@ class Agguato(CardEvent):
self.desc_eng = "The base distance from any 2 players is 1" self.desc_eng = "The base distance from any 2 players is 1"
class Cecchino(CardEvent): class Cecchino(CardEvent):
def __init__(self): #TODO def __init__(self):
super().__init__("Cecchino", "👁") super().__init__("Cecchino", "👁")
self.desc = "Nel proprio turno i giocatori possono scartare 2 Bang assieme per sparare un bang che necessita 2 mancato" self.desc = "Nel proprio turno i giocatori possono scartare 2 Bang assieme per sparare un bang che necessita 2 mancato (clicca la carta)"
self.desc_eng = "During their turn, players can discard 2 Bang! to shoot a bang that requires 2 missed" self.desc_eng = "During their turn, players can discard 2 Bang! to shoot a bang that requires 2 missed (click the card)"
class DeadMan(CardEvent): class DeadMan(CardEvent):
def __init__(self): def __init__(self):
@ -99,7 +99,7 @@ class Vendetta(CardEvent):
def get_all_events(): def get_all_events():
cards = [ cards = [
Agguato(), Agguato(),
# Cecchino(), Cecchino(),
DeadMan(), DeadMan(),
FratelliDiSangue(), FratelliDiSangue(),
IlGiudice(), IlGiudice(),

View File

@ -50,6 +50,7 @@ class Player:
self.is_drawing = False self.is_drawing = False
self.can_play_vendetta = True self.can_play_vendetta = True
self.is_giving_life = False self.is_giving_life = False
self.is_using_checchino = False
self.can_play_ranch = True self.can_play_ranch = True
self.is_playing_ranch = False self.is_playing_ranch = False
self.mancato_needed = 0 self.mancato_needed = 0
@ -63,6 +64,7 @@ class Player:
self.role: r.Role = None self.role: r.Role = None
self.character: chars.Character = None self.character: chars.Character = None
self.real_character: chars.Character = None self.real_character: chars.Character = None
self.is_using_checchino = False
self.lives = 0 self.lives = 0
self.max_lives = 0 self.max_lives = 0
self.is_my_turn = False self.is_my_turn = False
@ -336,6 +338,17 @@ class Player:
self.notify_self() self.notify_self()
def draw(self, pile): def draw(self, pile):
if self.is_my_turn and self.pending_action == PendingAction.PLAY and pile == 'event' and self.game.check_event(ce.Cecchino) and len([c for c in self.hand if c.name == cs.Bang(0,0).name]) >= 2:
self.is_using_checchino = True
self.available_cards = [{
'name': p['name'],
'icon': '⭐️' if p['is_sheriff'] else '🤠',
'alt_text': ''.join(['❤️']*p['lives'])+''.join(['💀']*(p['max_lives']-p['lives']))
} for p in self.game.get_visible_players(self) if p['dist'] <= self.get_sight()]
self.available_cards.append({'icon': ''})
self.pending_action = PendingAction.CHOOSE
self.is_giving_life = True
self.notify_self()
if self.pending_action != PendingAction.DRAW: if self.pending_action != PendingAction.DRAW:
return return
if pile == 'event' and self.lives < self.max_lives and self.game.check_event(ce.LiquoreForte): if pile == 'event' and self.lives < self.max_lives and self.game.check_event(ce.LiquoreForte):
@ -528,6 +541,18 @@ class Player:
self.sio.emit('chat_message', room=self.game.name, data=f'_fratelli_sangue|{self.name}|{player.name}') self.sio.emit('chat_message', room=self.game.name, data=f'_fratelli_sangue|{self.name}|{player.name}')
except: pass except: pass
self.play_turn() self.play_turn()
elif self.is_using_checchino and self.game.check_event(ce.Cecchino):
try:
if self.available_cards[card_index]['name'] != '':
for _ in range(2):
card = next(c for c in self.hand if c.name == cs.Bang(0,0).name)
self.hand.remove(card)
self.game.deck.scrap(card)
self.game.attack(self, self.available_cards[card_index]['name'], double=True)
except: pass
self.is_using_checchino = False
self.pending_action = PendingAction.PLAY
self.notify_self()
elif self.is_playing_ranch and self.game.check_event(ce.Ranch): elif self.is_playing_ranch and self.game.check_event(ce.Ranch):
if card_index == len(self.available_cards) - 1: if card_index == len(self.available_cards) - 1:
self.hand = [c for c in self.hand if c not in self.discarded_cards] self.hand = [c for c in self.hand if c not in self.discarded_cards]

View File

@ -81,7 +81,7 @@ export default {
} }
}, },
event() { event() {
if (this.pending_action !== false && this.pending_action < 2) { if (this.pending_action !== false) {
this.$socket.emit('draw', 'event') this.$socket.emit('draw', 'event')
} }
} }