import refactor

This commit is contained in:
Giulio 2022-03-25 17:49:13 +01:00
parent fd6c4cca1d
commit 4af54f79dd
2 changed files with 3 additions and 19 deletions

View File

@ -1,4 +1,6 @@
from typing import List, Set, Dict, Tuple, Optional from typing import List, Set, Dict, Tuple, Optional
import bang.expansions.fistful_of_cards.card_events as ce
import bang.expansions.high_noon.card_events as ceh
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from enum import IntEnum from enum import IntEnum
import bang.roles as r import bang.roles as r
@ -59,7 +61,6 @@ class Card(ABC):
self.must_be_used = False self.must_be_used = False
def play_card(self, player, against=None, _with=None):#self --> carta def play_card(self, player, against=None, _with=None):#self --> carta
import bang.expansions.fistful_of_cards.card_events as ce
if (player.game.check_event(ce.IlGiudice)) and self.usable_next_turn and not self.can_be_used_now: if (player.game.check_event(ce.IlGiudice)) and self.usable_next_turn and not self.can_be_used_now:
return False return False
if self.is_equipment: if self.is_equipment:
@ -96,7 +97,6 @@ class Card(ABC):
return self.name in [c.name for c in player.equipment] or self.name in [c.name for c in player.gold_rush_equipment] return self.name in [c.name for c in player.equipment] or self.name in [c.name for c in player.gold_rush_equipment]
def check_suit(self, game, accepted): def check_suit(self, game, accepted):
import bang.expansions.high_noon.card_events as ceh
if game.check_event(ceh.Benedizione): if game.check_event(ceh.Benedizione):
return Suit.HEARTS in accepted return Suit.HEARTS in accepted
elif game.check_event(ceh.Maledizione): elif game.check_event(ceh.Maledizione):
@ -149,7 +149,6 @@ class Prigione(Card):
self.alt_text = "♥️= 🆓" self.alt_text = "♥️= 🆓"
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if (player.game.check_event(ce.IlGiudice)): if (player.game.check_event(ce.IlGiudice)):
return False return False
if against != None and not isinstance(player.game.get_player_named(against).role, r.Sheriff): if against != None and not isinstance(player.game.get_player_named(against).role, r.Sheriff):
@ -215,8 +214,6 @@ class Bang(Card):
self.need_target = True self.need_target = True
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
import bang.expansions.high_noon.card_events as ceh
if player.game.check_event(ceh.Sermone) and not self.number == 42: # 42 gold rush if player.game.check_event(ceh.Sermone) and not self.number == 42: # 42 gold rush
return False return False
if ((player.has_played_bang and not self.number == 42) and (not any([isinstance(c, Volcanic) for c in player.equipment]) or player.game.check_event(ce.Lazo)) and against != None): # 42 gold rush: if ((player.has_played_bang and not self.number == 42) and (not any([isinstance(c, Volcanic) for c in player.equipment]) or player.game.check_event(ce.Lazo)) and against != None): # 42 gold rush:
@ -242,7 +239,6 @@ class Birra(Card):
# self.desc_eng = "Play this card to regain a life point. You cannot heal more than your character's maximum limit. If you are about to lose your last life point, you can also play this card on your opponent's turn. Beer no longer takes effect if there are only two players" # self.desc_eng = "Play this card to regain a life point. You cannot heal more than your character's maximum limit. If you are about to lose your last life point, you can also play this card on your opponent's turn. Beer no longer takes effect if there are only two players"
def play_card(self, player, against=None, _with=None, skipChecks=False): def play_card(self, player, against=None, _with=None, skipChecks=False):
import bang.expansions.high_noon.card_events as ceh
if player.game.check_event(ceh.IlReverendo): if player.game.check_event(ceh.IlReverendo):
return False return False
if not skipChecks: if not skipChecks:
@ -381,10 +377,8 @@ class Mancato(Card):
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
if against != None and player.character.check(player.game, chars.CalamityJanet): if against != None and player.character.check(player.game, chars.CalamityJanet):
import bang.expansions.fistful_of_cards.card_events as ce
if player.has_played_bang and (not any([isinstance(c, Volcanic) for c in player.equipment]) or player.game.check_event(ce.Lazo)): if player.has_played_bang and (not any([isinstance(c, Volcanic) for c in player.equipment]) or player.game.check_event(ce.Lazo)):
return False return False
import bang.expansions.high_noon.card_events as ceh
if player.game.check_event(ceh.Sermone): if player.game.check_event(ceh.Sermone):
return False return False
player.sio.emit('chat_message', room=player.game.name, player.sio.emit('chat_message', room=player.game.name,

View File

@ -1,4 +1,5 @@
from bang.cards import * from bang.cards import *
import bang.expansions.fistful_of_cards.card_events as ce
class Binocolo(Mirino): class Binocolo(Mirino):
def __init__(self, suit, number): def __init__(self, suit, number):
@ -149,7 +150,6 @@ class Bibbia(Schivata):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
pass pass
return False return False
@ -171,7 +171,6 @@ class Cappello(Mancato):
self.alt_text = "😅" self.alt_text = "😅"
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
pass pass
return False return False
@ -205,7 +204,6 @@ class Pugnale(Pugno):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
return super().play_card(player, against=against) return super().play_card(player, against=against)
else: else:
@ -227,7 +225,6 @@ class Derringer(Pugnale):
# self.desc_eng += ' and then draw a card.' # self.desc_eng += ' and then draw a card.'
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
player.hand.append(player.game.deck.draw(True)) player.hand.append(player.game.deck.draw(True))
return super().play_card(player, against=against) return super().play_card(player, against=against)
@ -254,7 +251,6 @@ class Borraccia(Card):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
super().play_card(player, against) super().play_card(player, against)
player.lives = min(player.lives+1, player.max_lives) player.lives = min(player.lives+1, player.max_lives)
@ -278,7 +274,6 @@ class PonyExpress(WellsFargo):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
return super().play_card(player, against) return super().play_card(player, against)
else: else:
@ -299,7 +294,6 @@ class Howitzer(Gatling):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
return super().play_card(player, against) return super().play_card(player, against)
else: else:
@ -320,7 +314,6 @@ class CanCan(CatBalou):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
player.sio.emit('chat_message', room=player.game.name, data=f'_play_card_against|{player.name}|{self.name}|{against}') player.sio.emit('chat_message', room=player.game.name, data=f'_play_card_against|{player.name}|{self.name}|{against}')
return super().play_card(player, against) return super().play_card(player, against)
@ -344,7 +337,6 @@ class Conestoga(Panico):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
return super().play_card(player, against) return super().play_card(player, against)
else: else:
@ -365,7 +357,6 @@ class Pepperbox(Bang):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
if against != None: if against != None:
Card.play_card(self, player, against=against) Card.play_card(self, player, against=against)
@ -391,7 +382,6 @@ class FucileDaCaccia(Card):
self.can_be_used_now = False self.can_be_used_now = False
def play_card(self, player, against, _with=None): def play_card(self, player, against, _with=None):
import bang.expansions.fistful_of_cards.card_events as ce
if self.can_be_used_now: if self.can_be_used_now:
if against != None: if against != None:
super().play_card(player, against=against) super().play_card(player, against=against)