record-daemon: add record raw events, subscribe lp change events
record-daemon / Build, check and test (push) Successful in 2m0s

This commit is contained in:
vhaudiquet committed 2026-03-27 22:25:24 +01:00
1 parent aa53a84a46
commit b64937601a
8 files changed
+401 -30

No files matched your search

+77
View File
@@ -49,6 +49,10 @@ pub enum GameEvent {
#[serde(rename = "lcu-phase-change")]
PhaseChange(PhaseChangeInfo),
/// LP changed after a ranked game.
#[serde(rename = "lcu-lp-change")]
LpChange(LpChangeInfo),
/// Unknown event type.
#[serde(other)]
Unknown,
@@ -66,6 +70,66 @@ pub struct PhaseChangeInfo {
pub timestamp: DateTime<Utc>,
}
/// LP change event data after a ranked game.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LpChangeInfo {
/// Queue type (RANKED_SOLO_5x5, RANKED_FLEX_SR, etc.).
pub queue_type: String,
/// LP change amount (positive for gain, negative for loss).
pub lp_change: i32,
/// LP before the game.
pub lp_before: i32,
/// LP after the game.
pub lp_after: i32,
/// Current tier (IRON, BRONZE, SILVER, GOLD, PLATINUM, DIAMOND, MASTER, GRANDMASTER, CHALLENGER).
pub tier: String,
/// Current division (I, II, III, IV).
#[serde(default)]
pub division: Option<String>,
/// Current league points.
#[serde(default)]
pub league_points: Option<i32>,
/// Whether the player is in a promotional series.
#[serde(default)]
pub in_promos: bool,
/// Promotional series progress (e.g., "W:2 L:1").
#[serde(default)]
pub promo_progress: Option<String>,
/// Number of wins in promo series.
#[serde(default)]
pub promo_wins: Option<u32>,
/// Number of losses in promo series.
#[serde(default)]
pub promo_losses: Option<u32>,
/// Total games played in this queue.
#[serde(default)]
pub total_games: Option<u32>,
/// Total wins in this queue.
#[serde(default)]
pub total_wins: Option<u32>,
/// Total losses in this queue.
#[serde(default)]
pub total_losses: Option<u32>,
/// Timestamp when LP change occurred.
#[serde(default = "Utc::now")]
pub timestamp: DateTime<Utc>,
}
/// Match found event data.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -462,6 +526,18 @@ impl GameEvent {
GameEvent::PhaseChange(info) => {
format!("Phase changed to: {}", info.phase)
}
GameEvent::LpChange(lp) => {
let sign = if lp.lp_change >= 0 { "+" } else { "" };
format!(
"LP Change: {}{} LP ({} {} {} -> {} LP)",
sign,
lp.lp_change,
lp.tier,
lp.division.as_deref().unwrap_or(""),
lp.queue_type,
lp.lp_after
)
}
GameEvent::Unknown => "Unknown event".to_string(),
}
}
@@ -479,6 +555,7 @@ impl GameEvent {
GameEvent::StatsUpdate(_) => "stats_update",
GameEvent::GameEnd(_) => "game_end",
GameEvent::PhaseChange(_) => "phase_change",
GameEvent::LpChange(_) => "lp_change",
GameEvent::Unknown => "unknown",
}
}