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