diff --git a/esm/core/db.py b/esm/core/db.py
index 5901a62..2224224 100644
--- a/esm/core/db.py
+++ b/esm/core/db.py
@@ -15,13 +15,16 @@
# along with this program. If not, see .
from typing import Tuple
+from ..definitions import NAMES_FILE
from .esports.moba.generator import (
ChampionGenerator,
MobaPlayerGenerator,
TeamGenerator,
)
+from .esports.moba.mobateam import MobaTeam
from .gamestate import GameState
from .settings import Settings
+from .utils import load_list_from_file
class DB:
@@ -40,42 +43,11 @@ def players_file(self):
def champions_file(self):
return self.settings.champions_file
- def get_moba_generators(
- self,
- ) -> Tuple[MobaPlayerGenerator, TeamGenerator, ChampionGenerator]:
- players = MobaPlayerGenerator()
- teams = TeamGenerator()
- champions = ChampionGenerator()
- return players, teams, champions
-
- def generate_moba_files(self):
- players_gen, teams_gen, champions_gen = self.get_moba_generators()
- champions_gen.generate_champions()
- players_gen.champions_list = champions_gen.champions
-
- players_gen.lane = 0
- players_gen.generate_players(amount=self.settings.amount_players)
-
- amount_teams = int(self.settings.amount_players / 5)
-
- teams_gen.amount = amount_teams
- teams_gen.player_list = players_gen.players
- teams_gen.generate_teams()
-
- teams_gen.generate_file()
- champions_gen.generate_file()
- players_gen.generate_file()
-
- def load_moba_teams(self):
- players_gen, teams_gen, champions_gen = self.get_moba_generators()
-
- champions_gen.get_champions()
- players_gen.champions_list = champions_gen.champions
- players_gen.get_players_objects()
- teams_gen.player_list = players_gen.players
- teams_gen.get_teams_objects()
+ def generate_moba_files(self) -> None:
+ pass
- return teams_gen.teams
+ def load_moba_teams(self) -> list[MobaTeam]:
+ pass
def get_gamestate(self) -> GameState:
pass
diff --git a/esm/core/esmcore.py b/esm/core/esmcore.py
index be20af8..3d533a5 100644
--- a/esm/core/esmcore.py
+++ b/esm/core/esmcore.py
@@ -41,36 +41,6 @@ def __init__(self):
self.settings, self.db, self.settings.enable_auto_save
)
- @property
- def amount_players(self):
- return self.settings.amount_players
-
- @amount_players.setter
- def amount_players(self, value):
- try:
- self.check_player_amount()
- except AmountPlayersError:
- self.settings.amount_players = 50
- else:
- self.settings.amount_players = value
-
- def check_player_amount(self):
- if self.amount_players > 300 or self.amount_players < 50:
- error_message = dedent(
- """
- Number of players is not supported! Ranges from 50 to 300 players! Defaulting to 50.
- """
- ).strip()
- raise AmountPlayersError(error_message)
-
- if self.amount_players % 5 != 0:
- error_message = dedent(
- """
- Number of players is not supported! Number should be a multiple of 5!
- """
- )
- raise AmountPlayersError(error_message)
-
def check_if_files_exist(self) -> None:
if (
not os.path.exists(self.settings.champions_file)
diff --git a/esm/core/esports/manager.py b/esm/core/esports/manager.py
index e952777..7854c77 100644
--- a/esm/core/esports/manager.py
+++ b/esm/core/esports/manager.py
@@ -16,7 +16,7 @@
from datetime import date, datetime
from typing import Union
-from esm.core.esports.moba.team import Team
+from esm.core.esports.moba.mobateam import MobaTeam
from .player import Player
@@ -30,7 +30,7 @@ def __init__(
last_name: str,
birthday: Union[date, datetime, str],
nick_name: str,
- team: Union[int, Team],
+ team: Union[int, MobaTeam],
is_player: bool,
quality: int,
):
@@ -42,7 +42,7 @@ def __init__(
self.quality = quality
def get_dict(self):
- team = self.team.team_id if isinstance(self.team, Team) else self.team
+ team = self.team.team_id if isinstance(self.team, MobaTeam) else self.team
return {
"id": self.player_id.int,
"first_name": self.first_name,
diff --git a/esm/core/esports/moba/generator/generate_teams.py b/esm/core/esports/moba/generator/generate_teams.py
index 2cb519a..350427f 100644
--- a/esm/core/esports/moba/generator/generate_teams.py
+++ b/esm/core/esports/moba/generator/generate_teams.py
@@ -22,8 +22,8 @@
from esm.core.esports.moba.generator.generate_champions import Champion
from esm.core.esports.moba.generator.generate_players import MobaPlayerGenerator
from esm.core.esports.moba.generator.generator import GeneratorInterface
+from esm.core.esports.moba.mobateam import MobaTeam
from esm.core.esports.moba.player import Lanes, MobaPlayer
-from esm.core.esports.moba.team import Team
class TeamGeneratorError(Exception):
@@ -69,14 +69,14 @@ def generate_roster(
for lane in list(Lanes)
]
- def generate(self, team_definition: dict[str, str | int]) -> Team:
+ def generate(self, team_definition: dict[str, str | int]) -> MobaTeam:
"""
Generates the team
"""
nationality = team_definition["nationality"]
mu = team_definition["mu"]
sigma = team_definition["sigma"]
- return Team(
+ return MobaTeam(
team_id=self.generate_id(),
name=team_definition["name"],
nationality=nationality,
diff --git a/esm/core/esports/moba/match_tester.py b/esm/core/esports/moba/match_tester.py
index 8661a5e..ae9420e 100644
--- a/esm/core/esports/moba/match_tester.py
+++ b/esm/core/esports/moba/match_tester.py
@@ -51,7 +51,7 @@ def reset_values(self):
self.running_test = False
def _get_team_stats(self, i):
- team = self.match.game.teams[i]
+ team = self.match.teams[i]
self.amount_team_kills[i].append(team.kills)
self.amount_team_deaths[i].append(team.deaths)
self.amount_team_assists[i].append(team.assists)
@@ -63,7 +63,7 @@ def _get_team_stats(self, i):
self.avg_team_assists[i] += team.assists
def _get_amount_wins(self):
- if self.match.victorious_team == self.match.game.team1:
+ if self.match.victorious_team == self.match.team1:
self.amount_team_wins[0] += 1
else:
self.amount_team_wins[1] += 1
@@ -101,17 +101,17 @@ def run_match_test(self):
self.get_avg(self.avg_team_assists)
print("Average team kills:")
- print(f"{self.match.game.team1.team.name}: {self.amount_team_kills[0]}")
- print(f"{self.match.game.team2.team.name}: {self.amount_team_kills[1]}")
+ print(f"{self.match.team1.team.name}: {self.amount_team_kills[0]}")
+ print(f"{self.match.team2.team.name}: {self.amount_team_kills[1]}")
print("Average team deaths:")
- print(f"{self.match.game.team1.team.name}: {self.amount_team_deaths[0]}")
- print(f"{self.match.game.team2.team.name}: {self.amount_team_deaths[1]}")
+ print(f"{self.match.team1.team.name}: {self.amount_team_deaths[0]}")
+ print(f"{self.match.team2.team.name}: {self.amount_team_deaths[1]}")
print("Average team assists:")
- print(f"{self.match.game.team1.team.name}: {self.amount_team_assists[0]}")
- print(f"{self.match.game.team2.team.name}: {self.amount_team_assists[1]}")
+ print(f"{self.match.team1.team.name}: {self.amount_team_assists[0]}")
+ print(f"{self.match.team2.team.name}: {self.amount_team_assists[1]}")
print("Amount team wins:")
- print(f"{self.match.game.team1.team.name}: {self.amount_team_wins[0]}")
- print(f"{self.match.game.team2.team.name}: {self.amount_team_wins[1]}")
+ print(f"{self.match.team1.team.name}: {self.amount_team_wins[0]}")
+ print(f"{self.match.team2.team.name}: {self.amount_team_wins[1]}")
print("Average game time was", self.get_avg_game_time())
print("Max game time was", self.get_max_game_time())
diff --git a/esm/core/esports/moba/team.py b/esm/core/esports/moba/mobateam.py
similarity index 94%
rename from esm/core/esports/moba/team.py
rename to esm/core/esports/moba/mobateam.py
index 29d43aa..14ed147 100644
--- a/esm/core/esports/moba/team.py
+++ b/esm/core/esports/moba/mobateam.py
@@ -43,7 +43,7 @@ def get_players_from_list(
@dataclass
-class Team(Serializable):
+class MobaTeam(Serializable):
team_id: uuid.UUID
name: str
nationality: str
@@ -75,11 +75,11 @@ class TeamStats:
assists: int = 0
-class TeamSimulation:
+class MobaTeamSimulation:
def __init__(
- self, team: Team, players: list[MobaPlayerSimulation], is_players_team: bool
+ self, team: MobaTeam, players: list[MobaPlayerSimulation], is_players_team: bool
):
- self.team: Team = team
+ self.team: MobaTeam = team
self.towers: dict[str, int] = {
"top": 3,
"mid": 3,
@@ -91,6 +91,11 @@ def __init__(
"mid": 1,
"bot": 1,
}
+ self.inhibitors_cooldown: dict[str, float] = {
+ "top": 0.0,
+ "mid": 0.0,
+ "bot": 0.0,
+ }
self.is_players_team: bool = is_players_team
self.nexus: int = 1
self.players: list[MobaPlayerSimulation] = players
@@ -102,12 +107,6 @@ def __init__(
self._points: int = 0
self._bans: list[Champion] = []
- def is_tower_up(self, lane: str) -> bool:
- return self.towers[lane] != 0
-
- def are_all_towers_up(self) -> bool:
- return 0 not in self.towers.values()
-
def are_all_towers_down(self) -> bool:
return (
self.towers["top"] == 0
@@ -257,6 +256,6 @@ def __repr__(self):
def __eq__(self, other):
return (
self.team.team_id == other.team.team_id
- if isinstance(other, TeamSimulation)
+ if isinstance(other, MobaTeamSimulation)
else NotImplemented
)
diff --git a/esm/core/esports/moba/modules/match_manager.py b/esm/core/esports/moba/modules/match_manager.py
index a9efeb6..102ca00 100644
--- a/esm/core/esports/moba/modules/match_manager.py
+++ b/esm/core/esports/moba/modules/match_manager.py
@@ -22,7 +22,7 @@
from esm.core.esports.moba.simulation.match_live import MatchLive
from ..mobamatch import MobaMatch
-from ..team import TeamSimulation
+from ..mobateam import MobaTeamSimulation
class MatchManager:
@@ -36,8 +36,8 @@ def initialize_game(
self,
game_id: uuid.UUID,
championship_id: uuid.UUID,
- team1: TeamSimulation,
- team2: TeamSimulation,
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
):
self.current_game = MobaMatch(game_id, championship_id, team1, team2)
diff --git a/esm/core/esports/moba/progression.py b/esm/core/esports/moba/progression.py
index 9e51449..3d7ac66 100644
--- a/esm/core/esports/moba/progression.py
+++ b/esm/core/esports/moba/progression.py
@@ -17,8 +17,8 @@
from typing import Union
from uuid import UUID
+from .mobateam import MobaTeam
from .player import MobaPlayer
-from .team import Team
class Progression(ABC):
@@ -28,7 +28,7 @@ def progress(self, *args, **kwargs):
class PlayerProgression(Progression):
- def progress(self, opp_team: Team, player: MobaPlayer):
+ def progress(self, opp_team: MobaTeam, player: MobaPlayer):
pass
diff --git a/esm/core/esports/moba/simulation/events/general.py b/esm/core/esports/moba/simulation/events/general.py
index 26ecbee..82a09dd 100644
--- a/esm/core/esports/moba/simulation/events/general.py
+++ b/esm/core/esports/moba/simulation/events/general.py
@@ -21,20 +21,12 @@
from queue import Queue
from typing import Union
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
from esm.core.esports.moba.simulation.commentaries import Commentaries
-from esm.core.esports.moba.team import TeamSimulation
logger = logging.getLogger(__name__)
-class EventCreator(ABC):
- @abstractmethod
- def factory_method(
- self, event_chosen: dict, game_time: float, show_commentary: bool, queue: Queue
- ):
- pass
-
-
class MobaEvent(ABC):
def __init__(
self,
@@ -71,8 +63,8 @@ def get_from_dict(
@staticmethod
def _get_probable_team(
- team1: TeamSimulation, team2: TeamSimulation
- ) -> tuple[TeamSimulation, TeamSimulation]:
+ team1: MobaTeamSimulation, team2: MobaTeamSimulation
+ ) -> tuple[MobaTeamSimulation, MobaTeamSimulation]:
"""
Gets the team with a higher probability to attack the other team
"""
@@ -131,9 +123,9 @@ def calculate_event(self, *args, **kwargs):
class NothingEvent(MobaEvent):
def calculate_event(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
- which_nexus: Union[TeamSimulation, None],
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
+ which_nexus: Union[MobaTeamSimulation, None],
):
pass
diff --git a/esm/core/esports/moba/simulation/events/inhib.py b/esm/core/esports/moba/simulation/events/inhib.py
index 98d05ce..b450017 100644
--- a/esm/core/esports/moba/simulation/events/inhib.py
+++ b/esm/core/esports/moba/simulation/events/inhib.py
@@ -15,36 +15,21 @@
# along with this program. If not, see .
import logging
import random
-from queue import Queue
from typing import Union
-from esm.core.esports.moba.team import TeamSimulation
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
-from .general import EventCreator, MobaEvent
+from .general import MobaEvent
logger = logging.getLogger(__name__)
-class InhibEventEventCreator(EventCreator):
- def factory_method(
- self, event_chosen: dict, game_time: float, show_commentary: bool, queue: Queue
- ):
- return InhibEvent(
- event_name=event_chosen["name"],
- priority=event_chosen["priority"],
- points=event_chosen["points"],
- event_time=game_time,
- show_commentary=show_commentary,
- queue=queue,
- )
-
-
class InhibEvent(MobaEvent):
def calculate_event(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
- which_nexus: Union[TeamSimulation, None],
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
+ which_nexus: Union[MobaTeamSimulation, None],
):
if team1.get_exposed_inhibs():
attack_team = team2
diff --git a/esm/core/esports/moba/simulation/events/jungle.py b/esm/core/esports/moba/simulation/events/jungle.py
index 6225610..5b9c64d 100644
--- a/esm/core/esports/moba/simulation/events/jungle.py
+++ b/esm/core/esports/moba/simulation/events/jungle.py
@@ -15,36 +15,21 @@
# along with this program. If not, see .
import logging
import random
-from queue import Queue
from typing import Union
-from esm.core.esports.moba.team import TeamSimulation
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
-from .general import EventCreator, MobaEvent
+from .general import MobaEvent
logger = logging.getLogger(__name__)
-class JungleEventEventCreator(EventCreator):
- def factory_method(
- self, event_chosen: dict, game_time: float, show_commentary: bool, queue: Queue
- ):
- return JungleEvent(
- event_name=event_chosen["name"],
- priority=event_chosen["priority"],
- points=event_chosen["points"],
- event_time=game_time,
- show_commentary=show_commentary,
- queue=queue,
- )
-
-
class JungleEvent(MobaEvent):
def calculate_event(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
- which_nexus: Union[TeamSimulation, None],
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
+ which_nexus: Union[MobaTeamSimulation, None],
):
"""
Calculates the outcome of a major jungle attempt (baron, dragon or herald)
diff --git a/esm/core/esports/moba/simulation/events/kill.py b/esm/core/esports/moba/simulation/events/kill.py
index d48804a..ab5d1b3 100644
--- a/esm/core/esports/moba/simulation/events/kill.py
+++ b/esm/core/esports/moba/simulation/events/kill.py
@@ -15,31 +15,16 @@
# along with this program. If not, see .
import logging
import random
-from queue import Queue
from typing import Union
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
from esm.core.esports.moba.player import MobaPlayerSimulation
-from esm.core.esports.moba.team import TeamSimulation
-from .general import EventCreator, MobaEvent
+from .general import MobaEvent
logger = logging.getLogger(__name__)
-class KillEventEventCreator(EventCreator):
- def factory_method(
- self, event_chosen: dict, game_time: float, show_commentary: bool, queue: Queue
- ):
- return KillEvent(
- event_name=event_chosen["name"],
- priority=event_chosen["priority"],
- points=event_chosen["points"],
- event_time=game_time,
- show_commentary=show_commentary,
- queue=queue,
- )
-
-
class KillEvent(MobaEvent):
def choose_duel_players(
self, killer: MobaPlayerSimulation, team: list, amount: int
@@ -152,9 +137,9 @@ def get_kill_dict(
def calculate_event(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
- which_nexus: Union[TeamSimulation, None],
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
+ which_nexus: Union[MobaTeamSimulation, None],
):
"""
This will calculate the kill event
diff --git a/esm/core/esports/moba/simulation/events/nexus.py b/esm/core/esports/moba/simulation/events/nexus.py
index 67b268f..ca6af04 100644
--- a/esm/core/esports/moba/simulation/events/nexus.py
+++ b/esm/core/esports/moba/simulation/events/nexus.py
@@ -15,36 +15,21 @@
# along with this program. If not, see .
import logging
import random
-from queue import Queue
from typing import Union
-from esm.core.esports.moba.team import TeamSimulation
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
-from .general import EventCreator, MobaEvent
+from .general import MobaEvent
logger = logging.getLogger(__name__)
-class NexusEventEventCreator(EventCreator):
- def factory_method(
- self, event_chosen: dict, game_time: float, show_commentary: bool, queue: Queue
- ):
- return NexusEvent(
- event_name=event_chosen["name"],
- priority=event_chosen["priority"],
- points=event_chosen["points"],
- event_time=game_time,
- show_commentary=show_commentary,
- queue=queue,
- )
-
-
class NexusEvent(MobaEvent):
def calculate_event(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
- which_nexus: Union[TeamSimulation, None],
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
+ which_nexus: Union[MobaTeamSimulation, None],
):
if which_nexus is not None:
if which_nexus == team1:
diff --git a/esm/core/esports/moba/simulation/events/tower.py b/esm/core/esports/moba/simulation/events/tower.py
index f9a5914..5ad6612 100644
--- a/esm/core/esports/moba/simulation/events/tower.py
+++ b/esm/core/esports/moba/simulation/events/tower.py
@@ -18,29 +18,17 @@
from queue import Queue
from typing import Union
-from esm.core.esports.moba.team import TeamSimulation
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
-from .general import EventCreator, MobaEvent
+from .general import MobaEvent
logger = logging.getLogger(__name__)
-class TowerEventEventCreator(EventCreator):
- def factory_method(
- self, event_chosen: dict, game_time: float, show_commentary: bool, queue: Queue
- ):
- return TowerEvent(
- event_name=event_chosen["name"],
- priority=event_chosen["priority"],
- points=event_chosen["points"],
- event_time=game_time,
- show_commentary=show_commentary,
- queue=queue,
- )
-
-
class TowerEvent(MobaEvent):
- def _get_tower_attributes(self, team1: TeamSimulation, team2: TeamSimulation):
+ def _get_tower_attributes(
+ self, team1: MobaTeamSimulation, team2: MobaTeamSimulation
+ ):
"""
Checks which towers are up, and if they can be attacked. If it is a Base tower,
there is a higher chance to focus on it
@@ -97,9 +85,9 @@ def _destroy_tower(self, prevailing, attack_team, def_team, lane):
def calculate_event(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
- which_nexus: Union[TeamSimulation, None],
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
+ which_nexus: Union[MobaTeamSimulation, None],
):
"""
This method calculates the tower assault outcome
diff --git a/esm/core/esports/moba/simulation/match_live.py b/esm/core/esports/moba/simulation/match_live.py
index 37e02de..8462a15 100644
--- a/esm/core/esports/moba/simulation/match_live.py
+++ b/esm/core/esports/moba/simulation/match_live.py
@@ -25,9 +25,9 @@
from esm.core.esports.moba.champion import Champion
from esm.core.esports.moba.mobamatch import MatchType, MobaMatch
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
from esm.core.esports.moba.simulation.mobaevent import MobaEventHandler
from esm.core.esports.moba.simulation.picksbans import PicksBans
-from esm.core.esports.moba.team import TeamSimulation
class MatchLive:
@@ -45,8 +45,8 @@ def __init__(
self,
game: MobaMatch,
champions: list[Champion],
- team1: TeamSimulation,
- team2: TeamSimulation,
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
show_commentary: bool = True,
match_speed: int = 1,
simulation_delay: bool = True,
@@ -125,6 +125,15 @@ def increment_game_time(self, quantity):
"""
self.game_time += quantity
+ def check_inhibitor_cooldown(self):
+ for team in self.teams:
+ for inhib, cooldown in team.inhibitors_cooldown.items():
+ if cooldown > 0.0:
+ team.inhibitors_cooldown[inhib] -= 0.5
+ if cooldown <= 0.0 and team.inhibitors[inhib] == 0:
+ team.inhibitors_cooldown[inhib] = 0.0
+ team.inhibitors_cooldown[inhib] = 1
+
def get_tower_number(self) -> int:
"""
Gets the amount of towers in the game. If neither team has any towers, the game stops trying to generate the
@@ -134,7 +143,7 @@ def get_tower_number(self) -> int:
def get_team_exposed_nexus(
self,
- ) -> Union[Tuple[TeamSimulation, TeamSimulation], TeamSimulation, None]:
+ ) -> Union[Tuple[MobaTeamSimulation, MobaTeamSimulation], MobaTeamSimulation, None]:
"""
Gets the exposed nexus from one or both of the teams.
"""
@@ -193,6 +202,7 @@ def _run_match(self):
self.event_handler.event.calculate_event(
self.game.team1, self.game.team2, self.get_team_exposed_nexus()
)
+ self.check_inhibitor_cooldown()
self.check_match_over()
if not self.is_match_over:
@@ -205,8 +215,8 @@ def _run_match(self):
class MatchSeries:
def __init__(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
championship_id: uuid.UUID,
champions: list[Champion],
match_type: MatchType,
diff --git a/esm/core/esports/moba/simulation/picksbans.py b/esm/core/esports/moba/simulation/picksbans.py
index 0465a62..f3fbea9 100644
--- a/esm/core/esports/moba/simulation/picksbans.py
+++ b/esm/core/esports/moba/simulation/picksbans.py
@@ -18,8 +18,8 @@
from esm.core.esports.moba.champion import Champion
from esm.core.esports.moba.generator import ChampionGenerator
+from esm.core.esports.moba.mobateam import MobaTeamSimulation
from esm.core.esports.moba.player import MobaPlayer
-from esm.core.esports.moba.team import TeamSimulation
class PicksBans:
@@ -29,8 +29,8 @@ class PicksBans:
def __init__(
self,
- team1: TeamSimulation,
- team2: TeamSimulation,
+ team1: MobaTeamSimulation,
+ team2: MobaTeamSimulation,
champion_list: list,
ban_per_team: int = 5,
difficulty_level: int = 1,
@@ -58,7 +58,7 @@ def pick(self, player: MobaPlayer, champion: Champion) -> None:
champion.status = "Picked"
self.picked_champions.append(champion)
- def ban(self, team: TeamSimulation, champion: Champion) -> None:
+ def ban(self, team: MobaTeamSimulation, champion: Champion) -> None:
team.bans = champion
champion.status = "Banned"
self.banned_champions.append(champion)
diff --git a/esm/core/new_game.py b/esm/core/new_game.py
deleted file mode 100644
index b54701e..0000000
--- a/esm/core/new_game.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# eSports Manager - free and open source eSports Management game
-# Copyright (C) 2020-2024 Pedrenrique G. Guimarães
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-from esm.core.esports.manager import Manager
-from esm.core.esports.moba.generator import (
- ChampionGenerator,
- MobaPlayerGenerator,
- TeamGenerator,
-)
-from esm.core.esports.moba.team import Team
-
-
-class CreateGameSession:
- def __init__(self):
- self.filename = None
- self.game_name = None
- self.manager_name = None
- self.date_of_birth = None
- self.season = None
- self.esport = None
- self.manager = None
- self.team = None
- self.teams = TeamGenerator()
- self.players = MobaPlayerGenerator()
- self.champions = ChampionGenerator()
-
- def get_names(
- self,
- filename: str,
- game_name: str,
- manager_name: str,
- date_of_birth: str,
- season: str,
- esport: str,
- ):
- self.filename = filename
- self.game_name = game_name
- self.manager_name = manager_name
- self.date_of_birth = date_of_birth
- self.season = season
- self.esport = esport
-
- def start_new_game(self):
- self.manager = Manager(
- self.manager_name, self.date_of_birth, self.team, True, 50
- )
-
- def generate_new_database(self):
- self.teams.generate_teams()
- self.players.generate_players()
- self.champions.generate_champions()
- self.write_files()
-
- def write_files(self):
- self.teams.generate_file()
- self.players.generate_file()
- self.champions.generate_file()
-
- def get_team(self, team: Team):
- self.team = team
diff --git a/esm/core/save_load/load_game.py b/esm/core/save_load/load_game.py
index de5bf6a..c9702ba 100644
--- a/esm/core/save_load/load_game.py
+++ b/esm/core/save_load/load_game.py
@@ -51,11 +51,8 @@ def load_game_file(self, filename: str):
Load data from the game file.
"""
filename = os.path.join(self.folder, filename)
- if self.check_game_file(filename):
- with open(filename, "rb") as fp:
- return cbor2.load(fp)
- else:
- raise LoadGameError("The save file is corrupted!")
+ with open(filename, "rb") as fp:
+ return cbor2.load(fp)
@staticmethod
def __check_key_integrity(data: dict):
diff --git a/esm/core/settings.py b/esm/core/settings.py
index a8b348e..d75a2db 100644
--- a/esm/core/settings.py
+++ b/esm/core/settings.py
@@ -26,7 +26,6 @@
@dataclass
class Settings:
font_scale: int = 1
- amount_players: int = 50
enable_auto_save = True
root_dir: Union[str, Path] = ROOT_DIR
res_dir: Union[str, Path] = RES_DIR
@@ -46,7 +45,6 @@ def load_config_file(self):
def parse_config_file(self, data):
self.font_scale = data["font_scale"]
- self.amount_players = data["amount_players"]
self.enable_auto_save = data["enable_auto_save"]
self.root_dir = data["root_dir"]
self.res_dir = data["res_dir"]
@@ -59,7 +57,6 @@ def parse_config_file(self, data):
def get_data(self):
return {
"font_scale": self.font_scale,
- "amount_players": self.amount_players,
"root_dir": str(self.root_dir),
"enable_auto_save": str(self.enable_auto_save),
"res_dir": str(self.res_dir),
diff --git a/esm/esm.py b/esm/esm.py
index 018d60b..a85c9b2 100644
--- a/esm/esm.py
+++ b/esm/esm.py
@@ -33,14 +33,6 @@ def __init__(self):
self.view = GUIController(self.core)
- @property
- def amount_players(self):
- return self.core.amount_players
-
- @amount_players.setter
- def amount_players(self, value):
- self.core.amount_players = value
-
@property
def settings(self):
return self.core.settings
diff --git a/esm/res/db/moba/definitions/championships/regions/lcs/lcs.json b/esm/res/db/moba/definitions/championships/regions/lcs/lcs.json
index ca95964..bfddbb9 100644
--- a/esm/res/db/moba/definitions/championships/regions/lcs/lcs.json
+++ b/esm/res/db/moba/definitions/championships/regions/lcs/lcs.json
@@ -1,50 +1,34 @@
[
{
- "name": "100 Thieves",
- "nationality": "United States",
- "mu": 78,
- "sigma": 12
+ "id": "lcs_1",
+ "name": "League Championship Series Spring Split",
+ "short_name": "LCS Spring Split",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lcs_playoffs_1"
},
{
- "name": "FlyQuest",
- "nationality": "United States",
- "mu": 81,
- "sigma": 5
+ "id": "lcs_playoffs_1",
+ "name":"League Championship Series Spring Split Play-offs",
+ "short_name": "LCS Spring Split Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "msi_play_in"
},
{
- "name": "Cloud9",
- "nationality": "United States",
- "mu": 82,
- "sigma": 15
+ "id": "lcs_2",
+ "name": "League Championship Series Summer Split",
+ "short_name": "LCS Summer Split",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lcs_playoffs_2"
},
{
- "name": "Dignitas",
- "nationality": "United States",
- "mu": 79,
- "sigma": 20
- },
- {
- "name": "Team Liquid",
- "nationality": "United States",
- "mu": 75,
- "sigma": 13
- },
- {
- "name": "NRG",
- "nationality": "United States",
- "mu": 74,
- "sigma": 15
- },
- {
- "name": "Shopify Rebellion",
- "nationality": "United States",
- "mu": 75,
- "sigma": 19
- },
- {
- "name": "Immortals",
- "nationality": "United States",
- "mu": 73,
- "sigma": 12
+ "id": "lcs_playoffs_2",
+ "name":"League Championship Series Summer Split Play-offs",
+ "short_name": "LCS Summer Split Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "worlds_play_in"
}
]
\ No newline at end of file
diff --git a/esm/res/db/moba/definitions/championships/regions/lec/lec.json b/esm/res/db/moba/definitions/championships/regions/lec/lec.json
index f40845c..37e9163 100644
--- a/esm/res/db/moba/definitions/championships/regions/lec/lec.json
+++ b/esm/res/db/moba/definitions/championships/regions/lec/lec.json
@@ -1,62 +1,34 @@
[
{
- "name": "G2 Esports",
- "nationality": "Spain",
- "mu": 84,
- "sigma": 12
- },
- {
- "name": "Team BDS",
- "nationality": "Switzerland",
- "mu": 82,
- "sigma": 10
- },
- {
- "name": "SK Gaming",
- "nationality": "Germany",
- "mu": 80,
- "sigma": 12
- },
- {
- "name": "MAD Lions",
- "nationality": "Spain",
- "mu": 78,
- "sigma": 8
- },
- {
- "name": "Fnatic",
- "nationality": "United Kingdom",
- "mu": 75,
- "sigma": 5
- },
- {
- "name": "Team Vitality",
- "nationality": "France",
- "mu": 79,
- "sigma": 10
- },
- {
- "name": "Team Heretics",
- "nationality": "Spain",
- "mu": 75,
- "sigma": 10
- },
- {
- "name": "GIANTX",
- "nationality": "United Kingdom",
- "mu": 74,
- "sigma": 7
- },
- {
- "name": "Rogue",
- "nationality": "United States",
- "mu": 78,
- "sigma": 10
- },
- {
- "name": "Karmine Corp",
- "nationality": "France",
- "mu": 72,
- "sigma": 12
+ "id": "lec_1",
+ "name": "League of Legends EMEA Championship Spring Split",
+ "short_name": "LEC Spring Split",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lec_playoffs_1"
+ },
+ {
+ "id": "lec_playoffs_1",
+ "name":"League of Legends EMEA Championship Spring Split Play-offs",
+ "short_name": "LEC Spring Split Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "msi_play_in"
+ },
+ {
+ "id": "lec_2",
+ "name": "League of Legends EMEA Championship Summer Split",
+ "short_name": "LEC Summer Split",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lec_playoffs_2"
+ },
+ {
+ "id": "lec_playoffs_2",
+ "name":"League of Legends EMEA Championship Summer Split Play-offs",
+ "short_name": "LEC Summer Split Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "worlds_play_in"
}
]
\ No newline at end of file
diff --git a/esm/res/db/moba/definitions/championships/regions/lla/lla.json b/esm/res/db/moba/definitions/championships/regions/lla/lla.json
index e69de29..d3ee9d1 100644
--- a/esm/res/db/moba/definitions/championships/regions/lla/lla.json
+++ b/esm/res/db/moba/definitions/championships/regions/lla/lla.json
@@ -0,0 +1,34 @@
+[
+ {
+ "id": "lla_1",
+ "name": "Liga Latinoamérica Opening Season",
+ "short_name": "LLA Opening Season",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lla_playoffs_1"
+ },
+ {
+ "id": "lla_playoffs_1",
+ "name":"Liga Latinoamérica Opening Season Play-offs",
+ "short_name": "LLA Opening Season Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "msi_play_in"
+ },
+ {
+ "id": "lla_2",
+ "name": "Liga Latinoamérica Closing Season",
+ "short_name": "LLA Closing Season",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lla_playoffs_2"
+ },
+ {
+ "id": "lla_playoffs_2",
+ "name":"Liga Latinoamérica Closing Season Play-offs",
+ "short_name": "LLA Closing Season Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "worlds_play_in"
+ }
+]
\ No newline at end of file
diff --git a/esm/res/db/moba/definitions/championships/regions/lpl/lpl.json b/esm/res/db/moba/definitions/championships/regions/lpl/lpl.json
index 7f6e458..ffff087 100644
--- a/esm/res/db/moba/definitions/championships/regions/lpl/lpl.json
+++ b/esm/res/db/moba/definitions/championships/regions/lpl/lpl.json
@@ -1,104 +1,34 @@
[
{
- "name": "Bilibili Gaming",
- "nationality": "China",
- "mu": 94,
- "sigma": 10
- },
- {
- "name": "JD Gaming",
- "nationality": "China",
- "mu": 92,
- "sigma": 10
- },
- {
- "name": "Top Esports",
- "nationality": "China",
- "mu": 90,
- "sigma": 5
- },
- {
- "name": "FunPlus Phoenix",
- "nationality": "China",
- "mu": 89,
- "sigma": 12
- },
- {
- "name": "Ninjas in Pyjamas",
- "nationality": "China",
- "mu": 85,
- "sigma": 13
- },
- {
- "name": "Invictus Gaming",
- "nationality": "China",
- "mu": 84,
- "sigma": 15
- },
- {
- "name": "Team WE",
- "nationality": "China",
- "mu": 83,
- "sigma": 10
- },
- {
- "name": "Oh My God",
- "nationality": "China",
- "mu": 82,
- "sigma": 12
- },
- {
- "name": "Anyone's Legend",
- "nationality": "China",
- "mu": 80,
- "sigma": 17
- },
- {
- "name": "LNG Esports",
- "nationality": "China",
- "mu": 89,
- "sigma": 16
- },
- {
- "name": "Weibo Gaming",
- "nationality": "China",
- "mu": 82,
- "sigma": 5
- },
- {
- "name": "ThunderTalk Gaming",
- "nationality": "China",
- "mu": 83,
- "sigma": 10
- },
- {
- "name": "Rare Atom Gaming",
- "nationality": "China",
- "mu": 86,
- "sigma": 10
- },
- {
- "name": "LGD Gaming",
- "nationality": "China",
- "mu": 88,
- "sigma": 10
- },
- {
- "name": "Royal Never Give Up",
- "nationality": "China",
- "mu": 80,
- "sigma": 10
- },
- {
- "name": "EDward Gaming",
- "nationality": "China",
- "mu": 78,
- "sigma": 10
- },
- {
- "name": "Ultra Prime",
- "nationality": "China",
- "mu": 75,
- "sigma": 10
+ "id": "lpl_1",
+ "name": "League of Legends Pro League Spring Split",
+ "short_name": "LPL Spring Split",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lpl_playoffs_1"
+ },
+ {
+ "id": "lpl_playoffs_1",
+ "name":"League of Legends Pro League Spring Split Play-offs",
+ "short_name": "LPL Spring Split Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "msi_play_in"
+ },
+ {
+ "id": "lpl_2",
+ "name": "League of Legends Pro League Summer Split",
+ "short_name": "LPL Summer Split",
+ "type": "regional_league",
+ "format": "round-robin",
+ "qualifies_to": "lpl_playoffs_2"
+ },
+ {
+ "id": "lpl_playoffs_2",
+ "name":"League of Legends Pro League Summer Split Play-offs",
+ "short_name": "LPL Summer Split Play-offs",
+ "type": "regional_league",
+ "format": "playoffs-losers-bracket",
+ "qualifies_to": "worlds_play_in"
}
]
\ No newline at end of file
diff --git a/esm/res/db/moba/definitions/championships/worlds.json b/esm/res/db/moba/definitions/championships/worlds.json
index 556e691..5e4916f 100644
--- a/esm/res/db/moba/definitions/championships/worlds.json
+++ b/esm/res/db/moba/definitions/championships/worlds.json
@@ -18,5 +18,25 @@
"name": "Worlds Play-offs",
"type": "premier",
"format": "playoffs"
+ },
+ {
+ "id": "msi_play_in",
+ "name": "MSI Play-In Group Stage",
+ "type": "premier",
+ "format": "groups"
+ },
+ {
+ "id": "msi",
+ "name": "MSI Group Stage",
+ "type": "premier",
+ "format": "groups",
+ "qualifies_to": "msi_playoffs"
+ },
+ {
+ "id": "msi_playoffs",
+ "name": "MSI Play-offs",
+ "type": "premier",
+ "format": "playoffs",
+ "qualifies_to": "worlds_play_in"
}
]
\ No newline at end of file
diff --git a/esm/res/db/moba/definitions/teams/regions/lla/lla.json b/esm/res/db/moba/definitions/teams/regions/lla/lla.json
index e69de29..7156637 100644
--- a/esm/res/db/moba/definitions/teams/regions/lla/lla.json
+++ b/esm/res/db/moba/definitions/teams/regions/lla/lla.json
@@ -0,0 +1,44 @@
+[
+ {
+ "name": "Estral Esports",
+ "nationality": "Mexico",
+ "mu": 50,
+ "sigma": 15
+ },
+ {
+ "name": "Movistar R7",
+ "nationality": "Mexico",
+ "mu": 50,
+ "sigma": 10
+ },
+ {
+ "name": "Isurus",
+ "nationality": "Argentina",
+ "mu": 48,
+ "sigma": 20
+ },
+ {
+ "name": "Leviatan",
+ "nationality": "Argentina",
+ "mu": 47,
+ "sigma": 20
+ },
+ {
+ "name": "All Knights",
+ "nationality": "Chile",
+ "mu": 45,
+ "sigma": 10
+ },
+ {
+ "name": "Six Karma",
+ "nationality": "Mexico",
+ "mu": 45,
+ "sigma": 20
+ },
+ {
+ "name": "Infinity",
+ "nationality": "Costa Rica",
+ "mu": 45,
+ "sigma": 20
+ }
+]
\ No newline at end of file
diff --git a/esm/tests/test_generate_teams.py b/esm/tests/test_generate_teams.py
index cb29363..c7499db 100644
--- a/esm/tests/test_generate_teams.py
+++ b/esm/tests/test_generate_teams.py
@@ -25,8 +25,8 @@
TeamGenerator,
TeamGeneratorError,
)
+from ..core.esports.moba.mobateam import MobaTeam
from ..core.esports.moba.player import MobaPlayer
-from ..core.esports.moba.team import Team
def mock_team_definition() -> dict[str, int | str]:
@@ -75,7 +75,7 @@ def test_team_generator_champion_list_is_empty():
def test_generate_team(team_generator):
team_def = mock_team_definition()
team = team_generator.generate(team_definition=team_def)
- assert isinstance(team, Team)
+ assert isinstance(team, MobaTeam)
assert team.name == team_def["name"]
assert team.nationality == team_def["nationality"]
for player in team.roster:
@@ -85,7 +85,7 @@ def test_generate_team(team_generator):
def test_generate_multiple_teams(team_generator):
teams = [team_generator.generate(team_def) for team_def in mock_team_definitions()]
for team, team_def in zip(teams, mock_team_definitions()):
- assert isinstance(team, Team)
+ assert isinstance(team, MobaTeam)
assert team.name == team_def["name"]
assert team.nationality == team_def["nationality"]
assert team.roster is not None
diff --git a/esm/ui/controllers/debug_championship_cont.py b/esm/ui/controllers/debug_championship_cont.py
index fa2ddc3..9725f33 100644
--- a/esm/ui/controllers/debug_championship_cont.py
+++ b/esm/ui/controllers/debug_championship_cont.py
@@ -15,9 +15,11 @@
# along with this program. If not, see .
import threading
import uuid
+from typing import Optional
from esm.core.esmcore import ESMCore
from esm.core.esports.moba.championship import Championship
+from esm.core.esports.moba.mobateam import MobaTeam
from esm.ui.igamecontroller import IGameController
from esm.ui.layouts.debug_championship import DebugChampionshipLayout
@@ -30,7 +32,7 @@ def __init__(self, controller: IGameController, core: ESMCore):
self.controller = controller
self.layout = DebugChampionshipLayout()
self.championship = None
- self.teams = None
+ self.teams: Optional[list[MobaTeam]] = None
self.match_details = []
self.championship_details = []
self.championship_thread = None
@@ -61,14 +63,14 @@ def get_default_championship_details(self):
def get_default_match_details(self):
self.match_details = [
- [match.game.team1.name, match.game.team2.name, "None"]
+ [match.team1.team.name, match.team2.team.name, "None"]
for match in self.championship.matches
]
def assign_win_and_loss_in_championship_table(self, match):
for detail in self.championship_details:
- if detail[0] in [match.game.team1.name, match.game.team2.name]:
- if detail[0] == match.game.victorious_team.name:
+ if detail[0] in [match.team1.team.name, match.team2.team.name]:
+ if detail[0] == match.victorious_team.name:
detail[2] += 1
detail[4] += 3
else:
@@ -77,8 +79,8 @@ def assign_win_and_loss_in_championship_table(self, match):
def get_winning_team(self, live_match):
for detail in self.match_details:
if (
- live_match.game.team1.name == detail[0]
- and live_match.game.team2.name == detail[1]
+ live_match.team1.name == detail[0]
+ and live_match.team2.name == detail[1]
):
if live_match.victorious_team.name == detail[0]:
detail[2] = detail[0]
diff --git a/esm/ui/controllers/game/game_dashboard_cont.py b/esm/ui/controllers/game/game_dashboard_cont.py
index 6972278..bd14e6e 100644
--- a/esm/ui/controllers/game/game_dashboard_cont.py
+++ b/esm/ui/controllers/game/game_dashboard_cont.py
@@ -17,7 +17,7 @@
from typing import Optional
from esm.core.esmcore import ESMCore
-from esm.core.esports.moba.team import Team
+from esm.core.esports.moba.mobateam import MobaTeam
from esm.ui.controllers.controllerinterface import IController
from esm.ui.igamecontroller import IGameController
from esm.ui.layouts.game.game_dashboard import GameDashboardLayout
@@ -28,7 +28,7 @@ def __init__(self, controller: IGameController, core: ESMCore):
self.controller = controller
self.core = core
self.layout = GameDashboardLayout()
- self.team_name: Optional[Team] = None
+ self.team_name: Optional[MobaTeam] = None
# TODO: rewrite this class
def update(self, event, values, make_screen):
diff --git a/esm/ui/controllers/settings_cont.py b/esm/ui/controllers/settings_cont.py
index 13f2504..e9d432a 100644
--- a/esm/ui/controllers/settings_cont.py
+++ b/esm/ui/controllers/settings_cont.py
@@ -46,9 +46,6 @@ def update_inputs(self):
self.controller.update_element_on_screen(
"settings_fontsize_input", value=self.core.settings.font_scale
)
- self.controller.update_element_on_screen(
- "settings_amount_input", value=self.core.settings.amount_players
- )
self.controller.update_element_on_screen(
"settings_enable_autosave", value=self.core.settings.enable_auto_save
)
@@ -130,16 +127,5 @@ def update(self, event, values, make_screen):
self.update_inputs()
elif event == "settings_generate_btn":
- try:
- value = int(values["settings_amount_input"])
- self.core.check_player_amount()
- except ValueError as e:
- self.controller.get_gui_information_window(
- e, "Error in number of players!"
- )
- self.amount_players = 50
- else:
- self.controller.amount_players = value
- finally:
- self.core.db.generate_moba_files()
- self.update_inputs()
+ self.core.db.generate_moba_files()
+ self.update_inputs()
diff --git a/esm/ui/layouts/settings.py b/esm/ui/layouts/settings.py
index 48c2a29..aff52cd 100644
--- a/esm/ui/layouts/settings.py
+++ b/esm/ui/layouts/settings.py
@@ -42,7 +42,6 @@ def layout(self) -> list:
labels_inputs = [
[esm_form_text("Language:", pad=label_pad)],
[esm_form_text("Font scale:", pad=label_pad)],
- [esm_form_text("Amount of players to generate:", pad=label_pad)],
]
labels_files = [
@@ -70,14 +69,6 @@ def layout(self) -> list:
"1", size=size_elements, key="settings_fontsize_input", pad=(3, 5)
)
],
- [
- esm_input_text("50", key="settings_amount_input", size=size_elements),
- esm_button(
- "Generate",
- font=(default_font, default_font_size),
- key="settings_generate_btn",
- ),
- ],
[
esm_checkbox(
"Enable autosave: ", default=True, key="settings_enable_autosave"