Keep a whole row in "Autres champions" and tidy the cards code (#75)

- "Autres champions" grid is never shorter than one card row.
- A Format change keeps the home's statistics (#71); the home cards
  are built when "Defi" is shown again; hidden grids give back their
  decoded portraits; the card holds its portrait as Arc<Path>.
- Unavailability becomes Unpickable (glossary), "selection" becomes
  "champ select" in comments (#74); the statistics error is shown by
  the banner only during a champ select.
- Column breakpoints follow the mockup's max-width rules, the home
  tools row is search, filters, sort; stale comments fixed.
- Tests: whole row, hidden grids, stats scopes, error shown once, and
  the capture's reasons end to end in the open section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-21 02:26:14 +01:00
1 parent 2cd8b2c545
commit 4612d89a3d
8 files changed
+535 -159

No files matched your search

+24 -24
View File
@@ -33,10 +33,10 @@ pub struct ChampSelect {
taken_by_ally: HashSet<u32>,
}
/// Why the champ select does not let the local player pick a champion. Reasons add up; a
/// champion available to pick has none. Whether the champion is Completed is not part of it.
/// Why the local player cannot pick a champion: the reasons add up, and a Pickable champion
/// has none. Whether the champion is Completed is not part of it.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct Unavailability {
pub struct Unpickable {
pub banned: bool,
pub taken_by_ally: bool,
/// The client does not offer the champion (not pickable, or disabled), and neither a ban
@@ -153,14 +153,14 @@ impl ChampSelect {
}
/// Why the local player cannot pick this champion. The player's own pick, hovered or
/// locked, is never unavailable.
pub fn unavailability(&self, id: u32) -> Unavailability {
/// locked, is never unpickable.
pub fn unpickable(&self, id: u32) -> Unpickable {
if self.current == Some(id) {
return Unavailability::default();
return Unpickable::default();
}
let banned = self.banned.contains(&id);
let taken_by_ally = self.taken_by_ally.contains(&id);
Unavailability {
Unpickable {
banned,
taken_by_ally,
not_offered: !banned && !taken_by_ally && !self.pickable.contains(&id),
@@ -413,8 +413,8 @@ mod tests {
.unwrap()
}
fn reasons(banned: bool, taken_by_ally: bool, not_offered: bool) -> Unavailability {
Unavailability {
fn reasons(banned: bool, taken_by_ally: bool, not_offered: bool) -> Unpickable {
Unpickable {
banned,
taken_by_ally,
not_offered,
@@ -435,22 +435,22 @@ mod tests {
json!({"myTeamBans": [5], "theirTeamBans": [2]}),
));
// A completed ban, either team's ban list.
assert_eq!(pick.unavailability(1), reasons(true, false, false));
assert_eq!(pick.unavailability(5), reasons(true, false, false));
assert_eq!(pick.unpickable(1), reasons(true, false, false));
assert_eq!(pick.unpickable(5), reasons(true, false, false));
// Banned and taken by an ally add up; a ban in progress or a pick action count for
// nothing; a player of the other team is not an ally.
assert_eq!(pick.unavailability(2), reasons(true, true, false));
assert_eq!(pick.unavailability(3), Unavailability::default());
assert_eq!(pick.unavailability(4), Unavailability::default());
assert_eq!(pick.unavailability(77), reasons(false, false, true));
assert_eq!(pick.unpickable(2), reasons(true, true, false));
assert_eq!(pick.unpickable(3), Unpickable::default());
assert_eq!(pick.unpickable(4), Unpickable::default());
assert_eq!(pick.unpickable(77), reasons(false, false, true));
// Not in the client's pickable list.
assert_eq!(pick.unavailability(99), reasons(false, false, true));
assert_eq!(pick.unavailability(6), Unavailability::default());
assert_eq!(pick.unpickable(99), reasons(false, false, true));
assert_eq!(pick.unpickable(6), Unpickable::default());
// `can_pick` agrees with the reasons.
for id in [1, 2, 3, 4, 5, 6, 77, 99] {
assert_eq!(
pick.can_pick(id),
pick.unavailability(id) == Unavailability::default(),
pick.unpickable(id) == Unpickable::default(),
"champion {id}"
);
}
@@ -459,9 +459,9 @@ mod tests {
#[test]
fn an_ally_pre_pick_takes_nothing_but_the_confirmed_pick_does() {
let hover = champ_select(session(0, 0, 3, json!([]), json!({})));
assert_eq!(hover.unavailability(3), Unavailability::default());
assert_eq!(hover.unpickable(3), Unpickable::default());
let locked = champ_select(session(0, 3, 3, json!([]), json!({})));
assert_eq!(locked.unavailability(3), reasons(false, true, false));
assert_eq!(locked.unpickable(3), reasons(false, true, false));
}
#[test]
@@ -473,8 +473,8 @@ mod tests {
None,
)
.unwrap();
assert_eq!(pick.unavailability(3), reasons(false, false, true));
assert_eq!(pick.unavailability(1), Unavailability::default());
assert_eq!(pick.unpickable(3), reasons(false, false, true));
assert_eq!(pick.unpickable(1), Unpickable::default());
}
#[test]
@@ -483,11 +483,11 @@ mod tests {
let banned = json!([[{"type": "ban", "championId": 99, "completed": true}]]);
let intent = champ_select(session(99, 99, 0, banned.clone(), json!({})));
assert_eq!(intent.current, Some(99));
assert_eq!(intent.unavailability(99), Unavailability::default());
assert_eq!(intent.unpickable(99), Unpickable::default());
let mut locked = session(0, 99, 0, banned, json!({"myTeamBans": [99]}));
locked["myTeam"][0]["championId"] = json!(99);
let locked = champ_select(locked);
assert_eq!(locked.unavailability(99), Unavailability::default());
assert_eq!(locked.unpickable(99), Unpickable::default());
assert!(locked.can_pick(99));
}
+1 -1
View File
@@ -14,7 +14,7 @@ mod statistics;
mod tracker;
mod update_package;
pub use champ_select::{ChampSelect, ChampSelectReader, Unavailability};
pub use champ_select::{ChampSelect, ChampSelectReader, Unpickable};
pub use champion_search::ChampionSearch;
pub use champions::{Champion, ChampionCatalog, ChampionSource, DataDragon};
pub use client::{ClientError, ClientEvent, ClientSnapshot, GameClientSource, GamePhase, Gameflow};