@ -1,9 +1,31 @@
# include <gtest/gtest.h>
# include "engine/random.hpp"
# include "missiles.h"
using namespace devilution ;
TEST ( Missiles , RotateBlockedMissileArrow )
{
Player & player = Players [ 0 ] ;
// missile can be a copy or a reference, there's no nullptr check and the functions that use it don't expect the instance to be part of a global structure so it doesn't really matter for this use.
Missile missile = * AddMissile ( { 0 , 0 } , { 0 , 0 } , Direction : : South , MIS_ARROW , TARGET_MONSTERS , player . getId ( ) , 0 , 0 ) ;
EXPECT_EQ ( missile . _miAnimFrame , 1 ) ;
SetRndSeed ( 0 ) ;
TestRotateBlockedMissile ( missile ) ;
EXPECT_EQ ( missile . _miAnimFrame , 16 ) ;
SetRndSeed ( 3210 ) ;
TestRotateBlockedMissile ( missile ) ;
EXPECT_EQ ( missile . _miAnimFrame , 1 ) ;
missile . _miAnimFrame = 5 ;
SetRndSeed ( 1234 ) ;
TestRotateBlockedMissile ( missile ) ;
EXPECT_EQ ( missile . _miAnimFrame , 6 ) ;
}
TEST ( Missiles , GetDirection8 )
{
EXPECT_EQ ( Direction : : South , GetDirection ( { 0 , 0 } , { 15 , 15 } ) ) ;