From 67abec99ba4281228b2ec841711f4d87751bf995 Mon Sep 17 00:00:00 2001 From: Alberto Xamin Date: Thu, 26 Nov 2020 23:19:53 +0100 Subject: [PATCH] add all cards with scrap --- backend/bang/expansions/dodge_city/cards.py | 69 ++++++++++++++++++++- backend/bang/players.py | 2 +- frontend/src/components/Player.vue | 19 +++++- 3 files changed, 84 insertions(+), 6 deletions(-) diff --git a/backend/bang/expansions/dodge_city/cards.py b/backend/bang/expansions/dodge_city/cards.py index f129136..c5d1fb0 100644 --- a/backend/bang/expansions/dodge_city/cards.py +++ b/backend/bang/expansions/dodge_city/cards.py @@ -21,7 +21,6 @@ class Pugno(Card): def play_card(self, player, against, _with=None): if against != None: - import bang.characters as chars super().play_card(player, against=against) player.game.attack(player, against) return True @@ -56,6 +55,68 @@ class RagTime(Panico): return True return False +class Rissa(Gatling): + def __init__(self, suit, number): + super().__init__(suit, number) + self.name = 'Rissa' + self.icon = '🥊' + self.need_with = True + + def play_card(self, player, against, _with): + if _with != None: + player.game.deck.scrap(_with) + super().play_card(player, against=against) + return True + return False + +class SpringField(Card): + def __init__(self, suit, number): + super().__init__(suit, 'Springfield', number) + self.icon = '🌵' + self.desc = "Spara a un giocatore" + self.need_target = True + self.need_with = True + + def play_card(self, player, against, _with=None): + if against != None and _with != None: + player.game.deck.scrap(_with) + super().play_card(player, against=against) + player.game.attack(player, against) + return True + return False + +class Tequila(Card): + def __init__(self, suit, number): + super().__init__(suit, 'Tequila', number) + self.icon = '🍹' + self.desc = "Fai recuperare 1 vita a un giocatore" + self.need_target = True + self.need_with = True + + def play_card(self, player, against, _with=None): + if against != None and _with != None: + player.game.deck.scrap(_with) + player.game.get_player_named(against).lives = min(player.game.get_player_named(against).lives+1, player.game.get_player_named(against).max_lives) + player.game.get_player_named(against).notify_self() + return True + return False + +class Whisky(Card): + def __init__(self, suit, number): + super().__init__(suit, 'Whisky', number) + self.icon = '🥃' + self.desc = "Recupera 2 vite" + self.need_with = True + + def play_card(self, player, against, _with=None): + if _with != None: + player.game.deck.scrap(_with) + player.lives = min(player.lives+2, player.max_lives) + player.notify_self() + return True + return False + + def get_starting_deck() -> List[Card]: return [ #TODO: aggiungere anche le carte normalmente presenti https://bang.dvgiochi.com/cardslist.php?id=3 @@ -80,5 +141,9 @@ def get_starting_deck() -> List[Card]: Pugno(Suit.SPADES, 10), Schivata(Suit.DIAMONDS, 7), Schivata(Suit.HEARTS, 'K'), - RagTime(Suit.HEARTS, 9) + RagTime(Suit.HEARTS, 9), + Rissa(Suit.SPADES, 'J'), + SpringField(Suit.SPADES, 'K'), + Tequila(Suit.CLUBS, 9), + Whisky(Suit.HEARTS, 'Q'), ] diff --git a/backend/bang/players.py b/backend/bang/players.py index 69d6fdc..98ad2bf 100644 --- a/backend/bang/players.py +++ b/backend/bang/players.py @@ -254,7 +254,7 @@ class Player: return card: cs.Card = self.hand.pop(hand_index) withCard: cs.Card = None - if _with: + if _with != None: withCard = self.hand.pop(_with) if hand_index > _with else self.hand.pop(_with - 1) print(self.name, 'is playing ', card, ' against:', against, ' with:', _with) did_play_card = card.play_card(self, against, withCard) diff --git a/frontend/src/components/Player.vue b/frontend/src/components/Player.vue index 9dace6e..e77e288 100644 --- a/frontend/src/components/Player.vue +++ b/frontend/src/components/Player.vue @@ -124,6 +124,9 @@ export default { }, notify_card(mess) { this.notifycard = mess + setTimeout(function(){ + this.notifycard = null + }.bind(this), 4000) } }, computed:{ @@ -222,8 +225,18 @@ export default { this.card_against = null }, selectWith(card) { - this.card_against = this.card_with - this.card_with = card + if (this.card_with.need_target) { + this.card_against = this.card_with + this.card_with = card + } else { + let card_data = { + index: this.hand.indexOf(this.card_with), + against: null, + with: this.hand.indexOf(card), + } + this.card_with = null + this.$socket.emit('play_card', card_data) + } }, cancelCardAgainst() { this.card_against = null @@ -233,7 +246,7 @@ export default { let card_data = { index: this.hand.indexOf(card), against: against, - with: this.hand.indexOf(this.card_with), + with: this.hand.indexOf(this.card_with) > -1 ? this.hand.indexOf(this.card_with):null, } this.card_with = null console.log(card_data)