add mancato verdi
This commit is contained in:
parent
1370efc98a
commit
0a50379447
@ -36,6 +36,8 @@ class Card(ABC):
|
||||
self.desc = desc
|
||||
self.need_target = False
|
||||
self.can_target_self = False
|
||||
self.can_be_used_now = True
|
||||
self.usable_next_turn = False
|
||||
self.need_with = False
|
||||
|
||||
def __str__(self):
|
||||
@ -284,7 +286,7 @@ class Mancato(Card):
|
||||
def __init__(self, suit, number):
|
||||
super().__init__(suit, 'Mancato!', number)
|
||||
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):
|
||||
import bang.characters as chars
|
||||
|
@ -6,6 +6,10 @@ class Deck:
|
||||
def __init__(self, game):
|
||||
super().__init__()
|
||||
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
|
||||
random.shuffle(self.cards)
|
||||
self.scrap_pile: List[cs.Card] = []
|
||||
|
@ -31,7 +31,7 @@ class Schivata(Mancato):
|
||||
super().__init__(suit, number)
|
||||
self.name = 'Schivata'
|
||||
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 = '☝️🆓'
|
||||
|
||||
def play_card(self, player, against, _with=None):
|
||||
@ -130,6 +130,53 @@ class Whisky(Card):
|
||||
return True
|
||||
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 = '👒'
|
||||
|
||||
def get_starting_deck() -> List[Card]:
|
||||
return [
|
||||
@ -160,4 +207,10 @@ def get_starting_deck() -> List[Card]:
|
||||
SpringField(Suit.SPADES, 'K'),
|
||||
Tequila(Suit.CLUBS, 9),
|
||||
Whisky(Suit.HEARTS, 'Q'),
|
||||
Bibbia(Suit.HEARTS, 10),
|
||||
Cappello(Suit.DIAMONDS, 'J'),
|
||||
PlaccaDiFerro(Suit.DIAMONDS, 'A'),
|
||||
PlaccaDiFerro(Suit.SPADES, 'Q'),
|
||||
Sombrero(Suit.CLUBS, 7),
|
||||
|
||||
]
|
||||
|
@ -16,7 +16,6 @@ class PendingAction(IntEnum):
|
||||
WAIT = 4
|
||||
CHOOSE = 5
|
||||
|
||||
|
||||
class Player:
|
||||
|
||||
def __init__(self, name, sid, sio):
|
||||
@ -321,19 +320,25 @@ class Player:
|
||||
if self.mancato_needed <= 0:
|
||||
self.game.responders_did_respond_resume_turn()
|
||||
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.game.responders_did_respond_resume_turn()
|
||||
else:
|
||||
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.notify_self()
|
||||
|
||||
def get_banged(self, attacker, double=False):
|
||||
self.attacker = attacker
|
||||
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')
|
||||
self.take_damage_response()
|
||||
return False
|
||||
@ -345,7 +350,7 @@ class Player:
|
||||
else:
|
||||
print('has mancato')
|
||||
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.notify_self()
|
||||
return True
|
||||
@ -407,8 +412,10 @@ class Player:
|
||||
|
||||
def respond(self, hand_index):
|
||||
self.pending_action = PendingAction.WAIT
|
||||
if hand_index != -1 and self.hand[hand_index].name in self.expected_response:
|
||||
card = self.hand.pop(hand_index)
|
||||
if hand_index != -1 and (
|
||||
((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)
|
||||
self.game.deck.scrap(card)
|
||||
self.notify_self()
|
||||
@ -465,6 +472,9 @@ class Player:
|
||||
f"I {self.name} have to many cards in my hand and I can't end the turn")
|
||||
else:
|
||||
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.notify_self()
|
||||
self.game.next_turn()
|
||||
|
@ -16,7 +16,7 @@
|
||||
<div v-else>
|
||||
<div v-if="!isInLobby" >
|
||||
<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>
|
||||
<div style="display: flex">
|
||||
<Card v-for="lobby in openLobbies" v-bind:key="lobby.name" :card="getLobbyCard(lobby)" @click.native="joinLobby(lobby)"/>
|
||||
|
@ -1,5 +1,5 @@
|
||||
<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>
|
||||
<div class="emoji">{{card.icon}}</div>
|
||||
<div class="alt_text">{{card.alt_text}}</div>
|
||||
@ -68,6 +68,10 @@ export default {
|
||||
0 0 0 6pt white,
|
||||
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 {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
|
@ -192,7 +192,10 @@ export default {
|
||||
icon: '❌',
|
||||
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)
|
||||
})
|
||||
return cc
|
||||
@ -242,7 +245,12 @@ export default {
|
||||
}
|
||||
},
|
||||
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) {
|
||||
this.really_play_card(this.card_against, player.name)
|
||||
|
Loading…
Reference in New Issue
Block a user