Do not require sync clicking.

This commit is contained in:
Derek Jamison 2023-03-23 17:10:59 -04:00
parent 1540853283
commit 2fa4067702

View File

@ -1200,52 +1200,20 @@ static bool rps_state_machine_local_moved(GameContext* game_context, Move move)
localMove = MoveCount1; localMove = MoveCount1;
localState = StateCount1; localState = StateCount1;
} else if(MoveCount == move && StateCount1 == game_context->data->local_player) { } else if(MoveCount == move && StateCount1 == game_context->data->local_player) {
if((StateCount1 == game_context->data->remote_player) || localMove = MoveCount2;
(StateCount2 == game_context->data->remote_player)) { localState = StateCount2;
localMove = MoveCount2;
localState = StateCount2;
} else {
localState = StateErrorLocalFast;
FURI_LOG_I(
TAG, "Local count sync error. remote is %c.", game_context->data->remote_player);
}
} else if(StateCount2 == game_context->data->local_player) { } else if(StateCount2 == game_context->data->local_player) {
if(MoveRock == move) { if(MoveRock == move) {
if((StateCount2 == game_context->data->remote_player) || localMove = MoveRock;
isFinalMove(game_context->data->remote_player)) { localState = StateRock;
localMove = MoveRock;
localState = StateRock;
} else {
localState = StateErrorLocalFast;
FURI_LOG_I(
TAG,
"Local rock sync error. remote is %c.",
game_context->data->remote_player);
}
} else if(MovePaper == move) { } else if(MovePaper == move) {
if((StateCount2 == game_context->data->remote_player) || localMove = MovePaper;
isFinalMove(game_context->data->remote_player)) { localState = StatePaper;
localMove = MovePaper;
localState = StatePaper;
} else {
localState = StateErrorLocalFast;
FURI_LOG_I(
TAG,
"Local paper sync error. remote is %c.",
game_context->data->remote_player);
}
} else if(MoveScissors == move) { } else if(MoveScissors == move) {
if((StateCount2 == game_context->data->remote_player) || localMove = MoveScissors;
isFinalMove(game_context->data->remote_player)) { localState = StateScissors;
localMove = MoveScissors; } else if(MoveCount == move) {
localState = StateScissors; // Ignore. We are already at count #2.
} else {
localState = StateErrorLocalFast;
FURI_LOG_I(
TAG,
"Local scissors sync error. remote is %c.",
game_context->data->remote_player);
}
} else { } else {
FURI_LOG_E( FURI_LOG_E(
TAG, TAG,
@ -1271,9 +1239,6 @@ static bool rps_state_machine_local_moved(GameContext* game_context, Move move)
if(StateReady != localState) { if(StateReady != localState) {
game_context->data->local_player = localState; game_context->data->local_player = localState;
game_context->data->local_move_tick = furi_get_tick(); game_context->data->local_move_tick = furi_get_tick();
if(isError(localState)) {
game_context->data->screen_state = ScreenError;
}
} }
return StateReady != localState; return StateReady != localState;
@ -1289,41 +1254,13 @@ static bool rps_state_machine_remote_moved(GameContext* game_context, Move move)
if(MoveCount1 == move && StateReady == game_context->data->remote_player) { if(MoveCount1 == move && StateReady == game_context->data->remote_player) {
remoteState = StateCount1; remoteState = StateCount1;
} else if(MoveCount2 == move && StateCount1 == game_context->data->remote_player) { } else if(MoveCount2 == move && StateCount1 == game_context->data->remote_player) {
if((StateCount1 == game_context->data->local_player) || remoteState = StateCount2;
(StateCount2 == game_context->data->local_player)) {
remoteState = StateCount2;
} else {
remoteState = StateErrorRemoteFast;
FURI_LOG_I(
TAG, "Remote count sync error. local is %c.", game_context->data->local_player);
}
} else if(MoveRock == move && StateCount2 == game_context->data->remote_player) { } else if(MoveRock == move && StateCount2 == game_context->data->remote_player) {
if((StateCount2 == game_context->data->local_player) || remoteState = StateRock;
isFinalMove(game_context->data->local_player)) {
remoteState = StateRock;
} else {
remoteState = StateErrorRemoteFast;
FURI_LOG_I(
TAG, "Remote rock sync error. local is %c.", game_context->data->local_player);
}
} else if(MovePaper == move && StateCount2 == game_context->data->remote_player) { } else if(MovePaper == move && StateCount2 == game_context->data->remote_player) {
if((StateCount2 == game_context->data->local_player) || remoteState = StatePaper;
isFinalMove(game_context->data->local_player)) {
remoteState = StatePaper;
} else {
remoteState = StateErrorRemoteFast;
FURI_LOG_I(
TAG, "Remote paper sync error. local is %c.", game_context->data->local_player);
}
} else if(MoveScissors == move && StateCount2 == game_context->data->remote_player) { } else if(MoveScissors == move && StateCount2 == game_context->data->remote_player) {
if((StateCount2 == game_context->data->local_player) || remoteState = StateScissors;
isFinalMove(game_context->data->local_player)) {
remoteState = StateScissors;
} else {
remoteState = StateErrorRemoteFast;
FURI_LOG_I(
TAG, "Remote scissors sync error. local is %c.", game_context->data->local_player);
}
} else { } else {
FURI_LOG_E( FURI_LOG_E(
TAG, TAG,
@ -1331,16 +1268,11 @@ static bool rps_state_machine_remote_moved(GameContext* game_context, Move move)
move, move,
game_context->data->local_player, game_context->data->local_player,
game_context->data->remote_player); game_context->data->remote_player);
remoteState = StateError;
} }
if(StateReady != remoteState) { if(StateReady != remoteState) {
game_context->data->remote_player = remoteState; game_context->data->remote_player = remoteState;
game_context->data->remote_move_tick = furi_get_tick(); game_context->data->remote_move_tick = furi_get_tick();
if(isError(remoteState)) {
game_context->data->local_player = remoteState;
game_context->data->screen_state = ScreenError;
}
} }
return StateReady != remoteState; return StateReady != remoteState;
@ -2400,6 +2332,7 @@ int32_t rock_paper_scissors_app(void* p) {
break; break;
case GameEventSongEnded: case GameEventSongEnded:
if(isResult(game_context->data->local_player)) { if(isResult(game_context->data->local_player)) {
game_context->data->keyboard_col = 0; // YES
game_context->data->screen_state = ScreenFinishedGame; game_context->data->screen_state = ScreenFinishedGame;
} }
break; break;