add all cards with scrap

This commit is contained in:
Alberto Xamin 2020-11-26 23:19:53 +01:00
parent 3772d3cbf9
commit 67abec99ba
No known key found for this signature in database
GPG Key ID: 4F026F48309500A2
3 changed files with 84 additions and 6 deletions

View File

@ -21,7 +21,6 @@ class Pugno(Card):
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
if against != None: if against != None:
import bang.characters as chars
super().play_card(player, against=against) super().play_card(player, against=against)
player.game.attack(player, against) player.game.attack(player, against)
return True return True
@ -56,6 +55,68 @@ class RagTime(Panico):
return True return True
return False 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]: def get_starting_deck() -> List[Card]:
return [ return [
#TODO: aggiungere anche le carte normalmente presenti https://bang.dvgiochi.com/cardslist.php?id=3 #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), Pugno(Suit.SPADES, 10),
Schivata(Suit.DIAMONDS, 7), Schivata(Suit.DIAMONDS, 7),
Schivata(Suit.HEARTS, 'K'), 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'),
] ]

View File

@ -254,7 +254,7 @@ class Player:
return return
card: cs.Card = self.hand.pop(hand_index) card: cs.Card = self.hand.pop(hand_index)
withCard: cs.Card = None withCard: cs.Card = None
if _with: if _with != None:
withCard = self.hand.pop(_with) if hand_index > _with else self.hand.pop(_with - 1) 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) print(self.name, 'is playing ', card, ' against:', against, ' with:', _with)
did_play_card = card.play_card(self, against, withCard) did_play_card = card.play_card(self, against, withCard)

View File

@ -124,6 +124,9 @@ export default {
}, },
notify_card(mess) { notify_card(mess) {
this.notifycard = mess this.notifycard = mess
setTimeout(function(){
this.notifycard = null
}.bind(this), 4000)
} }
}, },
computed:{ computed:{
@ -222,8 +225,18 @@ export default {
this.card_against = null this.card_against = null
}, },
selectWith(card) { selectWith(card) {
this.card_against = this.card_with if (this.card_with.need_target) {
this.card_with = card 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() { cancelCardAgainst() {
this.card_against = null this.card_against = null
@ -233,7 +246,7 @@ export default {
let card_data = { let card_data = {
index: this.hand.indexOf(card), index: this.hand.indexOf(card),
against: against, 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 this.card_with = null
console.log(card_data) console.log(card_data)