minor refactor
This commit is contained in:
parent
3262580592
commit
62ac700c5b
@ -1,4 +1,5 @@
|
||||
from typing import List, Set, Dict, Tuple, Optional
|
||||
from __future__ import annotations
|
||||
from typing import List, Set, Dict, Tuple, Optional, TYPE_CHECKING
|
||||
import bang.expansions.fistful_of_cards.card_events as ce
|
||||
import bang.expansions.high_noon.card_events as ceh
|
||||
from abc import ABC, abstractmethod
|
||||
@ -6,6 +7,10 @@ from enum import IntEnum
|
||||
import bang.roles as r
|
||||
from globals import G
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from bang.players import Player
|
||||
from bang.game import Game
|
||||
|
||||
class Suit(IntEnum):
|
||||
DIAMONDS = 0 # ♦
|
||||
CLUBS = 1 # ♣
|
||||
@ -64,7 +69,7 @@ class Card(ABC):
|
||||
if self.must_be_used:
|
||||
self.must_be_used = False
|
||||
|
||||
def play_card(self, player, against=None, _with=None):#self --> carta
|
||||
def play_card(self, player:Player, against:str=None, _with:int=None):#self --> carta
|
||||
if (player.game.check_event(ce.IlGiudice)) and self.usable_next_turn and not self.can_be_used_now:
|
||||
return False
|
||||
if self.is_equipment:
|
||||
@ -98,10 +103,10 @@ class Card(ABC):
|
||||
def use_card(self, player):
|
||||
pass
|
||||
|
||||
def is_duplicate_card(self, player):
|
||||
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 is_duplicate_card(self, player:Player):
|
||||
return any(c.name==self.name for c in player.equipment) or any(c.name==self.name for c in player.gold_rush_equipment)
|
||||
|
||||
def check_suit(self, game, accepted):
|
||||
def check_suit(self, game:Game, accepted:List[Suit]):
|
||||
if game.check_event(ceh.Benedizione):
|
||||
return Suit.HEARTS in accepted
|
||||
elif game.check_event(ceh.Maledizione):
|
||||
|
@ -50,7 +50,7 @@ class Player:
|
||||
def is_admin(self):
|
||||
return self.discord_id in {'244893980960096266', '539795574019457034'}
|
||||
|
||||
def get_avatar(self):
|
||||
def _get_avatar(self):
|
||||
import requests
|
||||
headers = {
|
||||
'Authorization': 'Bearer ' + self.discord_token,
|
||||
@ -89,7 +89,7 @@ class Player:
|
||||
if self.is_bot:
|
||||
self.avatar = robot_pictures[randrange(len(robot_pictures))]
|
||||
if self.discord_token:
|
||||
G.sio.start_background_task(self.get_avatar)
|
||||
G.sio.start_background_task(self._get_avatar)
|
||||
self.game: g = None
|
||||
self.reset()
|
||||
|
||||
@ -187,7 +187,6 @@ class Player:
|
||||
self.pending_action = PendingAction.DRAW
|
||||
self.notify_self()
|
||||
|
||||
|
||||
def prepare(self):
|
||||
self.max_lives = self.character.max_lives + self.role.health_mod
|
||||
self.lives = self.max_lives
|
||||
|
Loading…
Reference in New Issue
Block a user