Opponent prep: the designer's review
The period caption shortens in a narrow row; «Last N» with both colours shows «N + N»; the menu says from which date it counts; undated games left out are named in the summary; no games in a period offer all games. Without any dates a period by months takes all. Crisp icons (★, 🗐); saved is a quiet mark. The list cuts long texts, names the colour in words, opens on double-click, renames with Cancel, explains a missing database, and tells while it opens one. CP_PREP_LIST for screenshots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
570bd84dcf
commit
e80933d48d
6 changed files with 456 additions and 169 deletions
|
|
@ -41,7 +41,7 @@ pub use errors::{EXACT, ErrorCounts, OpeningError, PositionCache, PositionEval,
|
|||
pub use game_review::{Eval, Judgement};
|
||||
pub use games::{BookExit, GameInfo, Outcome, Tally, move_label};
|
||||
pub use openings::Opening;
|
||||
pub use period::{Chosen, Period, PoolGame};
|
||||
pub use period::{Chosen, Period, PoolGame, newest as period_newest};
|
||||
pub use players::{Candidate, Player, candidates, games_of};
|
||||
pub use tree::{Node, Tree};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
//! back from his newest game, so an old database is not left empty), or his last games
|
||||
//! of each colour. Games without a date are taken by «all» only; by number they count
|
||||
//! as the oldest, in the order of the database (so a database without dates gives its
|
||||
//! last records).
|
||||
//! last records). When no game has a date, a period by months takes them all: it
|
||||
//! cannot choose, and an empty report would explain nothing.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ pub fn choose(pool: &[PoolGame], period: Period) -> Vec<(u32, bool)> {
|
|||
Period::Months(months) => {
|
||||
let newest = newest(pool);
|
||||
if newest == 0 {
|
||||
return Vec::new();
|
||||
return choose(pool, Period::All);
|
||||
}
|
||||
let from = cutoff(newest, months);
|
||||
pool.iter()
|
||||
|
|
@ -94,7 +95,7 @@ pub fn count(pool: &[PoolGame], period: Period, side: Side) -> Chosen {
|
|||
.filter(|(_, w)| of_side(*w))
|
||||
.count();
|
||||
let undated_out = match period {
|
||||
Period::Months(_) => pool
|
||||
Period::Months(_) if newest(pool) != 0 => pool
|
||||
.iter()
|
||||
.filter(|g| g.date == 0 && of_side(g.white))
|
||||
.count(),
|
||||
|
|
@ -136,8 +137,13 @@ mod tests {
|
|||
let c = count(&pool, Period::Months(24), Side::Black);
|
||||
assert_eq!((c.games, c.undated_out), (1, 1));
|
||||
assert_eq!(count(&pool, Period::All, Side::Any).undated_out, 0);
|
||||
// Nothing dated: a period takes nothing.
|
||||
assert!(choose(&[g(0, true, 0)], Period::Months(12)).is_empty());
|
||||
// Nothing dated: a period by months takes all.
|
||||
let undated = [g(0, true, 0), g(1, false, 0)];
|
||||
assert_eq!(choose(&undated, Period::Months(12)).len(), 2);
|
||||
assert_eq!(
|
||||
count(&undated, Period::Months(12), Side::Any).undated_out,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue