test(whip): arregla W4/W6 — first update ha d'arribar al primer active frame
El YAML del whip declara frame_ms=80, així que el frame 0 viu [0, 80] ms i `active_frames=[1, 2]` comença a 80 ms. Els tests feien `update(0.06F)` amb el comentari "60 ms → frame 1 (active)" — incorrecte: 60 < 80, encara al frame 0, sense danyar res. Tres asserts d'`getState() == HURT` mai no es complien. Canvi a `update(0.09F)`: assegura que el primer tick entra al frame 1 i `applyDamage()` corre. Comentari actualitzat amb el càlcul correcte.
This commit is contained in:
1 parent
6f8ab74d6b
commit
9291ef6572
1 file changed
+10
-5
@@ -213,8 +213,10 @@ namespace {
|
||||
auto whip = makeWhip(WhipAttack::Direction::EAST, BOX, 48.0F);
|
||||
whip->setWorldContext(&manager, nullptr);
|
||||
|
||||
// 60 ms → frame 1 (active). active_frames: [1, 2].
|
||||
whip->update(0.06F);
|
||||
// frame_ms=80 al YAML → frame 0 viu [0, 80] ms, frame 1 [80, 160] ms.
|
||||
// active_frames=[1, 2], així que cal arribar com a mínim a 80 ms
|
||||
// perquè `isFrameActive()` retorne true i `applyDamage()` corra.
|
||||
whip->update(0.09F);
|
||||
|
||||
REQUIRE(mummy_raw->getState() == Mummy::State::HURT);
|
||||
}
|
||||
@@ -272,8 +274,9 @@ namespace {
|
||||
auto whip = makeWhip(WhipAttack::Direction::EAST, BOX, 48.0F);
|
||||
whip->setWorldContext(&manager, nullptr);
|
||||
|
||||
// Primera passada (frame 1, actiu) → mòmia a HURT.
|
||||
whip->update(0.06F);
|
||||
// frame_ms=80 → frame 0 [0, 80] ms; cal ≥ 80 ms per entrar al
|
||||
// frame 1 (primer dels active_frames=[1, 2]).
|
||||
whip->update(0.09F);
|
||||
REQUIRE(mummy_raw->getState() == Mummy::State::HURT);
|
||||
const float HURT_INITIAL = mummy_raw->getHurtRemainingS();
|
||||
|
||||
@@ -285,7 +288,9 @@ namespace {
|
||||
const float HURT_AFTER_MUMMY_TICK = mummy_raw->getHurtRemainingS();
|
||||
REQUIRE(HURT_AFTER_MUMMY_TICK < HURT_INITIAL);
|
||||
|
||||
whip->update(0.05F); // frame 2, encara actiu
|
||||
// Segon tick del whip: acumulat 0.09 + 0.05 = 0.14 s, encara
|
||||
// dins del frame 1 ([80, 160] ms). already_hit_ ha de bloquejar.
|
||||
whip->update(0.05F);
|
||||
REQUIRE(mummy_raw->getHurtRemainingS() == HURT_AFTER_MUMMY_TICK);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user