feat: Two-player Mastermind game - #57
Merged
Merged
Conversation
There was a problem hiding this comment.
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
protocolMutexguards 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.
| bool touchWasDown = false; | ||
| bool lastOnline = false; | ||
| uint8_t selectedPeg = 0; | ||
| MastermindPhase lastAdoptedMastermindPhase = MastermindPhase::Exited; |
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)); | ||
| } |
…lastAdoptedMastermindPhase, add protocolMutex to sendMastermindStateRequest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds two-player Mastermind code-breaking game for linked CYDs with synchronized game transitions and round persistence.