T52: a press wakes Ely from her doze, which the owner asked for after 0.1.4, where only a new mood woke her: calm lasts 5 minutes from her mood's start or the last press before she dozes, so after a press she stays awake 5 minutes, then dozes again
CI / platforms (ubuntu-24.04) (push) Successful in 1m29s
CI / platforms (windows-latest) (push) Successful in 1m31s
CI / macos (push) Canceled after 0s

This commit is contained in:
ZacharyZhang-NY committed 2026-10-19 02:35:13 -04:00
1 parent dbb19caaf8
commit 0eb8fc5c4e
7 files changed
+40 -7

No files matched your search

+4 -3
View File
@@ -37,7 +37,7 @@ pub fn mood(looks: impl IntoIterator<Item = Look>) -> Mood {
.unwrap_or(Mood::Calm)
}
/// Seconds she cheers a program that finished, and calm lasts before she dozes.
/// Seconds she cheers a program that finished, and calm lasts, from her mood's start or the last press, before she dozes.
const CHEER: f64 = 4.0;
const DOZE: f64 = 300.0;
/// Seconds a press keeps her wink.
@@ -127,14 +127,15 @@ pub struct Pose {
pub marks: Vec<(Mark, Motion)>,
}
/// Her pose `held` seconds into `mood`, `shown` seconds after she came, and `petted` seconds after a press.
/// Her pose `held` seconds into `mood`, `shown` seconds after she came, and `petted` seconds after a press, which wakes her from a doze for `DOZE` more.
pub fn pose(mood: Mood, held: f64, shown: f64, petted: Option<f64>) -> Pose {
let stirred = petted.map_or(held, |since| held.min(since));
let mut pose = match mood {
Mood::Waiting => waiting(held),
Mood::Error => fretting(held),
Mood::Working => working(held),
Mood::Done if held < CHEER => cheering(held),
Mood::Calm | Mood::Done if held >= DOZE => dozing(held - DOZE),
Mood::Calm | Mood::Done if stirred >= DOZE => dozing(stirred - DOZE),
Mood::Calm => calm(held),
Mood::Done => calm(held - CHEER),
};
+17
View File
@@ -169,6 +169,23 @@ fn a_press_winks_with_a_heart_that_rises() {
assert!(asleep.open[1] > 0.9, "a press wakes her other eye");
}
#[test]
fn a_press_wakes_her_from_her_doze_for_five_minutes_more() {
assert_eq!(at(Mood::Calm, 400.0).act, Act::Doze, "asleep, unpressed");
let pressed = |since: f64| pose(Mood::Calm, 400.0 + since, 410.0 + since, Some(since));
assert_eq!(pressed(0.5).act, Act::Wink);
assert_eq!(
(pressed(2.0).act, pressed(2.0).eyes),
(Act::Calm, Eyes::Open),
"awake after the wink"
);
assert_eq!(pressed(299.0).act, Act::Calm, "awake five minutes");
assert_eq!(pressed(301.0).act, Act::Doze, "then asleep again");
assert!(pressed(300.3).open[0] < 1.0, "her eyes fall shut again");
let finished = pose(Mood::Done, 400.0, 410.0, Some(2.0));
assert_eq!(finished.act, Act::Calm, "a finish long past wakes alike");
}
#[test]
fn she_rises_from_behind_the_edge_when_she_comes() {
assert!(pose(Mood::Calm, 0.0, 0.0, None).lift <= -DEPTH);
+15
View File
@@ -73,6 +73,21 @@ fn a_change_of_mood_or_a_press_eases_her_from_where_she_is_though_the_act_stays(
);
}
#[test]
fn a_press_on_her_while_she_dozes_wakes_her() {
let start = Instant::now();
let at = |secs: u64| start + Duration::from_secs(secs);
let mut pet = ely(Mood::Calm, start);
assert_eq!(pet.pose(at(400)).act, Act::Doze);
pet.press(at(400));
assert_eq!(pet.pose(at(402)).act, Act::Calm, "awake");
assert_eq!(
pet.pose(at(701)).act,
Act::Doze,
"five calm minutes on, asleep again"
);
}
#[test]
fn she_stands_on_the_top_edge_while_her_box_fits_above_it() {
assert_eq!(edge(HEAD + ROOM), Edge::Top, "just room for her");