add game configs

This commit is contained in:
bridge
2025-09-09 22:16:52 +08:00
parent 73bc62bec1
commit afddc466e0
5 changed files with 57 additions and 20 deletions

27
src/utils/df.py Normal file
View File

@@ -0,0 +1,27 @@
import pandas as pd
from pathlib import Path
from src.utils.config import CONFIG
def load_csv(path: Path) -> pd.DataFrame:
df = pd.read_csv(path)
row_types = {
"id": int,
"name": str,
"description": str,
"prompt": str,
}
for column, dtype in row_types.items():
if column in df.columns:
df[column] = df[column].astype(dtype)
return df
def load_game_configs() -> dict[str, pd.DataFrame]:
game_configs = {}
for path in CONFIG.paths.game_configs.glob("*.csv"):
df = load_csv(path)
game_configs[path.stem] = df
return game_configs
game_configs = load_game_configs()