Spaces:
Sleeping
Sleeping
| """Fixtures for L3 Feature layer tests.""" | |
| from __future__ import annotations | |
| import sys | |
| from pathlib import Path | |
| import pytest | |
| _PROJECT_ROOT = Path(__file__).resolve().parent.parent.parent | |
| sys.path.insert(0, str(_PROJECT_ROOT)) | |
| from werewolftown.config import StrategyConfig | |
| from werewolftown.state.game_state import GameState, PendingLedger, PlayerView | |
| def cfg() -> StrategyConfig: | |
| """Load the dev config for testing.""" | |
| return StrategyConfig.load("dev") | |
| def make_state(): | |
| """Construct a GameState with common defaults.""" | |
| def _make( | |
| player_id: str = "子涵", | |
| round: int = 1, | |
| cash: int = 50000, | |
| initial_cash: int = 50000, | |
| plots: frozenset[int] | None = None, | |
| shops: tuple[str, ...] | None = None, | |
| built_on: dict[int, str] | None = None, | |
| other_players: dict[str, PlayerView] | None = None, | |
| pending: PendingLedger | None = None, | |
| ) -> GameState: | |
| return GameState( | |
| player_id=player_id, | |
| round=round, | |
| cash=cash, | |
| initial_cash=initial_cash, | |
| plots=plots or frozenset(), | |
| shops=shops or (), | |
| built_on=built_on or {}, | |
| other_players=other_players or {}, | |
| pending=pending or PendingLedger(), | |
| ) | |
| return _make | |
| # ── Game constants for test assertions ── | |
| # Plots 4,5,6 are adjacent in block A (row 1: 4,5,6) | |
| # Plots 7,8,9,10 are adjacent in block A (row 2: 7,8,9,10) | |
| # Plots 1,2,3 are adjacent in block A (row 0: 1,2,3 — but 0 is None) | |
| # So: 4 adj 5, 5 adj 4&6, 6 adj 5 | |
| # 7 adj 8, 8 adj 7&9, 9 adj 8&10, 10 adj 9 | |
| # 1 adj 2, 2 adj 1&3, 3 adj 2 | |
| # 4 adj 8 (vertically: row1col1=4, row2col1=8... wait no, 4 is at (1,1) and 8 is at (2,1)) | |
| # Let me verify: _GRID row 1 = [None, 4, 5, 6], row 2 = [7, 8, 9, 10] | |
| # So 4 is at col1, 8 is at col1 in next row → 4 adj 8 | |
| # 5 adj 9, 6 adj 10 | |
| # 7 adj 8 (horizontally), 8 adj 7&9 (horizontally) + 4 (vertically) | |