Merge pull request #5 from albertoxamin/dev
update from dev with dodge city green cards
This commit is contained in:
commit
004b1d17ca
@ -36,6 +36,8 @@ class Card(ABC):
|
|||||||
self.desc = desc
|
self.desc = desc
|
||||||
self.need_target = False
|
self.need_target = False
|
||||||
self.can_target_self = False
|
self.can_target_self = False
|
||||||
|
self.can_be_used_now = True
|
||||||
|
self.usable_next_turn = False
|
||||||
self.need_with = False
|
self.need_with = False
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -284,7 +286,7 @@ class Mancato(Card):
|
|||||||
def __init__(self, suit, number):
|
def __init__(self, suit, number):
|
||||||
super().__init__(suit, 'Mancato!', number)
|
super().__init__(suit, 'Mancato!', number)
|
||||||
self.icon = '😅'
|
self.icon = '😅'
|
||||||
self.desc = "Usa questa carta per annullare un bang"
|
self.desc = "Usa questa carta per annullare un Bang!"
|
||||||
|
|
||||||
def play_card(self, player, against, _with=None):
|
def play_card(self, player, against, _with=None):
|
||||||
import bang.characters as chars
|
import bang.characters as chars
|
||||||
|
@ -6,6 +6,10 @@ class Deck:
|
|||||||
def __init__(self, game):
|
def __init__(self, game):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.cards: List[cs.Card] = cs.get_starting_deck(game.expansions)
|
self.cards: List[cs.Card] = cs.get_starting_deck(game.expansions)
|
||||||
|
self.mancato_cards: List[str] = []
|
||||||
|
for c in self.cards:
|
||||||
|
if isinstance(c, cs.Mancato) and c.name not in self.mancato_cards:
|
||||||
|
self.mancato_cards.append(c.name)
|
||||||
self.game = game
|
self.game = game
|
||||||
random.shuffle(self.cards)
|
random.shuffle(self.cards)
|
||||||
self.scrap_pile: List[cs.Card] = []
|
self.scrap_pile: List[cs.Card] = []
|
||||||
@ -46,5 +50,7 @@ class Deck:
|
|||||||
return self.draw()
|
return self.draw()
|
||||||
|
|
||||||
def scrap(self, card: cs.Card):
|
def scrap(self, card: cs.Card):
|
||||||
|
if card.usable_next_turn:
|
||||||
|
card.can_be_used_now = False
|
||||||
self.scrap_pile.append(card)
|
self.scrap_pile.append(card)
|
||||||
self.game.notify_scrap_pile()
|
self.game.notify_scrap_pile()
|
||||||
|
@ -31,7 +31,7 @@ class Schivata(Mancato):
|
|||||||
super().__init__(suit, number)
|
super().__init__(suit, number)
|
||||||
self.name = 'Schivata'
|
self.name = 'Schivata'
|
||||||
self.icon = '🙅♂️'
|
self.icon = '🙅♂️'
|
||||||
self.desc += " e poi pesca una carta"
|
self.desc = "Usa questa carta per annullare un Bang! e poi pesca una carta"
|
||||||
self.alt_text = '☝️🆓'
|
self.alt_text = '☝️🆓'
|
||||||
|
|
||||||
def play_card(self, player, against, _with=None):
|
def play_card(self, player, against, _with=None):
|
||||||
@ -69,9 +69,12 @@ class Rissa(CatBalou):
|
|||||||
|
|
||||||
def play_card(self, player, against, _with):
|
def play_card(self, player, against, _with):
|
||||||
if _with != None:
|
if _with != None:
|
||||||
|
players_with_cards = [p.name for p in player.game.players if p != player and (len(p.hand)+len(p.equipment)) > 0]
|
||||||
|
if len(players_with_cards) == 0:
|
||||||
|
return False
|
||||||
player.game.deck.scrap(_with)
|
player.game.deck.scrap(_with)
|
||||||
player.event_type = 'rissa'
|
player.event_type = 'rissa'
|
||||||
super().play_card(player, against=[p.name for p in player.game.players if p != player and (len(p.hand)+len(p.equipment)) > 0][0])
|
super().play_card(player, against=players_with_cards[0])
|
||||||
player.sio.emit('chat_message', room=player.game.name, data=f'{player.name} ha giocato {self.name}')
|
player.sio.emit('chat_message', room=player.game.name, data=f'{player.name} ha giocato {self.name}')
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -130,6 +133,198 @@ class Whisky(Card):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
class Bibbia(Schivata):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Bibbia'
|
||||||
|
self.icon = '📖'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def use_card(self, player):
|
||||||
|
player.hand.append(player.game.deck.draw())
|
||||||
|
player.notify_self()
|
||||||
|
|
||||||
|
class Cappello(Mancato):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Cappello'
|
||||||
|
self.icon = '🧢'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class PlaccaDiFerro(Cappello):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Placca Di Ferro'
|
||||||
|
self.icon = '🛡'
|
||||||
|
|
||||||
|
class Sombrero(Cappello):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Sombrero'
|
||||||
|
self.icon = '👒'
|
||||||
|
|
||||||
|
class Pugnale(Pugno):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Pugnale'
|
||||||
|
self.icon = '🗡'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
return super().play_card(player, against=against)
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class Derringer(Pugnale):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Derringer'
|
||||||
|
self.icon = '🚬'
|
||||||
|
self.alt_text += ' ☝️🆓'
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
player.hand.append(player.game.deck.draw())
|
||||||
|
return super().play_card(player, against=against)
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class Borraccia(Birra):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Borraccia'
|
||||||
|
self.icon = '🍼'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
return super().play_card(player, against)
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class PonyExpress(WellsFargo):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Pony Express'
|
||||||
|
self.icon = '🦄'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
return super().play_card(player, against)
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class Howitzer(Gatling):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Howitzer'
|
||||||
|
self.icon = '📡'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
return super().play_card(player, against)
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class CanCan(CatBalou):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Can Can'
|
||||||
|
self.icon = '👯♀️'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
return super().play_card(player, against)
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class Conestoga(Panico):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
Card.__init__(self, suit, 'Conestoga', number)
|
||||||
|
self.icon = '🏕'
|
||||||
|
self.desc = "Ruba 1 carta dalla mano di un giocatore a prescindere dalla distanza"
|
||||||
|
self.need_target = True
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
return super().play_card(player, against)
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class Pepperbox(Bang):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, number)
|
||||||
|
self.name = 'Pepperbox'
|
||||||
|
self.icon = '🌶'
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
if against != None:
|
||||||
|
Card.play_card(self, player, against=against)
|
||||||
|
player.game.attack(player, against)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
|
class FucileDaCaccia(Card):
|
||||||
|
def __init__(self, suit, number):
|
||||||
|
super().__init__(suit, 'Fucile Da Caccia', number)
|
||||||
|
self.icon = '🌂'
|
||||||
|
self.desc = "Spara a un giocatore a prescindere dalla distanza"
|
||||||
|
self.need_target = True
|
||||||
|
self.usable_next_turn = True
|
||||||
|
self.can_be_used_now = False
|
||||||
|
|
||||||
|
def play_card(self, player, against, _with=None):
|
||||||
|
if self.can_be_used_now:
|
||||||
|
if against != None:
|
||||||
|
super().play_card(player, against=against)
|
||||||
|
player.game.attack(player, against)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
player.equipment.append(self)
|
||||||
|
return True
|
||||||
|
|
||||||
def get_starting_deck() -> List[Card]:
|
def get_starting_deck() -> List[Card]:
|
||||||
return [
|
return [
|
||||||
@ -160,4 +355,18 @@ def get_starting_deck() -> List[Card]:
|
|||||||
SpringField(Suit.SPADES, 'K'),
|
SpringField(Suit.SPADES, 'K'),
|
||||||
Tequila(Suit.CLUBS, 9),
|
Tequila(Suit.CLUBS, 9),
|
||||||
Whisky(Suit.HEARTS, 'Q'),
|
Whisky(Suit.HEARTS, 'Q'),
|
||||||
|
Bibbia(Suit.HEARTS, 10),
|
||||||
|
Cappello(Suit.DIAMONDS, 'J'),
|
||||||
|
PlaccaDiFerro(Suit.DIAMONDS, 'A'),
|
||||||
|
PlaccaDiFerro(Suit.SPADES, 'Q'),
|
||||||
|
Sombrero(Suit.CLUBS, 7),
|
||||||
|
Pugnale(Suit.HEARTS, 8),
|
||||||
|
Derringer(Suit.SPADES, 7),
|
||||||
|
Borraccia(Suit.HEARTS, 7),
|
||||||
|
CanCan(Suit.CLUBS, 'J'),
|
||||||
|
Conestoga(Suit.DIAMONDS, 9),
|
||||||
|
FucileDaCaccia(Suit.CLUBS, 'Q'),
|
||||||
|
PonyExpress(Suit.DIAMONDS, 'Q'),
|
||||||
|
Pepperbox(Suit.HEARTS, 'A'),
|
||||||
|
Howitzer(Suit.SPADES, 9),
|
||||||
]
|
]
|
||||||
|
@ -23,13 +23,14 @@ class Game:
|
|||||||
self.expansions = []
|
self.expansions = []
|
||||||
|
|
||||||
def notify_room(self):
|
def notify_room(self):
|
||||||
self.sio.emit('room', room=self.name, data={
|
if len([p for p in self.players if p.character == None]) != 0:
|
||||||
'name': self.name,
|
self.sio.emit('room', room=self.name, data={
|
||||||
'started': self.started,
|
'name': self.name,
|
||||||
'players': [{'name':p.name, 'ready': False} for p in self.players],
|
'started': self.started,
|
||||||
'password': self.password,
|
'players': [{'name':p.name, 'ready': p.character != None} for p in self.players],
|
||||||
'expansions': self.expansions,
|
'password': self.password,
|
||||||
})
|
'expansions': self.expansions,
|
||||||
|
})
|
||||||
|
|
||||||
def toggle_expansion(self, expansion_name):
|
def toggle_expansion(self, expansion_name):
|
||||||
if not self.started:
|
if not self.started:
|
||||||
|
@ -16,7 +16,6 @@ class PendingAction(IntEnum):
|
|||||||
WAIT = 4
|
WAIT = 4
|
||||||
CHOOSE = 5
|
CHOOSE = 5
|
||||||
|
|
||||||
|
|
||||||
class Player:
|
class Player:
|
||||||
|
|
||||||
def __init__(self, name, sid, sio):
|
def __init__(self, name, sid, sio):
|
||||||
@ -250,22 +249,28 @@ class Player:
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
def play_card(self, hand_index: int, against=None, _with=None):
|
def play_card(self, hand_index: int, against=None, _with=None):
|
||||||
if not (0 <= hand_index < len(self.hand)):
|
if not self.is_my_turn or self.pending_action != PendingAction.PLAY:
|
||||||
print('illegal')
|
|
||||||
return
|
return
|
||||||
card: cs.Card = self.hand.pop(hand_index)
|
if not (0 <= hand_index < len(self.hand) + len(self.equipment)):
|
||||||
|
return
|
||||||
|
card: cs.Card = self.hand.pop(hand_index) if hand_index < len(self.hand) else self.equipment.pop(hand_index-len(self.hand))
|
||||||
withCard: cs.Card = None
|
withCard: cs.Card = None
|
||||||
if _with != None:
|
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)
|
||||||
if not card.is_equipment:
|
if not card.is_equipment and not card.usable_next_turn:
|
||||||
if did_play_card:
|
if did_play_card:
|
||||||
self.game.deck.scrap(card)
|
self.game.deck.scrap(card)
|
||||||
else:
|
else:
|
||||||
self.hand.insert(hand_index, card)
|
self.hand.insert(hand_index, card)
|
||||||
if withCard:
|
if withCard:
|
||||||
self.hand.insert(_with, withCard)
|
self.hand.insert(_with, withCard)
|
||||||
|
elif card.usable_next_turn and card.can_be_used_now:
|
||||||
|
if did_play_card:
|
||||||
|
self.game.deck.scrap(card)
|
||||||
|
else:
|
||||||
|
self.equipment.insert(hand_index-len(self.hand), card)
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
|
|
||||||
def choose(self, card_index):
|
def choose(self, card_index):
|
||||||
@ -280,6 +285,8 @@ class Player:
|
|||||||
card = target.hand.pop(card_index)
|
card = target.hand.pop(card_index)
|
||||||
target.notify_self()
|
target.notify_self()
|
||||||
if self.choose_action == 'steal':
|
if self.choose_action == 'steal':
|
||||||
|
if card.usable_next_turn:
|
||||||
|
card.can_be_used_now = False
|
||||||
self.hand.append(card)
|
self.hand.append(card)
|
||||||
else:
|
else:
|
||||||
self.game.deck.scrap(card)
|
self.game.deck.scrap(card)
|
||||||
@ -289,10 +296,9 @@ class Player:
|
|||||||
self.choose_action = ''
|
self.choose_action = ''
|
||||||
self.pending_action = PendingAction.PLAY
|
self.pending_action = PendingAction.PLAY
|
||||||
else:
|
else:
|
||||||
while len(self.game.players[self.game.players_map[self.target_p]+1].hand) + len(self.game.players[self.game.players_map[self.target_p]+1].equipment) == 0:
|
self.target_p = self.game.players[self.game.players_map[self.target_p]+1].name
|
||||||
|
while self.target_p == self.name or len(self.game.players[self.game.players_map[self.target_p]].hand) + len(self.game.players[self.game.players_map[self.target_p]].equipment) == 0:
|
||||||
self.target_p = self.game.players[self.game.players_map[self.target_p]+1].name
|
self.target_p = self.game.players[self.game.players_map[self.target_p]+1].name
|
||||||
if self.target_p == self.name:
|
|
||||||
self.target_p = self.game.players[self.game.players_map[self.target_p]+1].name
|
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
# specifico per personaggio
|
# specifico per personaggio
|
||||||
elif self.is_drawing and isinstance(self.character, chars.KitCarlson):
|
elif self.is_drawing and isinstance(self.character, chars.KitCarlson):
|
||||||
@ -321,19 +327,25 @@ class Player:
|
|||||||
if self.mancato_needed <= 0:
|
if self.mancato_needed <= 0:
|
||||||
self.game.responders_did_respond_resume_turn()
|
self.game.responders_did_respond_resume_turn()
|
||||||
return
|
return
|
||||||
if len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang))]) == 0:
|
if len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang))]) == 0\
|
||||||
|
and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0:
|
||||||
self.take_damage_response()
|
self.take_damage_response()
|
||||||
self.game.responders_did_respond_resume_turn()
|
self.game.responders_did_respond_resume_turn()
|
||||||
else:
|
else:
|
||||||
self.pending_action = PendingAction.RESPOND
|
self.pending_action = PendingAction.RESPOND
|
||||||
self.expected_response = [cs.Mancato(0, 0).name, csd.Schivata(0,0).name]
|
self.expected_response = self.game.deck.mancato_cards
|
||||||
self.on_failed_response_cb = self.take_damage_response
|
self.on_failed_response_cb = self.take_damage_response
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
|
|
||||||
def get_banged(self, attacker, double=False):
|
def get_banged(self, attacker, double=False):
|
||||||
self.attacker = attacker
|
self.attacker = attacker
|
||||||
self.mancato_needed = 1 if not double else 2
|
self.mancato_needed = 1 if not double else 2
|
||||||
if len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang))]) == 0 and len([c for c in self.equipment if isinstance(c, cs.Barile)]) == 0 and not isinstance(self.character, chars.Jourdonnais):
|
for i in range(len(self.equipment)):
|
||||||
|
if self.equipment[i].can_be_used_now:
|
||||||
|
print('usable', self.equipment[i])
|
||||||
|
if len([c for c in self.equipment if isinstance(c, cs.Barile)]) == 0 and not isinstance(self.character, chars.Jourdonnais)\
|
||||||
|
and len([c for c in self.hand if isinstance(c, cs.Mancato) or (isinstance(self.character, chars.CalamityJanet) and isinstance(c, cs.Bang))]) == 0\
|
||||||
|
and len([c for c in self.equipment if c.can_be_used_now and isinstance(c, cs.Mancato)]) == 0:
|
||||||
print('Cant defend')
|
print('Cant defend')
|
||||||
self.take_damage_response()
|
self.take_damage_response()
|
||||||
return False
|
return False
|
||||||
@ -345,7 +357,7 @@ class Player:
|
|||||||
else:
|
else:
|
||||||
print('has mancato')
|
print('has mancato')
|
||||||
self.pending_action = PendingAction.RESPOND
|
self.pending_action = PendingAction.RESPOND
|
||||||
self.expected_response = [cs.Mancato(0, 0).name, csd.Schivata(0,0).name]
|
self.expected_response = self.game.deck.mancato_cards
|
||||||
self.on_failed_response_cb = self.take_damage_response
|
self.on_failed_response_cb = self.take_damage_response
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
return True
|
return True
|
||||||
@ -402,13 +414,16 @@ class Player:
|
|||||||
data=f'{self.name} ha usato una birra per recuperare una vita.')
|
data=f'{self.name} ha usato una birra per recuperare una vita.')
|
||||||
break
|
break
|
||||||
self.mancato_needed = 0
|
self.mancato_needed = 0
|
||||||
|
self.event_type = ''
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
self.attacker = None
|
self.attacker = None
|
||||||
|
|
||||||
def respond(self, hand_index):
|
def respond(self, hand_index):
|
||||||
self.pending_action = PendingAction.WAIT
|
self.pending_action = PendingAction.WAIT
|
||||||
if hand_index != -1 and self.hand[hand_index].name in self.expected_response:
|
if hand_index != -1 and (
|
||||||
card = self.hand.pop(hand_index)
|
((hand_index < len(self.hand) and self.hand[hand_index].name in self.expected_response)) or
|
||||||
|
self.equipment[hand_index-len(self.hand)].name in self.expected_response):
|
||||||
|
card = self.hand.pop(hand_index) if hand_index < len(self.hand) else self.equipment.pop(hand_index-len(self.hand))
|
||||||
card.use_card(self)
|
card.use_card(self)
|
||||||
self.game.deck.scrap(card)
|
self.game.deck.scrap(card)
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
@ -465,6 +480,9 @@ class Player:
|
|||||||
f"I {self.name} have to many cards in my hand and I can't end the turn")
|
f"I {self.name} have to many cards in my hand and I can't end the turn")
|
||||||
else:
|
else:
|
||||||
self.is_my_turn = False
|
self.is_my_turn = False
|
||||||
|
for i in range(len(self.equipment)):
|
||||||
|
if self.equipment[i].usable_next_turn and not self.equipment[i].can_be_used_now:
|
||||||
|
self.equipment[i].can_be_used_now = True
|
||||||
self.pending_action = PendingAction.WAIT
|
self.pending_action = PendingAction.WAIT
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
self.game.next_turn()
|
self.game.next_turn()
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
<div v-if="!isInLobby" >
|
<div v-if="!isInLobby" >
|
||||||
<p>{{$t("online_players")}}{{onlinePlayers}}</p>
|
<p>{{$t("online_players")}}{{onlinePlayers}}</p>
|
||||||
<Card :card="getSelfCard" style="position:absolute; bottom:10pt; right: 10pt;"/>
|
<Card :card="getSelfCard" style="position:absolute; bottom:10pt; left: 10pt;"/>
|
||||||
<h2>{{$t("available_lobbies")}}</h2>
|
<h2>{{$t("available_lobbies")}}</h2>
|
||||||
<div style="display: flex">
|
<div style="display: flex">
|
||||||
<Card v-for="lobby in openLobbies" v-bind:key="lobby.name" :card="getLobbyCard(lobby)" @click.native="joinLobby(lobby)"/>
|
<Card v-for="lobby in openLobbies" v-bind:key="lobby.name" :card="getLobbyCard(lobby)" @click.native="joinLobby(lobby)"/>
|
||||||
@ -38,10 +38,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<select style="position:absolute;bottom:4pt;right:4pt;" v-model="$i18n.locale">
|
<select style="position:absolute;bottom:4pt;right:4pt;" v-model="$i18n.locale">
|
||||||
<option
|
<option
|
||||||
v-for="(lang, i) in ['it.🇮🇹', 'en.🇬🇧']"
|
v-for="(lang, i) in ['it.🇮🇹.Italiano', 'en.🇬🇧.English']"
|
||||||
:key="`lang-${i}`"
|
:key="`lang-${i}`"
|
||||||
:value="lang.split('.')[0]">
|
:value="lang.split('.')[0]">
|
||||||
{{lang.split('.')[1]}} {{lang.split('.')[0]}}
|
{{lang.split('.')[1]}} {{lang.split('.')[2]}}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :class="{ card: true, equipment: card.is_equipment, character:card.is_character, back:card.is_back}">
|
<div :class="{ card: true, equipment: card.is_equipment, character:card.is_character, back:card.is_back, 'usable-next-turn':card.usable_next_turn}">
|
||||||
<h4>{{card.name}}</h4>
|
<h4>{{card.name}}</h4>
|
||||||
<div class="emoji">{{card.icon}}</div>
|
<div class="emoji">{{card.icon}}</div>
|
||||||
<div class="alt_text">{{card.alt_text}}</div>
|
<div class="alt_text">{{card.alt_text}}</div>
|
||||||
@ -68,6 +68,10 @@ export default {
|
|||||||
0 0 0 6pt white,
|
0 0 0 6pt white,
|
||||||
0 0 5pt 6pt #aaa;
|
0 0 5pt 6pt #aaa;
|
||||||
}
|
}
|
||||||
|
.card.usable-next-turn {
|
||||||
|
box-shadow:
|
||||||
|
0 0 0 3pt rgb(192,192,117), 0 0 0 6pt white, 0 0 5pt 6pt #aaa
|
||||||
|
}
|
||||||
.card h4 {
|
.card h4 {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -127,5 +131,9 @@ export default {
|
|||||||
0 0 0 6pt #181a1b,
|
0 0 0 6pt #181a1b,
|
||||||
0 0 5pt 6pt #aaa;
|
0 0 5pt 6pt #aaa;
|
||||||
}
|
}
|
||||||
|
.card.usable-next-turn {
|
||||||
|
box-shadow:
|
||||||
|
0 0 0 3pt rgb(192,192,117), 0 0 0 6pt #181a1b, 0 0 5pt 6pt #aaa
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -132,7 +132,7 @@ export default {
|
|||||||
let rotateAngle = (i) * offsetAngle
|
let rotateAngle = (i) * offsetAngle
|
||||||
let size = 130
|
let size = 130
|
||||||
return {
|
return {
|
||||||
card:this.getPlayerCard(x),
|
card: this.getPlayerCard(x),
|
||||||
style: `position:absolute;transform: rotate(${rotateAngle}deg) translate(0, -${size}pt) rotate(-${rotateAngle}deg) translate(${size}pt,${size}pt)`,
|
style: `position:absolute;transform: rotate(${rotateAngle}deg) translate(0, -${size}pt) rotate(-${rotateAngle}deg) translate(${size}pt,${size}pt)`,
|
||||||
...x
|
...x
|
||||||
}
|
}
|
||||||
@ -155,10 +155,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
getPlayerCard(player) {
|
getPlayerCard(player) {
|
||||||
|
let icon = ''
|
||||||
|
if (!this.started) icon = '🤠'
|
||||||
|
else icon = player.ready !== undefined ? ((player.ready)?'👍': '🤔') : (player.is_sheriff ? '⭐' : player.icon)
|
||||||
return {
|
return {
|
||||||
name: player.name,
|
name: player.name,
|
||||||
number: ((this.username == player.name) ? this.$t('you') : (this.players[0].name == player.name) ? this.$t('owner') :'') + (player.dist ? `${player.dist}⛰` : ''),
|
number: ((this.username == player.name) ? this.$t('you') : (this.players[0].name == player.name) ? this.$t('owner') :'') + (player.dist ? `${player.dist}⛰` : ''),
|
||||||
icon: (player.lives === undefined || player.lives > 0) ? (player.is_sheriff ? '⭐' : player.icon || ((player.ready)?'👍': '🤠') ) : '☠️',
|
icon: icon,
|
||||||
is_character: true,
|
is_character: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
<span v-for="(n, i) in (max_lives-lives)" v-bind:key="n" :alt="i">💀</span>
|
<span v-for="(n, i) in (max_lives-lives)" v-bind:key="n" :alt="i">💀</span>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
<transition-group v-if="lives > 0" name="list" tag="div" style="margin: 0 0 0 10pt; display:flex;">
|
<transition-group v-if="lives > 0" name="list" tag="div" style="margin: 0 0 0 10pt; display:flex;">
|
||||||
<Card v-for="card in equipment" v-bind:key="card.name+card.number" :card="card" @pointerenter.native="desc=card.desc" @pointerleave.native="desc=''" />
|
<Card v-for="card in equipment" v-bind:key="card.name+card.number" :card="card"
|
||||||
|
@pointerenter.native="desc=card.desc" @pointerleave.native="desc=''"
|
||||||
|
@click.native="play_card(card, true)" />
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</div>
|
</div>
|
||||||
<transition name="list">
|
<transition name="list">
|
||||||
@ -22,7 +24,7 @@
|
|||||||
<span>{{$t('hand')}}</span>
|
<span>{{$t('hand')}}</span>
|
||||||
<transition-group name="list" tag="div" class="hand">
|
<transition-group name="list" tag="div" class="hand">
|
||||||
<Card v-for="card in hand" v-bind:key="card.name+card.number" :card="card"
|
<Card v-for="card in hand" v-bind:key="card.name+card.number" :card="card"
|
||||||
@click.native="play_card(card)"
|
@click.native="play_card(card, false)"
|
||||||
@pointerenter.native="hint=card.desc" @pointerleave.native="hint=''"/>
|
@pointerenter.native="hint=card.desc" @pointerleave.native="hint=''"/>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</div>
|
</div>
|
||||||
@ -192,7 +194,10 @@ export default {
|
|||||||
icon: '❌',
|
icon: '❌',
|
||||||
is_equipment: true,
|
is_equipment: true,
|
||||||
}]
|
}]
|
||||||
this.hand.filter(x => this.expected_response.indexOf(x.name) !== -1).forEach(x=>{
|
this.hand.filter(x => x.can_be_used_now && this.expected_response.indexOf(x.name) !== -1).forEach(x=>{
|
||||||
|
cc.push(x)
|
||||||
|
})
|
||||||
|
this.equipment.filter(x => x.can_be_used_now && this.expected_response.indexOf(x.name) !== -1).forEach(x=>{
|
||||||
cc.push(x)
|
cc.push(x)
|
||||||
})
|
})
|
||||||
return cc
|
return cc
|
||||||
@ -220,14 +225,16 @@ export default {
|
|||||||
scrap(c) {
|
scrap(c) {
|
||||||
this.$socket.emit('scrap', this.hand.indexOf(c))
|
this.$socket.emit('scrap', this.hand.indexOf(c))
|
||||||
},
|
},
|
||||||
play_card(card) {
|
play_card(card, from_equipment) {
|
||||||
|
if (from_equipment && (!card.usable_next_turn || !card.can_be_used_now)) return;
|
||||||
|
else if (card.usable_next_turn && !card.can_be_used_now) return this.really_play_card(card, null);
|
||||||
let calamity_special = (card.name === 'Mancato!' && this.character.name === 'Calamity Janet')
|
let calamity_special = (card.name === 'Mancato!' && this.character.name === 'Calamity Janet')
|
||||||
let cant_play_bang = (this.has_played_bang && this.equipment.filter(x => x.name == 'Volcanic').length == 0)
|
let cant_play_bang = (this.has_played_bang && this.equipment.filter(x => x.name == 'Volcanic').length == 0)
|
||||||
if (this.pending_action == 2) {
|
if (this.pending_action == 2) {
|
||||||
if (card.need_with && !this.card_with) {
|
if (card.need_with && !this.card_with) {
|
||||||
this.card_with = card
|
this.card_with = card
|
||||||
} else if ((card.need_target || calamity_special) && !((card.name == 'Bang!' || (calamity_special && card.name=='Mancato!')) && cant_play_bang)) {
|
} else if ((card.need_target || calamity_special) && !((card.name == 'Bang!' || (calamity_special && card.name=='Mancato!')) && cant_play_bang)) {
|
||||||
if (card.name == 'Bang!' || calamity_special)
|
if (card.name == 'Bang!' || card.name == "Pepperbox" || calamity_special)
|
||||||
this.range = this.sight
|
this.range = this.sight
|
||||||
else
|
else
|
||||||
this.range = card.range
|
this.range = card.range
|
||||||
@ -242,7 +249,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
respond(card) {
|
respond(card) {
|
||||||
this.$socket.emit('respond', this.hand.indexOf(card))
|
let res = this.hand.indexOf(card)
|
||||||
|
if (res === -1) {
|
||||||
|
res = this.equipment.indexOf(card)
|
||||||
|
if (res !== -1) res += this.hand.length
|
||||||
|
}
|
||||||
|
this.$socket.emit('respond', res)
|
||||||
},
|
},
|
||||||
selectAgainst(player) {
|
selectAgainst(player) {
|
||||||
this.really_play_card(this.card_against, player.name)
|
this.really_play_card(this.card_against, player.name)
|
||||||
@ -268,8 +280,13 @@ export default {
|
|||||||
this.card_with = null
|
this.card_with = null
|
||||||
},
|
},
|
||||||
really_play_card(card, against) {
|
really_play_card(card, against) {
|
||||||
|
let res = this.hand.indexOf(card)
|
||||||
|
if (res === -1) {
|
||||||
|
res = this.equipment.indexOf(card)
|
||||||
|
if (res !== -1) res += this.hand.length
|
||||||
|
}
|
||||||
let card_data = {
|
let card_data = {
|
||||||
index: this.hand.indexOf(card),
|
index: res,
|
||||||
against: against,
|
against: against,
|
||||||
with: this.hand.indexOf(this.card_with) > -1 ? this.hand.indexOf(this.card_with):null,
|
with: this.hand.indexOf(this.card_with) > -1 ? this.hand.indexOf(this.card_with):null,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user