Show the damage seen in Death Recaps in a player's details (#128)
By item and augment, then « Autres effets »; « En attente » for a Provisional Match, « Indisponible » when Riot refuses, « Réessayer » after a passing failure. A followed Match's timeline is fetched by a background queue, an older one's on its first opening. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7575ab0165
commit
7f56f090aa
19 files changed
+1093
-31
No files matched your search
@@ -3,6 +3,9 @@
|
||||
//! stored Matches change while it does), and only the Match chosen is decoded, on a worker too:
|
||||
//! nothing runs while the screen is hidden but marking the list stale (rule #1).
|
||||
|
||||
mod damage;
|
||||
mod damage_view;
|
||||
mod death;
|
||||
mod details;
|
||||
mod filters;
|
||||
mod list;
|
||||
@@ -10,6 +13,9 @@ mod recap;
|
||||
mod screen;
|
||||
mod shown;
|
||||
|
||||
pub(in crate::page) use damage::Death;
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) use damage::{NONE_SEEN, OTHERS, ShownDamage};
|
||||
use filters::Filters;
|
||||
use list::MatchChosen;
|
||||
pub(in crate::page) use list::MatchList;
|
||||
@@ -23,7 +29,7 @@ pub(in crate::page) use shown::{PENDING, ShownAugment, ShownPlayer, Slot, UNAVAI
|
||||
use super::{Page, Tab};
|
||||
use crate::card_images::CardImages;
|
||||
use crate::worker::{MatchEntry, RefreshGate, spawn_match_list, spawn_recap};
|
||||
use arena_tracker_core::{GameCatalog, MatchRecap, Season};
|
||||
use arena_tracker_core::{DeathRecapState, GameCatalog, MatchRecap, Season};
|
||||
use gpui_kit::component::input::InputEvent;
|
||||
use gpui_kit::*;
|
||||
use std::sync::Arc;
|
||||
@@ -43,6 +49,8 @@ pub(in crate::page) enum Recap {
|
||||
/// The player whose details are unfolded (their index in the recap, teams in order).
|
||||
/// Kept while the same Match is decoded again, gone with the recap otherwise.
|
||||
open: Option<usize>,
|
||||
/// The Death Recaps of the Match (#128): what the details show of them.
|
||||
death: Death,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -69,6 +77,9 @@ pub(in crate::page) struct Matches {
|
||||
pub(in crate::page) recap: Recap,
|
||||
recap_job: RefreshGate,
|
||||
recap_generation: u64,
|
||||
/// The Match whose Death Recap is being asked of Riot: asked once, however many times its
|
||||
/// recap is decoded meanwhile.
|
||||
death_fetching: Option<String>,
|
||||
/// The portraits of the recap, given back when the screen hides.
|
||||
recap_images: Entity<CardImages>,
|
||||
/// The names and icons of the items and augments, from the cache on disk.
|
||||
@@ -110,6 +121,7 @@ impl Matches {
|
||||
recap: Recap::None,
|
||||
recap_job: RefreshGate::default(),
|
||||
recap_generation: 0,
|
||||
death_fetching: None,
|
||||
recap_images: CardImages::new(cx),
|
||||
catalog: Arc::default(),
|
||||
list_open: false,
|
||||
@@ -160,6 +172,21 @@ impl Matches {
|
||||
self.error.as_ref()
|
||||
}
|
||||
|
||||
/// What is known of the Death Recaps of the recap shown.
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) fn death(&self) -> Option<&Death> {
|
||||
match &self.recap {
|
||||
Recap::Ready { death, .. } => Some(death),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The Match whose Death Recap is being asked of Riot.
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) fn death_fetching(&self) -> Option<&str> {
|
||||
self.death_fetching.as_deref()
|
||||
}
|
||||
|
||||
/// The recap shown, once decoded.
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) fn shown(&self) -> Option<&ShownRecap> {
|
||||
@@ -344,6 +371,7 @@ impl Page {
|
||||
self.tracker.clone(),
|
||||
puuid.clone(),
|
||||
selected.clone(),
|
||||
matches.catalog.clone(),
|
||||
matches.recap_generation,
|
||||
self.tx.clone(),
|
||||
),
|
||||
@@ -356,25 +384,37 @@ impl Page {
|
||||
&mut self,
|
||||
generation: u64,
|
||||
result: Result<Option<MatchRecap>, String>,
|
||||
death: Result<DeathRecapState, String>,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if generation == self.matches.recap_generation {
|
||||
self.matches.recap = match result {
|
||||
Ok(Some(recap)) => {
|
||||
// What the same Match showed before, when it is decoded again.
|
||||
let (open, previous) = match &self.matches.recap {
|
||||
Recap::Ready {
|
||||
recap: old,
|
||||
open,
|
||||
death,
|
||||
..
|
||||
} if old.match_id == recap.match_id => (*open, Some(death.clone())),
|
||||
_ => (None, None),
|
||||
};
|
||||
let death = self.death_on_arrival(&recap, death, previous.as_ref());
|
||||
let champions = self.champions();
|
||||
let catalog = self.matches.catalog.clone();
|
||||
let shown =
|
||||
ShownRecap::new(&recap, self.chosen_champion(), &champions, &catalog);
|
||||
let open = match &self.matches.recap {
|
||||
Recap::Ready {
|
||||
recap: old, open, ..
|
||||
} if old.match_id == recap.match_id => *open,
|
||||
_ => None,
|
||||
};
|
||||
let shown = ShownRecap::new(
|
||||
&recap,
|
||||
self.chosen_champion(),
|
||||
&champions,
|
||||
&catalog,
|
||||
&death,
|
||||
);
|
||||
Recap::Ready {
|
||||
recap: Box::new(recap),
|
||||
shown: Box::new(shown),
|
||||
open,
|
||||
death,
|
||||
}
|
||||
}
|
||||
Ok(None) => Recap::Missing,
|
||||
@@ -432,6 +472,8 @@ impl Page {
|
||||
if matches!(self.matches.recap, Recap::Ready { .. }) {
|
||||
let champions = self.champions();
|
||||
self.rewrite_recap(&champions);
|
||||
// The Death Recap is matched to the new names.
|
||||
self.death_recap_matched_again();
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
@@ -441,8 +483,14 @@ impl Page {
|
||||
let champion = self.chosen_champion();
|
||||
let champion = (champion.0, champion.1.to_string());
|
||||
let catalog = self.matches.catalog.clone();
|
||||
if let Recap::Ready { recap, shown, .. } = &mut self.matches.recap {
|
||||
**shown = ShownRecap::new(recap, (champion.0, &champion.1), champions, &catalog);
|
||||
if let Recap::Ready {
|
||||
recap,
|
||||
shown,
|
||||
death,
|
||||
..
|
||||
} = &mut self.matches.recap
|
||||
{
|
||||
**shown = ShownRecap::new(recap, (champion.0, &champion.1), champions, &catalog, death);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
//! The « Dégâts observés dans les récaps de mort » of a player's details (#128), written once
|
||||
//! with the rest of the recap. The Match-V5 timeline is the only source of damage by effect,
|
||||
//! and only for champions who died: the total of the Match per effect is not known, and what
|
||||
//! was dealt to a champion who survived is never attributed.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use arena_tracker_core::{DamageSums, DeathRecapState, Effect, GameCatalog, RecapPlayer};
|
||||
use gpui_kit::SharedString;
|
||||
|
||||
use super::shown::{PENDING, UNAVAILABLE};
|
||||
use crate::text::thousands;
|
||||
|
||||
pub(in crate::page) const LOADING: &str = "Chargement…";
|
||||
pub(in crate::page) const NONE_SEEN: &str = "Aucun dégât observé";
|
||||
/// What is not one of the player's items or augments: basic attacks, champion spells, effects
|
||||
/// the catalog cannot match.
|
||||
pub(in crate::page) const OTHERS: &str = "Autres effets";
|
||||
|
||||
/// What the page knows of the Death Recaps of the Match opened.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(in crate::page) enum Death {
|
||||
/// Riot is being asked for the timeline.
|
||||
Loading,
|
||||
/// The last try failed, for a reason that may pass: « Réessayer ».
|
||||
Failed,
|
||||
/// What is stored; `NotFetched` for a Provisional Match, which has no timeline yet.
|
||||
Known(DeathRecapState),
|
||||
}
|
||||
|
||||
/// One line: an item or an augment, or « Autres effets ».
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(in crate::page) struct ShownEffect {
|
||||
pub(in crate::page) name: SharedString,
|
||||
/// None shows the neutral icon (and none at all for « Autres effets »).
|
||||
pub(in crate::page) icon: Option<PathBuf>,
|
||||
/// The icon's place is kept even without a file: not for « Autres effets ».
|
||||
pub(in crate::page) has_icon_slot: bool,
|
||||
pub(in crate::page) total: SharedString,
|
||||
/// « Physiques 120 · Magiques 80 »: the types that dealt something.
|
||||
pub(in crate::page) types: SharedString,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(in crate::page) enum ShownDamage {
|
||||
/// A word instead of values: « En attente », « Chargement… », « Indisponible » or
|
||||
/// « Aucun dégât observé ».
|
||||
Note(&'static str),
|
||||
/// A transient failure: « Réessayer ».
|
||||
Retry,
|
||||
/// The player's items and augments, the most damaging first, then « Autres effets ».
|
||||
Seen(Vec<ShownEffect>),
|
||||
}
|
||||
|
||||
impl ShownDamage {
|
||||
pub(super) fn of(
|
||||
p: &RecapPlayer,
|
||||
provisional: bool,
|
||||
death: &Death,
|
||||
catalog: &GameCatalog,
|
||||
) -> ShownDamage {
|
||||
if provisional {
|
||||
return ShownDamage::Note(PENDING);
|
||||
}
|
||||
let stored = match death {
|
||||
Death::Failed => return ShownDamage::Retry,
|
||||
// Not fetched cannot stay shown for a published Match: it is being fetched.
|
||||
Death::Loading | Death::Known(DeathRecapState::NotFetched) => {
|
||||
return ShownDamage::Note(LOADING);
|
||||
}
|
||||
Death::Known(DeathRecapState::Refused) => return ShownDamage::Note(UNAVAILABLE),
|
||||
Death::Known(DeathRecapState::Stored(stored)) => stored,
|
||||
};
|
||||
let Some(dealt) = p.participant_id.and_then(|id| stored.player(id)) else {
|
||||
return ShownDamage::Note(NONE_SEEN);
|
||||
};
|
||||
let mut lines: Vec<_> = (dealt.effects.iter())
|
||||
.map(|entry| {
|
||||
let (name, icon) = match entry.effect {
|
||||
Effect::Item(id) => (catalog.item_name(id), catalog.item_icon(id)),
|
||||
Effect::Augment(id) => (catalog.augment_name(id), catalog.augment_icon(id)),
|
||||
};
|
||||
line(name.into(), icon, true, &entry.damage)
|
||||
})
|
||||
.collect();
|
||||
if dealt.others.total() > 0 {
|
||||
lines.push(line(OTHERS.into(), None, false, &dealt.others));
|
||||
}
|
||||
if lines.is_empty() {
|
||||
return ShownDamage::Note(NONE_SEEN);
|
||||
}
|
||||
ShownDamage::Seen(lines)
|
||||
}
|
||||
}
|
||||
|
||||
fn line(
|
||||
name: SharedString,
|
||||
icon: Option<PathBuf>,
|
||||
has_icon_slot: bool,
|
||||
damage: &DamageSums,
|
||||
) -> ShownEffect {
|
||||
let types = [
|
||||
("Physiques", damage.physical),
|
||||
("Magiques", damage.magic),
|
||||
("Bruts", damage.true_damage),
|
||||
]
|
||||
.iter()
|
||||
.filter(|(_, sum)| *sum > 0)
|
||||
.map(|(caption, sum)| format!("{caption} {}", thousands(*sum)))
|
||||
.collect::<Vec<_>>()
|
||||
.join(" · ");
|
||||
ShownEffect {
|
||||
name,
|
||||
icon,
|
||||
has_icon_slot,
|
||||
total: thousands(damage.total()).into(),
|
||||
types: types.into(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn damage(provisional: bool, death: &Death) -> ShownDamage {
|
||||
ShownDamage::of(
|
||||
&RecapPlayer {
|
||||
participant_id: Some(2),
|
||||
..RecapPlayer::default()
|
||||
},
|
||||
provisional,
|
||||
death,
|
||||
&GameCatalog::default(),
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_state_says_itself_in_a_word_or_a_button() {
|
||||
let known = |state| Death::Known(state);
|
||||
let note = |word| ShownDamage::Note(word);
|
||||
// A Provisional Match waits, whatever is known.
|
||||
assert_eq!(damage(true, &Death::Loading), note(PENDING));
|
||||
assert_eq!(
|
||||
damage(true, &known(DeathRecapState::NotFetched)),
|
||||
note(PENDING)
|
||||
);
|
||||
assert_eq!(damage(false, &Death::Loading), note(LOADING));
|
||||
assert_eq!(damage(false, &Death::Failed), ShownDamage::Retry);
|
||||
assert_eq!(
|
||||
damage(false, &known(DeathRecapState::Refused)),
|
||||
note(UNAVAILABLE)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
//! The section « Dégâts observés dans les récaps de mort » of a player's details, drawn for the
|
||||
//! player unfolded only: one line per item or augment with its icon, name and damage, then
|
||||
//! « Autres effets », or the word or button that stands for them.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use gpui_kit::base::Button as BaseButton;
|
||||
use gpui_kit::component::{ActiveTheme as _, Icon, IconName, Sizable as _, StyledExt as _, Theme};
|
||||
use gpui_kit::prelude::FluentBuilder as _;
|
||||
use gpui_kit::*;
|
||||
|
||||
use super::damage::{ShownDamage, ShownEffect};
|
||||
use crate::page::Page;
|
||||
|
||||
const TITLE: &str = "Dégâts observés dans les récaps de mort";
|
||||
/// Said once for the section: the timeline details only what a champion received before dying.
|
||||
const NOTE: &str = "Le total de la Partie par effet est indisponible : seuls les dégâts subis avant une élimination sont détaillés. Les dégâts infligés à un champion qui survit ne sont jamais attribués.";
|
||||
const ICON: f32 = 20.;
|
||||
|
||||
pub(super) fn section(damage: &ShownDamage, cx: &Context<Page>) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let muted = theme.muted_foreground;
|
||||
div()
|
||||
.v_flex()
|
||||
.gap_1()
|
||||
.debug_selector(|| "death-recap".into())
|
||||
.child(
|
||||
div()
|
||||
.text_sm()
|
||||
.font_weight(FontWeight::SEMIBOLD)
|
||||
.child(TITLE),
|
||||
)
|
||||
.child(match damage {
|
||||
ShownDamage::Note(word) => div()
|
||||
.text_sm()
|
||||
.text_color(muted)
|
||||
.debug_selector(|| "death-recap-note".into())
|
||||
.child(*word)
|
||||
.into_any_element(),
|
||||
ShownDamage::Retry => retry(cx).into_any_element(),
|
||||
ShownDamage::Seen(lines) => div()
|
||||
.v_flex()
|
||||
.gap_1()
|
||||
.children(lines.iter().map(|line| effect(line, theme)))
|
||||
.into_any_element(),
|
||||
})
|
||||
.child(div().text_xs().text_color(muted).child(NOTE))
|
||||
}
|
||||
|
||||
/// « Réessayer »: asks Riot again.
|
||||
fn retry(cx: &Context<Page>) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let (ring, border, hover, hover_foreground) = (
|
||||
theme.ring,
|
||||
theme.border,
|
||||
theme.accent,
|
||||
theme.accent_foreground,
|
||||
);
|
||||
div()
|
||||
.h_flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.child(
|
||||
div()
|
||||
.text_sm()
|
||||
.text_color(theme.muted_foreground)
|
||||
.child("Les récaps de mort n’ont pas pu être récupérés."),
|
||||
)
|
||||
.child(
|
||||
BaseButton::new("death-recap-retry")
|
||||
.px_2()
|
||||
.py_1()
|
||||
.rounded_md()
|
||||
.text_sm()
|
||||
.border_1()
|
||||
.border_color(border)
|
||||
.focus_visible(|style| style.border_color(ring))
|
||||
.hover(|style| style.bg(hover).text_color(hover_foreground))
|
||||
.accessibility_label("Réessayer")
|
||||
.debug_selector(|| "death-recap-retry".into())
|
||||
.child("Réessayer")
|
||||
.on_click(cx.listener(|page, _, _, cx| page.retry_death_recap(cx))),
|
||||
)
|
||||
}
|
||||
|
||||
fn icon(path: Option<&PathBuf>, theme: &Theme) -> AnyElement {
|
||||
match path {
|
||||
Some(path) => img(path.clone())
|
||||
.size(px(ICON))
|
||||
.flex_shrink_0()
|
||||
.rounded(px(3.))
|
||||
.into_any_element(),
|
||||
None => Icon::new(IconName::Frame)
|
||||
.xsmall()
|
||||
.text_color(theme.muted_foreground)
|
||||
.into_any_element(),
|
||||
}
|
||||
}
|
||||
|
||||
fn effect(line: &ShownEffect, theme: &Theme) -> impl IntoElement {
|
||||
div()
|
||||
.h_flex()
|
||||
.items_center()
|
||||
.gap_2()
|
||||
.when(line.has_icon_slot, |row| {
|
||||
row.child(
|
||||
div()
|
||||
.size(px(ICON))
|
||||
.flex_shrink_0()
|
||||
.flex()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.child(icon(line.icon.as_ref(), theme)),
|
||||
)
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.w(px(190.))
|
||||
.flex_shrink_0()
|
||||
.text_sm()
|
||||
.overflow_hidden()
|
||||
.whitespace_nowrap()
|
||||
.child(line.name.clone()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.w(px(70.))
|
||||
.flex_shrink_0()
|
||||
.text_sm()
|
||||
.font_weight(FontWeight::SEMIBOLD)
|
||||
.text_right()
|
||||
.whitespace_nowrap()
|
||||
.child(line.total.clone()),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.whitespace_nowrap()
|
||||
.text_color(theme.muted_foreground)
|
||||
.child(line.types.clone()),
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//! The Death Recap of the Match opened (#128): read with its recap, asked of Riot once when it
|
||||
//! was never fetched (an older Match, opened for the first time), asked again on « Réessayer »,
|
||||
//! and read again when the followed Match it belongs to was fetched in the background or the
|
||||
//! game data changed what its effects are matched to. Nothing is fetched for a Provisional
|
||||
//! Match, nor for the whole history.
|
||||
|
||||
use arena_tracker_core::{DeathRecapState, MatchRecap};
|
||||
use gpui_kit::*;
|
||||
|
||||
use super::damage::Death;
|
||||
use super::{Page, Recap};
|
||||
use crate::worker::spawn_death_recap;
|
||||
|
||||
impl Page {
|
||||
/// What to show of the Death Recap of `recap`, just decoded, from what was stored: the one
|
||||
/// not fetched is asked for here, once, unless a request for it is still on its way.
|
||||
/// `previous`: what the same Match showed before it was decoded again.
|
||||
pub(super) fn death_on_arrival(
|
||||
&mut self,
|
||||
recap: &MatchRecap,
|
||||
stored: Result<DeathRecapState, String>,
|
||||
previous: Option<&Death>,
|
||||
) -> Death {
|
||||
match stored {
|
||||
Ok(DeathRecapState::NotFetched) if recap.provisional => {
|
||||
Death::Known(DeathRecapState::NotFetched)
|
||||
}
|
||||
Ok(DeathRecapState::NotFetched) => {
|
||||
let matches = &mut self.matches;
|
||||
// « Réessayer » is the user's, not asked again as the recap is decoded again.
|
||||
if previous == Some(&Death::Failed) {
|
||||
return Death::Failed;
|
||||
}
|
||||
if matches.death_fetching.as_deref() != Some(recap.match_id.as_str()) {
|
||||
matches.death_fetching = Some(recap.match_id.clone());
|
||||
self.spawn_death_recap(recap.clone(), true);
|
||||
}
|
||||
Death::Loading
|
||||
}
|
||||
Ok(state) => Death::Known(state),
|
||||
Err(_) => Death::Failed,
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn_death_recap(&self, recap: MatchRecap, fetch: bool) {
|
||||
spawn_death_recap(
|
||||
self.tracker.clone(),
|
||||
recap,
|
||||
self.matches.catalog.clone(),
|
||||
fetch,
|
||||
self.tx.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
/// « Réessayer »: asks Riot again for the Death Recap of the Match opened.
|
||||
pub(super) fn retry_death_recap(&mut self, cx: &mut Context<Self>) {
|
||||
let Recap::Ready { recap, death, .. } = &mut self.matches.recap else {
|
||||
return;
|
||||
};
|
||||
if *death != Death::Failed {
|
||||
return;
|
||||
}
|
||||
*death = Death::Loading;
|
||||
let recap = (**recap).clone();
|
||||
self.matches.death_fetching = Some(recap.match_id.clone());
|
||||
self.spawn_death_recap(recap, true);
|
||||
self.rewrite_recap(&self.champions());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// The Death Recap read by the worker for the Match opened (an old answer for another
|
||||
/// Match is dropped). One that was asked of Riot and failed offers « Réessayer »; a mere
|
||||
/// read that found nothing leaves what is shown.
|
||||
pub(in crate::page) fn apply_death_recap(
|
||||
&mut self,
|
||||
match_id: String,
|
||||
fetched: bool,
|
||||
result: Result<DeathRecapState, String>,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if fetched && self.matches.death_fetching.as_deref() == Some(match_id.as_str()) {
|
||||
self.matches.death_fetching = None;
|
||||
}
|
||||
let Recap::Ready { recap, death, .. } = &mut self.matches.recap else {
|
||||
return;
|
||||
};
|
||||
if recap.match_id != match_id || recap.provisional {
|
||||
return;
|
||||
}
|
||||
*death = match result {
|
||||
Ok(state @ (DeathRecapState::Stored(_) | DeathRecapState::Refused)) => {
|
||||
Death::Known(state)
|
||||
}
|
||||
_ if fetched => Death::Failed,
|
||||
_ => return,
|
||||
};
|
||||
self.rewrite_recap(&self.champions());
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// The follower's queue fetched the Death Recap of a Match: shown when it is the one
|
||||
/// opened and does not have it yet.
|
||||
pub(in crate::page) fn death_recap_stored(&mut self, match_id: &str) {
|
||||
if let Recap::Ready { recap, death, .. } = &self.matches.recap
|
||||
&& recap.match_id == match_id
|
||||
&& !recap.provisional
|
||||
&& !matches!(death, Death::Known(_))
|
||||
{
|
||||
self.spawn_death_recap((**recap).clone(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/// New names for the effects: a stored Death Recap is matched to them again.
|
||||
pub(super) fn death_recap_matched_again(&self) {
|
||||
if let Recap::Ready { recap, death, .. } = &self.matches.recap
|
||||
&& matches!(death, Death::Known(DeathRecapState::Stored(_)))
|
||||
{
|
||||
self.spawn_death_recap((**recap).clone(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,8 @@ use gpui_kit::*;
|
||||
|
||||
use gpui_kit::base::Button as BaseButton;
|
||||
|
||||
use super::damage::ShownDamage;
|
||||
use super::damage_view;
|
||||
use super::details::Details;
|
||||
use super::shown::{ShownAugment, ShownPlayer, ShownRecap, ShownTeam, Slot, Value};
|
||||
use crate::page::Page;
|
||||
@@ -222,12 +224,15 @@ fn player(shown: &ShownPlayer, ix: usize, open: bool, cx: &Context<Page>) -> imp
|
||||
}
|
||||
})
|
||||
.child(line)
|
||||
.when(open, |card| card.child(details(&shown.details, theme)))
|
||||
.when(open, |card| {
|
||||
card.child(details(&shown.details, &shown.damage_seen, cx))
|
||||
})
|
||||
}
|
||||
|
||||
/// The measures of a player, a row per group: its title, then each measure under its caption.
|
||||
/// Built for the player unfolded only.
|
||||
fn details(details: &Details, theme: &Theme) -> impl IntoElement {
|
||||
/// then the damage seen in the Death Recaps. Built for the player unfolded only.
|
||||
fn details(details: &Details, damage: &ShownDamage, cx: &Context<Page>) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
div()
|
||||
.v_flex()
|
||||
.gap_2()
|
||||
@@ -255,6 +260,7 @@ fn details(details: &Details, theme: &Theme) -> impl IntoElement {
|
||||
.map(|measure| stat(measure.caption, &measure.value, 150., theme)),
|
||||
)
|
||||
}))
|
||||
.child(damage_view::section(damage, cx))
|
||||
}
|
||||
|
||||
/// What stands for items or augments the source does not give: « Objets : Indisponible ».
|
||||
|
||||
@@ -9,6 +9,7 @@ use arena_tracker_core::{
|
||||
};
|
||||
use gpui_kit::SharedString;
|
||||
|
||||
use super::damage::{Death, ShownDamage};
|
||||
use super::details::Details;
|
||||
use crate::local_time::local_time;
|
||||
use crate::text::{duration, match_time, ordinal, thousands};
|
||||
@@ -137,6 +138,8 @@ pub(in crate::page) struct ShownPlayer {
|
||||
pub(in crate::page) damage: Value,
|
||||
/// What unfolds under their line.
|
||||
pub(in crate::page) details: Details,
|
||||
/// The damage seen in the Death Recaps, under their details.
|
||||
pub(in crate::page) damage_seen: ShownDamage,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
@@ -162,12 +165,14 @@ pub(in crate::page) struct ShownRecap {
|
||||
|
||||
impl ShownRecap {
|
||||
/// `champion`: the Account's, from its row, should the recap not find the Account.
|
||||
/// `catalog`: the names and icons of the items and augments.
|
||||
/// `catalog`: the names and icons of the items and augments. `death`: what is known of the
|
||||
/// Death Recaps of the Match.
|
||||
pub(in crate::page) fn new(
|
||||
recap: &MatchRecap,
|
||||
champion: (u32, &str),
|
||||
champions: &Champions,
|
||||
catalog: &GameCatalog,
|
||||
death: &Death,
|
||||
) -> ShownRecap {
|
||||
let missing = if recap.provisional {
|
||||
PENDING
|
||||
@@ -196,7 +201,7 @@ impl ShownRecap {
|
||||
placement: Value::of(team.placement, missing, ordinal),
|
||||
account: team.players.iter().any(|p| p.is_account),
|
||||
players: (team.players.iter())
|
||||
.map(|p| player(p, missing, champions, catalog))
|
||||
.map(|p| player(p, recap.provisional, death, champions, catalog))
|
||||
.collect(),
|
||||
})
|
||||
.collect(),
|
||||
@@ -206,10 +211,12 @@ impl ShownRecap {
|
||||
|
||||
fn player(
|
||||
p: &RecapPlayer,
|
||||
missing: &'static str,
|
||||
provisional: bool,
|
||||
death: &Death,
|
||||
champions: &Champions,
|
||||
catalog: &GameCatalog,
|
||||
) -> ShownPlayer {
|
||||
let missing = if provisional { PENDING } else { UNAVAILABLE };
|
||||
let count = |value: Option<u32>| value.map_or_else(|| missing.to_string(), |v| v.to_string());
|
||||
let kda = [p.kills, p.deaths, p.assists];
|
||||
let absent = || Value::of(None::<()>, missing, |_| String::new());
|
||||
@@ -250,6 +257,7 @@ fn player(
|
||||
.ok_or_else(absent),
|
||||
damage: Value::of(p.damage_to_champions.total, missing, thousands),
|
||||
details: Details::of(p, missing),
|
||||
damage_seen: ShownDamage::of(p, provisional, death, catalog),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +304,7 @@ mod tests {
|
||||
(1, "x"),
|
||||
&Champions::default(),
|
||||
&GameCatalog::default(),
|
||||
&Death::Loading,
|
||||
);
|
||||
let team = &shown.teams[0];
|
||||
assert_eq!(team.placement.text, UNAVAILABLE);
|
||||
@@ -331,6 +340,7 @@ mod tests {
|
||||
(39, "x"),
|
||||
&Champions::default(),
|
||||
&GameCatalog::default(),
|
||||
&Death::Loading,
|
||||
);
|
||||
let p = &shown.teams[0].players[0];
|
||||
for value in [&p.riot_id, &p.level, &p.kda, &p.damage] {
|
||||
@@ -349,6 +359,7 @@ mod tests {
|
||||
(39, "x"),
|
||||
&Champions::default(),
|
||||
&GameCatalog::default(),
|
||||
&Death::Loading,
|
||||
);
|
||||
assert!(shown.provisional);
|
||||
assert_eq!(shown.teams[0].players[0].level.text, PENDING);
|
||||
|
||||
@@ -15,6 +15,7 @@ mod home;
|
||||
mod key_fixtures;
|
||||
mod match_animation;
|
||||
mod matches;
|
||||
mod matches_death_recap;
|
||||
mod matches_details;
|
||||
mod matches_filters;
|
||||
mod matches_fixtures;
|
||||
|
||||
@@ -0,0 +1,398 @@
|
||||
//! The « Dégâts observés dans les récaps de mort » of a player's details (#128): the damage
|
||||
//! of the timeline's Death Recaps by item and augment, and the states of the section.
|
||||
|
||||
use super::matches_fixtures::{Lobby, TwoAccounts, recap_ready};
|
||||
use super::page_fixtures::{center, draw, open_page_launched, switch_tab};
|
||||
use crate::card_images::tests::TestDir;
|
||||
use crate::page::matches::{Death, NONE_SEEN, OTHERS, Recap, ShownDamage, UNAVAILABLE};
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::worker::Msg;
|
||||
use arena_tracker_core::{
|
||||
Account, DeathRecapState, GameCatalog, GameData, MatchHistorySource, SourceError, Tracker,
|
||||
};
|
||||
use gpui_kit::{Entity, Modifiers, TestAppContext, VisualTestContext};
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
/// Two kills of the full-recap Match (the oldest of Alice): what Irelia (participant 2: the
|
||||
/// augment `augment_foxfire_spell`, ItemRedemption22, a basic attack and `augment_nowyouseeme`),
|
||||
/// Lissandra (participant 1) and a minion dealt to the victims.
|
||||
const TIMELINE: &str =
|
||||
include_str!("../../../../core/tests/fixtures/riot/timeline_1750_EUW1_9000000007.json");
|
||||
|
||||
/// The Matches of Alice (newest first): the one opened first, then the full recap.
|
||||
const FIRST: &str = "EUW1_9000000006";
|
||||
const FULL: &str = "EUW1_9000000007";
|
||||
|
||||
const ROWS: [&str; 3] = ["match-row-0", "match-row-1", "match-row-2"];
|
||||
const LINES: [&str; 6] = [
|
||||
"recap-player-0",
|
||||
"recap-player-1",
|
||||
"recap-player-2",
|
||||
"recap-player-3",
|
||||
"recap-player-4",
|
||||
"recap-player-5",
|
||||
];
|
||||
|
||||
/// What Riot answers to a timeline request.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
enum Script {
|
||||
Serve,
|
||||
/// Riot refuses the timeline, and the Match itself is there: a refusal.
|
||||
Refuse,
|
||||
/// The next `n` requests fail on the network.
|
||||
Fail(usize),
|
||||
}
|
||||
|
||||
/// Alice's history with timelines.
|
||||
struct Timelines {
|
||||
script: Arc<Mutex<Script>>,
|
||||
asked: Arc<Mutex<Vec<String>>>,
|
||||
}
|
||||
|
||||
impl MatchHistorySource for Timelines {
|
||||
fn resolve_account(&self, name: &str, tag: &str) -> Result<Account, SourceError> {
|
||||
TwoAccounts { more: false }.resolve_account(name, tag)
|
||||
}
|
||||
|
||||
fn match_ids(
|
||||
&self,
|
||||
puuid: &str,
|
||||
queue_id: u32,
|
||||
start: usize,
|
||||
count: usize,
|
||||
since: Option<i64>,
|
||||
) -> Result<Vec<String>, SourceError> {
|
||||
TwoAccounts { more: false }.match_ids(puuid, queue_id, start, count, since)
|
||||
}
|
||||
|
||||
fn fetch_match(&self, id: &str) -> Result<String, SourceError> {
|
||||
let payload = TwoAccounts { more: false }.fetch_match(id)?;
|
||||
// The Redemption item of Arena, in the first slot of every player of the full recap.
|
||||
Ok(payload.replace("\"item0\": 3157", "\"item0\": 223107"))
|
||||
}
|
||||
|
||||
fn fetch_timeline(&self, id: &str) -> Result<String, SourceError> {
|
||||
self.asked.lock().unwrap().push(id.into());
|
||||
let mut script = self.script.lock().unwrap();
|
||||
match *script {
|
||||
Script::Serve => Ok(TIMELINE.into()),
|
||||
Script::Refuse => Err(SourceError::InvalidKey),
|
||||
Script::Fail(n) => {
|
||||
*script = if n > 1 {
|
||||
Script::Fail(n - 1)
|
||||
} else {
|
||||
Script::Serve
|
||||
};
|
||||
Err(SourceError::Network("hors ligne".into()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A cache whose augment 212 is the one the timeline names, and with the item the exceptions
|
||||
/// table matches.
|
||||
fn cache(dir: &TestDir) -> GameData {
|
||||
std::fs::write(
|
||||
dir.path().join("catalog.json"),
|
||||
r#"{"version": "16.22.1", "icons_complete": true,
|
||||
"items": [{"id": 223107, "name": "Rédemption", "icon": ""}],
|
||||
"augments": [{"id": 212, "name_id": "Augment_Foxfire_Spell", "name": "Renard de feu",
|
||||
"rarity": null, "icon": ""}]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
GameData::new(dir.path().to_owned())
|
||||
}
|
||||
|
||||
struct Opened {
|
||||
page: Entity<Page>,
|
||||
window: VisualTestContext,
|
||||
asked: Arc<Mutex<Vec<String>>>,
|
||||
}
|
||||
|
||||
impl Opened {
|
||||
fn asked(&self, id: &str) -> usize {
|
||||
self.asked
|
||||
.lock()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.filter(|a| *a == id)
|
||||
.count()
|
||||
}
|
||||
|
||||
fn damage_of(&mut self, name: &str) -> ShownDamage {
|
||||
self.page.read_with(&self.window, |p, _| {
|
||||
let shown = p.matches.shown().unwrap();
|
||||
(shown.teams.iter().flat_map(|t| t.players.iter()))
|
||||
.find(|player| player.riot_id.text.starts_with(name))
|
||||
.unwrap()
|
||||
.damage_seen
|
||||
.clone()
|
||||
})
|
||||
}
|
||||
|
||||
/// The Death Recap of the Match opened is known, or its fetch failed.
|
||||
async fn settled(&mut self, cx: &mut TestAppContext) {
|
||||
cx.condition(&self.page, |p, _| {
|
||||
matches!(p.matches.death(), Some(Death::Known(_) | Death::Failed))
|
||||
})
|
||||
.await;
|
||||
draw(&mut self.window);
|
||||
}
|
||||
|
||||
/// The Death Recap of the Match opened is stored or refused.
|
||||
async fn known(&mut self, cx: &mut TestAppContext) {
|
||||
cx.condition(&self.page, |p, _| {
|
||||
matches!(p.matches.death(), Some(Death::Known(_)))
|
||||
})
|
||||
.await;
|
||||
draw(&mut self.window);
|
||||
}
|
||||
|
||||
/// Chooses the Match in `row` of the list, once the one before has settled.
|
||||
async fn open_row(&mut self, cx: &mut TestAppContext, row: usize) {
|
||||
let at = center(&mut self.window, ROWS[row]);
|
||||
self.window.simulate_click(at, Modifiers::none());
|
||||
draw(&mut self.window);
|
||||
recap_ready(&self.page, cx).await;
|
||||
self.settled(cx).await;
|
||||
}
|
||||
|
||||
/// Unfolds the player whose Riot ID starts with `name`.
|
||||
fn unfold(&mut self, name: &str) {
|
||||
let ix = self.page.read_with(&self.window, |p, _| {
|
||||
let shown = p.matches.shown().unwrap();
|
||||
(shown.teams.iter().flat_map(|t| t.players.iter()))
|
||||
.position(|player| player.riot_id.text.starts_with(name))
|
||||
.unwrap()
|
||||
});
|
||||
let at = center(&mut self.window, LINES[ix]);
|
||||
self.window.simulate_click(at, Modifiers::none());
|
||||
draw(&mut self.window);
|
||||
}
|
||||
|
||||
/// The Riot ID of the first player of the recap.
|
||||
fn first_player(&mut self) -> String {
|
||||
self.page.read_with(&self.window, |p, _| {
|
||||
let shown = p.matches.shown().unwrap();
|
||||
shown.teams[0].players[0].riot_id.text.to_string()
|
||||
})
|
||||
}
|
||||
|
||||
fn shown_section(&mut self) -> bool {
|
||||
self.window.debug_bounds("death-recap").is_some()
|
||||
}
|
||||
}
|
||||
|
||||
/// « Parties » on Alice's Matches, the most recent chosen and its Death Recap settled.
|
||||
async fn open(cx: &mut TestAppContext, script: Script, data: Option<GameData>) -> Opened {
|
||||
cx.executor().allow_parking();
|
||||
let (script, asked) = (Arc::new(Mutex::new(script)), Arc::default());
|
||||
let signed_in = Arc::new(Mutex::new("Alice".to_string()));
|
||||
let tracker = Tracker::open(
|
||||
Path::new(":memory:"),
|
||||
Box::new(Timelines {
|
||||
script,
|
||||
asked: Arc::clone(&asked),
|
||||
}),
|
||||
)
|
||||
.unwrap()
|
||||
.with_seasons(Vec::new())
|
||||
.with_client(Box::new(Lobby(signed_in)));
|
||||
tracker.sync("Bob#EUW", &mut |_| {}).unwrap();
|
||||
tracker.follow_client(0, None, &mut |_| {});
|
||||
let named = data.is_some();
|
||||
let (page, window) = open_page_launched(cx, tracker, None, data);
|
||||
let mut opened = Opened {
|
||||
page,
|
||||
window,
|
||||
asked,
|
||||
};
|
||||
switch_tab(&opened.page, &mut opened.window, Tab::Matches);
|
||||
if named {
|
||||
cx.condition(&opened.page, |p, _| !p.matches.catalog().is_empty())
|
||||
.await;
|
||||
}
|
||||
recap_ready(&opened.page, cx).await;
|
||||
opened.settled(cx).await;
|
||||
opened
|
||||
}
|
||||
|
||||
fn line(name: &str, total: &str, types: &str) -> (String, String, String) {
|
||||
(name.into(), total.into(), types.into())
|
||||
}
|
||||
|
||||
fn lines(damage: ShownDamage) -> Vec<(String, String, String)> {
|
||||
match damage {
|
||||
ShownDamage::Seen(lines) => lines
|
||||
.into_iter()
|
||||
.map(|l| (l.name.to_string(), l.total.to_string(), l.types.to_string()))
|
||||
.collect(),
|
||||
other => panic!("no lines: {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn each_effect_is_counted_once_for_the_player_who_dealt_it(cx: &mut TestAppContext) {
|
||||
let dir = TestDir::new("death-recap");
|
||||
let mut app = open(cx, Script::Serve, Some(cache(&dir))).await;
|
||||
// The most recent Match was fetched on its first opening; the older one is opened now.
|
||||
assert_eq!(app.asked(FIRST), 1);
|
||||
app.open_row(cx, 2).await;
|
||||
assert_eq!(app.asked(FULL), 1);
|
||||
|
||||
// The augment by its `augmentNameId`, the item by the exceptions table, most damaging
|
||||
// first (180.4 and 120.25 over two kills, rounded after the sum), the rest under
|
||||
// « Autres effets » (a basic attack, and an effect that is not one of the player's).
|
||||
assert_eq!(
|
||||
lines(app.damage_of("Joueur")),
|
||||
[
|
||||
line("Renard de feu", "180", "Magiques 180"),
|
||||
line("Rédemption", "120", "Magiques 120"),
|
||||
line(OTHERS, "83", "Physiques 50 · Magiques 33"),
|
||||
]
|
||||
);
|
||||
// A champion spell and an effect they do not own: only « Autres effets »; the minion
|
||||
// that is not a player is nobody's.
|
||||
assert_eq!(
|
||||
lines(app.damage_of("Autre01")),
|
||||
[line(OTHERS, "125", "Magiques 125")]
|
||||
);
|
||||
// Nothing dealt in the recaps that were fetched.
|
||||
assert_eq!(app.damage_of("Autre03"), ShownDamage::Note(NONE_SEEN));
|
||||
|
||||
// Drawn for the player unfolded only.
|
||||
assert!(!app.shown_section());
|
||||
app.unfold("Joueur");
|
||||
assert!(app.shown_section());
|
||||
|
||||
// Opening them again asks for nothing: stored.
|
||||
app.open_row(cx, 0).await;
|
||||
app.open_row(cx, 2).await;
|
||||
assert_eq!((app.asked(FIRST), app.asked(FULL)), (1, 1));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn a_refusal_is_unavailable_and_never_asked_again(cx: &mut TestAppContext) {
|
||||
let mut app = open(cx, Script::Refuse, None).await;
|
||||
assert_eq!(
|
||||
app.page
|
||||
.read_with(&app.window, |p, _| p.matches.death().cloned()),
|
||||
Some(Death::Known(DeathRecapState::Refused))
|
||||
);
|
||||
for player in ["Joueur", "Autre01"] {
|
||||
assert_eq!(app.damage_of(player), ShownDamage::Note(UNAVAILABLE));
|
||||
}
|
||||
app.open_row(cx, 2).await;
|
||||
app.open_row(cx, 0).await;
|
||||
app.open_row(cx, 2).await;
|
||||
assert_eq!((app.asked(FIRST), app.asked(FULL)), (1, 1));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn a_failure_offers_to_try_again_and_stores_nothing(cx: &mut TestAppContext) {
|
||||
let mut app = open(cx, Script::Fail(1), None).await;
|
||||
assert_eq!(
|
||||
app.page
|
||||
.read_with(&app.window, |p, _| p.matches.death().cloned()),
|
||||
Some(Death::Failed)
|
||||
);
|
||||
assert_eq!(app.damage_of("Joueur"), ShownDamage::Retry);
|
||||
// The player's details have the button, and the request is asked once more.
|
||||
// The first player: the section is on screen without scrolling.
|
||||
let first = app.first_player();
|
||||
app.unfold(&first);
|
||||
assert!(app.window.debug_bounds("death-recap-retry").is_some());
|
||||
let at = center(&mut app.window, "death-recap-retry");
|
||||
app.window.simulate_click(at, Modifiers::none());
|
||||
draw(&mut app.window);
|
||||
app.known(cx).await;
|
||||
assert_eq!(app.asked(FIRST), 2);
|
||||
assert!(matches!(
|
||||
app.page
|
||||
.read_with(&app.window, |p, _| p.matches.death().cloned()),
|
||||
Some(Death::Known(DeathRecapState::Stored(_)))
|
||||
));
|
||||
assert!(app.window.debug_bounds("death-recap-retry").is_none());
|
||||
assert_ne!(app.damage_of("Joueur"), ShownDamage::Retry);
|
||||
assert_eq!(
|
||||
app.page.read_with(&app.window, |p, _| p
|
||||
.matches
|
||||
.death_fetching()
|
||||
.map(String::from)),
|
||||
None
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn a_failed_match_is_asked_again_when_opened_again(cx: &mut TestAppContext) {
|
||||
let mut app = open(cx, Script::Fail(1), None).await;
|
||||
assert_eq!(app.damage_of("Joueur"), ShownDamage::Retry);
|
||||
// Another Match, then this one again: nothing was stored.
|
||||
app.open_row(cx, 2).await;
|
||||
app.open_row(cx, 0).await;
|
||||
assert_eq!(app.asked(FIRST), 2);
|
||||
assert!(matches!(
|
||||
app.page
|
||||
.read_with(&app.window, |p, _| p.matches.death().cloned()),
|
||||
Some(Death::Known(DeathRecapState::Stored(_)))
|
||||
));
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn the_followers_fetch_shows_in_the_recap_open(cx: &mut TestAppContext) {
|
||||
let mut app = open(cx, Script::Fail(1), None).await;
|
||||
assert_eq!(app.damage_of("Joueur"), ShownDamage::Retry);
|
||||
// The background thread of the queue fetched it meanwhile, and says so.
|
||||
app.page.update(&mut app.window, |page, _| {
|
||||
let Recap::Ready { recap, .. } = &page.matches.recap else {
|
||||
panic!("no recap");
|
||||
};
|
||||
page.tracker
|
||||
.fetch_death_recap(recap, &GameCatalog::default())
|
||||
.unwrap();
|
||||
});
|
||||
app.window.update(|window, cx| {
|
||||
app.page.update(cx, |page, cx| {
|
||||
page.apply(Msg::DeathRecapStored(FIRST.into()), window, cx)
|
||||
})
|
||||
});
|
||||
app.known(cx).await;
|
||||
assert!(!matches!(app.damage_of("Joueur"), ShownDamage::Retry));
|
||||
// Nobody asked Riot again from the page.
|
||||
assert_eq!(app.asked(FIRST), 2);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn a_new_catalog_matches_the_stored_recaps_again(cx: &mut TestAppContext) {
|
||||
// No names yet: the item still matches by the exceptions table, the augment cannot.
|
||||
let mut app = open(cx, Script::Serve, None).await;
|
||||
app.open_row(cx, 2).await;
|
||||
assert_eq!(
|
||||
lines(app.damage_of("Joueur")),
|
||||
[
|
||||
line("Objet 223107", "120", "Magiques 120"),
|
||||
line(OTHERS, "263", "Physiques 50 · Magiques 213"),
|
||||
]
|
||||
);
|
||||
let dir = TestDir::new("death-recap-later");
|
||||
let catalog = Arc::new(cache(&dir).load());
|
||||
app.window.update(|window, cx| {
|
||||
app.page.update(cx, |page, cx| {
|
||||
page.apply(Msg::GameData(catalog), window, cx)
|
||||
})
|
||||
});
|
||||
cx.condition(&app.page, |p, _| {
|
||||
p.matches.shown().is_some_and(|shown| {
|
||||
(shown.teams.iter().flat_map(|t| t.players.iter()))
|
||||
.any(|player| matches!(&player.damage_seen, ShownDamage::Seen(l) if l.len() == 3))
|
||||
})
|
||||
})
|
||||
.await;
|
||||
assert_eq!(
|
||||
lines(app.damage_of("Joueur"))[0],
|
||||
line("Renard de feu", "180", "Magiques 180")
|
||||
);
|
||||
// Nothing more was asked of Riot.
|
||||
assert_eq!((app.asked(FIRST), app.asked(FULL)), (1, 1));
|
||||
}
|
||||
@@ -172,7 +172,9 @@ async fn the_keyboard_unfolds_and_folds_without_the_mouse(cx: &mut TestAppContex
|
||||
assert!(cx.debug_bounds("recap-details").is_none());
|
||||
press_key(cx, "space");
|
||||
assert_eq!(unfolded(&page, cx), Some(1));
|
||||
// Tab reaches the next line, Enter unfolds it in place of the first.
|
||||
// Tab reaches « Réessayer » of its Death Recap (the source has no timeline), then the next
|
||||
// line; Enter unfolds it in place of the first.
|
||||
press_key(cx, "tab");
|
||||
press_key(cx, "tab");
|
||||
press_key(cx, "enter");
|
||||
assert_eq!(unfolded(&page, cx), Some(2));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::page_fixtures::{MATCH_1750, draw, open_page_with_tracker, switch_tab};
|
||||
use crate::page::matches::Recap;
|
||||
use crate::page::matches::{Death, Recap};
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::worker::Msg;
|
||||
use arena_tracker_core::{
|
||||
@@ -159,10 +159,13 @@ pub(super) async fn open_matches(cx: &mut TestAppContext) -> (Entity<Page>, Visu
|
||||
(page, window)
|
||||
}
|
||||
|
||||
/// Waits for the list and the recap of the Match chosen.
|
||||
/// Waits for the list and the recap of the Match chosen, and for its Death Recap to be asked
|
||||
/// of Riot (in these fixtures the source has no timeline: « Réessayer »).
|
||||
pub(super) async fn recap_ready(page: &Entity<Page>, cx: &mut TestAppContext) {
|
||||
cx.condition(page, |p, _| {
|
||||
p.matches.entries().is_some() && matches!(p.matches.recap, Recap::Ready { .. })
|
||||
p.matches.entries().is_some()
|
||||
&& matches!(p.matches.recap, Recap::Ready { .. })
|
||||
&& p.matches.death() != Some(&Death::Loading)
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ async fn open_full_recap(
|
||||
cx: &mut TestAppContext,
|
||||
window: &mut VisualTestContext,
|
||||
) {
|
||||
// The list is read on a worker: its rows are there once it has arrived.
|
||||
cx.condition(page, |p, _| p.matches.entries().is_some())
|
||||
.await;
|
||||
draw(window);
|
||||
let at = center(window, "match-row-2");
|
||||
window.simulate_click(at, Modifiers::none());
|
||||
draw(window);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use super::matches_fixtures::{TwoAccounts, recap_ready};
|
||||
use super::page_fixtures::{center, draw, open_page_with_tracker, switch_tab};
|
||||
use crate::page::matches::{PENDING, Recap};
|
||||
use crate::page::matches::{PENDING, Recap, ShownDamage};
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::worker::Msg;
|
||||
use arena_tracker_core::{
|
||||
@@ -173,12 +173,15 @@ async fn a_provisional_match_has_its_badge_and_waits_for_its_values(cx: &mut Tes
|
||||
page.read_with(&window, |p, _| {
|
||||
let shown = p.matches.shown().unwrap();
|
||||
assert!(shown.provisional);
|
||||
assert_eq!(p.matches.death_fetching(), None);
|
||||
// What the block does not give is waited for, never « Indisponible ».
|
||||
let mut missing = Vec::new();
|
||||
for team in &shown.teams {
|
||||
missing.extend(team.placement.missing.then_some(&team.placement));
|
||||
for player in &team.players {
|
||||
missing.extend([&player.riot_id, &player.level, &player.damage]);
|
||||
// No timeline yet: waited for too, and not asked for.
|
||||
assert_eq!(player.damage_seen, ShownDamage::Note(PENDING));
|
||||
for group in &player.details.0 {
|
||||
missing.extend(group.measures.iter().map(|m| &m.value));
|
||||
}
|
||||
|
||||
@@ -79,6 +79,7 @@ fn fail(page: &gpui_kit::Entity<crate::page::Page>, cx: &mut gpui_kit::VisualTes
|
||||
Msg::Recap {
|
||||
generation,
|
||||
recap: Box::new(Err("base verrouillée".into())),
|
||||
death: Box::new(Ok(arena_tracker_core::DeathRecapState::NotFetched)),
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
|
||||
@@ -103,7 +103,17 @@ impl Page {
|
||||
generation,
|
||||
matches,
|
||||
} => self.apply_matches(generation, matches, cx),
|
||||
Msg::Recap { generation, recap } => self.apply_recap(generation, *recap, cx),
|
||||
Msg::Recap {
|
||||
generation,
|
||||
recap,
|
||||
death,
|
||||
} => self.apply_recap(generation, *recap, *death, cx),
|
||||
Msg::DeathRecap {
|
||||
match_id,
|
||||
fetched,
|
||||
result,
|
||||
} => self.apply_death_recap(match_id, fetched, result, cx),
|
||||
Msg::DeathRecapStored(match_id) => self.death_recap_stored(&match_id),
|
||||
Msg::Crashed => self.mark_crashed(),
|
||||
Msg::RefreshCrashed => {
|
||||
self.refresh.reset();
|
||||
|
||||
@@ -9,14 +9,17 @@ use std::thread;
|
||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use arena_tracker_core::{
|
||||
ChampSelect, ClientEvent, GameCatalog, GameClientSource, GameData, LeagueClient, MatchRecap,
|
||||
Scope, Statistics, Status, SyncProgress, Tracker, UpdateChannel,
|
||||
ChampSelect, ClientEvent, DeathRecapState, GameCatalog, GameClientSource, GameData,
|
||||
LeagueClient, MatchRecap, Scope, Statistics, Status, SyncProgress, Tracker, UpdateChannel,
|
||||
};
|
||||
use gpui_kit::base::async_util::Sender;
|
||||
|
||||
mod death_recap;
|
||||
pub(crate) mod game_data;
|
||||
mod matches;
|
||||
|
||||
pub use death_recap::spawn_death_recap;
|
||||
use death_recap::spawn_death_recap_queue;
|
||||
pub use game_data::spawn_game_catalog;
|
||||
use game_data::spawn_game_data_refresh;
|
||||
pub use matches::{MatchEntry, spawn_match_list, spawn_recap};
|
||||
@@ -56,7 +59,17 @@ pub enum Msg {
|
||||
Recap {
|
||||
generation: u64,
|
||||
recap: Box<Result<Option<MatchRecap>, String>>,
|
||||
/// What is stored of its Death Recap (#128), read with it.
|
||||
death: Box<Result<DeathRecapState, String>>,
|
||||
},
|
||||
/// The Death Recap of a Match, read (`fetched`: after asking Riot if it was never fetched).
|
||||
DeathRecap {
|
||||
match_id: String,
|
||||
fetched: bool,
|
||||
result: Result<DeathRecapState, String>,
|
||||
},
|
||||
/// The follower's queue fetched the Death Recap of a Match it published: stored or refused.
|
||||
DeathRecapStored(String),
|
||||
/// The names and icons of the items and augments, read again from the cache on disk.
|
||||
GameData(Arc<GameCatalog>),
|
||||
/// A worker thread panicked.
|
||||
@@ -225,6 +238,7 @@ pub fn spawn_follower(
|
||||
game_data: Option<GameData>,
|
||||
tx: Sender<Msg>,
|
||||
) {
|
||||
spawn_death_recap_queue(tracker.clone(), tx.clone());
|
||||
let champions = tracker.clone();
|
||||
spawn_guarded(tx.clone(), Msg::Crashed, move |tx| {
|
||||
let mut throttle = Throttle::new(ART_TOLD_EVERY);
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
//! The Death Recaps of « Parties » (#128): one job for the Match opened, which reads what is
|
||||
//! stored or asks Riot for the timeline, and the thread that serves the followed Matches the
|
||||
//! core queues when they are published. Both run below normal priority: a timeline request
|
||||
//! waits on the shared limiter and on `Retry-After`.
|
||||
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use arena_tracker_core::{DeathRecapState, GameCatalog, MatchRecap, Tracker};
|
||||
use gpui_kit::base::async_util::Sender;
|
||||
|
||||
use super::{Msg, spawn_guarded};
|
||||
|
||||
/// How long the queue's thread sleeps before it looks again that the page is still there: it
|
||||
/// is woken by a published Match, never by a timer.
|
||||
const WAIT: Duration = Duration::from_secs(60);
|
||||
|
||||
/// Reads the Death Recap of `recap`, asking Riot first when `fetch` and it was never fetched
|
||||
/// (the first opening of a Match, and « Réessayer »). Always reports, a panic as an error.
|
||||
pub fn spawn_death_recap(
|
||||
tracker: Arc<Tracker>,
|
||||
recap: MatchRecap,
|
||||
catalog: Arc<GameCatalog>,
|
||||
fetch: bool,
|
||||
tx: Sender<Msg>,
|
||||
) {
|
||||
spawn_guarded(tx, Msg::Crashed, move |tx| {
|
||||
let result = catch_unwind(AssertUnwindSafe(|| {
|
||||
death_recap(&tracker, &recap, &catalog, fetch)
|
||||
}))
|
||||
.unwrap_or_else(|_| Err("erreur interne".into()));
|
||||
let _ = tx.try_send(Msg::DeathRecap {
|
||||
match_id: recap.match_id,
|
||||
fetched: fetch,
|
||||
result,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn death_recap(
|
||||
tracker: &Tracker,
|
||||
recap: &MatchRecap,
|
||||
catalog: &GameCatalog,
|
||||
fetch: bool,
|
||||
) -> Result<DeathRecapState, String> {
|
||||
let state = if fetch {
|
||||
tracker.fetch_death_recap(recap, catalog)
|
||||
} else {
|
||||
tracker.death_recap(recap, catalog)
|
||||
};
|
||||
state.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Fetches the Death Recaps of the Matches the follower publishes, one request at a time, for
|
||||
/// as long as the page listens. The page is told of each one stored, so an open recap shows it.
|
||||
pub fn spawn_death_recap_queue(tracker: Arc<Tracker>, tx: Sender<Msg>) {
|
||||
spawn_guarded(tx, Msg::Crashed, move |tx| {
|
||||
while !tx.is_closed() {
|
||||
serve_next(&tracker, WAIT, tx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Waits up to `wait` for a queued Match and fetches it; the page is told when it is stored. A
|
||||
/// failure tells nothing: nothing changed, and the first opening of the Match asks again.
|
||||
fn serve_next(tracker: &Tracker, wait: Duration, tx: &Sender<Msg>) {
|
||||
if let Some(done) = tracker.fetch_next_queued_death_recap(wait)
|
||||
&& done.result.is_ok()
|
||||
{
|
||||
let _ = tx.try_send(Msg::DeathRecapStored(done.match_id));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use arena_tracker_core::{Account, MatchHistorySource, SourceError};
|
||||
use gpui_kit::base::async_util::unbounded;
|
||||
use std::path::Path;
|
||||
|
||||
struct Silent;
|
||||
|
||||
impl MatchHistorySource for Silent {
|
||||
fn resolve_account(&self, name: &str, tag: &str) -> Result<Account, SourceError> {
|
||||
Ok(Account {
|
||||
puuid: name.into(),
|
||||
game_name: name.into(),
|
||||
tag_line: tag.into(),
|
||||
})
|
||||
}
|
||||
|
||||
fn match_ids(
|
||||
&self,
|
||||
_: &str,
|
||||
_: u32,
|
||||
_: usize,
|
||||
_: usize,
|
||||
_: Option<i64>,
|
||||
) -> Result<Vec<String>, SourceError> {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn fetch_match(&self, _: &str) -> Result<String, SourceError> {
|
||||
Err(SourceError::NotFound)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_empty_queue_tells_the_page_nothing() {
|
||||
let tracker = Tracker::open(Path::new(":memory:"), Box::new(Silent)).unwrap();
|
||||
let (tx, rx) = unbounded();
|
||||
serve_next(&tracker, Duration::from_millis(1), &tx);
|
||||
assert!(rx.try_recv().is_err());
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind};
|
||||
use std::sync::Arc;
|
||||
|
||||
use arena_tracker_core::{Format, Tracker};
|
||||
use arena_tracker_core::{DeathRecapState, Format, GameCatalog, Tracker};
|
||||
use gpui_kit::base::async_util::Sender;
|
||||
|
||||
use super::{Msg, spawn_guarded};
|
||||
@@ -65,26 +65,53 @@ pub fn spawn_match_list(tracker: Arc<Tracker>, puuid: String, generation: u64, t
|
||||
});
|
||||
}
|
||||
|
||||
/// Decodes the Match Recap of one Match of `puuid`: only the Match opened is decoded.
|
||||
/// Decodes the Match Recap of one Match of `puuid`: only the Match opened is decoded. Its Death
|
||||
/// Recap, as far as it is stored, is read with it (a read of the database, nothing asked of
|
||||
/// Riot), matched to the items and augments of `catalog`.
|
||||
pub fn spawn_recap(
|
||||
tracker: Arc<Tracker>,
|
||||
puuid: String,
|
||||
match_id: String,
|
||||
catalog: Arc<GameCatalog>,
|
||||
generation: u64,
|
||||
tx: Sender<Msg>,
|
||||
) {
|
||||
spawn_guarded(tx, Msg::Crashed, move |tx| {
|
||||
let recap = catch_unwind(AssertUnwindSafe(|| {
|
||||
(tracker.match_recap(&puuid, &match_id)).map_err(|e| e.to_string())
|
||||
let (recap, death) = catch_unwind(AssertUnwindSafe(|| {
|
||||
recap_and_death(&tracker, &puuid, &match_id, &catalog)
|
||||
}))
|
||||
.unwrap_or_else(|_| Err("erreur interne".into()));
|
||||
.unwrap_or_else(|_| (Err("erreur interne".into()), Err("erreur interne".into())));
|
||||
let _ = tx.try_send(Msg::Recap {
|
||||
generation,
|
||||
recap: Box::new(recap),
|
||||
death: Box::new(death),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
type Decoded = (
|
||||
Result<Option<arena_tracker_core::MatchRecap>, String>,
|
||||
Result<DeathRecapState, String>,
|
||||
);
|
||||
|
||||
fn recap_and_death(
|
||||
tracker: &Tracker,
|
||||
puuid: &str,
|
||||
match_id: &str,
|
||||
catalog: &GameCatalog,
|
||||
) -> Decoded {
|
||||
let recap = tracker
|
||||
.match_recap(puuid, match_id)
|
||||
.map_err(|e| e.to_string());
|
||||
let death = match &recap {
|
||||
Ok(Some(recap)) => tracker
|
||||
.death_recap(recap, catalog)
|
||||
.map_err(|e| e.to_string()),
|
||||
_ => Ok(DeathRecapState::NotFetched),
|
||||
};
|
||||
(recap, death)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::match_list;
|
||||
|
||||
@@ -8,7 +8,7 @@ Au début d’une Sélection des champions Arena, l’onglet **Sélection** appa
|
||||
|
||||
## Parties
|
||||
|
||||
L’onglet **Parties** liste vos Parties enregistrées, de la plus récente à la plus ancienne, pour le Compte du Défi (celui connecté au client, ou le dernier connu). Chaque ligne montre le champion, la date et l’heure, et le Placement. Au-dessus de la liste, des filtres se combinent : la **Saison** (la Saison actuelle par défaut, ou toutes les Saisons s’il n’y en a pas) et le **Format**, les mêmes sélecteurs que sur **Statistiques** : en changer sur une page le change sur l’autre ; le **Placement** (**Tous**, **Top 1** ou **Victoires**, les Parties que le jeu compte comme gagnées) ; et une recherche de champion, comme sur l’accueil (nom, abréviation connue comme « TF », sans tenir compte des accents ni des majuscules). Le Placement et la recherche sont gardés tant que l’appli reste ouverte. Si aucune Partie ne correspond, la liste le dit et le récapitulatif reste vide. À l’ouverture, la Partie la plus récente que les filtres laissent est choisie et son récapitulatif s’affiche à côté : les équipes rangées par Placement, votre ligne encadrée d’or, et pour chaque joueur son Riot ID, son niveau, son K/D/A, ses objets, ses améliorations et ses dégâts aux champions. Les objets et les améliorations montrent leur icône et leur nom (au survol pour un objet), tels que le client les donne ; sans eux (client jamais ouvert, objet récent), une icône neutre et « Objet n » ou « Amélioration n ». Ces noms et icônes sont gardés sur le disque : ils restent lisibles client fermé, et se renouvellent à l’ouverture du client après une mise à jour du jeu. Cliquez une autre Partie, ou parcourez la liste avec les flèches haut et bas. Cliquez la ligne d’un joueur (ou atteignez-la avec Tab, puis Entrée ou Espace) pour déplier ses détails : dégâts aux champions et reçus par type, dégâts atténués, soins et boucliers sur les alliés, or gagné et dépensé, contrôle ; recliquez pour les replier. Les totaux sont ceux de Riot, tels quels. Une valeur que Riot ne donne pas s’affiche « Indisponible ». Dans une fenêtre étroite, la liste et ses filtres s’ouvrent avec le bouton **Parties** au-dessus du récapitulatif. Si la Partie affichée n’est plus laissée par un filtre, la première Partie de la liste prend sa place.
|
||||
L’onglet **Parties** liste vos Parties enregistrées, de la plus récente à la plus ancienne, pour le Compte du Défi (celui connecté au client, ou le dernier connu). Chaque ligne montre le champion, la date et l’heure, et le Placement. Au-dessus de la liste, des filtres se combinent : la **Saison** (la Saison actuelle par défaut, ou toutes les Saisons s’il n’y en a pas) et le **Format**, les mêmes sélecteurs que sur **Statistiques** : en changer sur une page le change sur l’autre ; le **Placement** (**Tous**, **Top 1** ou **Victoires**, les Parties que le jeu compte comme gagnées) ; et une recherche de champion, comme sur l’accueil (nom, abréviation connue comme « TF », sans tenir compte des accents ni des majuscules). Le Placement et la recherche sont gardés tant que l’appli reste ouverte. Si aucune Partie ne correspond, la liste le dit et le récapitulatif reste vide. À l’ouverture, la Partie la plus récente que les filtres laissent est choisie et son récapitulatif s’affiche à côté : les équipes rangées par Placement, votre ligne encadrée d’or, et pour chaque joueur son Riot ID, son niveau, son K/D/A, ses objets, ses améliorations et ses dégâts aux champions. Les objets et les améliorations montrent leur icône et leur nom (au survol pour un objet), tels que le client les donne ; sans eux (client jamais ouvert, objet récent), une icône neutre et « Objet n » ou « Amélioration n ». Ces noms et icônes sont gardés sur le disque : ils restent lisibles client fermé, et se renouvellent à l’ouverture du client après une mise à jour du jeu. Cliquez une autre Partie, ou parcourez la liste avec les flèches haut et bas. Cliquez la ligne d’un joueur (ou atteignez-la avec Tab, puis Entrée ou Espace) pour déplier ses détails : dégâts aux champions et reçus par type, dégâts atténués, soins et boucliers sur les alliés, or gagné et dépensé, contrôle ; recliquez pour les replier. Les totaux sont ceux de Riot, tels quels. Une valeur que Riot ne donne pas s’affiche « Indisponible ». Sous ces valeurs, la section **Dégâts observés dans les récaps de mort** détaille, par objet et par amélioration du joueur (puis « Autres effets »), les dégâts que les récaps de mort des champions éliminés lui attribuent : c’est la seule source de dégâts par effet, si bien que les dégâts infligés à un champion qui survit n’y figurent jamais et que le total de la Partie par effet reste indisponible. Les récaps sont récupérés chez Riot une fois par Partie, à la fin d’une Partie suivie ou à la première ouverture d’une Partie plus ancienne ; une Partie provisoire affiche « En attente », une Partie dont Riot refuse les récaps « Indisponible », et en cas d’échec passager le bouton **Réessayer** les redemande. Dans une fenêtre étroite, la liste et ses filtres s’ouvrent avec le bouton **Parties** au-dessus du récapitulatif. Si la Partie affichée n’est plus laissée par un filtre, la première Partie de la liste prend sa place.
|
||||
|
||||
## Installer
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ L’onglet permanent « Parties », à droite de « Défi » dans la barre du ha
|
||||
- **Récapitulatif.** En tête, le champion du Compte, la date et l’heure, le Format, la durée, et « Provisoire » le cas échéant. Puis les équipes rangées par Placement, celui de l’équipe du Compte en doré, et la ligne du Compte encadrée d’or. Une ligne par joueur : portrait et nom du champion, Riot ID, niveau, K/D/A, dégâts aux champions, puis ses sept emplacements d’objets (un emplacement vide reste vide ; un objet montre son icône, avec son nom au survol) et ses améliorations (une pastille icône et nom). Un identifiant que le catalogue ne connaît pas (ou dont l’icône manque) garde l’icône neutre et le nom « Objet n » ou « Amélioration n ». Les valeurs viennent du JSON Match‑V5 déjà conservé, décodé à l’ouverture de la Partie et jamais pour toute la liste.
|
||||
- **Noms et icônes.** Ils viennent des données de jeu du client local (`/lol-game-data/assets/v1/items.json` et `cherry-augments.json`, dans la langue du client), gardées dans `game-data` du dossier des données : un `catalog.json` (noms, `augmentNameId`, rareté) et les icônes (`items/<id>.png`, `augments/<id>.png`). Le cache se lit une fois au lancement, sur un thread de fond, si bien que les noms et icônes déjà vus s’affichent client fermé. Il se renouvelle quand le client apparaît (au lancement s’il est là, puis à chaque fois qu’un Compte s’y connecte de nouveau), jamais sur minuteur : un thread de fond, en priorité basse, lit la version du jeu et ne télécharge rien si elle n’a pas changé ; sinon il remplace les noms, puis télécharge les icônes manquantes. Chaque fin d’étape relit le cache hors du thread de l’interface et récrit le récapitulatif affiché, sans changer la Partie choisie. Les icônes se chargent hors du thread de l’interface comme les portraits et sont rendues en quittant l’écran.
|
||||
- **Détails d’un joueur.** La ligne d’un joueur est un bouton (chevron à droite) : un clic, ou Entrée ou Espace une fois la ligne atteinte avec Tab, déplie ses détails dessous, un autre clic ou la même touche les replie. Un seul joueur est déplié à la fois ; l’état est gardé tant que la même Partie est décodée de nouveau, et oublié dès qu’on choisit une autre Partie, qu’on quitte l’écran ou qu’on change de Compte. Cinq rangées : « Dégâts aux champions » et « Dégâts reçus » (Total, Physiques, Magiques, Bruts), « Protection » (Dégâts atténués, Soins aux alliés, Boucliers sur les alliés), « Or » (Or gagné, Or dépensé, suivis de « or ») et « Contrôle » (Contrôle infligé, en secondes ou « 1 min 23 s », puis Score de contrôle, le nombre brut de Riot). Dégâts, soins et boucliers sont des points ; les milliers sont séparés par une espace fine insécable. Chaque total est celui que Riot publie, jamais la somme des types : ils peuvent différer. Une valeur absente s’affiche « Indisponible » (« En attente » dans une Partie provisoire), jamais 0 ; 0 n’apparaît que si la source le donne. Les valeurs sont écrites avec le récapitulatif, mais les éléments des détails ne sont construits que pour le joueur déplié : replié, le détail ne coûte rien à l’affichage.
|
||||
- **Dégâts observés dans les récaps de mort.** Sous les cinq rangées des détails d’un joueur, une section titrée « Dégâts observés dans les récaps de mort ». Seule la chronologie Match‑V5 donne des dégâts par effet, et seulement ceux qu’un champion reçoit avant de mourir : chaque entrée de récap de mort est comptée une seule fois, pour le joueur qui l’a infligée et son effet. Les dégâts infligés à un champion qui survit ne sont jamais attribués ; le total de la Partie par effet est indisponible, ce que la section dit une fois, en gris (« Le total de la Partie par effet est indisponible : seuls les dégâts subis avant une élimination sont détaillés. Les dégâts infligés à un champion qui survit ne sont jamais attribués. »). Une ligne par objet ou amélioration du joueur reconnu (icône et nom du catalogue, comme dans le récapitulatif, total des dégâts, puis les types qui ont infligé quelque chose, « Physiques 120 · Magiques 80 »), du plus au moins dommageable, puis « Autres effets » (attaques de base, sorts du champion, effets qui ne sont pas un objet ou une amélioration de sa fin de Partie). La correspondance est automatique quand le nom de l’effet est l’`augmentNameId` d’une amélioration du joueur (sans tenir compte de la casse) ; les objets, et les améliorations dont le nom diffère, passent par une table d’exceptions tenue à la main (`death_recap/exceptions.tsv` du cœur) ; elle est refaite à chaque lecture, si bien qu’un catalogue renouvelé ou une exception ajoutée s’applique aux Parties déjà récupérées. États de la section : « En attente » pour une Partie provisoire (pas de chronologie, rien n’est demandé) ; « Chargement… » pendant la requête ; « Indisponible » quand Riot refuse la chronologie de cette Partie (403, retenu : elle n’est plus redemandée) ; un bouton « Réessayer » avec un message en cas d’échec passager (réseau, limiteur), qui redemande ; « Aucun dégât observé » quand aucune entrée ne nomme ce joueur. La chronologie est récupérée une fois par Partie : en arrière-plan, à basse priorité, dès qu’une nouvelle Partie suivie est publiée ; à la première ouverture du récapitulatif pour une Partie plus ancienne, sans jamais rattraper l’historique en masse ni pendant une synchronisation. Seules les entrées des récaps de mort sont gardées en base, jamais la chronologie. Les requêtes passent par le limiteur existant et respectent `Retry-After`. Le récapitulatif ouvert se relit quand la récupération en arrière-plan de sa Partie se termine.
|
||||
- **Valeurs absentes.** Une valeur que la source ne donne pas s’affiche « Indisponible », en gris ; 0 seulement si la source donne 0. Dans une Partie provisoire, dont la source est le bloc de fin de partie du client, l’absence s’affiche « En attente ».
|
||||
- **Disposition.** La place de la bannière (#110) est réservée en haut, sous le titre « Parties ». Dessous, la liste (≈ 320 px, défilante, sous sa rangée de filtres) et le récapitulatif (défilant) côte à côte. Sous ≈ 900 px de large, la liste passe derrière un bouton « Parties » à chevron qui l’ouvre par-dessus le récapitulatif ; choisir une Partie la referme.
|
||||
- **Synchronisation.** Le bandeau, la ligne d’état et le bouton « Actualiser » de la barre de titre restent ceux des autres pages. Les Parties déjà connues restent consultables pendant la synchronisation et après un échec, qui s’affiche en une ligne au-dessus.
|
||||
|
||||
Reference in new issue
Block a user