Skip to content

Commit

Permalink
Store display_rating in PlayerEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
zuscher committed Nov 11, 2024
1 parent 82c2a1c commit e07683d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions multi-skill/src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ pub fn make_leaderboard(
let max_rating = player
.event_history
.iter()
.map(PlayerEvent::get_display_rating)
.map(|event| event.display_rating)
.max()
.unwrap();
let display_rating = last_event.get_display_rating();
let display_rating = last_event.display_rating;
let prev_rating = if num_contests == 1 {
0
} else {
player.event_history[num_contests - 2].get_display_rating()
player.event_history[num_contests - 2].display_rating
};
rating_data.push(PlayerSummary {
rank: None,
Expand Down
3 changes: 3 additions & 0 deletions multi-skill/src/systems/common/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct PlayerEvent {
pub rating_sig: i32,
pub perf_score: i32,
pub place: usize,
pub display_rating: i32,
}

impl PlayerEvent {
Expand Down Expand Up @@ -65,6 +66,8 @@ impl Player {
last_event.rating_mu = rating.mu.round() as i32;
last_event.rating_sig = rating.sig.round() as i32;
last_event.perf_score = performance_score.round() as i32;

last_event.display_rating = last_event.get_display_rating();
}

pub fn update_rating_with_normal(&mut self, performance: Rating) {
Expand Down
2 changes: 1 addition & 1 deletion worldrank-api/src/domain/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct HistoryPoint {
impl HistoryPoint {
pub fn new(event: &PlayerEvent, contest: &ContestSummary) -> Self {
Self {
display_rating: event.get_display_rating(),
display_rating: event.display_rating,
perf_score: event.perf_score,
place: event.place,
num_contestants: contest.num_contestants,
Expand Down

0 comments on commit e07683d

Please sign in to comment.