From 13736cdccdf7025658d16e70d2bb0c6c81c299ce Mon Sep 17 00:00:00 2001 From: Derek Jamison Date: Fri, 24 Mar 2023 09:12:37 -0400 Subject: [PATCH] Relaxed timing. Update readme. --- subghz/plugins/rock_paper_scissors/README.md | 9 ++++- .../rock_paper_scissors/rock_paper_scissors.c | 37 +++---------------- .../rock_paper_scissors/rock_paper_scissors.h | 5 --- 3 files changed, 13 insertions(+), 38 deletions(-) diff --git a/subghz/plugins/rock_paper_scissors/README.md b/subghz/plugins/rock_paper_scissors/README.md index b4a2627..38d687a 100644 --- a/subghz/plugins/rock_paper_scissors/README.md +++ b/subghz/plugins/rock_paper_scissors/README.md @@ -22,16 +22,21 @@ Completed work: - Allow viewing past games/scores. - A join ACK removes it from the list of available games. - Config - Allow changing hard-coded CONTACT_INFO message. +- Config - Allow saving CONTACT_INFO message. +- Relaxed timing, so Count 1/Count 2/RPS no longer have to be timed tightly. +- Play again screen. Remaining work (for subghz version): -- Config - Allow saving CONTACT_INFO message. +- Play again from one Flipper Zero auto-starts/exit other Flipper Zero. +- Wrap user content to two lines on Past Games screen. +- Allow for replacement keyboard. - Refactor the code, so it has less duplication. - Write tutorial. -- Add game ending animations. Future ideas: +- Add game ending animations. - Create stand-alone hardware badges that can play the game too. - Uses Princeton signals for second player. - Instead of subghz, use IR. diff --git a/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c b/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c index 121fc06..34f2096 100644 --- a/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c +++ b/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c @@ -51,11 +51,6 @@ static bool isFinalMove(GameState state) { return (StateRock == state) || (StatePaper == state) || (StateScissors == state); } -static bool isError(GameState state) { - return (StateError == state) || (StateErrorLocalFast == state) || - (StateErrorRemoteFast == state) || (StateErrorRemoteTimeout == state); -} - // When user makes a move, we briefly pulse the vibro motor. static void single_vibro() { NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); @@ -649,23 +644,15 @@ static void rps_render_error(Canvas* canvas, void* ctx) { GameData* data = game_context->data; GameState local_player = data->local_player; - canvas_set_font(canvas, FontSecondary); + canvas_set_font(canvas, FontPrimary); switch(local_player) { - case StateError: - canvas_draw_str_aligned(canvas, 5, 55, AlignLeft, AlignTop, "Unknown error"); - break; - - case StateErrorLocalFast: - canvas_draw_str_aligned(canvas, 5, 55, AlignLeft, AlignTop, "Too fast!"); - break; - - case StateErrorRemoteFast: - canvas_draw_str_aligned(canvas, 5, 55, AlignLeft, AlignTop, "Remote too fast!"); - break; - case StateErrorRemoteTimeout: - canvas_draw_str_aligned(canvas, 5, 55, AlignLeft, AlignTop, "Remote timeout."); + canvas_draw_str_aligned(canvas, 15, 5, AlignLeft, AlignTop, "Remote timeout."); + + canvas_set_font(canvas, FontSecondary); + canvas_draw_str_aligned(canvas, 5, 20, AlignLeft, AlignTop, "It appears the remote"); + canvas_draw_str_aligned(canvas, 5, 30, AlignLeft, AlignTop, "user has left the game?"); break; default: @@ -673,8 +660,6 @@ static void rps_render_error(Canvas* canvas, void* ctx) { break; } - canvas_draw_str_aligned(canvas, 120, 55, AlignLeft, AlignTop, "E"); - furi_mutex_release(game_context->mutex); } @@ -1111,16 +1096,6 @@ static void rps_state_machine_update(GameContext* game_context) { return; } - // TEMP - After Error, we reset back to Looking for player. - if(isError(d->local_player) && (duration(d->local_move_tick) > DURATION_SHOW_ERROR)) { - d->local_player = StateMainMenuHost; - d->remote_player = StateUnknown; - d->screen_state = ScreenMainMenu; - - FURI_LOG_I(TAG, "Reset from Error."); - return; - } - // Check for winner. if(isFinalMove(d->local_player) && isFinalMove(d->remote_player) && (duration(d->local_move_tick) > DURATION_SHOW_MOVES)) { diff --git a/subghz/plugins/rock_paper_scissors/rock_paper_scissors.h b/subghz/plugins/rock_paper_scissors/rock_paper_scissors.h index 8f389e4..e6b92ff 100644 --- a/subghz/plugins/rock_paper_scissors/rock_paper_scissors.h +++ b/subghz/plugins/rock_paper_scissors/rock_paper_scissors.h @@ -141,10 +141,7 @@ typedef enum { StateWonPaper = 'w', StateWonScissors = '+', // ScreenError states: - StateError = 'E', StateErrorRemoteTimeout = '7', // Joined but didn't make any moves. - StateErrorRemoteFast = '8', // Remote user sent moves after than local user. - StateErrorLocalFast = '9', // Local user sent moves after than remote user. // ScrenMainMenu states: StateUnknown = '?', StateMainMenuHost, @@ -316,8 +313,6 @@ static bool isResult(GameState state); // @returns true if game state is a rock, paper, scissors. static bool isFinalMove(GameState state); -static bool isError(GameState state); - // When user makes a move, we briefly pulse the vibro motor. static void single_vibro();