diff --git a/crates/core/src/champ_select.rs b/crates/core/src/champ_select.rs index 89912e2..8475870 100644 --- a/crates/core/src/champ_select.rs +++ b/crates/core/src/champ_select.rs @@ -4,9 +4,9 @@ use std::sync::{Arc, Mutex}; use serde_json::Value; +use crate::ClientError; use crate::client::Gameflow; use crate::league_client::{lock, parse}; -use crate::{ChampionRow, ChampionState, ClientError}; pub(crate) const PICKABLE_EVENT: &str = "OnJsonApiEvent_lol-champ-select_v1_pickable-champion-ids"; pub(crate) const DISABLED_EVENT: &str = "OnJsonApiEvent_lol-champ-select_v1_disabled-champion-ids"; @@ -143,11 +143,6 @@ impl ChampSelect { }) } - pub fn current_row<'a>(&self, rows: &'a [ChampionRow]) -> Option<&'a ChampionRow> { - let id = self.current?; - rows.iter().find(|r| r.champion.id == id) - } - /// Whether the local player can still pick this champion. Their own pick always stays /// pickable. pub fn can_pick(&self, id: u32) -> bool { @@ -179,13 +174,6 @@ impl ChampSelect { && self.banned == other.banned && self.taken_by_ally == other.taken_by_ally } - - /// A champion still to complete in the Challenge and pickable in this champ select. The - /// player's own hovered or locked champion stays in the list while not Completed: they can - /// pick it. - pub fn remaining(&self, row: &ChampionRow) -> bool { - row.state.is_some_and(|s| s != ChampionState::Completed) && self.can_pick(row.champion.id) - } } /// The live champ select, read the one way both the real client and the tests read it: the diff --git a/crates/core/tests/follow.rs b/crates/core/tests/follow.rs index b6730f1..851008d 100644 --- a/crates/core/tests/follow.rs +++ b/crates/core/tests/follow.rs @@ -1041,14 +1041,21 @@ fn arena_champ_select_replays_bans_hovers_and_lock_in_for_the_current_challenge( remaining: &[u32], ) { assert_eq!(pick.anvil_champions, Some(vec![233, 64, 5, 16, 68])); + let row_of = |id: u32| rows.iter().find(|r| r.champion.id == id); assert_eq!( - pick.current_row(rows) + pick.current + .and_then(row_of) .map(|r| (r.champion.id, r.attempts, r.state)), current.map(|(id, state)| (id, Some(1), Some(state))) ); + // Pickable and not Completed: the player's own hovered or locked champion stays in + // while not Completed. let mut ids: Vec<_> = rows .iter() - .filter(|r| pick.remaining(r)) + .filter(|r| { + r.state.is_some_and(|s| s != ChampionState::Completed) + && pick.can_pick(r.champion.id) + }) .map(|r| r.champion.id) .collect(); ids.sort_unstable();