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.fistful_of_cards.card_events as ce
|
||||||
import bang.expansions.high_noon.card_events as ceh
|
import bang.expansions.high_noon.card_events as ceh
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
@ -6,6 +7,10 @@ from enum import IntEnum
|
|||||||
import bang.roles as r
|
import bang.roles as r
|
||||||
from globals import G
|
from globals import G
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from bang.players import Player
|
||||||
|
from bang.game import Game
|
||||||
|
|
||||||
class Suit(IntEnum):
|
class Suit(IntEnum):
|
||||||
DIAMONDS = 0 # ♦
|
DIAMONDS = 0 # ♦
|
||||||
CLUBS = 1 # ♣
|
CLUBS = 1 # ♣
|
||||||
@ -64,7 +69,7 @@ class Card(ABC):
|
|||||||
if self.must_be_used:
|
if self.must_be_used:
|
||||||
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: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:
|
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:
|
||||||
@ -98,10 +103,10 @@ class Card(ABC):
|
|||||||
def use_card(self, player):
|
def use_card(self, player):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def is_duplicate_card(self, player):
|
def is_duplicate_card(self, player: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]
|
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):
|
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):
|
||||||
|
@ -50,7 +50,7 @@ class Player:
|
|||||||
def is_admin(self):
|
def is_admin(self):
|
||||||
return self.discord_id in {'244893980960096266', '539795574019457034'}
|
return self.discord_id in {'244893980960096266', '539795574019457034'}
|
||||||
|
|
||||||
def get_avatar(self):
|
def _get_avatar(self):
|
||||||
import requests
|
import requests
|
||||||
headers = {
|
headers = {
|
||||||
'Authorization': 'Bearer ' + self.discord_token,
|
'Authorization': 'Bearer ' + self.discord_token,
|
||||||
@ -89,7 +89,7 @@ class Player:
|
|||||||
if self.is_bot:
|
if self.is_bot:
|
||||||
self.avatar = robot_pictures[randrange(len(robot_pictures))]
|
self.avatar = robot_pictures[randrange(len(robot_pictures))]
|
||||||
if self.discord_token:
|
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.game: g = None
|
||||||
self.reset()
|
self.reset()
|
||||||
|
|
||||||
@ -187,7 +187,6 @@ class Player:
|
|||||||
self.pending_action = PendingAction.DRAW
|
self.pending_action = PendingAction.DRAW
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
|
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
self.max_lives = self.character.max_lives + self.role.health_mod
|
self.max_lives = self.character.max_lives + self.role.health_mod
|
||||||
self.lives = self.max_lives
|
self.lives = self.max_lives
|
||||||
@ -874,7 +873,7 @@ class Player:
|
|||||||
if card_index <= len(self.available_cards):
|
if card_index <= len(self.available_cards):
|
||||||
self.hand.remove(self.available_cards[card_index])
|
self.hand.remove(self.available_cards[card_index])
|
||||||
self.game.deck.scrap(self.available_cards[card_index], player=self)
|
self.game.deck.scrap(self.available_cards[card_index], player=self)
|
||||||
self.hand.append(cs.Bang(cs.Suit.CLUBS,42))
|
self.hand.append(cs.Bang(cs.Suit.CLUBS, 42))
|
||||||
self.pending_action = PendingAction.PLAY
|
self.pending_action = PendingAction.PLAY
|
||||||
self.notify_self()
|
self.notify_self()
|
||||||
elif 'choose_tornado' in self.choose_text:
|
elif 'choose_tornado' in self.choose_text:
|
||||||
|
Loading…
Reference in New Issue
Block a user