record-daemon: end-of-game stats, summoner spells
Some checks failed
record-daemon / Build, check and test (push) Failing after 8s
Some checks failed
record-daemon / Build, check and test (push) Failing after 8s
This commit is contained in:
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::error::{Result, TimelineError};
|
||||
use crate::lqp::GameEvent;
|
||||
use crate::lqp::{GameEvent, ItemBuild, RunePage, SummonerSpells};
|
||||
use crate::recording::RecordingResult;
|
||||
|
||||
/// A timestamped event in the timeline.
|
||||
@@ -54,12 +54,27 @@ pub struct RecordingMetadata {
|
||||
pub map_name: Option<String>,
|
||||
/// Player's summoner name.
|
||||
pub summoner_name: Option<String>,
|
||||
/// Player's PUUID.
|
||||
#[serde(default)]
|
||||
pub puuid: Option<String>,
|
||||
/// Team (100 = blue, 200 = red).
|
||||
pub team: Option<u32>,
|
||||
/// Whether the game was won.
|
||||
pub victory: Option<bool>,
|
||||
/// Final player stats.
|
||||
pub final_stats: Option<GameFinalStats>,
|
||||
/// Player's rune page at game start.
|
||||
#[serde(default)]
|
||||
pub runes: Option<RunePage>,
|
||||
/// Player's summoner spells.
|
||||
#[serde(default)]
|
||||
pub summoner_spells: Option<SummonerSpells>,
|
||||
/// Final item build at game end.
|
||||
#[serde(default)]
|
||||
pub final_items: Option<ItemBuild>,
|
||||
/// All players in the game (puuid -> summoner name mapping).
|
||||
#[serde(default)]
|
||||
pub all_players: Vec<PlayerIdentityInfo>,
|
||||
/// Recording start time.
|
||||
pub start_time: DateTime<Utc>,
|
||||
/// Recording end time.
|
||||
@@ -77,6 +92,22 @@ pub struct RecordingMetadata {
|
||||
pub finalized: bool,
|
||||
}
|
||||
|
||||
/// Player identity information for puuid to summoner name mapping.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PlayerIdentityInfo {
|
||||
/// Player's PUUID.
|
||||
pub puuid: String,
|
||||
/// Player's summoner name.
|
||||
pub summoner_name: String,
|
||||
/// Player's champion name.
|
||||
#[serde(default)]
|
||||
pub champion_name: Option<String>,
|
||||
/// Player's team (100 or 200).
|
||||
#[serde(default)]
|
||||
pub team: Option<u32>,
|
||||
}
|
||||
|
||||
/// Final game statistics for the player.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct GameFinalStats {
|
||||
@@ -111,9 +142,14 @@ pub struct MetadataUpdate {
|
||||
pub game_mode: Option<String>,
|
||||
pub map_name: Option<String>,
|
||||
pub summoner_name: Option<String>,
|
||||
pub puuid: Option<String>,
|
||||
pub team: Option<u32>,
|
||||
pub victory: Option<bool>,
|
||||
pub final_stats: Option<GameFinalStats>,
|
||||
pub runes: Option<RunePage>,
|
||||
pub summoner_spells: Option<SummonerSpells>,
|
||||
pub final_items: Option<ItemBuild>,
|
||||
pub all_players: Vec<PlayerIdentityInfo>,
|
||||
}
|
||||
|
||||
impl RecordingMetadata {
|
||||
@@ -130,9 +166,14 @@ impl RecordingMetadata {
|
||||
game_mode: None,
|
||||
map_name: None,
|
||||
summoner_name: None,
|
||||
puuid: None,
|
||||
team: None,
|
||||
victory: None,
|
||||
final_stats: None,
|
||||
runes: None,
|
||||
summoner_spells: None,
|
||||
final_items: None,
|
||||
all_players: Vec::new(),
|
||||
start_time: result.start_time,
|
||||
end_time: Some(result.end_time),
|
||||
duration: result.duration,
|
||||
@@ -192,9 +233,14 @@ impl TimelineStore {
|
||||
game_mode: None,
|
||||
map_name: None,
|
||||
summoner_name: None,
|
||||
puuid: None,
|
||||
team: None,
|
||||
victory: None,
|
||||
final_stats: None,
|
||||
runes: None,
|
||||
summoner_spells: None,
|
||||
final_items: None,
|
||||
all_players: Vec::new(),
|
||||
start_time: Utc::now(),
|
||||
end_time: None,
|
||||
duration: Duration::zero(),
|
||||
@@ -248,9 +294,14 @@ impl TimelineStore {
|
||||
game_mode: None,
|
||||
map_name: None,
|
||||
summoner_name: None,
|
||||
puuid: None,
|
||||
team: None,
|
||||
victory: None,
|
||||
final_stats: None,
|
||||
runes: None,
|
||||
summoner_spells: None,
|
||||
final_items: None,
|
||||
all_players: Vec::new(),
|
||||
start_time: result.start_time,
|
||||
end_time: Some(result.end_time),
|
||||
duration: result.duration,
|
||||
@@ -317,6 +368,9 @@ impl TimelineStore {
|
||||
if let Some(summoner_name) = update.summoner_name {
|
||||
metadata.summoner_name = Some(summoner_name);
|
||||
}
|
||||
if let Some(puuid) = update.puuid {
|
||||
metadata.puuid = Some(puuid);
|
||||
}
|
||||
if let Some(team) = update.team {
|
||||
metadata.team = Some(team);
|
||||
}
|
||||
@@ -326,6 +380,18 @@ impl TimelineStore {
|
||||
if let Some(final_stats) = update.final_stats {
|
||||
metadata.final_stats = Some(final_stats);
|
||||
}
|
||||
if let Some(runes) = update.runes {
|
||||
metadata.runes = Some(runes);
|
||||
}
|
||||
if let Some(summoner_spells) = update.summoner_spells {
|
||||
metadata.summoner_spells = Some(summoner_spells);
|
||||
}
|
||||
if let Some(final_items) = update.final_items {
|
||||
metadata.final_items = Some(final_items);
|
||||
}
|
||||
if !update.all_players.is_empty() {
|
||||
metadata.all_players = update.all_players;
|
||||
}
|
||||
}
|
||||
drop(recordings);
|
||||
self.persist_recording(recording_id)?;
|
||||
@@ -370,9 +436,14 @@ impl TimelineStore {
|
||||
game_mode: metadata.game_mode.clone(),
|
||||
map_name: metadata.map_name.clone(),
|
||||
summoner_name: metadata.summoner_name.clone(),
|
||||
puuid: metadata.puuid.clone(),
|
||||
team: metadata.team,
|
||||
victory: metadata.victory,
|
||||
final_stats: metadata.final_stats.clone(),
|
||||
runes: metadata.runes.clone(),
|
||||
summoner_spells: metadata.summoner_spells.clone(),
|
||||
final_items: metadata.final_items.clone(),
|
||||
all_players: metadata.all_players.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -416,9 +487,14 @@ impl TimelineStore {
|
||||
game_mode: metadata.game_mode,
|
||||
map_name: metadata.map_name,
|
||||
summoner_name: metadata.summoner_name,
|
||||
puuid: metadata.puuid,
|
||||
team: metadata.team,
|
||||
victory: metadata.victory,
|
||||
final_stats: metadata.final_stats,
|
||||
runes: metadata.runes,
|
||||
summoner_spells: metadata.summoner_spells,
|
||||
final_items: metadata.final_items,
|
||||
all_players: metadata.all_players,
|
||||
};
|
||||
|
||||
let file_path = self.storage_dir.join(format!("{}.json", id));
|
||||
@@ -453,9 +529,14 @@ impl TimelineStore {
|
||||
game_mode: None,
|
||||
map_name: None,
|
||||
summoner_name: None,
|
||||
puuid: None,
|
||||
team: None,
|
||||
victory: None,
|
||||
final_stats: None,
|
||||
runes: None,
|
||||
summoner_spells: None,
|
||||
final_items: None,
|
||||
all_players: Vec::new(),
|
||||
start_time: timeline.start_time,
|
||||
end_time: timeline.end_time,
|
||||
duration: timeline.duration(),
|
||||
|
||||
Reference in New Issue
Block a user