Add PlayerData TypedDict to fix type errors
This commit is contained in:
parent
565690cef2
commit
4f9999efa5
2 changed files with 16 additions and 2 deletions
|
|
@ -21,6 +21,7 @@ from mudlib.content import load_commands
|
|||
from mudlib.effects import clear_expired
|
||||
from mudlib.player import Player, players
|
||||
from mudlib.store import (
|
||||
PlayerData,
|
||||
account_exists,
|
||||
authenticate,
|
||||
create_account,
|
||||
|
|
@ -229,7 +230,7 @@ async def shell(
|
|||
update_last_login(player_name)
|
||||
|
||||
# Load player data from database or use defaults for new player
|
||||
player_data = login_result["player_data"]
|
||||
player_data: PlayerData | None = login_result["player_data"]
|
||||
if player_data is None:
|
||||
# New player - find a passable starting position
|
||||
center_x = _world.width // 2
|
||||
|
|
|
|||
|
|
@ -5,9 +5,22 @@ import hmac
|
|||
import os
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
from typing import TypedDict
|
||||
|
||||
from mudlib.player import Player
|
||||
|
||||
|
||||
class PlayerData(TypedDict):
|
||||
"""Shape of persisted player data from the database."""
|
||||
|
||||
x: int
|
||||
y: int
|
||||
pl: float
|
||||
stamina: float
|
||||
max_stamina: float
|
||||
flying: bool
|
||||
|
||||
|
||||
# Module-level database path
|
||||
_db_path: str | None = None
|
||||
|
||||
|
|
@ -188,7 +201,7 @@ def save_player(player: Player) -> None:
|
|||
conn.close()
|
||||
|
||||
|
||||
def load_player_data(name: str) -> dict | None:
|
||||
def load_player_data(name: str) -> PlayerData | None:
|
||||
"""Load player data from the database.
|
||||
|
||||
Args:
|
||||
|
|
|
|||
Loading…
Reference in a new issue