Multiple test players

This commit is contained in:
Eden Kirin
2023-03-30 12:05:58 +02:00
parent 33f2220356
commit 8a48d61dc9
2 changed files with 12 additions and 18 deletions

View File

@ -194,7 +194,7 @@ class GameEngineFactory:
board=board,
ws_server=ws_server,
)
GameEngineFactory.__add_test_player(game.players)
GameEngineFactory.__add_test_players(game.players)
return game
@staticmethod
@ -209,18 +209,10 @@ class GameEngineFactory:
)
@staticmethod
def __add_test_player(players: PlayerList) -> None:
if not (settings.debug and settings.debug.CREATE_TEST_PLAYER):
def __add_test_players(players: PlayerList) -> None:
if not settings.debug:
return
player = Player(
name="Pero",
uuid="test-player-id",
position=Position(
settings.debug.TEST_PLAYER_START_X,
settings.debug.TEST_PLAYER_START_Y,
),
can_be_deactivated=False,
)
players.append(player)
logging.info(f"Test player created: {player}")
for player in settings.debug.PLAYERS:
players.append(player)
logging.info(f"Test player created: {player}")

View File

@ -1,11 +1,15 @@
import logging
from dataclasses import dataclass
from typing import Optional
from typing import List, Optional
from hopper.models.player import Player
@dataclass
class GameSettings:
MOVE_DELAY: float = 0.5 # seconds
@dataclass
class BoardSettings:
WIDTH: int = 21
@ -29,9 +33,7 @@ class WSServerSettings:
@dataclass
class DebugSettings:
PRINT_BOARD: bool = False
CREATE_TEST_PLAYER: bool = False
TEST_PLAYER_START_X: int = 0
TEST_PLAYER_START_Y: int = 0
PLAYERS: Optional[List[Player]] = None
@dataclass