fix bug and new structure
This commit is contained in:
parent
57ce8a3ebb
commit
3d88fdeb12
@ -4,8 +4,8 @@ from typing import List
|
||||
import eventlet
|
||||
import socketio
|
||||
|
||||
from game import Game
|
||||
from players import Player
|
||||
from bang.game import Game
|
||||
from bang.players import Player
|
||||
|
||||
sio = socketio.Server(cors_allowed_origins="*")
|
||||
app = socketio.WSGIApp(sio, static_files={
|
||||
|
@ -1,7 +1,7 @@
|
||||
from typing import List, Set, Dict, Tuple, Optional
|
||||
from abc import ABC, abstractmethod
|
||||
from enum import IntEnum
|
||||
import roles as r
|
||||
import bang.roles as r
|
||||
|
||||
class Suit(IntEnum):
|
||||
DIAMONDS = 0 # ♦
|
||||
@ -57,7 +57,7 @@ class Card(ABC):
|
||||
for i in range(len(player.equipment)):
|
||||
print('tipo',type(self))
|
||||
if type(player.equipment[i]) == type(self):
|
||||
player.game.deck.scrap(self.equipment[i])
|
||||
player.game.deck.scrap(player.equipment[i])
|
||||
player.equipment[i] = self
|
||||
break
|
||||
else:
|
||||
@ -162,7 +162,7 @@ class Bang(Card):
|
||||
if player.has_played_bang and not any([isinstance(c, Volcanic) for c in player.equipment]) and against != None:
|
||||
return False
|
||||
elif against != None:
|
||||
import characters as chars
|
||||
import bang.characters as chars
|
||||
super().play_card(player, against=against)
|
||||
player.has_played_bang = not isinstance(
|
||||
player.character, chars.WillyTheKid)
|
||||
@ -199,7 +199,7 @@ class CatBalou(Card):
|
||||
def play_card(self, player, against):
|
||||
if against != None and (len(player.game.get_player_named(against).hand) + len(player.game.get_player_named(against).equipment)) > 0:
|
||||
super().play_card(player, against=against)
|
||||
from players import PendingAction
|
||||
from bang.players import PendingAction
|
||||
player.pending_action = PendingAction.CHOOSE
|
||||
player.choose_action = 'discard'
|
||||
player.target_p = against
|
||||
@ -281,7 +281,7 @@ class Mancato(Card):
|
||||
self.desc = "Usa questa carta per annullare un bang"
|
||||
|
||||
def play_card(self, player, against):
|
||||
import characters as chars
|
||||
import bang.characters as chars
|
||||
if (not player.has_played_bang and against != None and isinstance(player.character, chars.CalamityJanet)):
|
||||
player.sio.emit('chat_message', room=player.game.name,
|
||||
data=f'{player.name} ha giocato {self.name} come un BANG! contro {against}.')
|
||||
@ -301,7 +301,7 @@ class Panico(Card):
|
||||
def play_card(self, player, against):
|
||||
if against != None and (len(player.game.get_player_named(against).hand) + len(player.game.get_player_named(against).equipment)) > 0:
|
||||
super().play_card(player, against=against)
|
||||
from players import PendingAction
|
||||
from bang.players import PendingAction
|
||||
player.pending_action = PendingAction.CHOOSE
|
||||
player.choose_action = 'steal'
|
||||
player.target_p = against
|
||||
@ -339,8 +339,9 @@ class WellsFargo(Card):
|
||||
return True
|
||||
|
||||
|
||||
def get_starting_deck() -> List[Card]:
|
||||
return [
|
||||
def get_starting_deck(expansions:List[str]) -> List[Card]:
|
||||
from bang.expansions import DodgeCity
|
||||
base_cards = [
|
||||
Barile(Suit.SPADES, 'Q'),
|
||||
Barile(Suit.SPADES, 'K'),
|
||||
Dinamite(Suit.HEARTS, 2),
|
||||
@ -422,3 +423,7 @@ def get_starting_deck() -> List[Card]:
|
||||
Saloon(Suit.HEARTS, 5),
|
||||
WellsFargo(Suit.HEARTS, 3),
|
||||
]
|
||||
if 'dodge_city' in expansions:
|
||||
base_cards.extend(DodgeCity.get_cards())
|
||||
return base_cards
|
||||
|
@ -1,6 +1,6 @@
|
||||
from typing import List, Set, Dict, Tuple, Optional
|
||||
import random
|
||||
import cards as cs
|
||||
import bang.cards as cs
|
||||
|
||||
class Deck:
|
||||
def __init__(self, game):
|
5
backend/bang/expansions/__init__.py
Normal file
5
backend/bang/expansions/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
from bang.expansions.dodge_city import cards
|
||||
class DodgeCity():
|
||||
def get_cards():
|
||||
return cards.get_starting_deck()
|
13
backend/bang/expansions/dodge_city/cards.py
Normal file
13
backend/bang/expansions/dodge_city/cards.py
Normal file
@ -0,0 +1,13 @@
|
||||
from bang.cards import *
|
||||
|
||||
class Riparo(Mustang):
|
||||
def __init__(self, suit, number):
|
||||
super().__init__(suit, number)
|
||||
self.name = 'Riparo'
|
||||
self.icon = '⛰'
|
||||
|
||||
def get_starting_deck() -> List[Card]:
|
||||
return [
|
||||
Riparo(Suit.DIAMONDS, 'K'),
|
||||
Mustang(Suit.DIAMONDS, 'K'),
|
||||
]*100
|
@ -2,10 +2,10 @@
|
||||
from typing import List, Set, Dict, Tuple, Optional
|
||||
import random
|
||||
import socketio
|
||||
import players
|
||||
import characters
|
||||
from deck import Deck
|
||||
import roles
|
||||
import bang.players as players
|
||||
import bang.characters as characters
|
||||
from bang.deck import Deck
|
||||
import bang.roles as roles
|
||||
|
||||
class Game:
|
||||
def __init__(self, name, sio:socketio):
|
@ -2,10 +2,10 @@ from enum import IntEnum
|
||||
import json
|
||||
from random import randrange
|
||||
import socketio
|
||||
import deck
|
||||
import roles as r
|
||||
import cards as cs
|
||||
import characters as chars
|
||||
import bang.deck as deck
|
||||
import bang.roles as r
|
||||
import bang.cards as cs
|
||||
import bang.characters as chars
|
||||
|
||||
class PendingAction(IntEnum):
|
||||
PICK = 0
|
||||
@ -17,9 +17,9 @@ class PendingAction(IntEnum):
|
||||
|
||||
|
||||
class Player:
|
||||
import game as g
|
||||
|
||||
def __init__(self, name, sid, sio):
|
||||
import bang.game as g
|
||||
super().__init__()
|
||||
self.name = name
|
||||
self.sid = sid
|
Loading…
Reference in New Issue
Block a user