0.1.0-0-pre.4

This commit is contained in:
2026-09-16 01:01:09 +02:00
parent 2c79a05dd6
commit dc22011997
38 changed files with 540 additions and 131 deletions

View File

@@ -1,5 +1,5 @@
# file: crates/games/game-reflex-poc/Cargo.toml
# version: 1
# version: 2
[package]
name = "game-reflex-poc"
@@ -15,5 +15,8 @@ engine-v1-common = { path = "../../engines/engine-v1-common" }
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
[dev-dependencies]
game-logging-lib = { path = "../../common/game-logging-lib" }
[lints]
workspace = true

View File

@@ -1,5 +1,5 @@
// file: crates/games/game-reflex-poc/src/state.rs
// version: 2
// version: 3
/// Minimal deterministic state used to validate the first game boundary.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
@@ -36,23 +36,5 @@ impl engine_v1_common::EngineGame for ReflexState {
}
#[cfg(test)]
mod unit_tests {
#[test]
fn success_increments_score() {
let mut state = crate::ReflexState::new();
state.register_success();
assert_eq!(state.score(), 1);
}
#[test]
fn engine_update_maps_primary_action_to_success() {
let mut state = crate::ReflexState::new();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
engine_v1_common::EngineGame::update(
&mut state,
engine_v1_common::EngineFrame::new(0, std::time::Duration::from_millis(16), std::time::Duration::ZERO),
input,
);
assert_eq!(state.score(), 1);
}
}
#[path = "../unit_tests/state.rs"]
mod tests;

View File

@@ -0,0 +1,25 @@
// file: crates/games/game-reflex-poc/unit_tests/state.rs
// version: 1
#[test]
fn success_increments_score() {
game_logging_lib::with_test_tracing("success_increments_score", || {
let mut state = crate::ReflexState::new();
state.register_success();
assert_eq!(state.score(), 1);
});
}
#[test]
fn engine_update_maps_primary_action_to_success() {
game_logging_lib::with_test_tracing("engine_update_maps_primary_action_to_success", || {
let mut state = crate::ReflexState::new();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
engine_v1_common::EngineGame::update(
&mut state,
engine_v1_common::EngineFrame::new(0, std::time::Duration::from_millis(16), std::time::Duration::ZERO),
input,
);
assert_eq!(state.score(), 1);
});
}

View File

@@ -1,5 +1,5 @@
# file: crates/games/game-snake-poc/Cargo.toml
# version: 1
# version: 2
[package]
name = "game-snake-poc"
@@ -15,5 +15,8 @@ engine-v1-common = { path = "../../engines/engine-v1-common" }
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
[dev-dependencies]
game-logging-lib = { path = "../../common/game-logging-lib" }
[lints]
workspace = true

View File

@@ -1,5 +1,5 @@
// file: crates/games/game-snake-poc/src/state.rs
// version: 2
// version: 3
/// Minimal Snake state used to validate reusable engine dependencies.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -42,23 +42,5 @@ impl engine_v1_common::EngineGame for SnakeState {
}
#[cfg(test)]
mod unit_tests {
#[test]
fn growth_increments_length() {
let mut state = crate::SnakeState::new();
state.grow();
assert_eq!(state.length(), 2);
}
#[test]
fn engine_update_maps_primary_action_to_growth() {
let mut state = crate::SnakeState::new();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
engine_v1_common::EngineGame::update(
&mut state,
engine_v1_common::EngineFrame::new(0, std::time::Duration::from_millis(16), std::time::Duration::ZERO),
input,
);
assert_eq!(state.length(), 2);
}
}
#[path = "../unit_tests/state.rs"]
mod tests;

View File

@@ -0,0 +1,25 @@
// file: crates/games/game-snake-poc/unit_tests/state.rs
// version: 1
#[test]
fn growth_increments_length() {
game_logging_lib::with_test_tracing("growth_increments_length", || {
let mut state = crate::SnakeState::new();
state.grow();
assert_eq!(state.length(), 2);
});
}
#[test]
fn engine_update_maps_primary_action_to_growth() {
game_logging_lib::with_test_tracing("engine_update_maps_primary_action_to_growth", || {
let mut state = crate::SnakeState::new();
let input = engine_v1_common::InputState::none().with_action(engine_v1_common::GameAction::Primary, true);
engine_v1_common::EngineGame::update(
&mut state,
engine_v1_common::EngineFrame::new(0, std::time::Duration::from_millis(16), std::time::Duration::ZERO),
input,
);
assert_eq!(state.length(), 2);
});
}