Show the Live Match in a tab of its own, « En partie » (#109)
CI / core (pull_request) Successful in 1m50s
CI / core (pull_request) Successful in 1m50s
- The core reads the champion played in the client's gameflow session (champion selections, else the teams, by the summoner's client PUUID) and follows the Live Match from one read to the next: it starts with an Arena game in progress and lasts through that game's end-of-game screen. - The follower tells the page the Live Match on each change, before the champ select's end, so the end of a champ select that launched a game shows « En partie » instead of « Défi », without computing the statistics again. - « En partie »: the banner with the champion's splash, the Season and the count, its tick of the ring lit and the stake (« Un top 1 validerait X : 88 / 172 », or the day it was validated); « Champion en cours d’identification » until the client says it. Under it, the card's sheet and the champion's 5 latest Matches of the Season, read at low priority. - A Live Match is a phase like the champ select: the signed-in Account and the current Season, the Account selector greyed, « Paramètres » closed, and a minimised or hidden window shown again without the focus, never raised. - Its end-of-game block ends it and #129 decides the screen; without a block, the lobby shows « Défi ». A screen gone with its tab falls back to « Défi ». - Tests with the simulated client: launch from the champ select, a client met in a game, the champion identified late, the end with and without a block, a game outside Arena. docs/interface.md and the guide are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0192He3BEKJ9v922udzup4Qn
This commit is contained in:
1 parent
dcb7ac303c
commit
f257c57b27
38 files changed
+1766
-157
No files matched your search
@@ -237,8 +237,8 @@ impl Card {
|
||||
}
|
||||
|
||||
/// The sheet's figures for the Season, all Formats; « — » where there is none (no Season, or no
|
||||
/// Match). The date is only there once the champion is Completed.
|
||||
fn sheet_lines(row: &ChampionRow) -> Vec<(&'static str, SharedString)> {
|
||||
/// Match). The date is only there once the champion is Completed. « En partie » shows them too.
|
||||
pub fn sheet_lines(row: &ChampionRow) -> Vec<(&'static str, SharedString)> {
|
||||
let challenge = row.challenge;
|
||||
let count = |n: Option<usize>| -> SharedString {
|
||||
n.map_or_else(|| NONE.into(), |n| n.to_string().into())
|
||||
|
||||
+21
-2
@@ -35,7 +35,7 @@ use gpui_kit::base::async_util::{Sender, unbounded};
|
||||
use gpui_kit::component::*;
|
||||
use gpui_kit::*;
|
||||
|
||||
use page::{ChampionSortChosen, Launch, Page, RecapOpened};
|
||||
use page::{ChampionSortChosen, Launch, LiveMatchStarted, Page, RecapOpened};
|
||||
use settings::{KeyEvent, KeyForm, KeyStore, apply_theme};
|
||||
use title_bar::{MIN_WINDOW_SIZE, refresh_button, settings_button, title_bar, update_button};
|
||||
use worker::{CatalogRefresh, Msg, spawn_follower};
|
||||
@@ -64,6 +64,7 @@ struct RootView {
|
||||
_form_events: Subscription,
|
||||
_champ_select: Subscription,
|
||||
_recap: Subscription,
|
||||
_live_match: Subscription,
|
||||
_sort: Subscription,
|
||||
}
|
||||
|
||||
@@ -135,7 +136,8 @@ impl RootView {
|
||||
&& let Some(hwnd) = tray::window_hwnd(window)
|
||||
{
|
||||
// Outside this update: the native calls resize the window through GPUI.
|
||||
cx.spawn(async move |_, _| tray::reveal(hwnd)).detach();
|
||||
cx.spawn(async move |_, _| tray::reveal(hwnd, true))
|
||||
.detach();
|
||||
}
|
||||
if this.screen == Screen::Settings {
|
||||
// Champ select takes the window away: do not bring back half-typed edits.
|
||||
@@ -150,6 +152,22 @@ impl RootView {
|
||||
this.show_page(window, cx);
|
||||
}
|
||||
});
|
||||
// A Live Match started: « Paramètres » gives way, and a window minimised or hidden in the
|
||||
// notification area opens again without the focus; unlike a champ select, it is not
|
||||
// brought above the others, the game's included (#109).
|
||||
let live_match = cx.subscribe_in(
|
||||
&page,
|
||||
window,
|
||||
|this, _, _: &LiveMatchStarted, window, cx| {
|
||||
if let Some(hwnd) = tray::window_hwnd(window) {
|
||||
cx.spawn(async move |_, _| tray::reveal(hwnd, false))
|
||||
.detach();
|
||||
}
|
||||
if this.screen == Screen::Settings {
|
||||
this.show_page(window, cx);
|
||||
}
|
||||
},
|
||||
);
|
||||
// Saved with the other preferences; a failure keeps the choice for the session.
|
||||
let sort = cx.subscribe(
|
||||
&page,
|
||||
@@ -190,6 +208,7 @@ impl RootView {
|
||||
_form_events: form_events,
|
||||
_champ_select: champ_select,
|
||||
_recap: recap,
|
||||
_live_match: live_match,
|
||||
_sort: sort,
|
||||
}
|
||||
}
|
||||
|
||||
+27
-10
@@ -1,6 +1,6 @@
|
||||
//! The page and its screens: the shared state. `navigation` switches between them, `display`
|
||||
//! renders the header row and the alerts; `home`, `champ_select`, `statistics` and `matches`
|
||||
//! render the content under them.
|
||||
//! renders the header row and the alerts; `home`, `champ_select`, `in_game`, `statistics` and
|
||||
//! `matches` render the content under them.
|
||||
|
||||
use crate::banner_art::BannerArt;
|
||||
use crate::card::Card;
|
||||
@@ -12,8 +12,8 @@ use crate::ring::Ring;
|
||||
use crate::stage::{Entry, Leave, Taken};
|
||||
use crate::worker::{LiveChampSelect, Msg, RefreshGate};
|
||||
use arena_tracker_core::{
|
||||
Account, ChampionSearch, ChampionSort, Format, Scope, SeasonScope, StateFilter, Statistics,
|
||||
Status, SyncProgress, Tracker,
|
||||
Account, ChampionSearch, ChampionSort, Format, LiveMatch, Scope, SeasonScope, StateFilter,
|
||||
Statistics, Status, SyncProgress, Tracker,
|
||||
};
|
||||
use gpui_kit::base::async_util::Sender;
|
||||
use gpui_kit::component::input::InputState;
|
||||
@@ -33,6 +33,7 @@ mod display;
|
||||
mod displayed;
|
||||
mod home;
|
||||
mod hover;
|
||||
mod in_game;
|
||||
mod lifecycle;
|
||||
mod links;
|
||||
mod matches;
|
||||
@@ -115,9 +116,15 @@ impl EventEmitter<RecapOpened> for Page {}
|
||||
pub struct ChampionSortChosen(pub ChampionSort);
|
||||
impl EventEmitter<ChampionSortChosen> for Page {}
|
||||
|
||||
/// A Live Match started (#109): « Paramètres » gives way, and a window minimised or hidden
|
||||
/// opens again without the focus, the game keeping the keyboard.
|
||||
pub struct LiveMatchStarted;
|
||||
impl EventEmitter<LiveMatchStarted> for Page {}
|
||||
|
||||
/// The screens the page switches between: « Défi » and « Parties » are tabs of the top bar,
|
||||
/// « Statistiques » the Challenge's detail page, opened from the banner, and « Sélection » the
|
||||
/// tab of a phase, there only while an Arena champ select runs.
|
||||
/// « Statistiques » the Challenge's detail page, opened from the banner, and « Sélection » and
|
||||
/// « En partie » the tabs of a phase, there only while an Arena champ select or a Live Match
|
||||
/// runs.
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
enum Tab {
|
||||
/// « Défi », the home: the Challenge of one Season.
|
||||
@@ -128,6 +135,8 @@ enum Tab {
|
||||
Matches,
|
||||
/// « Sélection »: the champ select's banner, its Anvil champions and « Autres champions ».
|
||||
ChampSelect,
|
||||
/// « En partie »: the champion of the Live Match and what it can bring to the Challenge.
|
||||
InGame,
|
||||
}
|
||||
|
||||
/// A followed Match waiting to play: of several, the strongest plays, and the most recent of the
|
||||
@@ -181,10 +190,18 @@ pub struct Page {
|
||||
/// As of the last follower round or refresh.
|
||||
status: Status,
|
||||
champ_select: LiveChampSelect,
|
||||
/// The Account of `champ_select`, resolved when its Riot ID changes.
|
||||
champ_select_account: Option<String>,
|
||||
/// The Riot ID `champ_select_account` was resolved for.
|
||||
champ_select_riot_id: Option<String>,
|
||||
/// The Live Match the client plays (#109): « En partie » is there while it lasts.
|
||||
live_match: Option<LiveMatch>,
|
||||
/// The game whose Live Match became a Match with its end-of-game block: the client stays in
|
||||
/// that game until its lobby, but its tab does not come back.
|
||||
match_over: Option<Option<u64>>,
|
||||
/// What « En partie » shows, prepared when the Live Match or the statistics change.
|
||||
in_game: in_game::InGame,
|
||||
/// The Account of the phase (`champ_select`, else `live_match`), resolved when its Riot ID
|
||||
/// changes.
|
||||
phase_account: Option<String>,
|
||||
/// The Riot ID `phase_account` was resolved for.
|
||||
phase_riot_id: Option<String>,
|
||||
accounts: Vec<Account>,
|
||||
last_active: Option<Account>,
|
||||
/// The Account the user picked instead of following the one being updated.
|
||||
|
||||
@@ -11,19 +11,39 @@ mod motion;
|
||||
mod render;
|
||||
|
||||
impl Page {
|
||||
/// The Account of the live champ select. Resolved when the signed-in Riot ID changes (or the
|
||||
/// Accounts do), so preparing statistics builds no Riot ID per Account every time.
|
||||
pub(in crate::page) fn champ_select_account(&mut self) -> Option<String> {
|
||||
let id = self.champ_select.as_ref().map(|(id, _)| id.as_str())?;
|
||||
if self.champ_select_riot_id.as_deref() != Some(id) {
|
||||
self.champ_select_riot_id = Some(id.into());
|
||||
self.champ_select_account = self
|
||||
/// The Account of the phase: the live champ select's, else the Live Match's. Resolved when
|
||||
/// the signed-in Riot ID changes (or the Accounts do), so preparing statistics builds no
|
||||
/// Riot ID per Account every time.
|
||||
pub(in crate::page) fn phase_account(&mut self) -> Option<String> {
|
||||
let id = (self.champ_select.as_ref().map(|(id, _)| id.as_str()))
|
||||
.or(self.live_match.as_ref().map(|live| live.riot_id.as_str()))?;
|
||||
if self.phase_riot_id.as_deref() != Some(id) {
|
||||
self.phase_riot_id = Some(id.into());
|
||||
self.phase_account = self
|
||||
.accounts
|
||||
.iter()
|
||||
.find(|a| same_riot_id(&account_riot_id(a), id))
|
||||
.map(|a| a.puuid.clone());
|
||||
}
|
||||
self.champ_select_account.clone()
|
||||
self.phase_account.clone()
|
||||
}
|
||||
|
||||
/// The phase's Account and the current Season stand in for the home's, or the home's come
|
||||
/// back: what was computed for the scope left goes while the new one loads.
|
||||
pub(in crate::page) fn rescope(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
// The Account belongs to the signed-in Riot ID: resolve it once, not on every
|
||||
// statistics preparation.
|
||||
self.phase_riot_id = None;
|
||||
self.stats_generation += 1;
|
||||
self.stats = None;
|
||||
self.stats_error = None;
|
||||
self.forget_home();
|
||||
self.stored = None;
|
||||
self.reorder();
|
||||
self.reload_in_background(window, cx);
|
||||
// Nor does the banner keep the previous scope's Challenge while the new one loads: its
|
||||
// Season, its ticks and its splash go with the statistics.
|
||||
self.prepare_banner(cx);
|
||||
}
|
||||
|
||||
/// The champ select the client reports changed: entered, left, another one, or the same
|
||||
@@ -38,6 +58,10 @@ impl Page {
|
||||
let next = champ_select.as_ref();
|
||||
let changed_page = previous.is_some() != next.is_some();
|
||||
let switch = changed_page || previous.map(|(id, _)| id) != next.map(|(id, _)| id);
|
||||
// The game it launched is the same Account's in the same Season: its statistics stay.
|
||||
let launched = next.is_none()
|
||||
&& (previous.zip(self.live_match.as_ref()))
|
||||
.is_some_and(|((id, _), live)| same_riot_id(id, &live.riot_id));
|
||||
self.champ_select = champ_select;
|
||||
if changed_page {
|
||||
if self.in_champ_select() {
|
||||
@@ -59,28 +83,27 @@ impl Page {
|
||||
// An animation asked for during the champ select plays on the home.
|
||||
self.playback.stats_pending = self.playback.active();
|
||||
// The phase decides: « Sélection » goes, and « Défi » shows, from wherever the
|
||||
// player was (under the veil the hand left for, when it left).
|
||||
self.set_tab(Tab::Challenge, window, cx);
|
||||
// player was (under the veil the hand left for, when it left); « En partie »
|
||||
// when the champ select launched the game.
|
||||
let next = if self.in_live_match() {
|
||||
Tab::InGame
|
||||
} else {
|
||||
Tab::Challenge
|
||||
};
|
||||
self.set_tab(next, window, cx);
|
||||
}
|
||||
}
|
||||
if switch {
|
||||
// The Account belongs to the signed-in Riot ID: resolve it once, not on every
|
||||
// statistics preparation.
|
||||
self.champ_select_riot_id = None;
|
||||
self.stats_generation += 1;
|
||||
self.stats = None;
|
||||
self.stats_error = None;
|
||||
self.forget_home();
|
||||
self.stored = None;
|
||||
self.reorder();
|
||||
// A new champ select starts with « Autres champions » folded and searchless, at the
|
||||
// top of the page.
|
||||
self.fold_others(window, cx);
|
||||
self.paging.scroll.set_offset(point(px(0.), px(0.)));
|
||||
self.reload_in_background(window, cx);
|
||||
// Nor does the banner keep the previous scope's Challenge while the new one
|
||||
// loads: its Season, its ticks and its splash go with the statistics.
|
||||
self.prepare_banner(cx);
|
||||
if launched {
|
||||
// Only the banner stops being the champ select's.
|
||||
self.prepare_banner(cx);
|
||||
} else {
|
||||
self.rescope(window, cx);
|
||||
}
|
||||
}
|
||||
if changed_page {
|
||||
cx.emit(ChampSelectTransition {
|
||||
|
||||
@@ -140,11 +140,9 @@ impl Render for Page {
|
||||
Select::new(&self.account_select)
|
||||
.id("account")
|
||||
.placeholder("Aucun Compte")
|
||||
// The champ select and « Parties » are about
|
||||
// the signed-in Account.
|
||||
.disabled(
|
||||
self.in_champ_select() || self.tab == Tab::Matches,
|
||||
)
|
||||
// The phases and « Parties » are about the
|
||||
// signed-in Account.
|
||||
.disabled(self.in_phase() || self.tab == Tab::Matches)
|
||||
.w(px(260.))
|
||||
.min_w(px(150.)),
|
||||
)
|
||||
@@ -184,6 +182,7 @@ impl Render for Page {
|
||||
Tab::Statistics => self.statistics_content(cx),
|
||||
Tab::Matches => self.matches_content(window, cx),
|
||||
Tab::ChampSelect => self.champ_select_content(window, cx),
|
||||
Tab::InGame => self.in_game_content(window, cx),
|
||||
})
|
||||
.when(self.fade.is_some(), |screen| {
|
||||
let veil = cx.theme().background.opacity(self.veil(cx));
|
||||
|
||||
@@ -24,11 +24,11 @@ impl Page {
|
||||
.or(self.accounts.first())
|
||||
}
|
||||
|
||||
/// The Account whose data the page shows: during a champ select the one signed in to the
|
||||
/// client, whatever the pinned or followed one is, else `viewed`.
|
||||
/// The Account whose data the page shows: during a champ select or a Live Match the one
|
||||
/// signed in to the client, whatever the pinned or followed one is, else `viewed`.
|
||||
pub(in crate::page) fn displayed(&self) -> Option<&Account> {
|
||||
if self.in_champ_select() {
|
||||
let puuid = self.champ_select_account.as_deref()?;
|
||||
if self.in_phase() {
|
||||
let puuid = self.phase_account.as_deref()?;
|
||||
return self.accounts.iter().find(|a| a.puuid == puuid);
|
||||
}
|
||||
self.viewed()
|
||||
@@ -51,7 +51,9 @@ impl Page {
|
||||
pub(in crate::page) fn official(&self) -> Option<&ProgressCheck> {
|
||||
let updated = matches!((self.displayed(), &self.status.updating), (Some(v), Some(u)) if v.puuid == u.puuid);
|
||||
let shown = match (self.shown_tab, &self.season) {
|
||||
(Tab::Challenge | Tab::ChampSelect | Tab::Matches, _) => self.home_season.as_deref(),
|
||||
(Tab::Challenge | Tab::ChampSelect | Tab::InGame | Tab::Matches, _) => {
|
||||
self.home_season.as_deref()
|
||||
}
|
||||
(Tab::Statistics, SeasonScope::Season(season)) => Some(season.as_str()),
|
||||
(Tab::Statistics, SeasonScope::AllSeasons) => None,
|
||||
};
|
||||
@@ -62,7 +64,9 @@ impl Page {
|
||||
/// The tab's own statistics error: the home may have computed its own.
|
||||
pub(in crate::page) fn error(&self) -> Option<&String> {
|
||||
match (self.shown_tab, &self.home_scope) {
|
||||
(Tab::Challenge | Tab::ChampSelect | Tab::Matches, Some(_)) => self.home_error.as_ref(),
|
||||
(Tab::Challenge | Tab::ChampSelect | Tab::InGame | Tab::Matches, Some(_)) => {
|
||||
self.home_error.as_ref()
|
||||
}
|
||||
_ => self.stats_error.as_ref(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ mod banner;
|
||||
mod content;
|
||||
mod data;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) use content::IDENTIFYING;
|
||||
pub(in crate::page) use content::{BannerContent, Line};
|
||||
|
||||
use super::{Page, shown};
|
||||
@@ -115,9 +117,9 @@ impl Page {
|
||||
if self.home_season.is_none() {
|
||||
return Some(StatsNotice::NoSeason);
|
||||
}
|
||||
// During a champ select the Account is the one signed in to the client, known by the
|
||||
// follower's status; else it is the one viewed.
|
||||
let no_account = if self.in_champ_select() {
|
||||
// During a champ select or a Live Match the Account is the one signed in to the client,
|
||||
// known by the follower's status; else it is the one viewed.
|
||||
let no_account = if self.in_phase() {
|
||||
self.status.updating.is_none()
|
||||
} else {
|
||||
self.viewed().is_none()
|
||||
@@ -129,8 +131,8 @@ impl Page {
|
||||
})
|
||||
}
|
||||
|
||||
/// The centred column of « Défi » and « Sélection », as wide as the mockup's, with the
|
||||
/// banner on top.
|
||||
/// The centred column of « Défi », « Sélection » and « En partie », as wide as the mockup's,
|
||||
/// with the banner on top.
|
||||
pub(in crate::page) fn banner_column(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
|
||||
@@ -66,8 +66,8 @@ impl Page {
|
||||
.debug_selector(|| "no-season".into())
|
||||
.child(NO_SEASON)
|
||||
});
|
||||
// The champ select's banner is about the champ select only.
|
||||
let link = (self.shown_tab != Tab::ChampSelect).then(|| {
|
||||
// A phase's banner is about the phase only.
|
||||
let link = (!matches!(self.shown_tab, Tab::ChampSelect | Tab::InGame)).then(|| {
|
||||
// At the size of the line it ends. Its padding and border (5 px a side) hang out of
|
||||
// the row, which keeps the text line's height.
|
||||
self.tab_link(
|
||||
@@ -413,29 +413,47 @@ impl Page {
|
||||
self.banner = BannerContent::new(self.home_season.as_ref(), stats);
|
||||
self.champ_select_splashes = splashes;
|
||||
self.ring.update(cx, |ring, cx| ring.set_ticks(ticks, cx));
|
||||
// « En partie » reads the same statistics; it dresses the banner too.
|
||||
self.prepare_in_game(cx);
|
||||
self.dress_banner(cx);
|
||||
}
|
||||
|
||||
/// What the banner drawn says: the champ select's on « Sélection », else the home's.
|
||||
/// What the banner drawn says: the champ select's on « Sélection », the Live Match's on
|
||||
/// « En partie », else the home's.
|
||||
pub(in crate::page) fn shown_banner(&self) -> &BannerContent {
|
||||
if self.shown_tab == Tab::ChampSelect {
|
||||
&self.champ_select_banner
|
||||
} else {
|
||||
&self.banner
|
||||
match self.shown_tab {
|
||||
Tab::ChampSelect => &self.champ_select_banner,
|
||||
Tab::InGame => &self.in_game.banner,
|
||||
_ => &self.banner,
|
||||
}
|
||||
}
|
||||
|
||||
/// The ring and the illustration of the banner drawn. The champ select's dims the ticks
|
||||
/// without an anvil and shows the card hovered; the home's dims none and shows its own
|
||||
/// splash, unless the end of a Match holds it.
|
||||
/// without an anvil and shows the card hovered; the Live Match's lights its champion's tick
|
||||
/// and shows its splash; the home's dims none and shows its own splash, unless the end of a
|
||||
/// Match holds it.
|
||||
pub(in crate::page) fn dress_banner(&mut self, cx: &mut Context<Self>) {
|
||||
let selecting = self.shown_tab == Tab::ChampSelect;
|
||||
let anvil = (self.live_champ_select())
|
||||
.filter(|_| selecting)
|
||||
.and_then(|pick| pick.anvil_champions.as_deref());
|
||||
self.ring.update(cx, |ring, cx| ring.set_anvil(anvil, cx));
|
||||
let playing = self.shown_tab == Tab::InGame;
|
||||
// Elsewhere only a card under the pointer lights a tick.
|
||||
let lit = if playing {
|
||||
Some(self.in_game.champion)
|
||||
} else {
|
||||
self.lit_by.is_none().then_some(None)
|
||||
};
|
||||
if let Some(lit) = lit {
|
||||
self.ring.update(cx, |ring, cx| ring.set_lit(lit, cx));
|
||||
}
|
||||
if selecting {
|
||||
self.select_art(self.ring.read(cx).lit(), cx);
|
||||
} else if playing {
|
||||
let splash = self.in_game.banner.splash.clone();
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(splash, cx));
|
||||
} else if !self.playback.active() {
|
||||
self.banner_art
|
||||
.update(cx, |art, cx| art.set_target(self.banner.splash.clone(), cx));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::ops::Range;
|
||||
use std::rc::Rc;
|
||||
|
||||
use arena_tracker_core::{MatchOutcome, Splash, Statistics};
|
||||
use arena_tracker_core::{ChampionRow, MatchOutcome, Splash, Statistics};
|
||||
use gpui_kit::SharedString;
|
||||
|
||||
use crate::page::champ_select::UNKNOWN_ANVIL;
|
||||
@@ -63,7 +63,67 @@ pub(in crate::page) struct BannerContent {
|
||||
pub(in crate::page) splash: Option<Rc<Splash>>,
|
||||
}
|
||||
|
||||
/// The overline of a phase's banner: the Season, then the Challenge's count.
|
||||
fn overline_with_count(season: Option<&SharedString>, stats: Option<&Statistics>) -> String {
|
||||
let mut season = season.map(overline).unwrap_or_default();
|
||||
if let Some(challenge) = stats.and_then(|s| s.challenge.as_ref()) {
|
||||
use std::fmt::Write;
|
||||
if !season.is_empty() {
|
||||
season.push_str(" · ");
|
||||
}
|
||||
write!(
|
||||
season,
|
||||
"{} / {} validés",
|
||||
challenge.completed, challenge.total
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
season
|
||||
}
|
||||
|
||||
/// The title of « En partie » while the client has not said the champion played.
|
||||
pub(in crate::page) const IDENTIFYING: &str = "Champion en cours d’identification";
|
||||
|
||||
impl BannerContent {
|
||||
/// « En partie »'s banner (#109): the Season and the count, the champion played (`row`,
|
||||
/// once `identified` and its statistics known), and what the Match can bring it: « Un top 1
|
||||
/// validerait X : 88 / 172 », or the day it was validated. Its splash, none while the
|
||||
/// champion is not known.
|
||||
pub(in crate::page) fn in_game(
|
||||
season: Option<&SharedString>,
|
||||
stats: Option<&Statistics>,
|
||||
identified: bool,
|
||||
row: Option<&ChampionRow>,
|
||||
) -> Self {
|
||||
let challenge = stats.and_then(|s| s.challenge.as_ref());
|
||||
let title = match row {
|
||||
Some(row) => Line::plain(&row.champion.name),
|
||||
None if identified => Line::plain("Partie en cours"),
|
||||
None => Line::plain(IDENTIFYING),
|
||||
};
|
||||
let detail = match (row, challenge) {
|
||||
(Some(row), Some(challenge)) => {
|
||||
let name = &row.champion.name;
|
||||
match row.challenge.and_then(|c| c.completed_on) {
|
||||
Some(day) => Line::new("", name, &format!(" validé le {}", short_date(day))),
|
||||
None => Line::new(
|
||||
"Un top 1 validerait ",
|
||||
name,
|
||||
&format!(" : {} / {}", challenge.completed + 1, challenge.total),
|
||||
),
|
||||
}
|
||||
}
|
||||
_ => Line::default(),
|
||||
};
|
||||
Self {
|
||||
season: overline_with_count(season, stats).into(),
|
||||
title,
|
||||
detail,
|
||||
last_match: None,
|
||||
splash: row.and_then(|row| row.splash.clone()).map(Rc::new),
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::page) fn champ_select(
|
||||
season: Option<&SharedString>,
|
||||
stats: Option<&Statistics>,
|
||||
@@ -71,19 +131,7 @@ impl BannerContent {
|
||||
count: usize,
|
||||
splash: Option<Rc<Splash>>,
|
||||
) -> Self {
|
||||
let mut season = season.map(overline).unwrap_or_default();
|
||||
if let Some(challenge) = stats.and_then(|s| s.challenge.as_ref()) {
|
||||
use std::fmt::Write;
|
||||
if !season.is_empty() {
|
||||
season.push_str(" · ");
|
||||
}
|
||||
write!(
|
||||
season,
|
||||
"{} / {} validés",
|
||||
challenge.completed, challenge.total
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
let season = overline_with_count(season, stats);
|
||||
let detail = if !known {
|
||||
Line::plain(UNKNOWN_ANVIL)
|
||||
} else if stats.is_some() {
|
||||
|
||||
@@ -0,0 +1,306 @@
|
||||
//! « En partie » (#109): the tab of the Live Match's phase. It shows the champion played and what
|
||||
//! the Match can bring it in the Challenge: the banner with its splash, its tick of the ring lit
|
||||
//! and the stake, the figures of its card's sheet and its latest Matches of the Season. « La
|
||||
//! phase décide »: the start of a Live Match shows it, its end shows « Parties » (its
|
||||
//! end-of-game block, #129) or « Défi ».
|
||||
|
||||
use super::matches::Outcome;
|
||||
use super::{LiveMatchStarted, Page, Tab, home::BannerContent};
|
||||
use crate::card::sheet_lines;
|
||||
use crate::text::ordinal;
|
||||
use crate::worker::{MatchEntry, spawn_recent_matches};
|
||||
use arena_tracker_core::{FollowedMatch, LiveMatch};
|
||||
use gpui_kit::*;
|
||||
|
||||
mod render;
|
||||
|
||||
/// What « En partie » shows, prepared when the Live Match or the statistics change: nothing is
|
||||
/// looked up while drawing.
|
||||
#[derive(Default)]
|
||||
pub(in crate::page) struct InGame {
|
||||
/// The Season and the Challenge's count, the champion, and what a top 1 would bring.
|
||||
pub(in crate::page) banner: BannerContent,
|
||||
/// The champion played, once the client said it: its tick of the ring is lit.
|
||||
pub(in crate::page) champion: Option<u32>,
|
||||
/// « Première Partie avec X cette Saison », for a champion without a Match in it.
|
||||
first_match: SharedString,
|
||||
/// The figures of its card's sheet; empty while its row is not known.
|
||||
sheet: Vec<(&'static str, SharedString)>,
|
||||
recent: Recent,
|
||||
/// What `recent` was asked for.
|
||||
asked: Option<RecentKey>,
|
||||
/// Of the latest request for `recent`: an older answer is dropped.
|
||||
generation: u64,
|
||||
}
|
||||
|
||||
/// What the latest Matches are read for.
|
||||
#[derive(Clone, PartialEq)]
|
||||
struct RecentKey {
|
||||
puuid: String,
|
||||
champion: u32,
|
||||
season: SharedString,
|
||||
/// How many Matches the Account had stored: a new one may be the champion's.
|
||||
stored: Option<usize>,
|
||||
}
|
||||
|
||||
impl RecentKey {
|
||||
/// The same list, whatever was stored since.
|
||||
fn same_list(&self, other: &RecentKey) -> bool {
|
||||
(&self.puuid, self.champion, &self.season) == (&other.puuid, other.champion, &other.season)
|
||||
}
|
||||
}
|
||||
|
||||
/// The champion's latest Matches of the Season.
|
||||
#[derive(Default)]
|
||||
enum Recent {
|
||||
#[default]
|
||||
Loading,
|
||||
Ready(Vec<RecentMatch>),
|
||||
Failed(SharedString),
|
||||
}
|
||||
|
||||
/// One of the champion's latest Matches, written when it arrives.
|
||||
struct RecentMatch {
|
||||
when: SharedString,
|
||||
placement: SharedString,
|
||||
outcome: Outcome,
|
||||
provisional: bool,
|
||||
format: SharedString,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl InGame {
|
||||
/// The latest Matches were read, or failed to be.
|
||||
pub(in crate::page) fn recent_read(&self) -> bool {
|
||||
!matches!(self.recent, Recent::Loading)
|
||||
}
|
||||
|
||||
/// The latest Matches as (when, Placement, Format, provisional); `None` until read.
|
||||
pub(in crate::page) fn recent_lines(&self) -> Option<Vec<(String, String, String, bool)>> {
|
||||
match &self.recent {
|
||||
Recent::Ready(matches) => Some(
|
||||
(matches.iter())
|
||||
.map(|m| {
|
||||
let text = |s: &SharedString| s.to_string();
|
||||
(
|
||||
text(&m.when),
|
||||
text(&m.placement),
|
||||
text(&m.format),
|
||||
m.provisional,
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::page) fn sheet(&self) -> &[(&'static str, SharedString)] {
|
||||
&self.sheet
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MatchEntry> for RecentMatch {
|
||||
fn from(entry: MatchEntry) -> RecentMatch {
|
||||
RecentMatch {
|
||||
when: entry.when.into(),
|
||||
placement: ordinal(entry.placement).into(),
|
||||
outcome: Outcome::of(entry.placement, entry.win),
|
||||
provisional: entry.provisional,
|
||||
format: entry.format.name().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Page {
|
||||
pub(in crate::page) fn in_live_match(&self) -> bool {
|
||||
self.live_match.is_some()
|
||||
}
|
||||
|
||||
/// A champ select or a Live Match runs: the page is about the Account signed in to the
|
||||
/// client and the current Season.
|
||||
pub(in crate::page) fn in_phase(&self) -> bool {
|
||||
self.in_champ_select() || self.in_live_match()
|
||||
}
|
||||
|
||||
/// Whether « En partie » is in the top bar: during the Live Match, once the champ select
|
||||
/// that launched it has ended.
|
||||
pub(in crate::page) fn live_match_tab(&self) -> bool {
|
||||
self.in_live_match() && !self.in_champ_select()
|
||||
}
|
||||
|
||||
/// The Live Match the client reports changed: it started, its champion became known, or
|
||||
/// the client left it. Only the client's events get here: no polling.
|
||||
pub(in crate::page) fn change_live_match(
|
||||
&mut self,
|
||||
live: Option<LiveMatch>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let Some(live) = live else {
|
||||
// Out of the game: the next one shows again.
|
||||
self.match_over = None;
|
||||
if let Some(game) = self.leave_live_match(window, cx)
|
||||
&& !self.in_champ_select()
|
||||
&& (game.is_none() || self.decided_game != game)
|
||||
{
|
||||
// Its end without a block shows the Challenge, once, from wherever the player
|
||||
// is (#129).
|
||||
self.decided_game = game;
|
||||
self.set_tab(Tab::Challenge, window, cx);
|
||||
}
|
||||
self.leave_gone_tab(window, cx);
|
||||
return;
|
||||
};
|
||||
// Its end-of-game block already made it a Match.
|
||||
if self.match_over == Some(live.game_id) {
|
||||
return;
|
||||
}
|
||||
let started = (self.live_match.as_ref()).is_none_or(|shown| shown.game_id != live.game_id);
|
||||
self.live_match = Some(live);
|
||||
if !started {
|
||||
// Its champion identified (Bravery): the screen follows.
|
||||
self.prepare_in_game(cx);
|
||||
return;
|
||||
}
|
||||
cx.emit(LiveMatchStarted);
|
||||
if self.in_champ_select() {
|
||||
// The champ select that launched the game ends next, and its end shows
|
||||
// « En partie » (`change_champ_select`).
|
||||
return;
|
||||
}
|
||||
self.rescope(window, cx);
|
||||
// The phase decides: « En partie » shows, from wherever the player was.
|
||||
self.set_tab(Tab::InGame, window, cx);
|
||||
}
|
||||
|
||||
/// The Live Match ended while « En partie » was chosen, and nothing chose another screen (a
|
||||
/// block of another Account, a game whose end was decided already): « Défi » shows rather
|
||||
/// than a tab the top bar no longer has.
|
||||
pub(in crate::page) fn leave_gone_tab(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.tab == Tab::InGame && !self.live_match_tab() {
|
||||
self.set_tab(Tab::Challenge, window, cx);
|
||||
}
|
||||
}
|
||||
|
||||
/// The Live Match is over: its tab goes, and the home's Account and Season come back. The
|
||||
/// id of its game, if one was live.
|
||||
fn leave_live_match(
|
||||
&mut self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<Option<u64>> {
|
||||
let live = self.live_match.take()?;
|
||||
if !self.in_champ_select() {
|
||||
// An animation asked for during it plays on the home.
|
||||
self.playback.stats_pending = self.playback.active();
|
||||
self.rescope(window, cx);
|
||||
}
|
||||
Some(live.game_id)
|
||||
}
|
||||
|
||||
/// A round reported `followed`: the end-of-game block of the Live Match's game made it a
|
||||
/// Match, and its tab goes now rather than at the lobby; what the end shows is the block's
|
||||
/// (#129). Whether the statistics were asked for again.
|
||||
pub(in crate::page) fn end_live_match_with_block(
|
||||
&mut self,
|
||||
followed: &[FollowedMatch],
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> bool {
|
||||
let Some(live) = &self.live_match else {
|
||||
return false;
|
||||
};
|
||||
let game = live.game_id;
|
||||
let its_block = followed
|
||||
.iter()
|
||||
.any(|m| m.provisional && (m.game_id.is_none() || game.is_none() || m.game_id == game));
|
||||
if !its_block {
|
||||
return false;
|
||||
}
|
||||
self.match_over = Some(game);
|
||||
self.leave_live_match(window, cx);
|
||||
true
|
||||
}
|
||||
|
||||
/// Prepares what « En partie » shows from the Live Match and the home statistics, which are
|
||||
/// the Account's in the current Season during it; asks for the champion's latest Matches
|
||||
/// when they may have changed. Once the Live Match is over, the screen keeps what it showed
|
||||
/// until it is left.
|
||||
pub(in crate::page) fn prepare_in_game(&mut self, cx: &mut Context<Self>) {
|
||||
let Some(live) = &self.live_match else {
|
||||
if self.shown_tab != Tab::InGame {
|
||||
self.in_game = InGame::default();
|
||||
}
|
||||
return;
|
||||
};
|
||||
let champion = live.champion_id;
|
||||
let stats = self.home_statistics();
|
||||
let row = champion
|
||||
.and_then(|id| stats.and_then(|s| s.rows.iter().find(|row| row.champion.id == id)));
|
||||
let banner =
|
||||
BannerContent::in_game(self.home_season.as_ref(), stats, champion.is_some(), row);
|
||||
let first_match = row.map_or_else(SharedString::default, |row| {
|
||||
format!("Première Partie avec {} cette Saison", row.champion.name).into()
|
||||
});
|
||||
let sheet = row.map(sheet_lines).unwrap_or_default();
|
||||
// Asked once the statistics are there: they say how many Matches are stored.
|
||||
let asked = (stats.is_some())
|
||||
.then(|| {
|
||||
Some(RecentKey {
|
||||
puuid: self.displayed()?.puuid.clone(),
|
||||
champion: champion?,
|
||||
season: self.home_season.clone()?,
|
||||
stored: self.stored,
|
||||
})
|
||||
})
|
||||
.flatten();
|
||||
self.in_game.banner = banner;
|
||||
self.in_game.champion = champion;
|
||||
self.in_game.first_match = first_match;
|
||||
self.in_game.sheet = sheet;
|
||||
if let Some(asked) = asked
|
||||
&& self.in_game.asked.as_ref() != Some(&asked)
|
||||
{
|
||||
self.ask_recent(asked, cx);
|
||||
}
|
||||
self.dress_banner(cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// Reads the champion's latest Matches on a below-normal worker.
|
||||
fn ask_recent(&mut self, asked: RecentKey, cx: &mut Context<Self>) {
|
||||
let in_game = &mut self.in_game;
|
||||
in_game.generation += 1;
|
||||
// The Matches of another Account, champion or Season are not shown meanwhile; those
|
||||
// of the same are, until the new ones come.
|
||||
if (in_game.asked.as_ref()).is_none_or(|before| !before.same_list(&asked)) {
|
||||
in_game.recent = Recent::Loading;
|
||||
}
|
||||
in_game.asked = Some(asked.clone());
|
||||
spawn_recent_matches(
|
||||
self.tracker.clone(),
|
||||
asked.puuid,
|
||||
asked.champion,
|
||||
asked.season.to_string(),
|
||||
in_game.generation,
|
||||
self.tx.clone(),
|
||||
);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// The champion's latest Matches arrived: those of the latest request only.
|
||||
pub(in crate::page) fn apply_recent(
|
||||
&mut self,
|
||||
generation: u64,
|
||||
matches: Result<Vec<MatchEntry>, String>,
|
||||
) {
|
||||
if generation != self.in_game.generation || self.in_game.asked.is_none() {
|
||||
return;
|
||||
}
|
||||
self.in_game.recent = match matches {
|
||||
Ok(matches) => Recent::Ready(matches.into_iter().map(RecentMatch::from).collect()),
|
||||
Err(error) => Recent::Failed(error.into()),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
use super::{InGame, Recent, RecentMatch};
|
||||
use crate::page::home::notice_line;
|
||||
use crate::page::{Page, shown};
|
||||
use crate::theme::{gold_ink, heading, surface};
|
||||
use gpui_kit::component::{ActiveTheme as _, StyledExt as _, Theme};
|
||||
use gpui_kit::*;
|
||||
|
||||
/// What stands for the latest Matches while they are read.
|
||||
const LOADING: &str = "Chargement des Parties…";
|
||||
|
||||
impl Page {
|
||||
/// « En partie »: the banner of the Live Match, then the champion's sheet and its latest
|
||||
/// Matches of the Season side by side (one above the other in a narrow window). The column
|
||||
/// scrolls in a low window, as the home's does.
|
||||
pub(in crate::page) fn in_game_content(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Page>,
|
||||
) -> Vec<AnyElement> {
|
||||
let mut column = self.banner_column(window, cx);
|
||||
let theme = cx.theme();
|
||||
match self.stats_notice() {
|
||||
// The header already says there is no Season, and a banner the statistics' error.
|
||||
Some(notice) if notice.said_elsewhere() => {}
|
||||
Some(notice) => {
|
||||
column = column.child(notice_line(
|
||||
"in-game-notice",
|
||||
notice.label(self.error().map(String::as_str)),
|
||||
theme.muted_foreground,
|
||||
));
|
||||
}
|
||||
None if shown("in-game-details") && !self.in_game.sheet.is_empty() => {
|
||||
column = column.child(details(&self.in_game, cx));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
vec![column.id("in-game").overflow_y_scroll().into_any_element()]
|
||||
}
|
||||
}
|
||||
|
||||
/// The champion's sheet, then its latest Matches.
|
||||
fn details(in_game: &InGame, cx: &App) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
div()
|
||||
.h_flex()
|
||||
.flex_wrap()
|
||||
.items_start()
|
||||
.gap_3()
|
||||
.child(
|
||||
panel("Fiche du champion", "in-game-sheet", cx).children(in_game.sheet.iter().map(
|
||||
|(label, value)| {
|
||||
line(theme)
|
||||
.debug_selector(move || format!("in-game-sheet-{label}"))
|
||||
.child(div().text_color(theme.muted_foreground).child(*label))
|
||||
.child(div().font_weight(FontWeight::SEMIBOLD).child(value.clone()))
|
||||
},
|
||||
)),
|
||||
)
|
||||
.child(
|
||||
panel("Dernières Parties de la Saison", "in-game-recent", cx)
|
||||
.children(recent(in_game, theme)),
|
||||
)
|
||||
}
|
||||
|
||||
/// A titled panel of the screen: the two share the width, or wrap one above the other.
|
||||
fn panel(title: &'static str, selector: &'static str, cx: &App) -> Div {
|
||||
let theme = cx.theme();
|
||||
div()
|
||||
.v_flex()
|
||||
.flex_1()
|
||||
.min_w(px(280.))
|
||||
.gap_2()
|
||||
.p_4()
|
||||
.bg(surface(theme))
|
||||
.border_1()
|
||||
.border_color(theme.border)
|
||||
.rounded(px(12.))
|
||||
.debug_selector(move || selector.into())
|
||||
.child(heading(cx).mb_1().text_lg().child(title))
|
||||
}
|
||||
|
||||
/// One line of a panel: its label left, its value right.
|
||||
fn line(theme: &Theme) -> Div {
|
||||
div()
|
||||
.h_flex()
|
||||
.justify_between()
|
||||
.items_center()
|
||||
.gap_3()
|
||||
.py_1()
|
||||
.border_b_1()
|
||||
.border_color(theme.border)
|
||||
.text_sm()
|
||||
}
|
||||
|
||||
/// The lines of the latest Matches, or what stands for them.
|
||||
fn recent(in_game: &InGame, theme: &Theme) -> Vec<AnyElement> {
|
||||
let muted = theme.muted_foreground;
|
||||
match &in_game.recent {
|
||||
Recent::Loading => vec![notice_line("in-game-recent-loading", LOADING.into(), muted)],
|
||||
Recent::Failed(error) => vec![notice_line("in-game-recent-error", error.clone(), muted)],
|
||||
Recent::Ready(matches) if matches.is_empty() => vec![notice_line(
|
||||
"in-game-first-match",
|
||||
in_game.first_match.clone(),
|
||||
muted,
|
||||
)],
|
||||
Recent::Ready(matches) => (matches.iter().enumerate())
|
||||
.map(|(ix, played)| recent_line(ix, played, theme).into_any_element())
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// A Match: when it started and its Format, then its Placement in the colour of its result, as
|
||||
/// in « Parties ».
|
||||
fn recent_line(ix: usize, played: &RecentMatch, theme: &Theme) -> Div {
|
||||
let ink = played.outcome.ink(theme);
|
||||
line(theme)
|
||||
.debug_selector(move || format!("in-game-recent-{ix}"))
|
||||
.child(
|
||||
div().v_flex().min_w_0().child(played.when.clone()).child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(theme.muted_foreground)
|
||||
.child(played.format.clone()),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.v_flex()
|
||||
.items_end()
|
||||
.flex_shrink_0()
|
||||
.child(
|
||||
div()
|
||||
.font_weight(FontWeight::SEMIBOLD)
|
||||
.text_color(ink)
|
||||
.child(played.placement.clone()),
|
||||
)
|
||||
.children(played.provisional.then(|| {
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(gold_ink(theme))
|
||||
.child("Provisoire")
|
||||
})),
|
||||
)
|
||||
}
|
||||
@@ -28,7 +28,6 @@ use list::MatchChosen;
|
||||
pub(in crate::page) use list::MatchList;
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) use list::MatchRow as Row;
|
||||
#[cfg(test)]
|
||||
pub(in crate::page) use list::Outcome;
|
||||
pub use list::init;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
//! shows the new Match, from any screen, never bringing the window forward nor taking the focus.
|
||||
//! With the preference off, or when the game ended without a block, the Challenge shows instead.
|
||||
//! Each game's end is decided once: nothing brings the player back to either screen afterwards.
|
||||
//! During a Live Match, « En partie » stays until the block or the lobby (#109).
|
||||
|
||||
use crate::page::{ALL_SEASONS, Page, RecapOpened, Tab};
|
||||
use crate::worker::MatchEntry;
|
||||
@@ -54,6 +55,11 @@ impl Page {
|
||||
let Some(end) = end else {
|
||||
return;
|
||||
};
|
||||
// « En partie » stays on the game's end-of-game screen: the block, or the lobby
|
||||
// without one, decides then (#109).
|
||||
if self.in_live_match() {
|
||||
return;
|
||||
}
|
||||
if end.game_id.is_none() || end.game_id != self.decided_game {
|
||||
self.decided_game = end.game_id;
|
||||
self.set_tab(Tab::Challenge, window, cx);
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::ops::Range;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use gpui_kit::component::scroll::Scrollbar;
|
||||
use gpui_kit::component::{ActiveTheme as _, StyledExt as _};
|
||||
use gpui_kit::component::{ActiveTheme as _, StyledExt as _, Theme};
|
||||
use gpui_kit::prelude::FluentBuilder as _;
|
||||
use gpui_kit::*;
|
||||
|
||||
@@ -50,6 +50,16 @@ pub(in crate::page) enum Outcome {
|
||||
}
|
||||
|
||||
impl Outcome {
|
||||
/// The ink of its Placement: the palette's text inks, as the kit's base green is too pale
|
||||
/// on the light theme.
|
||||
pub(in crate::page) fn ink(self, theme: &Theme) -> Hsla {
|
||||
match self {
|
||||
Outcome::Top1 => gold_ink(theme),
|
||||
Outcome::Win => theme.success,
|
||||
Outcome::Loss => theme.danger,
|
||||
}
|
||||
}
|
||||
|
||||
/// A top 1 is also a Win: it is drawn as a top 1.
|
||||
pub(in crate::page) fn of(placement: u8, win: bool) -> Outcome {
|
||||
match (placement, win) {
|
||||
@@ -179,12 +189,7 @@ impl MatchList {
|
||||
theme.tokens.table_hover,
|
||||
theme.table_row_border,
|
||||
);
|
||||
let placement_ink = match row.outcome {
|
||||
Outcome::Top1 => gold,
|
||||
// The palette's text inks: the kit's base green is too pale on the light theme.
|
||||
Outcome::Win => theme.success,
|
||||
Outcome::Loss => theme.danger,
|
||||
};
|
||||
let placement_ink = row.outcome.ink(theme);
|
||||
let portrait = match &row.portrait {
|
||||
Some(path) => img(path.clone())
|
||||
.size(px(PORTRAIT))
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
//! The navigation between the screens: the tabs of the top bar (« Défi », « Parties » and,
|
||||
//! during an Arena champ select, « Sélection »), and the veil under which the screen arriving
|
||||
//! replaces the one leaving. « La phase décide »: entering an Arena champ select
|
||||
//! shows « Sélection », its end shows « Défi »; nothing else moves the player.
|
||||
//! during an Arena champ select, « Sélection », during a Live Match « En partie »), and the veil
|
||||
//! under which the screen arriving replaces the one leaving. « La phase décide »: entering an
|
||||
//! Arena champ select shows « Sélection », its end shows « Défi », or « En partie » when it
|
||||
//! launched the game; the start of a Live Match shows « En partie », its end « Parties » or
|
||||
//! « Défi » (#129); nothing else moves the player.
|
||||
|
||||
use super::{Page, Tab};
|
||||
use crate::motion::{Fade, FadePhase};
|
||||
@@ -27,12 +29,14 @@ impl Page {
|
||||
);
|
||||
let champ_select =
|
||||
(self.in_champ_select()).then_some(("tab-champ-select", "Sélection", Tab::ChampSelect));
|
||||
let in_game = (self.live_match_tab()).then_some(("tab-in-game", "En partie", Tab::InGame));
|
||||
let tabs = [
|
||||
("tab-challenge", "Défi", Tab::Challenge),
|
||||
("tab-matches", "Parties", Tab::Matches),
|
||||
]
|
||||
.into_iter()
|
||||
.chain(champ_select);
|
||||
.chain(champ_select)
|
||||
.chain(in_game);
|
||||
div()
|
||||
.h_flex()
|
||||
.gap_1()
|
||||
@@ -72,8 +76,11 @@ impl Page {
|
||||
}
|
||||
|
||||
pub(super) fn set_tab(&mut self, tab: Tab, window: &mut Window, cx: &mut Context<Self>) {
|
||||
// « Sélection » only exists while the champ select runs.
|
||||
if tab == Tab::ChampSelect && !self.in_champ_select() {
|
||||
// « Sélection » only exists while the champ select runs, « En partie » while the Live
|
||||
// Match does.
|
||||
if (tab == Tab::ChampSelect && !self.in_champ_select())
|
||||
|| (tab == Tab::InGame && !self.live_match_tab())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if self.tab != tab {
|
||||
@@ -129,7 +136,10 @@ impl Page {
|
||||
self.prepare_home_cards(cx);
|
||||
}
|
||||
self.refresh_home(cx);
|
||||
// The ring and the illustration are the banner's on « Défi » and « Sélection ».
|
||||
// What « En partie » showed after its Live Match goes with it.
|
||||
self.prepare_in_game(cx);
|
||||
// The ring and the illustration are the banner's on « Défi », « Sélection » and
|
||||
// « En partie ».
|
||||
self.dress_banner(cx);
|
||||
self.release_hidden(window, cx);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use super::scrollbar::PageScrollbar;
|
||||
use super::statistics::ChartsRow;
|
||||
use super::{
|
||||
ALL_FORMATS, ALL_SEASONS, AccountItem, Launch, MatchPlayback, Page, SORTS, Tab, home, now_ms,
|
||||
ALL_FORMATS, ALL_SEASONS, AccountItem, Launch, MatchPlayback, Page, SORTS, Tab, home, in_game,
|
||||
now_ms,
|
||||
};
|
||||
use crate::banner_art::BannerArt;
|
||||
use crate::card_grid::{CardGrid, Paging};
|
||||
@@ -212,8 +213,11 @@ impl Page {
|
||||
tx,
|
||||
notice,
|
||||
champ_select: None,
|
||||
champ_select_account: None,
|
||||
champ_select_riot_id: None,
|
||||
live_match: None,
|
||||
match_over: None,
|
||||
in_game: in_game::InGame::default(),
|
||||
phase_account: None,
|
||||
phase_riot_id: None,
|
||||
accounts: Vec::new(),
|
||||
last_active: None,
|
||||
pinned: None,
|
||||
|
||||
@@ -44,7 +44,7 @@ impl Page {
|
||||
self.account_items = items.clone();
|
||||
if changed {
|
||||
// The live champ select's Account may now be in the list: resolve it again.
|
||||
self.champ_select_riot_id = None;
|
||||
self.phase_riot_id = None;
|
||||
}
|
||||
if changed {
|
||||
(self.account_select).update(cx, |select, cx| select.set_items(items, window, cx));
|
||||
@@ -54,15 +54,16 @@ impl Page {
|
||||
self.matches_changed(cx);
|
||||
}
|
||||
|
||||
/// The selector shows the Account of the screen: during a champ select (disabled) the one
|
||||
/// signed in, on « Parties » (disabled) the history's, else the one viewed.
|
||||
/// The selector shows the Account of the screen: during a champ select or a Live Match
|
||||
/// (disabled) the one signed in, on « Parties » (disabled) the history's, else the one
|
||||
/// viewed.
|
||||
pub(in crate::page) fn select_shown_account(
|
||||
&mut self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let shown = if self.in_champ_select() {
|
||||
self.champ_select_account()
|
||||
let shown = if self.in_phase() {
|
||||
self.phase_account()
|
||||
} else if self.tab == Tab::Matches {
|
||||
self.history_account().map(|a| a.puuid.clone())
|
||||
} else {
|
||||
@@ -92,12 +93,12 @@ impl Page {
|
||||
{
|
||||
self.filter = StateFilter::All;
|
||||
}
|
||||
if self.in_champ_select() {
|
||||
if self.in_phase() {
|
||||
if computing {
|
||||
self.stats_generation += 1;
|
||||
}
|
||||
// The home is the champ select's, on « Défi » too: its Challenge is the current
|
||||
// Season's, whatever « Statistiques » analyses.
|
||||
// The home is the phase's, on « Défi » too: its Challenge is the current Season's,
|
||||
// whatever « Statistiques » analyses.
|
||||
self.current_season = self.tracker.current_season(now_ms()).map(|s| s.name);
|
||||
self.home_season = self.current_season.clone().map(Into::into);
|
||||
let home = self.current_season.clone().map(|season| Scope {
|
||||
@@ -105,7 +106,7 @@ impl Page {
|
||||
format: None,
|
||||
});
|
||||
self.home_scope = home.filter(|home| *home != self.statistics_scope());
|
||||
let puuid = self.champ_select_account()?;
|
||||
let puuid = self.phase_account()?;
|
||||
return self.current_season.is_some().then_some(puuid);
|
||||
}
|
||||
let previous_season = self.home_season.clone();
|
||||
|
||||
@@ -13,6 +13,9 @@ mod champ_select_scroll;
|
||||
mod champ_select_tab;
|
||||
mod grid;
|
||||
mod home;
|
||||
mod in_game;
|
||||
mod in_game_end;
|
||||
mod in_game_fixtures;
|
||||
mod key_fixtures;
|
||||
mod match_animation;
|
||||
mod match_end_fixtures;
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
//! « En partie » (#109): the tab of the Live Match's phase, read from the simulated client as
|
||||
//! the follower reads it. It shows when the game starts, from the champ select or when the
|
||||
//! client is met in a game, and holds the champion played and its stake in the Challenge.
|
||||
|
||||
use super::champ_select_fixtures::{finish_motion, frames, start_leaving};
|
||||
use super::in_game_fixtures::{GAME, in_game_ready, joueur_in_champ_select, joueur_in_lobby, tell};
|
||||
use super::matches_auto_open::tabs;
|
||||
use super::page_fixtures::{draw, switch_tab};
|
||||
use crate::card::sheet_lines;
|
||||
use crate::page::home::IDENTIFYING;
|
||||
use crate::page::{Page, Tab};
|
||||
use crate::text::short_date;
|
||||
use arena_tracker_core::{GamePhase, LiveMatch};
|
||||
use gpui_kit::{Entity, TestAppContext, VisualTestContext, WindowVisibility};
|
||||
|
||||
fn banner_text(page: &Entity<Page>, cx: &mut VisualTestContext) -> (String, String, String) {
|
||||
page.read_with(cx, |p, _| {
|
||||
let banner = p.shown_banner();
|
||||
(
|
||||
banner.season.to_string(),
|
||||
banner.title.text.to_string(),
|
||||
banner.detail.text.to_string(),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn lit(page: &Entity<Page>, cx: &mut VisualTestContext) -> Option<u32> {
|
||||
page.read_with(cx, |p, cx| p.ring.read(cx).lit())
|
||||
}
|
||||
|
||||
/// The game starts at the end of the champ select: the follower tells the Live Match, then the
|
||||
/// champ select's end. The hand leaves as usual, then « En partie » comes out of the veil in
|
||||
/// place of « Défi », and « Sélection » is gone.
|
||||
#[gpui::test]
|
||||
async fn a_game_launched_from_the_champ_select_shows_en_partie(app: &mut TestAppContext) {
|
||||
let (page, mut window, mut client, started) = joueur_in_champ_select(app, &frames()[0]).await;
|
||||
let cx = &mut window;
|
||||
client.set(GamePhase::InGame, true, Some(233));
|
||||
client.read(&page, cx);
|
||||
// Still the champ select's: its end decides.
|
||||
assert_eq!(tabs(&page, cx), (Tab::ChampSelect, Tab::ChampSelect));
|
||||
assert_eq!(started.get(), 1);
|
||||
draw(cx);
|
||||
assert!(cx.debug_bounds("tab-in-game").is_none());
|
||||
|
||||
let generation = page.read_with(cx, |p, _| p.stats_generation);
|
||||
start_leaving(&page, cx);
|
||||
assert!(page.read_with(cx, |p, _| p.leave.is_some()));
|
||||
finish_motion(&page, cx);
|
||||
assert_eq!(tabs(&page, cx), (Tab::InGame, Tab::InGame));
|
||||
// The same Account in the same Season: nothing is computed again.
|
||||
page.read_with(cx, |p, _| {
|
||||
assert_eq!(p.stats_generation, generation);
|
||||
assert!(p.stats.is_some());
|
||||
});
|
||||
in_game_ready(&page, app).await;
|
||||
draw(&mut window);
|
||||
let cx = &mut window;
|
||||
assert!(cx.debug_bounds("tab-champ-select").is_none());
|
||||
let parties = cx.debug_bounds("tab-matches").unwrap();
|
||||
let in_game = cx.debug_bounds("tab-in-game").unwrap();
|
||||
assert!(in_game.origin.x > parties.origin.x);
|
||||
// Briar, played once, not validated: the banner says what a top 1 would bring.
|
||||
assert_eq!(
|
||||
banner_text(&page, cx),
|
||||
(
|
||||
"SAISON · 1 / 9 validés".into(),
|
||||
"Briar".into(),
|
||||
"Un top 1 validerait Briar : 2 / 9".into()
|
||||
)
|
||||
);
|
||||
assert_eq!(lit(&page, cx), Some(233));
|
||||
// The banner of a phase has no link to « Statistiques ».
|
||||
assert!(cx.debug_bounds("statistics-link").is_none());
|
||||
assert!(cx.debug_bounds("in-game-sheet").is_some());
|
||||
assert!(cx.debug_bounds("in-game-recent").is_some());
|
||||
assert_eq!(started.get(), 1);
|
||||
}
|
||||
|
||||
/// The app meets the client in a game: « En partie » shows at once from wherever the player
|
||||
/// was, the window never activated, and the page says a Live Match started (« Paramètres »
|
||||
/// gives way and a minimised window opens again, `main`).
|
||||
#[gpui::test]
|
||||
async fn a_client_met_in_a_game_shows_en_partie_without_the_focus(app: &mut TestAppContext) {
|
||||
let (page, mut window, mut client, started) = joueur_in_lobby(app).await;
|
||||
let cx = &mut window;
|
||||
switch_tab(&page, cx, Tab::Statistics);
|
||||
cx.deactivate_window();
|
||||
cx.simulate_visibility_change(WindowVisibility::Hidden);
|
||||
|
||||
client.set(GamePhase::InGame, true, Some(16));
|
||||
client.read(&page, cx);
|
||||
// Hidden, the switch is at once, without the veil.
|
||||
assert_eq!(tabs(&page, cx), (Tab::InGame, Tab::InGame));
|
||||
assert!(page.read_with(cx, |p, _| p.fade.is_none()));
|
||||
assert_eq!(started.get(), 1);
|
||||
cx.update(|window, cx| {
|
||||
assert_eq!(cx.active_window(), None);
|
||||
assert!(!window.is_window_active());
|
||||
assert_eq!(window.focused(cx), None);
|
||||
});
|
||||
|
||||
in_game_ready(&page, app).await;
|
||||
let cx = &mut window;
|
||||
// Soraka is validated: the banner gives the day.
|
||||
let day = page.read_with(cx, |p, _| {
|
||||
let stats = p.home_statistics().unwrap();
|
||||
let row = stats.rows.iter().find(|row| row.champion.id == 16).unwrap();
|
||||
row.challenge.unwrap().completed_on.unwrap()
|
||||
});
|
||||
let (_, title, detail) = banner_text(&page, cx);
|
||||
assert_eq!(title, "Soraka");
|
||||
assert_eq!(detail, format!("Soraka validé le {}", short_date(day)));
|
||||
assert_eq!(lit(&page, cx), Some(16));
|
||||
}
|
||||
|
||||
/// The sheet is the card's, and the champion's latest Matches of the Season are listed with
|
||||
/// their date, Placement and Format; without one, the first Match is announced.
|
||||
#[gpui::test]
|
||||
async fn en_partie_holds_the_sheet_and_the_latest_matches(app: &mut TestAppContext) {
|
||||
let (page, mut window, mut client, _) = joueur_in_lobby(app).await;
|
||||
client.set(GamePhase::InGame, true, Some(233));
|
||||
client.read(&page, &mut window);
|
||||
in_game_ready(&page, app).await;
|
||||
let cx = &mut window;
|
||||
finish_motion(&page, cx);
|
||||
draw(cx);
|
||||
page.read_with(cx, |p, _| {
|
||||
let stats = p.home_statistics().unwrap();
|
||||
let row = stats
|
||||
.rows
|
||||
.iter()
|
||||
.find(|row| row.champion.id == 233)
|
||||
.unwrap();
|
||||
assert_eq!(p.in_game.sheet(), sheet_lines(row).as_slice());
|
||||
let recent = p.in_game.recent_lines().unwrap();
|
||||
assert_eq!(recent.len(), 1);
|
||||
let (_, placement, format, provisional) = &recent[0];
|
||||
assert_eq!(
|
||||
(placement.as_str(), format.as_str(), *provisional),
|
||||
("4ᵉ", "Arena 3x6", false)
|
||||
);
|
||||
});
|
||||
assert!(cx.debug_bounds("in-game-sheet-Parties").is_some());
|
||||
assert!(cx.debug_bounds("in-game-recent-0").is_some());
|
||||
assert!(cx.debug_bounds("in-game-first-match").is_none());
|
||||
|
||||
// A Match stored meanwhile: the list is read again, and stays shown until it comes.
|
||||
let (shown, generation) =
|
||||
page.read_with(cx, |p, _| (p.in_game.recent_lines(), p.stats_generation));
|
||||
cx.update(|window, cx| {
|
||||
page.update(cx, |p, cx| {
|
||||
let stats = p.stats.clone().unwrap();
|
||||
let stored = p.stored.map(|n| n + 1);
|
||||
p.apply(
|
||||
crate::worker::Msg::Statistics {
|
||||
generation,
|
||||
stats: Ok(stats),
|
||||
home: None,
|
||||
stored,
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
});
|
||||
assert_eq!(page.read_with(cx, |p, _| p.in_game.recent_lines()), shown);
|
||||
in_game_ready(&page, app).await;
|
||||
let cx = &mut window;
|
||||
|
||||
// Another game, with Ahri, never played this Season.
|
||||
client.lobby();
|
||||
client.read(&page, cx);
|
||||
client.set(GamePhase::InGame, true, Some(103));
|
||||
client.read(&page, cx);
|
||||
in_game_ready(&page, app).await;
|
||||
let cx = &mut window;
|
||||
finish_motion(&page, cx);
|
||||
draw(cx);
|
||||
assert_eq!(
|
||||
page.read_with(cx, |p, _| p.in_game.recent_lines()),
|
||||
Some(Vec::new())
|
||||
);
|
||||
assert!(cx.debug_bounds("in-game-first-match").is_some());
|
||||
assert!(cx.debug_bounds("in-game-recent-0").is_none());
|
||||
}
|
||||
|
||||
/// Until the client says the champion (Bravery draws it), the banner has no illustration and
|
||||
/// says it is being identified; its champion then fills the screen.
|
||||
#[gpui::test]
|
||||
async fn the_champion_is_identified_when_the_client_says_it(app: &mut TestAppContext) {
|
||||
let (page, mut window, mut client, started) = joueur_in_lobby(app).await;
|
||||
client.set(GamePhase::InGame, true, None);
|
||||
client.read(&page, &mut window);
|
||||
app.condition(&page, |p, _| p.stats.is_some()).await;
|
||||
finish_motion(&page, &mut window);
|
||||
draw(&mut window);
|
||||
let cx = &mut window;
|
||||
assert_eq!(tabs(&page, cx), (Tab::InGame, Tab::InGame));
|
||||
let (season, title, detail) = banner_text(&page, cx);
|
||||
assert_eq!((title.as_str(), detail.as_str()), (IDENTIFYING, ""));
|
||||
assert_eq!(season, "SAISON · 1 / 9 validés");
|
||||
page.read_with(cx, |p, cx| {
|
||||
assert!(p.in_game.banner.splash.is_none());
|
||||
assert_eq!(p.banner_art.read(cx).target, None);
|
||||
});
|
||||
assert_eq!(lit(&page, cx), None);
|
||||
assert!(cx.debug_bounds("in-game-sheet").is_none());
|
||||
|
||||
client.set(GamePhase::InGame, true, Some(233));
|
||||
client.read(&page, cx);
|
||||
in_game_ready(&page, app).await;
|
||||
draw(&mut window);
|
||||
let cx = &mut window;
|
||||
assert_eq!(banner_text(&page, cx).1, "Briar");
|
||||
assert_eq!(lit(&page, cx), Some(233));
|
||||
assert!(cx.debug_bounds("in-game-sheet").is_some());
|
||||
// The same Live Match: it did not start again.
|
||||
assert_eq!(started.get(), 1);
|
||||
}
|
||||
|
||||
/// A game outside Arena makes nothing appear.
|
||||
#[gpui::test]
|
||||
async fn a_game_outside_arena_shows_nothing(app: &mut TestAppContext) {
|
||||
let (page, mut window, mut client, started) = joueur_in_lobby(app).await;
|
||||
let cx = &mut window;
|
||||
for phase in [GamePhase::ChampSelect, GamePhase::InGame, GamePhase::Ended] {
|
||||
client.set(phase, false, Some(233));
|
||||
client.read(&page, cx);
|
||||
}
|
||||
draw(cx);
|
||||
assert_eq!(tabs(&page, cx), (Tab::Challenge, Tab::Challenge));
|
||||
assert!(cx.debug_bounds("tab-in-game").is_none());
|
||||
assert!(page.read_with(cx, |p, _| p.live_match.is_none()));
|
||||
assert_eq!(started.get(), 0);
|
||||
}
|
||||
|
||||
/// During the Live Match « Défi » and « Statistiques » stay reachable, on the signed-in
|
||||
/// Account's current Challenge, and « En partie » shows again as it was, with nothing computed
|
||||
/// again; only a new phase moves the player.
|
||||
#[gpui::test]
|
||||
async fn the_challenge_and_en_partie_take_turns(app: &mut TestAppContext) {
|
||||
let (page, mut window, mut client, _) = joueur_in_lobby(app).await;
|
||||
client.set(GamePhase::InGame, true, Some(233));
|
||||
client.read(&page, &mut window);
|
||||
in_game_ready(&page, app).await;
|
||||
let cx = &mut window;
|
||||
finish_motion(&page, cx);
|
||||
let generation = page.read_with(cx, |p, _| (p.stats_generation, p.in_game.recent_lines()));
|
||||
|
||||
switch_tab(&page, cx, Tab::Challenge);
|
||||
draw(cx);
|
||||
assert!(cx.debug_bounds("home-tools").is_some());
|
||||
assert!(cx.debug_bounds("tab-in-game").is_some());
|
||||
assert_eq!(banner_text(&page, cx).1, "1 / 9 champions validés");
|
||||
// Only a card under the pointer lights a tick there.
|
||||
assert_eq!(lit(&page, cx), None);
|
||||
// The client's events change nothing shown.
|
||||
client.set(GamePhase::InGame, true, Some(233));
|
||||
client.read(&page, cx);
|
||||
assert_eq!(tabs(&page, cx), (Tab::Challenge, Tab::Challenge));
|
||||
|
||||
switch_tab(&page, cx, Tab::InGame);
|
||||
draw(cx);
|
||||
assert_eq!(banner_text(&page, cx).1, "Briar");
|
||||
assert_eq!(lit(&page, cx), Some(233));
|
||||
let again = page.read_with(cx, |p, _| (p.stats_generation, p.in_game.recent_lines()));
|
||||
assert_eq!(again, generation);
|
||||
}
|
||||
|
||||
/// The end of the game without its end-of-game block: « En partie » stays on the end-of-game
|
||||
/// screen, then the lobby removes it and shows the Challenge, from wherever the player is.
|
||||
#[gpui::test]
|
||||
async fn the_lobby_after_a_game_without_a_block_shows_the_challenge(app: &mut TestAppContext) {
|
||||
let (page, mut window, mut client, _) = joueur_in_lobby(app).await;
|
||||
client.set(GamePhase::InGame, true, Some(233));
|
||||
client.read(&page, &mut window);
|
||||
in_game_ready(&page, app).await;
|
||||
let cx = &mut window;
|
||||
finish_motion(&page, cx);
|
||||
|
||||
client.set(GamePhase::Ended, true, Some(233));
|
||||
client.read(&page, cx);
|
||||
// The follower's round tells the game's end: the lobby or the block decides.
|
||||
cx.update(|window, cx| {
|
||||
page.update(cx, |p, cx| {
|
||||
let status = p.status.clone();
|
||||
p.apply(
|
||||
crate::worker::Msg::Round {
|
||||
status,
|
||||
reload: false,
|
||||
matches: Vec::new(),
|
||||
game_end: Some(arena_tracker_core::GameEnd {
|
||||
game_id: Some(GAME),
|
||||
}),
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
});
|
||||
assert_eq!(tabs(&page, cx), (Tab::InGame, Tab::InGame));
|
||||
|
||||
switch_tab(&page, cx, Tab::Statistics);
|
||||
client.lobby();
|
||||
client.read(&page, cx);
|
||||
assert_eq!(page.read_with(cx, |p, _| p.tab), Tab::Challenge);
|
||||
finish_motion(&page, cx);
|
||||
app.condition(&page, |p, _| p.stats.is_some()).await;
|
||||
draw(&mut window);
|
||||
let cx = &mut window;
|
||||
assert_eq!(tabs(&page, cx), (Tab::Challenge, Tab::Challenge));
|
||||
assert!(cx.debug_bounds("tab-in-game").is_none());
|
||||
assert_eq!(lit(&page, cx), None);
|
||||
// What it showed went with the screen.
|
||||
assert!(page.read_with(cx, |p, _| p.in_game.sheet().is_empty()));
|
||||
}
|
||||
|
||||
/// A Live Match told while the window shows the page starts with the veil of the tabs.
|
||||
#[gpui::test]
|
||||
async fn a_live_match_comes_out_of_the_veil_when_the_window_shows(app: &mut TestAppContext) {
|
||||
let (page, mut window, _, _) = joueur_in_lobby(app).await;
|
||||
let cx = &mut window;
|
||||
let live = LiveMatch {
|
||||
riot_id: "Joueur#EUW".into(),
|
||||
game_id: Some(GAME),
|
||||
champion_id: Some(233),
|
||||
};
|
||||
tell(&page, cx, Some(live));
|
||||
assert_eq!(tabs(&page, cx), (Tab::InGame, Tab::Challenge));
|
||||
assert!(page.read_with(cx, |p, _| p.fade.is_some()));
|
||||
finish_motion(&page, cx);
|
||||
assert_eq!(tabs(&page, cx), (Tab::InGame, Tab::InGame));
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
//! The end of the Live Match with its end-of-game block (#109, #129): the block makes the game a
|
||||
//! Match, « En partie » goes, and the block decides what shows; the rest of the game's end
|
||||
//! moves nothing.
|
||||
|
||||
use super::in_game_fixtures::tell;
|
||||
use super::matches_auto_open::{
|
||||
before_the_end, game_ends, its_recap, left_alone, settle_tabs, tabs,
|
||||
};
|
||||
use super::matches_fixtures::chosen;
|
||||
use super::matches_provisional::{GAME, MATCH};
|
||||
use super::page_fixtures::draw;
|
||||
use crate::page::Tab;
|
||||
use arena_tracker_core::LiveMatch;
|
||||
|
||||
/// Alice's Live Match: the game whose block the client holds, with Irelia.
|
||||
fn alice_playing() -> Option<LiveMatch> {
|
||||
Some(LiveMatch {
|
||||
riot_id: "Alice#EUW".into(),
|
||||
game_id: Some(GAME),
|
||||
champion_id: Some(39),
|
||||
})
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn the_block_of_the_live_match_opens_its_recap_in_place_of_en_partie(
|
||||
cx: &mut gpui_kit::TestAppContext,
|
||||
) {
|
||||
let (page, mut window, held, opened) = before_the_end(cx);
|
||||
tell(&page, &mut window, alice_playing());
|
||||
settle_tabs(&page, &mut window);
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::InGame, Tab::InGame));
|
||||
|
||||
game_ends(&page, &held, &mut window);
|
||||
settle_tabs(&page, &mut window);
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Matches, Tab::Matches));
|
||||
assert_eq!(opened.get(), 1);
|
||||
its_recap(&page, cx).await;
|
||||
assert_eq!(chosen(&page, &mut window).as_deref(), Some(MATCH));
|
||||
draw(&mut window);
|
||||
assert!(window.debug_bounds("tab-in-game").is_none());
|
||||
|
||||
// The client stays on the game's end-of-game screen, then goes back to its lobby: the tab
|
||||
// does not come back, and nothing moves the player.
|
||||
tell(&page, &mut window, alice_playing());
|
||||
tell(&page, &mut window, None);
|
||||
settle_tabs(&page, &mut window);
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Matches, Tab::Matches));
|
||||
assert!(window.debug_bounds("tab-in-game").is_none());
|
||||
assert_eq!(opened.get(), 1);
|
||||
left_alone(&mut window, true);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn with_the_preference_off_the_block_of_the_live_match_shows_the_challenge(
|
||||
cx: &mut gpui_kit::TestAppContext,
|
||||
) {
|
||||
let (page, mut window, held, opened) = before_the_end(cx);
|
||||
page.update(&mut window, |page, _| {
|
||||
page.set_open_recap_at_match_end(false)
|
||||
});
|
||||
tell(&page, &mut window, alice_playing());
|
||||
settle_tabs(&page, &mut window);
|
||||
|
||||
game_ends(&page, &held, &mut window);
|
||||
settle_tabs(&page, &mut window);
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Challenge, Tab::Challenge));
|
||||
assert_eq!(opened.get(), 0);
|
||||
tell(&page, &mut window, None);
|
||||
settle_tabs(&page, &mut window);
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Challenge, Tab::Challenge));
|
||||
draw(&mut window);
|
||||
assert!(window.debug_bounds("tab-in-game").is_none());
|
||||
}
|
||||
|
||||
/// A block that makes the game a Match but that the end of a Match does not open (another
|
||||
/// Account's): « Défi » shows rather than a tab the top bar no longer has.
|
||||
#[gpui::test]
|
||||
async fn a_block_that_opens_nothing_leaves_en_partie_for_the_challenge(
|
||||
cx: &mut gpui_kit::TestAppContext,
|
||||
) {
|
||||
let (page, mut window, _, opened) = before_the_end(cx);
|
||||
tell(&page, &mut window, alice_playing());
|
||||
settle_tabs(&page, &mut window);
|
||||
let theirs = arena_tracker_core::FollowedMatch {
|
||||
puuid: "Bob".into(),
|
||||
match_id: MATCH.into(),
|
||||
provisional: true,
|
||||
game_id: Some(GAME),
|
||||
season: None,
|
||||
format: arena_tracker_core::Format::Arena3x6,
|
||||
champion_id: 39,
|
||||
started_at_ms: 0,
|
||||
end: arena_tracker_core::MatchEnd::Nothing,
|
||||
};
|
||||
window.update(|window, cx| {
|
||||
page.update(cx, |p, cx| {
|
||||
let status = p.status.clone();
|
||||
let round = crate::worker::Msg::Round {
|
||||
status,
|
||||
reload: true,
|
||||
matches: vec![theirs],
|
||||
game_end: None,
|
||||
};
|
||||
p.apply(round, window, cx)
|
||||
})
|
||||
});
|
||||
settle_tabs(&page, &mut window);
|
||||
assert_eq!(tabs(&page, &mut window), (Tab::Challenge, Tab::Challenge));
|
||||
assert_eq!(opened.get(), 0);
|
||||
assert!(window.debug_bounds("tab-in-game").is_none());
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
//! Joueur's game client, driven by the test, and the Live Match the follower reads from it
|
||||
//! (#109).
|
||||
|
||||
use super::champ_select_fixtures::{finish_motion, joueur_tracker, send};
|
||||
use super::page_fixtures::{draw, open_page_with_tracker};
|
||||
use crate::page::{LiveMatchStarted, Page};
|
||||
use crate::worker::Msg;
|
||||
use arena_tracker_core::{
|
||||
ChampSelect, ClientError, ClientEvent, GameClientSource, GamePhase, Gameflow, LiveMatch,
|
||||
};
|
||||
use gpui_kit::{Entity, TestAppContext, VisualTestContext};
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
/// The client's id of Joueur's game.
|
||||
pub(super) const GAME: u64 = 4242;
|
||||
|
||||
/// Joueur signed in to the client, in the gameflow the test sets.
|
||||
struct Game(Arc<Mutex<Gameflow>>);
|
||||
|
||||
impl GameClientSource for Game {
|
||||
fn signed_in(&self) -> Result<(String, String), ClientError> {
|
||||
Ok(("Joueur".into(), "EUW".into()))
|
||||
}
|
||||
|
||||
fn gameflow(&self) -> Result<Gameflow, ClientError> {
|
||||
Ok(self.0.lock().unwrap().clone())
|
||||
}
|
||||
|
||||
fn official_progress(&self, _: &str) -> Result<Option<u32>, ClientError> {
|
||||
Ok(None)
|
||||
}
|
||||
|
||||
fn champ_select(&self) -> Result<ChampSelect, ClientError> {
|
||||
Err(ClientError::Absent)
|
||||
}
|
||||
|
||||
fn wait_for_event(&self, _: Duration) -> ClientEvent {
|
||||
ClientEvent::Other
|
||||
}
|
||||
}
|
||||
|
||||
/// The client the test drives, and the Live Match the follower last told the page.
|
||||
pub(super) struct Client {
|
||||
flow: Arc<Mutex<Gameflow>>,
|
||||
told: Option<LiveMatch>,
|
||||
}
|
||||
|
||||
impl Client {
|
||||
/// The client in `phase` of game `GAME`, Arena or not, Joueur playing `champion`.
|
||||
pub(super) fn set(&self, phase: GamePhase, arena: bool, champion: Option<u32>) {
|
||||
*self.flow.lock().unwrap() = Gameflow {
|
||||
phase,
|
||||
arena,
|
||||
game_id: Some(GAME),
|
||||
queue_id: Some(1750),
|
||||
champion_id: champion,
|
||||
};
|
||||
}
|
||||
|
||||
/// The client back in its lobby.
|
||||
pub(super) fn lobby(&self) {
|
||||
*self.flow.lock().unwrap() = Gameflow::default();
|
||||
}
|
||||
|
||||
/// A gameflow event: the follower reads the client and tells the page the Live Match when
|
||||
/// it changed, as the worker does.
|
||||
pub(super) fn read(&mut self, page: &Entity<Page>, cx: &mut VisualTestContext) {
|
||||
let snapshot = page.read_with(cx, |p, _| p.tracker.client_snapshot());
|
||||
let Ok(next) = snapshot.live_match(self.told.as_ref()) else {
|
||||
return;
|
||||
};
|
||||
if next != self.told {
|
||||
self.told = next.clone();
|
||||
tell(page, cx, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The follower tells the page the Live Match `live`.
|
||||
pub(super) fn tell(page: &Entity<Page>, cx: &mut VisualTestContext, live: Option<LiveMatch>) {
|
||||
cx.update(|window, cx| page.update(cx, |p, cx| p.apply(Msg::LiveMatch(live), window, cx)));
|
||||
}
|
||||
|
||||
/// The page on Joueur's statistics, Joueur in the client's lobby; how many times the page said
|
||||
/// a Live Match started.
|
||||
pub(super) async fn joueur_in_lobby(
|
||||
cx: &mut TestAppContext,
|
||||
) -> (Entity<Page>, VisualTestContext, Client, Rc<Cell<usize>>) {
|
||||
cx.executor().allow_parking();
|
||||
let flow = Arc::new(Mutex::new(Gameflow::default()));
|
||||
let tracker = joueur_tracker().with_client(Box::new(Game(flow.clone())));
|
||||
let (page, mut window) = open_page_with_tracker(cx, tracker);
|
||||
let started = Rc::new(Cell::new(0));
|
||||
let counted = started.clone();
|
||||
window.update(|_, cx| {
|
||||
cx.subscribe(&page, move |_, _: &LiveMatchStarted, _| {
|
||||
counted.set(counted.get() + 1)
|
||||
})
|
||||
.detach()
|
||||
});
|
||||
cx.condition(&page, |p, _| p.stats.is_some()).await;
|
||||
draw(&mut window);
|
||||
let client = Client { flow, told: None };
|
||||
(page, window, client, started)
|
||||
}
|
||||
|
||||
/// Joueur's page during the champ select `pick`, its hand dealt.
|
||||
pub(super) async fn joueur_in_champ_select(
|
||||
cx: &mut TestAppContext,
|
||||
pick: &ChampSelect,
|
||||
) -> (Entity<Page>, VisualTestContext, Client, Rc<Cell<usize>>) {
|
||||
let (page, mut window, client, started) = joueur_in_lobby(cx).await;
|
||||
client.set(GamePhase::ChampSelect, true, None);
|
||||
send(&page, &mut window, pick);
|
||||
cx.condition(&page, |p, _| p.stats.is_some()).await;
|
||||
draw(&mut window);
|
||||
finish_motion(&page, &mut window);
|
||||
(page, window, client, started)
|
||||
}
|
||||
|
||||
/// Waits for the statistics of the Live Match's scope and for the champion's latest Matches.
|
||||
pub(super) async fn in_game_ready(page: &Entity<Page>, cx: &mut TestAppContext) {
|
||||
cx.condition(page, |p, _| p.stats.is_some() && p.in_game.recent_read())
|
||||
.await;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ use std::rc::Rc;
|
||||
|
||||
/// The page on Alice's Matches before the game ends, the client's hold on its block, and how
|
||||
/// many times the page said it opened a recap.
|
||||
fn before_the_end(
|
||||
pub(super) fn before_the_end(
|
||||
cx: &mut TestAppContext,
|
||||
) -> (Entity<Page>, VisualTestContext, Held, Rc<Cell<usize>>) {
|
||||
before_the_end_in(cx, vec![season("Saison", 2020)])
|
||||
@@ -45,7 +45,7 @@ fn before_the_end_in(
|
||||
|
||||
/// The game ends: the client gives its end-of-game block, and the follower's round stores its
|
||||
/// Provisional Match and tells the page, as the worker does.
|
||||
fn game_ends(page: &Entity<Page>, held: &Held, cx: &mut VisualTestContext) {
|
||||
pub(super) fn game_ends(page: &Entity<Page>, held: &Held, cx: &mut VisualTestContext) {
|
||||
*held.lock().unwrap() = Some(block());
|
||||
let ended = round(page, cx, LEFT_AT_MS);
|
||||
assert_eq!(ended.len(), 1);
|
||||
@@ -82,7 +82,7 @@ fn round(page: &Entity<Page>, cx: &mut VisualTestContext, now_ms: i64) -> Vec<Fo
|
||||
}
|
||||
|
||||
/// Lets the transition between the tabs end.
|
||||
fn settle_tabs(page: &Entity<Page>, cx: &mut VisualTestContext) {
|
||||
pub(super) fn settle_tabs(page: &Entity<Page>, cx: &mut VisualTestContext) {
|
||||
for _ in 0..10 {
|
||||
if page.read_with(cx, |p, _| p.fade.is_none()) {
|
||||
return draw(cx);
|
||||
@@ -93,7 +93,7 @@ fn settle_tabs(page: &Entity<Page>, cx: &mut VisualTestContext) {
|
||||
}
|
||||
|
||||
/// Waits for the recap of the Match that ended.
|
||||
async fn its_recap(page: &Entity<Page>, cx: &mut TestAppContext) {
|
||||
pub(super) async fn its_recap(page: &Entity<Page>, cx: &mut TestAppContext) {
|
||||
cx.condition(
|
||||
page,
|
||||
|p, _| matches!(&p.matches.recap, Recap::Ready { recap, .. } if recap.match_id == MATCH),
|
||||
@@ -101,12 +101,12 @@ async fn its_recap(page: &Entity<Page>, cx: &mut TestAppContext) {
|
||||
.await;
|
||||
}
|
||||
|
||||
fn tabs(page: &Entity<Page>, cx: &mut VisualTestContext) -> (Tab, Tab) {
|
||||
pub(super) fn tabs(page: &Entity<Page>, cx: &mut VisualTestContext) -> (Tab, Tab) {
|
||||
page.read_with(cx, |p, _| (p.tab, p.shown_tab))
|
||||
}
|
||||
|
||||
/// The window was neither activated nor shown, and nothing in it took the focus.
|
||||
fn left_alone(cx: &mut VisualTestContext, visible: bool) {
|
||||
pub(super) fn left_alone(cx: &mut VisualTestContext, visible: bool) {
|
||||
cx.update(|window, cx| {
|
||||
assert_eq!(cx.active_window(), None, "the window was activated");
|
||||
assert!(!window.is_window_active());
|
||||
|
||||
@@ -13,6 +13,11 @@ impl Page {
|
||||
}
|
||||
Msg::Champions => self.reload_in_background(window, cx),
|
||||
Msg::GameData(catalog) => self.apply_game_data(catalog, cx),
|
||||
Msg::LiveMatch(live) => self.change_live_match(live, window, cx),
|
||||
Msg::RecentMatches {
|
||||
generation,
|
||||
matches,
|
||||
} => self.apply_recent(generation, matches),
|
||||
Msg::ChampSelect(champ_select) => {
|
||||
if self.leave.is_some() {
|
||||
if champ_select.is_none() {
|
||||
@@ -68,10 +73,16 @@ impl Page {
|
||||
self.stats_generation += 1;
|
||||
}
|
||||
}
|
||||
if reload {
|
||||
// The Live Match's block makes it a Match: the statistics come back to the home's
|
||||
// scope, which reads the Match too.
|
||||
let rescoped = self.end_live_match_with_block(&matches, window, cx);
|
||||
if reload && !rescoped {
|
||||
self.reload_in_background(window, cx);
|
||||
}
|
||||
self.follow_match_end(&matches, game_end, window, cx);
|
||||
if rescoped {
|
||||
self.leave_gone_tab(window, cx);
|
||||
}
|
||||
if self.in_champ_select() {
|
||||
self.prepare_champ_select(cx);
|
||||
}
|
||||
|
||||
@@ -319,9 +319,10 @@ pub fn reopen(hwnd: HWND) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Brings the window above the other windows, whether minimized, hidden in the notification area
|
||||
/// or only covered, while the foreground app keeps the keyboard.
|
||||
pub fn reveal(hwnd: HWND) {
|
||||
/// Shows the window, minimized or hidden in the notification area, while the foreground app
|
||||
/// keeps the keyboard; `raise` also brings it above the other windows, even when only covered
|
||||
/// (an Arena champ select, not a Live Match: the game stays above it).
|
||||
pub fn reveal(hwnd: HWND, raise: bool) {
|
||||
unsafe {
|
||||
let iconic = IsIconic(hwnd).as_bool();
|
||||
if let Some(tray) = installed_tray(hwnd) {
|
||||
@@ -336,6 +337,9 @@ pub fn reveal(hwnd: HWND) {
|
||||
};
|
||||
// ShowWindow sends the WM_SHOWWINDOW or WM_SIZE that tells GPUI the window is visible.
|
||||
let _ = ShowWindow(hwnd, command);
|
||||
if !raise {
|
||||
return;
|
||||
}
|
||||
// While another app has the foreground, HWND_TOP leaves the window where it is: a topmost
|
||||
// round trip puts it above every non-topmost window, still without activating it.
|
||||
let flags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE;
|
||||
|
||||
@@ -8,8 +8,8 @@ use std::thread;
|
||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use arena_tracker_core::{
|
||||
ChampSelect, ClientEvent, DeathRecapState, GameCatalog, MatchRecap, Scope, Statistics, Status,
|
||||
SyncProgress, Tracker, UpdateChannel,
|
||||
ChampSelect, ClientEvent, DeathRecapState, GameCatalog, LiveMatch, MatchRecap, Scope,
|
||||
Statistics, Status, SyncProgress, Tracker, UpdateChannel,
|
||||
};
|
||||
use gpui_kit::base::async_util::Sender;
|
||||
|
||||
@@ -20,13 +20,20 @@ mod matches;
|
||||
pub use death_recap::spawn_death_recap;
|
||||
use death_recap::spawn_death_recap_queue;
|
||||
pub use game_data::CatalogRefresh;
|
||||
pub use matches::{MatchEntry, spawn_match_list, spawn_recap};
|
||||
pub use matches::{MatchEntry, spawn_match_list, spawn_recap, spawn_recent_matches};
|
||||
|
||||
/// The signed-in Riot ID and its pick, or none outside an Arena champ select.
|
||||
pub type LiveChampSelect = Option<(String, ChampSelect)>;
|
||||
|
||||
pub enum Msg {
|
||||
ChampSelect(LiveChampSelect),
|
||||
/// The Live Match changed: it started, its champion became known, or it ended (#109).
|
||||
LiveMatch(Option<LiveMatch>),
|
||||
/// A champion's latest Matches of the Season, for « En partie », newest first.
|
||||
RecentMatches {
|
||||
generation: u64,
|
||||
matches: Result<Vec<MatchEntry>, String>,
|
||||
},
|
||||
/// A sync is fetching Matches.
|
||||
Progress(SyncProgress),
|
||||
/// The champion catalog or portraits changed on disk: the statistics carry them.
|
||||
@@ -300,6 +307,7 @@ pub fn spawn_follower(
|
||||
});
|
||||
spawn_guarded(tx, Msg::Crashed, move |tx| {
|
||||
let mut previous = None;
|
||||
let mut live = None;
|
||||
let mut snapshot = tracker.client_snapshot();
|
||||
let mut needs_snapshot = true;
|
||||
let mut client_up = false;
|
||||
@@ -323,6 +331,17 @@ pub fn spawn_follower(
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Before the champ select: the page knows a game started when the champ select
|
||||
// that launched it ends. A failed read keeps what the page shows.
|
||||
match snapshot.live_match(live.as_ref()) {
|
||||
Ok(next) if next != live => {
|
||||
if tx.try_send(Msg::LiveMatch(next.clone())).is_err() {
|
||||
break;
|
||||
}
|
||||
live = next;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
match tracker.champ_select_with(&snapshot) {
|
||||
Ok(champ_select) if champ_select != previous => {
|
||||
if tx.try_send(Msg::ChampSelect(champ_select.clone())).is_err() {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
//! The jobs of « Parties »: the list of an Account's Matches, and the Match Recap of the one
|
||||
//! opened. Each runs on a below-normal thread and always reports, a panic as an error, so the
|
||||
//! page's gate for it is never left waiting.
|
||||
//! opened; and the latest Matches of the champion « En partie » shows. Each runs on a
|
||||
//! below-normal thread and always reports, a panic as an error, so the page's gate for it is
|
||||
//! never left waiting.
|
||||
|
||||
use std::panic::{AssertUnwindSafe, catch_unwind};
|
||||
use std::sync::Arc;
|
||||
|
||||
use arena_tracker_core::{DeathRecapState, Format, GameCatalog, Tracker};
|
||||
use arena_tracker_core::{DeathRecapState, Format, GameCatalog, Match, Tracker};
|
||||
use gpui_kit::base::async_util::Sender;
|
||||
|
||||
use super::{Msg, spawn_guarded};
|
||||
@@ -30,16 +31,9 @@ pub struct MatchEntry {
|
||||
pub win: bool,
|
||||
}
|
||||
|
||||
/// The stored Matches of `puuid`, newest first.
|
||||
pub fn match_list(tracker: &Tracker, puuid: &str) -> Result<Vec<MatchEntry>, String> {
|
||||
let matches = tracker
|
||||
.matches(puuid)
|
||||
.map_err(|e| format!("Parties indisponibles : {e}"))?;
|
||||
// The store gives them oldest first.
|
||||
Ok(matches
|
||||
.into_iter()
|
||||
.rev()
|
||||
.map(|m| MatchEntry {
|
||||
impl From<Match> for MatchEntry {
|
||||
fn from(m: Match) -> MatchEntry {
|
||||
MatchEntry {
|
||||
when: match_time(local_time(m.started_at_ms)),
|
||||
match_id: m.match_id,
|
||||
champion_id: m.champion_id,
|
||||
@@ -49,8 +43,44 @@ pub fn match_list(tracker: &Tracker, puuid: &str) -> Result<Vec<MatchEntry>, Str
|
||||
provisional: m.provisional,
|
||||
format: m.format,
|
||||
win: m.win,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The stored Matches of `puuid`, newest first.
|
||||
pub fn match_list(tracker: &Tracker, puuid: &str) -> Result<Vec<MatchEntry>, String> {
|
||||
let matches = tracker
|
||||
.matches(puuid)
|
||||
.map_err(|e| format!("Parties indisponibles : {e}"))?;
|
||||
// The store gives them oldest first.
|
||||
Ok(matches.into_iter().rev().map(MatchEntry::from).collect())
|
||||
}
|
||||
|
||||
/// How many of a champion's Matches « En partie » lists.
|
||||
const RECENT_MATCHES: usize = 5;
|
||||
|
||||
/// Reads the latest Matches of `puuid` with `champion_id` in `season`, for « En partie ».
|
||||
pub fn spawn_recent_matches(
|
||||
tracker: Arc<Tracker>,
|
||||
puuid: String,
|
||||
champion_id: u32,
|
||||
season: String,
|
||||
generation: u64,
|
||||
tx: Sender<Msg>,
|
||||
) {
|
||||
spawn_guarded(tx, Msg::Crashed, move |tx| {
|
||||
let matches = catch_unwind(AssertUnwindSafe(|| {
|
||||
tracker
|
||||
.recent_champion_matches(&puuid, champion_id, &season, RECENT_MATCHES)
|
||||
.map(|matches| matches.into_iter().map(MatchEntry::from).collect())
|
||||
.map_err(|e| format!("Parties indisponibles : {e}"))
|
||||
}))
|
||||
.unwrap_or_else(|_| Err("Parties indisponibles : erreur interne".into()));
|
||||
let _ = tx.try_send(Msg::RecentMatches {
|
||||
generation,
|
||||
matches,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// Lists the Matches of `puuid` for « Parties ».
|
||||
|
||||
@@ -116,6 +116,9 @@ pub struct Gameflow {
|
||||
pub game_id: Option<u64>,
|
||||
/// The current game's queue; `None` when there is no game.
|
||||
pub queue_id: Option<u32>,
|
||||
/// The champion the signed-in summoner plays in the current game; `None` when there is no
|
||||
/// game or the client does not say it yet.
|
||||
pub champion_id: Option<u32>,
|
||||
}
|
||||
|
||||
impl Gameflow {
|
||||
@@ -125,6 +128,50 @@ impl Gameflow {
|
||||
}
|
||||
}
|
||||
|
||||
/// The Live Match: the Arena game the signed-in Account plays, from its start until the client
|
||||
/// leaves it for good (its lobby, another phase, or the client closing). Its end-of-game screen
|
||||
/// is still part of it: the page ends it sooner when the game's end-of-game block arrives (#109).
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct LiveMatch {
|
||||
/// `gameName#tagLine` of the Account signed in to the client.
|
||||
pub riot_id: String,
|
||||
/// The client's id of the game, when it gives one.
|
||||
pub game_id: Option<u64>,
|
||||
/// The champion played; `None` until the client says it.
|
||||
pub champion_id: Option<u32>,
|
||||
}
|
||||
|
||||
impl ClientSnapshot {
|
||||
/// The Live Match this read shows, `previous` being the one the read before showed. It
|
||||
/// starts only with an Arena game in progress, so a client met on an end-of-game screen
|
||||
/// shows none; it lasts through that game's end. A champion once known is kept for the
|
||||
/// game. `Err`: the read failed, and what is shown stays.
|
||||
pub fn live_match(
|
||||
&self,
|
||||
previous: Option<&LiveMatch>,
|
||||
) -> Result<Option<LiveMatch>, ClientError> {
|
||||
let (flow, (name, tag)) = match (&self.gameflow, &self.signed_in) {
|
||||
(Ok(flow), Ok(id)) => (flow, id),
|
||||
(Err(ClientError::Absent), _) | (_, Err(ClientError::Absent)) => return Ok(None),
|
||||
(Err(error), _) | (_, Err(error)) => return Err(error.clone()),
|
||||
};
|
||||
let riot_id = crate::follow::riot_id(name, tag);
|
||||
let same_game = previous.filter(|p| p.game_id == flow.game_id && p.riot_id == riot_id);
|
||||
let goes_on = match flow.phase {
|
||||
GamePhase::InGame => true,
|
||||
GamePhase::Ended => same_game.is_some(),
|
||||
GamePhase::Idle | GamePhase::ChampSelect => false,
|
||||
};
|
||||
Ok((flow.arena && goes_on).then(|| LiveMatch {
|
||||
champion_id: flow
|
||||
.champion_id
|
||||
.or_else(|| same_game.and_then(|p| p.champion_id)),
|
||||
game_id: flow.game_id,
|
||||
riot_id,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@@ -203,6 +250,73 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// A read signed in as Joueur#EUW, in `phase` of Arena game 7 or not, playing `champion`.
|
||||
fn read(phase: GamePhase, arena: bool, champion: Option<u32>) -> ClientSnapshot {
|
||||
ClientSnapshot {
|
||||
signed_in: Ok(("Joueur".into(), "EUW".into())),
|
||||
gameflow: Ok(Gameflow {
|
||||
phase,
|
||||
arena,
|
||||
game_id: Some(7),
|
||||
champion_id: champion,
|
||||
..Gameflow::default()
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_live_match_lasts_from_its_start_to_the_lobby() {
|
||||
let live = |game_id, champion_id| LiveMatch {
|
||||
riot_id: "Joueur#EUW".into(),
|
||||
game_id: Some(game_id),
|
||||
champion_id,
|
||||
};
|
||||
// An end-of-game screen met first is no Live Match: it never started.
|
||||
assert_eq!(
|
||||
read(GamePhase::Ended, true, None).live_match(None),
|
||||
Ok(None)
|
||||
);
|
||||
let started = read(GamePhase::InGame, true, None).live_match(None);
|
||||
assert_eq!(started, Ok(Some(live(7, None))));
|
||||
// The champion comes later (Bravery), and stays once known.
|
||||
let known = read(GamePhase::InGame, true, Some(103)).live_match(Some(&live(7, None)));
|
||||
assert_eq!(known, Ok(Some(live(7, Some(103)))));
|
||||
let ended = read(GamePhase::Ended, true, None).live_match(Some(&live(7, Some(103))));
|
||||
assert_eq!(ended, Ok(Some(live(7, Some(103)))));
|
||||
// The end of another game is not this one's.
|
||||
assert_eq!(
|
||||
read(GamePhase::Ended, true, None).live_match(Some(&live(8, None))),
|
||||
Ok(None)
|
||||
);
|
||||
for phase in [GamePhase::Idle, GamePhase::ChampSelect] {
|
||||
assert_eq!(
|
||||
read(phase, true, None).live_match(Some(&live(7, None))),
|
||||
Ok(None)
|
||||
);
|
||||
}
|
||||
// Not Arena: no Live Match.
|
||||
assert_eq!(
|
||||
read(GamePhase::InGame, false, Some(103)).live_match(None),
|
||||
Ok(None)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_failed_read_keeps_the_live_match_and_a_closed_client_ends_it() {
|
||||
let shown = read(GamePhase::InGame, true, Some(103))
|
||||
.live_match(None)
|
||||
.unwrap();
|
||||
let failed = ClientSnapshot {
|
||||
gameflow: Err(ClientError::Other("panne".into())),
|
||||
..read(GamePhase::InGame, true, None)
|
||||
};
|
||||
assert!(failed.live_match(shown.as_ref()).is_err());
|
||||
assert_eq!(
|
||||
ClientSnapshot::absent().live_match(shown.as_ref()),
|
||||
Ok(None)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_an_arena_champ_select_shows_the_live_pick() {
|
||||
let flow = |phase, arena| Gameflow {
|
||||
|
||||
@@ -197,7 +197,9 @@ impl GameClientSource for LeagueClient {
|
||||
|
||||
fn gameflow(&self) -> Result<Gameflow, ClientError> {
|
||||
let (status, body) = self.get("/lol-gameflow/v1/session")?;
|
||||
let flow = decode_gameflow(status, &body)?;
|
||||
// The summoner the sign-in read just before found: the champion played is theirs.
|
||||
let puuid = lock(&self.summoner).as_ref().and_then(|s| s.puuid.clone());
|
||||
let flow = decode_gameflow(status, &body, puuid.as_deref())?;
|
||||
self.champ_select_reader
|
||||
.reset_unless_arena_champ_select(&flow);
|
||||
Ok(flow)
|
||||
|
||||
@@ -51,8 +51,13 @@ pub(super) fn decode_summoner(
|
||||
}
|
||||
|
||||
/// No session (404) means no game. The other fields are read leniently: the API is
|
||||
/// unofficial and changes with patches.
|
||||
pub fn decode_gameflow(status: u16, body: &str) -> Result<Gameflow, ClientError> {
|
||||
/// unofficial and changes with patches. `local_puuid`, the client's PUUID of the signed-in
|
||||
/// summoner, finds the champion they play in the game's champion lists.
|
||||
pub fn decode_gameflow(
|
||||
status: u16,
|
||||
body: &str,
|
||||
local_puuid: Option<&str>,
|
||||
) -> Result<Gameflow, ClientError> {
|
||||
match status {
|
||||
404 => Ok(Gameflow::default()),
|
||||
200 => {
|
||||
@@ -72,12 +77,28 @@ pub fn decode_gameflow(status: u16, body: &str) -> Result<Gameflow, ClientError>
|
||||
.and_then(Value::as_u64)
|
||||
.and_then(|id| u32::try_from(id).ok())
|
||||
.filter(|&id| id != 0),
|
||||
champion_id: local_puuid.and_then(|puuid| played_champion(&session, puuid)),
|
||||
})
|
||||
}
|
||||
_ => Err(ClientError::Other(format!("HTTP {status}"))),
|
||||
}
|
||||
}
|
||||
|
||||
/// The champion `puuid` plays in the game of a gameflow session: from the champion
|
||||
/// selections, else from the teams. `None` while the client gives none (0), as in a Bravery
|
||||
/// game before the champion is drawn.
|
||||
fn played_champion(session: &Value, puuid: &str) -> Option<u32> {
|
||||
["playerChampionSelections", "teamOne", "teamTwo"]
|
||||
.iter()
|
||||
.filter_map(|list| session["gameData"][list].as_array())
|
||||
.flatten()
|
||||
.filter(|player| player["puuid"].as_str() == Some(puuid))
|
||||
.find_map(|player| {
|
||||
let id = player["championId"].as_u64()?;
|
||||
u32::try_from(id).ok().filter(|&id| id != 0)
|
||||
})
|
||||
}
|
||||
|
||||
/// (group id, id of the group's first counter) of the group with exactly this name.
|
||||
pub(super) fn find_track(
|
||||
body: &str,
|
||||
|
||||
@@ -105,12 +105,13 @@ fn nobody_signed_in_yet_is_absent() {
|
||||
#[test]
|
||||
fn no_gameflow_session_means_idle() {
|
||||
assert_eq!(
|
||||
decode_gameflow(404, NO_SESSION),
|
||||
decode_gameflow(404, NO_SESSION, None),
|
||||
Ok(Gameflow {
|
||||
phase: GamePhase::Idle,
|
||||
arena: false,
|
||||
game_id: None,
|
||||
queue_id: None
|
||||
queue_id: None,
|
||||
champion_id: None
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -118,22 +119,24 @@ fn no_gameflow_session_means_idle() {
|
||||
#[test]
|
||||
fn an_arena_game_in_progress_is_in_game_and_arena() {
|
||||
assert_eq!(
|
||||
decode_gameflow(200, ARENA_GAME),
|
||||
decode_gameflow(200, ARENA_GAME, None),
|
||||
Ok(Gameflow {
|
||||
phase: GamePhase::InGame,
|
||||
arena: true,
|
||||
game_id: Some(9000000099),
|
||||
queue_id: Some(1750)
|
||||
queue_id: Some(1750),
|
||||
champion_id: None
|
||||
})
|
||||
);
|
||||
let classic = r#"{"phase": "InProgress", "gameData": {"queue": {"gameMode": "CLASSIC"}}}"#;
|
||||
assert_eq!(
|
||||
decode_gameflow(200, classic),
|
||||
decode_gameflow(200, classic, None),
|
||||
Ok(Gameflow {
|
||||
phase: GamePhase::InGame,
|
||||
arena: false,
|
||||
game_id: None,
|
||||
queue_id: None
|
||||
queue_id: None,
|
||||
champion_id: None
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -143,37 +146,73 @@ fn unknown_and_missing_gameflow_fields_are_not_errors() {
|
||||
let extra = r#"{"phase": "ChampSelect", "somethingNew": {"a": [1, 2]}, "map": null,
|
||||
"gameData": {"queue": null}}"#;
|
||||
assert_eq!(
|
||||
decode_gameflow(200, extra),
|
||||
decode_gameflow(200, extra, None),
|
||||
Ok(Gameflow {
|
||||
phase: GamePhase::ChampSelect,
|
||||
arena: false,
|
||||
game_id: None,
|
||||
queue_id: None
|
||||
queue_id: None,
|
||||
champion_id: None
|
||||
})
|
||||
);
|
||||
assert_eq!(decode_gameflow(200, "{}"), decode_gameflow(404, ""));
|
||||
assert_eq!(
|
||||
decode_gameflow(200, "{}", None),
|
||||
decode_gameflow(404, "", None)
|
||||
);
|
||||
// The map alone says Arena when the queue is missing.
|
||||
let map_only = r#"{"phase": "EndOfGame", "map": {"gameMode": "CHERRY"}}"#;
|
||||
assert_eq!(
|
||||
decode_gameflow(200, map_only),
|
||||
decode_gameflow(200, map_only, None),
|
||||
Ok(Gameflow {
|
||||
phase: GamePhase::Ended,
|
||||
arena: true,
|
||||
game_id: None,
|
||||
queue_id: None
|
||||
queue_id: None,
|
||||
champion_id: None
|
||||
})
|
||||
);
|
||||
// An id of 0 means no game; one that is not a number is ignored.
|
||||
for id in ["0", "\"x\"", "null", "-1"] {
|
||||
let body = format!(r#"{{"phase": "InProgress", "gameData": {{"gameId": {id}}}}}"#);
|
||||
assert_eq!(decode_gameflow(200, &body).unwrap().game_id, None, "{id}");
|
||||
assert_eq!(
|
||||
decode_gameflow(200, &body, None).unwrap().game_id,
|
||||
None,
|
||||
"{id}"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
decode_gameflow(503, ""),
|
||||
decode_gameflow(503, "", None),
|
||||
Err(ClientError::Other("HTTP 503".into()))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_champion_played_is_the_signed_in_summoners() {
|
||||
let me = "fixture-puuid-self";
|
||||
let session = |selections: &str, team: &str| {
|
||||
format!(
|
||||
r#"{{"phase": "InProgress", "gameData": {{"queue": {{"gameMode": "CHERRY"}},
|
||||
"playerChampionSelections": {selections}, "teamOne": {team}}}}}"#
|
||||
)
|
||||
};
|
||||
let played = |body: &str, puuid| decode_gameflow(200, body, puuid).unwrap().champion_id;
|
||||
let selections = format!(
|
||||
r#"[{{"championId": 12, "puuid": "someone"}}, {{"championId": 103, "puuid": "{me}"}}]"#
|
||||
);
|
||||
let body = session(&selections, "[]");
|
||||
assert_eq!(played(&body, Some(me)), Some(103));
|
||||
// Without the summoner's PUUID, nobody is the player.
|
||||
assert_eq!(played(&body, None), None);
|
||||
assert_eq!(played(&body, Some("another")), None);
|
||||
// The teams stand in when the selections do not name the player.
|
||||
let team = format!(r#"[{{"championId": 25, "puuid": "{me}"}}]"#);
|
||||
assert_eq!(played(&session("[]", &team), Some(me)), Some(25));
|
||||
// No champion drawn yet (Bravery), or the lists missing.
|
||||
let undrawn = format!(r#"[{{"championId": 0, "puuid": "{me}"}}]"#);
|
||||
assert_eq!(played(&session(&undrawn, "[]"), Some(me)), None);
|
||||
assert_eq!(played(ARENA_GAME, Some(me)), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn finds_the_champs_completed_tracks_by_exact_name() {
|
||||
for (name, group, counter) in [
|
||||
|
||||
@@ -23,7 +23,8 @@ pub use champ_select::{ChampSelect, ChampSelectReader, Unpickable};
|
||||
pub use champion_search::ChampionSearch;
|
||||
pub use champions::{CARD_ASPECT, Champion, ChampionCatalog, ChampionSource, DataDragon};
|
||||
pub use client::{
|
||||
ClientError, ClientEvent, ClientSnapshot, EndOfGameBlock, GameClientSource, GamePhase, Gameflow,
|
||||
ClientError, ClientEvent, ClientSnapshot, EndOfGameBlock, GameClientSource, GamePhase,
|
||||
Gameflow, LiveMatch,
|
||||
};
|
||||
pub use config::{ChampionSort, Config, Preferences, ThemePreference, UpdateChannel, data_dir};
|
||||
pub use date::Date;
|
||||
|
||||
@@ -433,6 +433,23 @@ impl Tracker {
|
||||
}))
|
||||
}
|
||||
|
||||
/// The Account's latest `limit` Matches with one champion in the Season named `season`,
|
||||
/// newest first: what « En partie » lists (#109).
|
||||
pub fn recent_champion_matches(
|
||||
&self,
|
||||
puuid: &str,
|
||||
champion_id: u32,
|
||||
season: &str,
|
||||
limit: usize,
|
||||
) -> Result<Vec<Match>, Error> {
|
||||
let range =
|
||||
period(&self.seasons, season).ok_or_else(|| Error::UnknownSeason(season.into()))?;
|
||||
let mut matches = self.champion_matches(puuid, champion_id, range)?;
|
||||
matches.reverse();
|
||||
matches.truncate(limit);
|
||||
Ok(matches)
|
||||
}
|
||||
|
||||
pub fn statistics(&self, puuid: &str, scope: &Scope) -> Result<Statistics, Error> {
|
||||
let season_period = match &scope.season {
|
||||
SeasonScope::AllSeasons => None,
|
||||
|
||||
@@ -135,6 +135,12 @@ impl FakeClient {
|
||||
self.state.lock().unwrap().gameflow.game_id = game_id;
|
||||
}
|
||||
|
||||
/// The champion the signed-in summoner plays in the game (kept across phases until
|
||||
/// changed); `None` while the client does not say it.
|
||||
pub fn set_champion(&self, champion_id: Option<u32>) {
|
||||
self.state.lock().unwrap().gameflow.champion_id = champion_id;
|
||||
}
|
||||
|
||||
pub fn set_champ_select(&self, raw: RawChampSelect) {
|
||||
self.state.lock().unwrap().champ_select = Some(raw);
|
||||
}
|
||||
@@ -219,7 +225,7 @@ impl GameClientSource for FakeClient {
|
||||
return Err(error.clone());
|
||||
}
|
||||
let flow = match &state.raw_gameflow {
|
||||
Some(body) => decode_gameflow(200, body)?,
|
||||
Some(body) => decode_gameflow(200, body, state.summoner_puuid.as_deref())?,
|
||||
None => state.gameflow.clone(),
|
||||
};
|
||||
state
|
||||
|
||||
@@ -206,6 +206,8 @@ mod accounts;
|
||||
mod champ_select;
|
||||
#[path = "follow/death_recaps.rs"]
|
||||
mod death_recaps;
|
||||
#[path = "follow/in_game.rs"]
|
||||
mod in_game;
|
||||
#[path = "follow/live_matches.rs"]
|
||||
mod live_matches;
|
||||
#[path = "follow/pending_matches.rs"]
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
//! The Live Match the page shows as « En partie » (#109): read from the client's gameflow, from
|
||||
//! the start of an Arena game until the client leaves it.
|
||||
|
||||
use super::*;
|
||||
use arena_tracker_core::LiveMatch;
|
||||
use common::RIOT_ID;
|
||||
|
||||
/// What the page shows after one more read of the client, `shown` being what it showed: a read
|
||||
/// that fails keeps it, as the follower does.
|
||||
fn read_live(tracker: &Tracker, shown: &mut Option<LiveMatch>) -> Option<LiveMatch> {
|
||||
if let Ok(next) = tracker.client_snapshot().live_match(shown.as_ref()) {
|
||||
*shown = next;
|
||||
}
|
||||
shown.clone()
|
||||
}
|
||||
|
||||
/// The summoner of the recorded client, as its gameflow names the players.
|
||||
const SUMMONER_PUUID: &str = "fixture-puuid-self";
|
||||
|
||||
#[test]
|
||||
fn a_game_launched_from_the_champ_select_is_live_until_the_lobby() {
|
||||
let world = World::new(&[]);
|
||||
let tracker = world.tracker();
|
||||
let mut shown = None;
|
||||
world.client.set_phase("ChampSelect", true);
|
||||
assert_eq!(read_live(&tracker, &mut shown), None);
|
||||
|
||||
let game = common::recorded_game_id();
|
||||
world.client.set_game_id(Some(game));
|
||||
world.client.set_phase("GameStart", true);
|
||||
// Started, its champion not said yet: the page identifies it later.
|
||||
let started = LiveMatch {
|
||||
riot_id: RIOT_ID.into(),
|
||||
game_id: Some(game),
|
||||
champion_id: None,
|
||||
};
|
||||
assert_eq!(read_live(&tracker, &mut shown), Some(started.clone()));
|
||||
|
||||
world.client.set_champion(Some(222));
|
||||
world.client.set_phase("InProgress", true);
|
||||
let playing = LiveMatch {
|
||||
champion_id: Some(222),
|
||||
..started
|
||||
};
|
||||
assert_eq!(read_live(&tracker, &mut shown), Some(playing.clone()));
|
||||
// Its end-of-game screen is still the Live Match, a failed read too.
|
||||
for phase in ["WaitingForStats", "PreEndOfGame", "EndOfGame"] {
|
||||
world.client.set_phase(phase, true);
|
||||
assert_eq!(
|
||||
read_live(&tracker, &mut shown),
|
||||
Some(playing.clone()),
|
||||
"{phase}"
|
||||
);
|
||||
}
|
||||
world
|
||||
.client
|
||||
.fail_gameflow(Some(ClientError::Other("panne".into())));
|
||||
assert_eq!(read_live(&tracker, &mut shown), Some(playing));
|
||||
world.client.fail_gameflow(None);
|
||||
|
||||
world.client.return_to_lobby();
|
||||
assert_eq!(read_live(&tracker, &mut shown), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_client_met_in_a_game_shows_it_and_finds_its_champion_in_the_session() {
|
||||
let world = World::new(&[]);
|
||||
let tracker = world.tracker();
|
||||
let mut shown = None;
|
||||
// The recorded session of an Arena game in progress names no champion.
|
||||
let recorded = include_str!("../fixtures/client/gameflow_session_in_game.json");
|
||||
world.client.set_gameflow(recorded);
|
||||
let live = read_live(&tracker, &mut shown).unwrap();
|
||||
assert_eq!(
|
||||
(live.game_id, live.champion_id),
|
||||
(Some(common::recorded_game_id()), None)
|
||||
);
|
||||
|
||||
let mut session: serde_json::Value = serde_json::from_str(recorded).unwrap();
|
||||
session["gameData"]["playerChampionSelections"] = serde_json::json!([
|
||||
{"championId": 103, "puuid": "someone-else"},
|
||||
{"championId": 222, "puuid": SUMMONER_PUUID},
|
||||
]);
|
||||
world.client.set_gameflow(&session.to_string());
|
||||
assert_eq!(
|
||||
read_live(&tracker, &mut shown).unwrap().champion_id,
|
||||
Some(222)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_end_screen_met_after_the_game_is_not_live() {
|
||||
let world = World::new(&[]);
|
||||
let tracker = world.tracker();
|
||||
world.client.set_game_id(Some(common::recorded_game_id()));
|
||||
world.client.set_phase("EndOfGame", true);
|
||||
assert_eq!(read_live(&tracker, &mut None), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_game_outside_arena_is_never_live() {
|
||||
let world = World::new(&[]);
|
||||
let tracker = world.tracker();
|
||||
let mut shown = None;
|
||||
world.client.set_game_id(Some(common::recorded_game_id()));
|
||||
world.client.set_champion(Some(222));
|
||||
for phase in ["ChampSelect", "InProgress", "EndOfGame"] {
|
||||
world.client.set_phase(phase, false);
|
||||
assert_eq!(read_live(&tracker, &mut shown), None, "{phase}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn closing_the_client_ends_the_live_match() {
|
||||
let world = World::new(&[]);
|
||||
let tracker = world.tracker();
|
||||
let mut shown = None;
|
||||
world.client.set_phase("InProgress", true);
|
||||
assert!(read_live(&tracker, &mut shown).is_some());
|
||||
world.client.sign_out();
|
||||
assert_eq!(read_live(&tracker, &mut shown), None);
|
||||
}
|
||||
@@ -194,3 +194,32 @@ fn the_champion_challenge_follows_the_account() {
|
||||
assert_eq!(theirs.matches, 1);
|
||||
assert_eq!(theirs.completed_on, Some(date(2026, 1, 3)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_latest_matches_of_a_champion_are_those_of_its_season_newest_first() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let mut matches = run(11, &[5, 4, 3, 2, 1, 6], jan(2, 0));
|
||||
// Another champion, and the same one in the next Season: neither is listed.
|
||||
matches.push(played_match(12, 1, jan(2, 9)));
|
||||
matches.push(played_match(11, 1, at(date(2026, 4, 2), 0)));
|
||||
let tracker = imported_tracker(dir.path(), &matches);
|
||||
|
||||
let recent = tracker
|
||||
.recent_champion_matches(SELF_PUUID, 11, S1, 5)
|
||||
.unwrap();
|
||||
let placements: Vec<_> = recent.iter().map(|m| m.placement).collect();
|
||||
assert_eq!(placements, [6, 1, 2, 3, 4]);
|
||||
assert!(recent.iter().all(|m| m.champion_id == 11));
|
||||
assert!(
|
||||
recent
|
||||
.windows(2)
|
||||
.all(|w| w[0].started_at_ms > w[1].started_at_ms)
|
||||
);
|
||||
// Never played in the Season: none.
|
||||
let none = tracker.recent_champion_matches(SELF_PUUID, 13, S1, 5);
|
||||
assert!(none.unwrap().is_empty());
|
||||
assert!(matches!(
|
||||
tracker.recent_champion_matches(SELF_PUUID, 11, "Saison Z", 5),
|
||||
Err(Error::UnknownSeason(_))
|
||||
));
|
||||
}
|
||||
@@ -4,13 +4,15 @@
|
||||
|
||||
L’appli s’ouvre sur **Défi** : la bannière du Défi de la Saison, puis les cartes de vos champions. Pour l’analyse détaillée (courbe des champions validés, Placements, Tentatives, tableau des champions, avec les sélecteurs de Saison et de Format), ouvrez **Statistiques ›**, le lien au bout de la ligne de la Saison, en haut de la bannière. La page porte **‹ Défi** en haut à gauche, qui ramène au Défi ; l’onglet **Défi** de la barre du haut y ramène aussi. Au clavier, Tab atteint le lien et le retour, Entrée ou Espace les active.
|
||||
|
||||
Au début d’une Sélection des champions Arena, l’onglet **Sélection** apparaît à droite de **Défi** et **Parties** et l’appli l’affiche d’elle-même, où que vous soyez. Il montre les Champions de l’Enclume et « Autres champions ». Pendant la sélection, l’onglet **Défi** montre l’accueil habituel (et **Statistiques ›**) ; revenez sur **Sélection** quand vous voulez, la main y est posée. Les bans et les choix des alliés ne vous ramènent pas sur **Sélection**. À la fin de la sélection, l’onglet disparaît et l’appli affiche le Défi.
|
||||
Au début d’une Sélection des champions Arena, l’onglet **Sélection** apparaît à droite de **Défi** et **Parties** et l’appli l’affiche d’elle-même, où que vous soyez. Il montre les Champions de l’Enclume et « Autres champions ». Pendant la sélection, l’onglet **Défi** montre l’accueil habituel (et **Statistiques ›**) ; revenez sur **Sélection** quand vous voulez, la main y est posée. Les bans et les choix des alliés ne vous ramènent pas sur **Sélection**. À la fin de la sélection, l’onglet disparaît et l’appli affiche le Défi, ou **En partie** si la partie est lancée.
|
||||
|
||||
Au lancement d’une Partie Arena, y compris quand l’appli démarre ou retrouve le client en pleine partie, l’onglet **En partie** apparaît à la place de **Sélection** et l’appli l’affiche, où que vous soyez. Sa bannière montre le champion que vous jouez sur son illustration, avec la Saison et le compteur du Défi, l’anneau où sa graduation est allumée, et l’enjeu : « Un top 1 validerait X : 88 / 172 », ou le jour où il a été validé. Dessous, sa fiche (Parties, Victoires, meilleur Placement, Tentatives, points de maîtrise, premier top 1) et ses 5 dernières Parties de la Saison, avec date, Format et Placement. Tant que le client n’a pas dit quel champion vous jouez (en Bravery, par exemple), la bannière indique « Champion en cours d’identification ». **Défi** et **Statistiques** restent accessibles pendant la partie. L’onglet reste jusqu’au résultat de la Partie ; une partie hors Arena ne fait rien apparaître.
|
||||
|
||||
## Parties
|
||||
|
||||
L’onglet **Parties** liste vos Parties enregistrées, de la plus récente à la plus ancienne, pour le Compte connecté au client (ou le dernier connu quand il est fermé), même si un autre Compte est épinglé sur le Défi. Chaque ligne montre le champion, la date et l’heure, et le Placement, en or pour un top 1, en vert pour une autre Victoire, en rouge sinon. 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 (une barre comparée au meilleur de la Partie, partagée entre physiques, magiques et bruts, le total à côté). Les objets et les améliorations montrent leur icône dans une case, leur nom dans la bulle de survol, toujours en français, quelle que soit la langue du client (les objets viennent de Data Dragon, les améliorations de CommunityDragon) ; sans eux (première ouverture hors ligne, objet très récent), une icône neutre et « Objet n » ou « Amélioration n ». Survoler un objet ou une amélioration, dans le récapitulatif ou dans **Dégâts observés dans les récaps de mort**, affiche une bulle avec son nom et sa description ; un « ? » marque une valeur que le jeu calcule pendant la Partie, et « Description indisponible » une description que le catalogue n’a pas. Ces noms, descriptions et icônes sont gardés sur le disque : ils restent lisibles hors ligne. L’appli regarde si le jeu a changé de patch à son lancement et à chaque ouverture du client, jamais en continu, et ne télécharge de nouveau que dans ce cas ; au premier téléchargement, les icônes apparaissent au fur et à mesure ; si CommunityDragon n’a pas encore le nouveau patch, les noms précédents restent jusqu’à la vérification suivante. 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, en barres avec leur valeur à côté : dégâts aux champions et reçus (une barre partagée entre physiques, magiques et bruts), puis dégâts atténués, soins et boucliers sur les alliés, or gagné et dépensé, contrôle (une barre par valeur, pleine pour le meilleur joueur de la Partie) ; 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.
|
||||
|
||||
À la fin d’une Partie Arena, dès que le client donne son résultat, l’appli affiche **Parties** sur cette Partie (marquée « Provisoire » jusqu’à sa publication par Riot), où que vous soyez, Paramètres compris. Le Placement repasse à **Tous** et la recherche se vide pour qu’elle apparaisse. Si la Saison ou le Format choisis l’écartent, ils reviennent à la Saison de la Partie (toutes les Saisons si aucune ne la contient) et à tous les Formats (sur **Statistiques** aussi). La fenêtre ne passe pas au premier plan et ne vous prend pas le focus : réduite ou cachée dans la zone de notification, elle le reste. Changez ensuite d’onglet librement, rien ne vous ramène sur **Parties**. Si le client ne donne pas de résultat, l’appli affiche le Défi. Pour afficher le Défi plutôt que **Parties** à la fin d’une Partie, désactivez **Ouvrir le récapitulatif en fin de Partie** dans les Paramètres : la Partie reste dans la liste.
|
||||
À la fin d’une Partie Arena, dès que le client donne son résultat, l’appli affiche **Parties** sur cette Partie (marquée « Provisoire » jusqu’à sa publication par Riot), où que vous soyez, Paramètres compris. Le Placement repasse à **Tous** et la recherche se vide pour qu’elle apparaisse. Si la Saison ou le Format choisis l’écartent, ils reviennent à la Saison de la Partie (toutes les Saisons si aucune ne la contient) et à tous les Formats (sur **Statistiques** aussi). La fenêtre ne passe pas au premier plan et ne vous prend pas le focus : réduite ou cachée dans la zone de notification, elle le reste. Changez ensuite d’onglet librement, rien ne vous ramène sur **Parties**. Si le client ne donne pas de résultat, **En partie** reste jusqu’au retour au salon, puis l’appli affiche le Défi. Pour afficher le Défi plutôt que **Parties** à la fin d’une Partie, désactivez **Ouvrir le récapitulatif en fin de Partie** dans les Paramètres : la Partie reste dans la liste.
|
||||
|
||||
## Installer
|
||||
|
||||
@@ -47,7 +49,7 @@ Si l’installation échoue, la version précédente s’ouvre avec un bandeau q
|
||||
|
||||
Par défaut, le bouton de fermeture cache la fenêtre dans la zone de notification, et Arena Tracker continue de suivre les Parties. Un clic sur son icône rouvre la fenêtre ; un clic droit propose « Ouvrir » et « Quitter ». L’option **Fermer dans la zone de notification** des Paramètres désactive ce comportement : la fermeture quitte alors l’application.
|
||||
|
||||
Relancer Arena Tracker depuis le menu Démarrer pendant qu’il tourne ramène simplement sa fenêtre. Au début d’une Sélection des champions Arena, la fenêtre réduite ou cachée se rouvre d’elle-même, sans prendre le focus.
|
||||
Relancer Arena Tracker depuis le menu Démarrer pendant qu’il tourne ramène simplement sa fenêtre. Au début d’une Sélection des champions Arena, la fenêtre réduite ou cachée se rouvre d’elle-même, sans prendre le focus ; au lancement d’une Partie Arena aussi, sans prendre le focus (le jeu garde le clavier), mais une fenêtre seulement recouverte le reste.
|
||||
|
||||
## Données
|
||||
|
||||
|
||||
+14
-5
@@ -33,11 +33,20 @@ Au survol ou au focus clavier, la fiche du champion apparaît en glissant sur la
|
||||
|
||||
### Pendant la sélection Arena
|
||||
|
||||
1. La détection d’une sélection Arena fait apparaître l’onglet « Sélection » à droite de « Défi » et « Parties » dans la barre du haut, et l’appli l’affiche, d’où que l’on soit (« Défi », « Statistiques », « Parties ») ; « Paramètres » se ferme. L’onglet montre la rangée de cartes sous la bannière de sélection. La règle de bascule est « la phase décide » : seule l’entrée dans une nouvelle phase déplace le joueur. Pendant la sélection, l’onglet « Défi » montre l’accueil habituel (bannière du Défi, grille, filtres, recherche, lien « Statistiques › »), pour le Compte connecté et la Saison en cours ; revenir sur « Sélection » montre la main posée, sans rejouer la distribution. Les bans et les choix qui arrivent pendant qu’un autre onglet est affiché ne ramènent pas sur « Sélection ». À la fin de la sélection (annulée ou partie lancée), l’onglet disparaît et l’appli affiche le Défi. Une sélection hors Arena ne fait rien apparaître. Le joueur garde le focus dans League : à l’entrée en sélection, la fenêtre passe au-dessus des autres fenêtres (League compris), qu’elle soit réduite, cachée dans la zone de notification ou seulement recouverte, sans prendre le focus, et reste ouverte à la fin de la sélection. Ce comportement n’a pas de réglage.
|
||||
1. La détection d’une sélection Arena fait apparaître l’onglet « Sélection » à droite de « Défi » et « Parties » dans la barre du haut, et l’appli l’affiche, d’où que l’on soit (« Défi », « Statistiques », « Parties ») ; « Paramètres » se ferme. L’onglet montre la rangée de cartes sous la bannière de sélection. La règle de bascule est « la phase décide » : seule l’entrée dans une nouvelle phase déplace le joueur. Pendant la sélection, l’onglet « Défi » montre l’accueil habituel (bannière du Défi, grille, filtres, recherche, lien « Statistiques › »), pour le Compte connecté et la Saison en cours ; revenir sur « Sélection » montre la main posée, sans rejouer la distribution. Les bans et les choix qui arrivent pendant qu’un autre onglet est affiché ne ramènent pas sur « Sélection ». À la fin de la sélection (annulée ou partie lancée), l’onglet disparaît et l’appli affiche le Défi, ou « En partie » quand la Partie est lancée (voir « Pendant une Partie en cours »). Une sélection hors Arena ne fait rien apparaître. Le joueur garde le focus dans League : à l’entrée en sélection, la fenêtre passe au-dessus des autres fenêtres (League compris), qu’elle soit réduite, cachée dans la zone de notification ou seulement recouverte, sans prendre le focus, et reste ouverte à la fin de la sélection. Ce comportement n’a pas de réglage.
|
||||
2. La rangée « Champions de l’Enclume » contient **tous** les champions marqués d’une enclume dans la sélection en cours, dans le tri choisi. Au-dessous, « Autres champions » est replié par défaut. L’ouvrir affiche tous les champions sans enclume, avec le même tri et les mêmes cartes. Sa recherche par nom filtre uniquement cette section. La sélection défile comme une seule page (bannière, enclumes, « Autres champions »), avec une seule barre de défilement.
|
||||
3. Dans les deux sections, les cartes gardent leur place lorsqu’un champion est validé, banni ou pris par un allié (dans la main, une carte prise par un allié s’abaisse seulement de 8 px). Son portrait est grisé et la carte indique les raisons applicables : « Validé », « Banni », « Pris par un allié », et « Indisponible » pour un champion que le client ne propose pas (non possédé ou désactivé). Un champion validé et banni porte les deux indications.
|
||||
4. Une présélection alliée laisse la carte dans son état courant. « Pris par un allié » apparaît à la confirmation du choix. Les bans et les choix alliés expirent avec la sélection : ils n’affectent ni les coches personnelles, ni le compteur du Défi, ni la sélection suivante.
|
||||
|
||||
### Pendant une Partie en cours
|
||||
|
||||
1. Au lancement d’une Partie en cours Arena (le client en partie, phases « GameStart », « InProgress » ou « Reconnect », y compris quand l’appli démarre ou retrouve le client en pleine partie), l’onglet « En partie » apparaît à droite de « Défi » et « Parties », « Sélection » disparaît, et l’appli l’affiche, d’où que l’on soit ; « Paramètres » se ferme. C’est la règle « la phase décide » de la sélection. Lancée depuis la sélection, la Partie attend la sortie de la main si « Sélection » est affichée, puis « En partie » sort du voile à la place du Défi ; ailleurs, il arrive avec le voile des transitions, ou d’un coup dans une fenêtre cachée ou réduite. Une fenêtre réduite ou cachée dans la zone de notification se rouvre sans prendre le focus (le jeu garde le clavier) ; une fenêtre seulement recouverte le reste : contrairement à la sélection, l’appli ne passe pas au-dessus des autres fenêtres. Un client trouvé sur l’écran de fin d’une partie n’ouvre rien : la Partie en cours n’a pas commencé sous ses yeux.
|
||||
2. Pendant la Partie en cours, comme pendant une sélection, l’appli est celle du Compte connecté au client et de la Saison en cours : « Défi » montre son accueil, le sélecteur de Compte est grisé, et « Défi » et « Statistiques » restent accessibles ; revenir sur « En partie » le montre tel qu’il était, sans rien recalculer. Seule l’entrée dans une nouvelle phase déplace le joueur.
|
||||
3. **Bannière.** La bannière de l’accueil, sans le lien « Statistiques › » : l’illustration du champion joué, en surtitre la Saison et le compteur du Défi (« SAISON 2 · 2026 · 87 / 172 validés »), le nom du champion en titre, et l’anneau avec la graduation de ce champion allumée (aucune graduation éteinte). Sa ligne donne l’enjeu : « Un top 1 validerait X : 88 / 172 » (le compteur qu’il atteindrait) pour un champion non validé, « X validé le 12 nov. » pour un champion validé. Tant que le client n’a pas dit le champion joué (Bravery, par exemple), la bannière n’a pas d’illustration, son titre est « Champion en cours d’identification », sa ligne est vide et aucune graduation n’est allumée. Le champion connu mais ses statistiques pas encore lues (client trouvé en pleine partie), le titre est « Partie en cours ».
|
||||
4. **Fiche.** Sous la bannière, « Fiche du champion » reprend les lignes de la fiche de sa carte : Parties, Victoires, meilleur Placement, Tentatives, points de maîtrise, et « Premier top 1 » s’il est validé. À côté (dessous dans une fenêtre étroite), « Dernières Parties de la Saison » liste ses 5 dernières Parties de la Saison, de la plus récente à la plus ancienne, avec date et heure, Format et Placement coloré comme dans « Parties » (« Provisoire » le cas échéant) ; sans Partie, « Première Partie avec X cette Saison ». Sans statistiques, la ligne d’attente de l’accueil (« Chargement des statistiques… », « Compte indisponible ») tient leur place.
|
||||
5. **Fin.** La Partie en cours dure jusqu’à l’arrivée de son bloc de fin, ou au retour au salon (ou la fermeture du client) sans bloc : son écran de fin en fait encore partie. Le bloc en fait une Partie : l’onglet disparaît et l’ouverture en fin de Partie décide (« Parties » sur son récapitulatif, ou le Défi si le réglage est coupé, voir « Page « Parties » ») ; le retour au salon qui suit ne déplace rien. Sans bloc, le retour au salon fait disparaître l’onglet et affiche le Défi, d’où que l’on soit. Si la fin ne choisit aucun écran alors que « En partie » est affiché (bloc d’un autre Compte, fin déjà décidée), le Défi s’affiche aussi. Une partie hors Arena ne fait rien apparaître.
|
||||
6. **Règle n° 1.** L’écran suit les événements du client déjà écoutés (session de jeu), sans lecture périodique : le champion est lu dans la session de jeu que chaque événement fait relire, et la Partie en cours démarre, change de champion ou s’arrête avec elle. Le texte de l’écran est préparé quand la Partie en cours ou les statistiques changent, jamais au rendu ; les 5 Parties sont lues en arrière-plan, à basse priorité, quand le champion est connu, puis seulement si les Parties enregistrées ont changé. Les listes d’objets et d’améliorations de #48 s’y ajouteront en v3.
|
||||
|
||||
### Identité
|
||||
|
||||
Cette section décrit l’identité « L’Anneau ». [La page de référence](prototype-identite.html) la montre : l’accueil, une Partie au hasard, un top 1, la sélection, le thème clair et « Statistiques ». C’est une maquette : elle ne montre pas toute la spécification (l’animation différée, par exemple), et en cas d’écart cette section prévaut. Les critères ci-dessus restent valables ; l’identité ne change ni les données, ni les marques, ni le vocabulaire. On dit « validé » et « Premier top 1 », jamais « sacre ».
|
||||
@@ -54,13 +63,13 @@ Cette section décrit l’identité « L’Anneau ». [La page de référence](p
|
||||
|
||||
**Illustration.** La bannière montre une fenêtre d’environ 80 % de la largeur du splash du champion, centrée sur lui (voir les décisions d’implémentation pour le cadrage). Elle passe d’une illustration à l’autre par un fondu.
|
||||
|
||||
**Animations.** Elles sont toujours déclenchées par un événement et ne dessinent rien au repos. Elles suivent le réglage Windows « Afficher les animations », lu au démarrage et à chacun de ses changements : coupé, chaque animation laisse place à son état final. L’appli n’a pas de réglage « Animations ». « Défi » est visible quand la fenêtre est affichée et non réduite (Windows ne signale pas une fenêtre seulement recouverte), sans « Statistiques », « Sélection » ni « Paramètres » devant lui, et hors sélection : une animation demandée pendant une sélection attend sa fin.
|
||||
**Animations.** Elles sont toujours déclenchées par un événement et ne dessinent rien au repos. Elles suivent le réglage Windows « Afficher les animations », lu au démarrage et à chacun de ses changements : coupé, chaque animation laisse place à son état final. L’appli n’a pas de réglage « Animations ». « Défi » est visible quand la fenêtre est affichée et non réduite (Windows ne signale pas une fenêtre seulement recouverte), sans « Statistiques », « Sélection », « En partie » ni « Paramètres » devant lui, et hors sélection : une animation demandée pendant une sélection attend sa fin.
|
||||
|
||||
- Fin d’une Partie suivie en direct. Un top 1 déclenche la comète, la bannière et « Validé ». Une nouvelle Marque fait monter la graduation d’un cran et remplit la coche. Sinon, la graduation clignote et la ligne « Dernière Partie » apparaît en fondu. L’animation est différée jusqu’à ce que « Défi » soit visible, elle ne joue que la plus forte des Parties terminées entre-temps, et elle est abandonnée si une sélection commence. Les Parties importées ou lues dans l’historique n’animent rien.
|
||||
- Entrée en sélection, dès que la fenêtre montre l’onglet « Sélection » : une bande de lumière dorée traverse la fenêtre (≈ 0,9 s), « Sélection des champions » arrive en fondu en montant de 8 px, puis les Champions de l’Enclume montent du bas de la fenêtre l’un après l’autre (départ à 380 ms, puis toutes les 110 ms), sans rotation. L’onglet « Sélection » s’affiche d’un coup, sans voile, d’où que l’on soit : la bande de lumière tient lieu de transition. Elle ne joue qu’une fois par sélection : quitter « Sélection » pendant la distribution pose la main, et y revenir la montre posée. Une carte encore en mouvement ne réagit au survol ou au focus clavier qu’une fois posée ; si le pointeur bouge avant, le focus clavier en attente est oublié. Les motifs qui arrivent pendant la distribution s’affichent sur leur carte sans la relancer. Réglage Windows coupé : la main apparaît posée, sans balayage.
|
||||
- Confirmation d’un allié : « Pris par un allié » apparaît sur sa carte de la main, qui s’abaisse de 8 px et se grise, même levée sous le pointeur ou le clavier ; elle reste 8 px plus bas que les autres. Rien d’autre ne bouge.
|
||||
- Sortie de sélection, si « Sélection » est affichée : les cartes de la main descendent en s’effaçant (≈ 0,3 s, de la dernière à la première), chacune depuis là où elle est : une sortie pendant la distribution reprend les cartes en mouvement où elles en sont, celles pas encore parties restent invisibles ; une carte levée part de sa hauteur, toujours levée, les autres gardent le voile de la main, et une carte qu’une confirmation abaissait part d’où elle en était, sa version d’avant toujours en fondu par-dessus. Puis l’accueil revient comme après un changement d’onglet, dans l’état décrit plus haut (« Tous », recherche vide). Si le voile d’un changement d’onglet couvrait déjà « Sélection », il reste où il en est pendant que la main sort. Depuis « Défi », la sélection disparaît simplement ; depuis « Statistiques », le Défi revient avec le voile des transitions. L’écran « En partie » changera cette cible au lancement d’une partie.
|
||||
- Transitions entre « Défi », « Statistiques », « Parties » et « Sélection » (le lien de la bannière, « ‹ Défi » ou les onglets les déclenchent) : l’écran sortant passe sous un voile de la couleur du fond (≈ 130 ms), puis l’entrant en sort (≈ 280 ms). La barre du haut ne bouge pas. Changer d’écran pendant une transition repart de là où en est le voile. Les sélecteurs de Saison et de Format sont sur la ligne du titre « Statistiques », sous le voile : la barre du haut, commune aux deux écrans, garde sa hauteur. Pas de glissement : déplacer l’écran redessinerait à chaque image la grille, l’anneau et les graphiques, qui sont en cache.
|
||||
- Sortie de sélection, si « Sélection » est affichée : les cartes de la main descendent en s’effaçant (≈ 0,3 s, de la dernière à la première), chacune depuis là où elle est : une sortie pendant la distribution reprend les cartes en mouvement où elles en sont, celles pas encore parties restent invisibles ; une carte levée part de sa hauteur, toujours levée, les autres gardent le voile de la main, et une carte qu’une confirmation abaissait part d’où elle en était, sa version d’avant toujours en fondu par-dessus. Puis l’accueil revient comme après un changement d’onglet, dans l’état décrit plus haut (« Tous », recherche vide). Si le voile d’un changement d’onglet couvrait déjà « Sélection », il reste où il en est pendant que la main sort. Depuis « Défi », la sélection disparaît simplement ; depuis « Statistiques », le Défi revient avec le voile des transitions. Quand la sélection a lancé la Partie, c’est « En partie » qui revient à la place du Défi.
|
||||
- Transitions entre « Défi », « Statistiques », « Parties », « Sélection » et « En partie » (le lien de la bannière, « ‹ Défi » ou les onglets les déclenchent) : l’écran sortant passe sous un voile de la couleur du fond (≈ 130 ms), puis l’entrant en sort (≈ 280 ms). La barre du haut ne bouge pas. Changer d’écran pendant une transition repart de là où en est le voile. Les sélecteurs de Saison et de Format sont sur la ligne du titre « Statistiques », sous le voile : la barre du haut, commune aux deux écrans, garde sa hauteur. Pas de glissement : déplacer l’écran redessinerait à chaque image la grille, l’anneau et les graphiques, qui sont en cache.
|
||||
- Survol et focus clavier : le même sur toutes les cartes (grille de l’accueil, main de la sélection, « Autres champions »), en ≈ 350 ms. Une carte jouable monte de 10 px avec une ombre dorée ; une carte grisée monte de 4 px, sans ombre dorée. L’illustration zoome à 107 % dans la carte, qui garde sa taille, pendant que le nom et les coches s’effacent et que la fiche glisse depuis le bas. Quitter une carte en cours d’animation repart de là où elle en est. Une seule carte est levée à la fois : une carte levée au clavier redescend dès que le pointeur bouge. Une molette la repose aussitôt, même en haut ou en bas de la liste. Le voile sur les cartes voisines ne s’applique que dans la main de la sélection. Réglage Windows coupé : la fiche apparaît sans glisser et la carte ne monte pas.
|
||||
- Limites de GPUI, sans le modifier (ADR-0004) : pas de rotation, pas d’espacement des lettres animé, une montée de la carte au lieu d’un grossissement, un voile au lieu d’un filtre ou d’un fondu de l’écran entier.
|
||||
|
||||
@@ -75,7 +84,7 @@ Pour une Saison, présenter d’abord la courbe cumulée des champions validés,
|
||||
L’onglet permanent « Parties », à droite de « Défi » dans la barre du haut, liste les Parties enregistrées du Compte connecté au client, ou du dernier connu quand le client est fermé (un Compte épinglé sur le Défi ne change pas la liste ; un changement de Compte dans le client la bascule), de la plus récente à la plus ancienne, filtrées par Saison, Format, Placement et champion (voir « Filtres »). « Défi » n’est allumé que sur « Défi » et « Statistiques », « Parties » sur sa page. On y passe avec le voile des transitions.
|
||||
|
||||
- **Sélection.** Ouvrir l’onglet à la main choisit la Partie la plus récente de celles que les filtres laissent : le choix précédent n’est pas gardé d’une ouverture à l’autre. Un clic ou les flèches haut et bas choisissent une autre Partie, Entrée confirme ; son Récapitulatif de partie s’affiche à côté. Pendant une synchronisation, la Partie choisie le reste tant qu’elle est listée et que les filtres la laissent.
|
||||
- **Ouverture en fin de Partie.** À l’arrivée du bloc de fin d’une Partie Arena suivie (sa Partie provisoire), l’appli affiche « Parties » avec cette Partie choisie et son récapitulatif, d’où que l’on soit (« Défi », « Statistiques », le récapitulatif d’une autre Partie) ; « Paramètres » se ferme, comme à l’entrée en sélection (« la phase décide »). Le Placement revient à « Tous » et la recherche se vide pour qu’elle soit listée ; si la Saison ou le Format choisis (ceux de « Statistiques », les mêmes sélecteurs) l’écartent, ils reviennent à la Saison de la Partie (toutes les Saisons si aucune ne la contient) et à « Tous les Formats », « Statistiques » se recalculant en conséquence en arrière-plan, pour que la nouvelle Partie soit celle qui est choisie ; s’ils la gardent, ils ne bougent pas. Tant que la liste relue ne la contient pas, aucun autre récapitulatif ne s’affiche. La fenêtre n’est jamais mise au premier plan et ne prend pas le focus : réduite ou cachée dans la zone de notification, elle le reste, et la bascule s’y fait sans voile. Le bloc est enregistré en base dès son arrivée, sans attendre une synchronisation en cours, avec le Compte connecté à ce moment : la Partie provisoire est de ce Compte, même si un autre se connecte avant sa conversion. Un bloc dont rien ne dit le mode (ni mode, ni file, ni partie vue en cours) est gardé ; seul un bloc d’un autre mode est écarté. Le texte du bloc, gardé tel que reçu tant que la Partie provisoire peut en avoir besoin (bloc pas encore converti, ou converti et toujours provisoire), est effacé de la base dès qu’il ne sert plus : bloc d’une Partie qui n’est pas Arena, ou Partie publiée par Riot. Un bloc qui ne se convertit pas est relu toutes les 20 s pendant la fenêtre d’attente de la Partie (environ 30 minutes), puis seulement après une synchronisation réussie (adoption d’un Compte, par exemple), et abandonné au bout de 7 jours (son texte reste alors). Ensuite rien ne ramène sur « Parties » : la correction de la Partie publiée, une relecture ou une synchronisation ne déplacent pas le joueur. Quand le client quitte une Partie Arena sans bloc, l’appli affiche le Défi, d’où que l’on soit. La fin de chaque Partie ne décide qu’une fois : la sortie de partie qui suit un bloc ne déplace rien, mais un bloc arrivé après la sortie ouvre encore son récapitulatif. Une Partie trouvée seulement chez Riot ne déplace rien, et pendant une sélection Arena rien ne bascule. (« En partie », #109, restera affiché jusqu’au bloc ou au retour au lobby.) Le réglage « Ouvrir le récapitulatif en fin de Partie » des Paramètres, activé par défaut et enregistré, coupe cette ouverture : l’appli affiche le Défi, et la Partie est dans l’historique. Une Partie qu’aucune Saison ne contient s’ouvre aussi, sans rien apporter au Défi. L’animation de fin de Partie garde ses règles : elle attend que « Défi » soit visible.
|
||||
- **Ouverture en fin de Partie.** À l’arrivée du bloc de fin d’une Partie Arena suivie (sa Partie provisoire), l’appli affiche « Parties » avec cette Partie choisie et son récapitulatif, d’où que l’on soit (« Défi », « Statistiques », le récapitulatif d’une autre Partie) ; « Paramètres » se ferme, comme à l’entrée en sélection (« la phase décide »). Le Placement revient à « Tous » et la recherche se vide pour qu’elle soit listée ; si la Saison ou le Format choisis (ceux de « Statistiques », les mêmes sélecteurs) l’écartent, ils reviennent à la Saison de la Partie (toutes les Saisons si aucune ne la contient) et à « Tous les Formats », « Statistiques » se recalculant en conséquence en arrière-plan, pour que la nouvelle Partie soit celle qui est choisie ; s’ils la gardent, ils ne bougent pas. Tant que la liste relue ne la contient pas, aucun autre récapitulatif ne s’affiche. La fenêtre n’est jamais mise au premier plan et ne prend pas le focus : réduite ou cachée dans la zone de notification, elle le reste, et la bascule s’y fait sans voile. Le bloc est enregistré en base dès son arrivée, sans attendre une synchronisation en cours, avec le Compte connecté à ce moment : la Partie provisoire est de ce Compte, même si un autre se connecte avant sa conversion. Un bloc dont rien ne dit le mode (ni mode, ni file, ni partie vue en cours) est gardé ; seul un bloc d’un autre mode est écarté. Le texte du bloc, gardé tel que reçu tant que la Partie provisoire peut en avoir besoin (bloc pas encore converti, ou converti et toujours provisoire), est effacé de la base dès qu’il ne sert plus : bloc d’une Partie qui n’est pas Arena, ou Partie publiée par Riot. Un bloc qui ne se convertit pas est relu toutes les 20 s pendant la fenêtre d’attente de la Partie (environ 30 minutes), puis seulement après une synchronisation réussie (adoption d’un Compte, par exemple), et abandonné au bout de 7 jours (son texte reste alors). Ensuite rien ne ramène sur « Parties » : la correction de la Partie publiée, une relecture ou une synchronisation ne déplacent pas le joueur. Quand le client quitte une Partie Arena sans bloc, l’appli affiche le Défi, d’où que l’on soit. La fin de chaque Partie ne décide qu’une fois : la sortie de partie qui suit un bloc ne déplace rien, mais un bloc arrivé après la sortie ouvre encore son récapitulatif. Une Partie trouvée seulement chez Riot ne déplace rien, et pendant une sélection Arena rien ne bascule. « En partie » reste affiché jusqu’au bloc ou au retour au salon : une sortie de partie sans bloc n’affiche le Défi qu’au retour au salon (voir « Pendant une Partie en cours »). Le réglage « Ouvrir le récapitulatif en fin de Partie » des Paramètres, activé par défaut et enregistré, coupe cette ouverture : l’appli affiche le Défi, et la Partie est dans l’historique. Une Partie qu’aucune Saison ne contient s’ouvre aussi, sans rien apporter au Défi. L’animation de fin de Partie garde ses règles : elle attend que « Défi » soit visible.
|
||||
- **Filtres.** Une rangée au-dessus de la liste (dans la colonne de la liste : derrière le bouton « Parties » dans une fenêtre étroite) : les sélecteurs de Saison et de Format, un contrôle segmenté de Placement « Tous · Top 1 · Victoires » et un champ de recherche de champion. Les filtres se combinent. Saison et Format sont les sélecteurs de « Statistiques », avec le même état : choisir l’un sur une page le change sur l’autre (et, comme sur « Statistiques », la Saison choisie est celle du Défi affiché sur « Défi »). Par défaut la Saison actuelle, ou « Toutes les Saisons » quand il n’y en a pas, comme sur « Statistiques ». Une Partie est de la Saison dont la période contient son début. « Top 1 » garde les Parties de Placement 1 ; « Victoires » celles que le jeu compte comme gagnées (Win : le top 3 en Arena 3x6). La recherche est celle de l’accueil (nom, identifiant Data Dragon, alias connus ; sans casse ni accents), avec son propre champ. Placement et recherche ne sont pas ceux de « Statistiques » et sont gardés tant que l’appli tourne, sans être enregistrés ; ils reviennent à « Tous » et à vide au lancement. Le filtrage se fait sur les Parties déjà chargées, sans nouvelle lecture de la base : seules les lignes gardées sont écrites dans la liste. Si la Partie choisie est écartée, la première Partie gardée est choisie et son récapitulatif s’affiche ; s’il n’en reste aucune, la liste dit « Aucune Partie ne correspond aux filtres » et le récapitulatif est vide. Les filtres restent affichés pour être changés.
|
||||
- **Compte.** Aucune sélection manuelle : le sélecteur de Compte de la barre du haut est grisé sur cette page. Un changement de Compte dans le client remplace la liste aussitôt, sans jamais mélanger les Parties de deux Comptes, et choisit la plus récente.
|
||||
- **Ligne de la liste.** Portrait et nom du champion, date et heure de début (heure de Windows, « 15 nov. 2026 · 18:29 »), Placement (« 1ᵉʳ », « 2ᵉ »…) coloré selon le résultat : or pour un top 1, vert pour une autre Victoire, rouge sinon, et « Provisoire » pour une Partie provisoire. Pas de Format dans la ligne.
|
||||
|
||||
Reference in new issue
Block a user