record-daemon: end-of-game stats, summoner spells
record-daemon / Build, check and test (push) Failing after 8s
record-daemon / Build, check and test (push) Failing after 8s
This commit is contained in:
1 parent
079d72649f
commit
12fe579aca
7 files changed
+754
-21
No files matched your search
@@ -6,7 +6,7 @@ use parking_lot::RwLock;
|
||||
use tracing::{info, trace, warn};
|
||||
|
||||
use super::DaemonStatus;
|
||||
use crate::lqp::{GameEndInfo, GameEvent, GameflowPhase};
|
||||
use crate::lqp::{GameEndInfo, GameEvent, GameflowPhase, ItemBuild, RunePage, SummonerSpells};
|
||||
|
||||
/// Internal daemon state.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@@ -52,11 +52,19 @@ pub enum StateTransition {
|
||||
map_name: Option<String>,
|
||||
team: Option<u32>,
|
||||
summoner_name: Option<String>,
|
||||
/// Player's PUUID
|
||||
puuid: Option<String>,
|
||||
/// Rune page at game start
|
||||
runes: Option<RunePage>,
|
||||
/// Summoner spells
|
||||
summoner_spells: Option<SummonerSpells>,
|
||||
},
|
||||
/// Game ended.
|
||||
GameEnded {
|
||||
/// Game end info with stats from WebSocket.
|
||||
game_end_info: Option<GameEndInfo>,
|
||||
/// Final items
|
||||
final_items: Option<ItemBuild>,
|
||||
},
|
||||
/// Error occurred.
|
||||
Error(String),
|
||||
@@ -224,18 +232,41 @@ impl DaemonStateMachine {
|
||||
);
|
||||
|
||||
match event {
|
||||
GameEvent::GameStart(info) => Some(StateTransition::GameStarted {
|
||||
game_id: info.game_id,
|
||||
champion: info.champion.clone(),
|
||||
queue_type: info.queue_type.clone(),
|
||||
queue_id: info.queue_id,
|
||||
game_mode: info.game_mode.clone(),
|
||||
map_name: info.map_name.clone(),
|
||||
team: info.team,
|
||||
summoner_name: info.summoner_name.clone(),
|
||||
}),
|
||||
GameEvent::GameStart(info) => {
|
||||
// Extract summoner spells from session data if available
|
||||
let summoner_spells = info.session.as_ref().and_then(|session| {
|
||||
session.player_champion_selections.first().map(|selection| {
|
||||
SummonerSpells {
|
||||
spell1_id: selection.spell1_id,
|
||||
spell2_id: selection.spell2_id,
|
||||
spell1_name: crate::lqp::spell_id_to_name(selection.spell1_id),
|
||||
spell2_name: crate::lqp::spell_id_to_name(selection.spell2_id),
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Extract puuid from session data if available
|
||||
let puuid = info.session.as_ref().and_then(|session| {
|
||||
session.player_champion_selections.first().map(|selection| selection.puuid.clone())
|
||||
});
|
||||
|
||||
Some(StateTransition::GameStarted {
|
||||
game_id: info.game_id,
|
||||
champion: info.champion.clone(),
|
||||
queue_type: info.queue_type.clone(),
|
||||
queue_id: info.queue_id,
|
||||
game_mode: info.game_mode.clone(),
|
||||
map_name: info.map_name.clone(),
|
||||
team: info.team,
|
||||
summoner_name: info.summoner_name.clone(),
|
||||
puuid,
|
||||
runes: None, // Will be populated from client.fetch_player_game_metadata()
|
||||
summoner_spells,
|
||||
})
|
||||
}
|
||||
GameEvent::GameEnd(info) => Some(StateTransition::GameEnded {
|
||||
game_end_info: Some(info.clone()),
|
||||
final_items: None, // Will be populated from client.fetch_final_items()
|
||||
}),
|
||||
GameEvent::PhaseChange(info) => {
|
||||
// Only trigger GameEnded on EndOfGame phase (stats are available by then)
|
||||
@@ -243,6 +274,7 @@ impl DaemonStateMachine {
|
||||
if info.phase == "EndOfGame" && self.is_recording() {
|
||||
Some(StateTransition::GameEnded {
|
||||
game_end_info: None,
|
||||
final_items: None,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
@@ -297,6 +329,9 @@ mod tests {
|
||||
map_name: None,
|
||||
team: None,
|
||||
summoner_name: None,
|
||||
puuid: None,
|
||||
runes: None,
|
||||
summoner_spells: None,
|
||||
});
|
||||
|
||||
assert_eq!(new_state, Some(DaemonState::Recording));
|
||||
@@ -318,6 +353,9 @@ mod tests {
|
||||
map_name: None,
|
||||
team: None,
|
||||
summoner_name: None,
|
||||
puuid: None,
|
||||
runes: None,
|
||||
summoner_spells: None,
|
||||
});
|
||||
|
||||
assert_eq!(result, None);
|
||||
|
||||
Reference in new issue
Block a user