From 9291ef6572b39e309ca37c47fb7bf0e53e1043c0 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 11 May 2026 11:28:51 +0200 Subject: [PATCH] =?UTF-8?q?test(whip):=20arregla=20W4/W6=20=E2=80=94=20fir?= =?UTF-8?q?st=20update=20ha=20d'arribar=20al=20primer=20active=20frame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/test_whip_attack.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_whip_attack.cpp b/tests/test_whip_attack.cpp index 7aef493..cf43c07 100644 --- a/tests/test_whip_attack.cpp +++ b/tests/test_whip_attack.cpp @@ -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); }