Set scopa targets to their traditional defaults
CI / Build and push docker image (push) Successful in 2m6s
CI / Build and push docker image (push) Successful in 2m6s
Partnership games go to 21: scopone scientifico (the tournament target) and scopa a quattro, while two-player scopa keeps its usual 11. The scopa package resolves the default from the player count and exposes a per variant options_schema default, so the lobby creation form shows the right value without frontend changes.
This commit is contained in:
13 files changed
+94
-30
No files matched your search
@@ -172,11 +172,20 @@ class DealTest(unittest.TestCase):
|
||||
def test_create_game_defaults(self) -> None:
|
||||
state = engine.create_game("p0", "p0")
|
||||
self.assertEqual(2, state.player_count)
|
||||
# Two-player scopa is traditionally played to 11 points.
|
||||
self.assertEqual(11, state.target_score)
|
||||
self.assertFalse(state.asso_pigliatutto)
|
||||
self.assertEqual("p0", state.players[0].sub)
|
||||
self.assertEqual("lobby", state.phase)
|
||||
|
||||
def test_create_game_four_player_default_target(self) -> None:
|
||||
# The four-player partnership game (like scopone) goes to 21.
|
||||
state = engine.create_game("p0", "p0", player_count=4)
|
||||
self.assertEqual(21, state.target_score)
|
||||
# An explicit target still wins over the default.
|
||||
explicit = engine.create_game("p0", "p0", player_count=4, target_score=16)
|
||||
self.assertEqual(16, explicit.target_score)
|
||||
|
||||
def test_create_game_player_count_validation(self) -> None:
|
||||
for bad in (1, 3, 5, 0):
|
||||
with self.assertRaises(IllegalMove):
|
||||
|
||||
@@ -21,8 +21,6 @@ from tavolo.scopa.state import (
|
||||
ScopaState,
|
||||
)
|
||||
|
||||
ENGINES = (ScopaEngine, ScopaQuattroEngine)
|
||||
|
||||
|
||||
def _session(engine, **options) -> GameSession:
|
||||
session = GameSession(
|
||||
@@ -66,14 +64,26 @@ def _drive_to_end(engine, session: GameSession) -> None:
|
||||
|
||||
class CreateTest(unittest.TestCase):
|
||||
def test_create_seats_creator_on_side_a(self) -> None:
|
||||
for engine_type in ENGINES:
|
||||
for engine_type, target in ((ScopaEngine, 11), (ScopaQuattroEngine, 21)):
|
||||
engine = engine_type()
|
||||
session = _session(engine)
|
||||
self.assertEqual("A", session.players[0].team)
|
||||
self.assertIsInstance(session.state, ScopaState)
|
||||
self.assertEqual(11, session.state.target_score)
|
||||
# Two-player scopa is played to 11, the partnership game to 21.
|
||||
self.assertEqual(target, session.state.target_score)
|
||||
self.assertFalse(session.state.asso_pigliatutto)
|
||||
|
||||
def test_schema_defaults_follow_the_variant(self) -> None:
|
||||
self.assertEqual(
|
||||
11, ScopaEngine().options_schema["properties"]["target_score"]["default"]
|
||||
)
|
||||
self.assertEqual(
|
||||
21,
|
||||
ScopaQuattroEngine().options_schema["properties"]["target_score"][
|
||||
"default"
|
||||
],
|
||||
)
|
||||
|
||||
def test_create_options(self) -> None:
|
||||
engine = ScopaEngine()
|
||||
session = _session(engine, target_score=21, asso_pigliatutto=True)
|
||||
|
||||
Reference in new issue
Block a user