Skip to content

feat: Two-player Mastermind game - #57

Merged
ap0ught merged 7 commits into
mainfrom
feat/two-player-mastermind
Aug 8, 2026
Merged

feat: Two-player Mastermind game#57
ap0ught merged 7 commits into
mainfrom
feat/two-player-mastermind

Conversation

@ap0ught

@ap0ught ap0ught commented Aug 8, 2026

Copy link
Copy Markdown
Member

Adds two-player Mastermind code-breaking game for linked CYDs with synchronized game transitions and round persistence.

Copilot AI lite review requested due to automatic review settings August 8, 2026 18:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a synchronized two-player Mastermind game mode alongside the existing Greek Slide puzzle, including new protocol message types, shared epoch-based game selection, and UI/rendering paths for Mastermind on linked CYD devices.

Changes:

  • Introduces Mastermind core state machine + validation/transition helpers and corresponding CI test coverage.
  • Extends the ESP-NOW protocol with Mastermind state/full-state/ack/request packets and integrates Mastermind UI + game flow into src/main.cpp.
  • Updates home screen UX and README to reflect a multi-game collection and the security/recovery model.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/mastermind_logic_test.cpp Adds deterministic assertion-based coverage for Mastermind logic, transitions, and game selection clock helpers.
src/main.cpp Implements Mastermind UI, input handling, state synchronization, epoch-based active-game arbitration, and protocol handling.
README.md Updates project positioning to “two-player games”, documents Mastermind rules and security/recovery expectations.
include/protocol.h Bumps protocol version and adds Mastermind wire packet definitions + size assertions.
include/mastermind_logic.h Adds Mastermind state model, validation, transition rules, digesting, and reconciliation helpers.
include/game_selection.h Adds shared “active game clock” helpers to arbitrate between concurrent game epochs.
.github/workflows/build.yml Extends CI to compile/run Mastermind logic tests in addition to puzzle tests.
Suppressed comments (1)

src/main.cpp:1206

  • protocolMutex guards other protocol send paths, but the Mastermind state-request send is unguarded. If the mutex is required to serialize ESP-NOW access with the receive callback and other sends, this path should take it too for consistency.
void sendMastermindStateRequest() {
    uint32_t gameId = 0;
    uint32_t revision = 0;
    uint32_t digest = 0;
    portENTER_CRITICAL(&gameMux);
    if (mastermindStateReady) {
        gameId = mastermindState.gameId;
        revision = mastermindState.revision;
        digest = mastermindStateDigest(mastermindState);
    }
    portEXIT_CRITICAL(&gameMux);
    MastermindStateRequestPacket packet{
        makeHeader(MessageType::MastermindRequestState), gameId, revision,
        digest};
    esp_now_send(expectedPeerAddress, reinterpret_cast<uint8_t*>(&packet),
                 sizeof(packet));

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main.cpp Outdated
bool touchWasDown = false;
bool lastOnline = false;
uint8_t selectedPeg = 0;
MastermindPhase lastAdoptedMastermindPhase = MastermindPhase::Exited;
Comment thread src/main.cpp
Comment thread src/main.cpp
Comment on lines +1179 to +1189
void sendMastermindAck(const MastermindPendingAck& ack) {
GameAckPacket packet{makeHeader(MessageType::MastermindAck),
ack.targetBoardId,
ack.gameId,
ack.revision,
ack.stateDigest,
ack.acknowledgedType,
{0, 0, 0}};
esp_now_send(expectedPeerAddress, reinterpret_cast<uint8_t*>(&packet),
sizeof(packet));
}
@ap0ught
ap0ught merged commit ecfd951 into main Aug 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants