• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FlysonBot / Mastermind / 23087608066

14 Mar 2026 12:02PM UTC coverage: 86.288%. First build
23087608066

push

github

web-flow
feat: release v2.2.0

feat: release v2.2.0

    variable game parameters (c and d)
    assisted mode undo support and solution elimination %
    hide code input when player sets code
    Python test suite for all gamemodes
    CI coverage workflow for Python and Java
    fix non-standard Maven test directory name

465 of 494 new or added lines in 9 files covered. (94.13%)

623 of 722 relevant lines covered (86.29%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

17.65
/src/main/python/mastermind/ui/prompts.py
1
import random
1✔
2

3
from mastermind.ui.console import console
1✔
4
from mastermind.ui.convert_code import parse_code
1✔
5
from rich.prompt import IntPrompt, Prompt
1✔
6

7

8
def ask_game_settings() -> tuple[int, int, int]:
1✔
9
    """Ask for colors, digits, and max tries. Returns (c, d, max_tries)."""
10

NEW
11
    while True:
×
NEW
12
        c = IntPrompt.ask("  Colors (1–9)", default=6, console=console)
×
NEW
13
        if 1 <= c <= 9:
×
NEW
14
            break
×
NEW
15
        console.print("  [red]! Must be between 1 and 9.[/red]")
×
16

NEW
17
    while True:
×
NEW
18
        d = IntPrompt.ask("  Digits (1–9)", default=4, console=console)
×
NEW
19
        if 1 <= d <= 9:
×
NEW
20
            break
×
NEW
21
        console.print("  [red]! Must be between 1 and 9.[/red]")
×
22

NEW
23
    while True:
×
NEW
24
        max_tries = IntPrompt.ask("  Max tries", default=10, console=console)
×
NEW
25
        if max_tries >= 1:
×
NEW
26
            break
×
NEW
27
        console.print("  [red]! Must be at least 1.[/red]")
×
28

NEW
29
    return c, d, max_tries
×
30

31

32
def ask_secret(c: int, d: int, human_follow_up: str, computer_follow_up: str) -> int:
1✔
33
    """
34
    Ask who sets the secret code and return the secret index.
35

36
    human_follow_up    — message printed after the human enters a valid code
37
    computer_follow_up — message printed after the computer picks a code
38
    """
NEW
39
    choice = Prompt.ask(
×
40
        "Who sets the secret code?\n  [bold]1)[/bold] Computer\n  [bold]2)[/bold] Human\n",
41
        choices=["1", "2"],
42
        show_choices=False,
43
        default="1",
44
        console=console,
45
    )
46

NEW
47
    if choice == "2":
×
NEW
48
        while True:
×
NEW
49
            raw = Prompt.ask(
×
50
                f"Enter your secret code ([cyan]{d} digits, each 1–{c}[/cyan], hidden)",
51
                password=True,
52
                console=console,
53
            )
NEW
54
            secret_ind = parse_code(raw, c, d)
×
NEW
55
            if secret_ind is not None:
×
NEW
56
                break
×
NEW
57
            console.print(
×
58
                f"  [red]! Invalid. Use exactly {d} digits, each between 1 and {c}.[/red]"
59
            )
NEW
60
        console.print(human_follow_up)
×
61
    else:
NEW
62
        secret_ind = random.randrange(c**d)
×
NEW
63
        console.print(computer_follow_up)
×
64

NEW
65
    return secret_ind
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc