-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
145 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Wrapper for service module to add types.""" | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import services | ||
from sims.sim_info_manager import SimInfoManager | ||
|
||
from .clientmanager import ClientManager | ||
|
||
if TYPE_CHECKING: | ||
import server | ||
|
||
|
||
def client_manager() -> ClientManager: | ||
"""Typed version of services.client_manager.""" | ||
manager: server.clientmanager.ClientManager = services.client_manager() | ||
|
||
return ClientManager(manager) | ||
|
||
|
||
def sim_info_manager() -> SimInfoManager: | ||
"""Typed version of services.sim_info_manager.""" | ||
return services.sim_info_manager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Wrapper for server.clientmanager.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import services | ||
|
||
if TYPE_CHECKING: | ||
from server import clientmanager | ||
from server.client import Client | ||
from typing_extensions import Self | ||
|
||
|
||
class ClientManager: | ||
"""Wrapper for server.clientmanager.""" | ||
|
||
inner: clientmanager.ClientManager | ||
|
||
def __init__(self: Self, inner: clientmanager.ClientManager) -> None: | ||
"""Create a new wrapper instance.""" | ||
self.inner = inner | ||
|
||
def get_client_by_household_id(self: Self, household_id: int) -> Client | None: | ||
"""Get a game client by household id.""" | ||
return self.inner.get_client_by_household_id(household_id) | ||
|
||
def get_active_client(self: Self) -> Client | None: | ||
"""Get the client of the active household.""" | ||
return self.get_client_by_household_id(services.active_household_id()) |