Skip to content

Commit

Permalink
feat(app): keep votes consistent when player leaves.
Browse files Browse the repository at this point in the history
This is done by rendering the newest history event during GamePhase::Revealed, if we have one.
  • Loading branch information
ja-ko committed Jun 9, 2024
1 parent 5f0ea9e commit 78eabdf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ui/voting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,15 @@ impl Page for VotingPage {
self.last_phase = app.room.phase;
}

render_own_vote(&app.room.players, app.average_votes(), app.room.phase, &app.vote, &app.room.deck, vote_view, frame);
match app.room.phase {
GamePhase::Revealed if app.history.len() > 0 => {
let entry = app.history.as_slice().last().expect("Can't get last item of history.");
render_own_vote(&entry.votes, entry.average, GamePhase::Revealed, &entry.own_vote, &entry.deck, vote_view, frame);
}
_ => {
render_own_vote(&app.room.players, app.average_votes(), app.room.phase, &app.vote, &app.room.deck, vote_view, frame);
}
}
self.render_log(app, log, frame);
self.render_votes(app, left_side, frame);
render_overview(app, header, frame);
Expand Down

0 comments on commit 78eabdf

Please sign in to comment.