2013-12-10 22:47:56 +01:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2013-12-20 17:02:46 +01:00
|
|
|
#include <engine/GameWorld.hpp>
|
2016-09-09 22:13:22 +02:00
|
|
|
#include <objects/InstanceObject.hpp>
|
2017-10-26 03:51:24 +02:00
|
|
|
#include "test_Globals.hpp"
|
2013-12-10 22:47:56 +01:00
|
|
|
|
2017-10-27 05:41:19 +02:00
|
|
|
BOOST_AUTO_TEST_SUITE(ObjectTests)
|
2013-12-10 22:47:56 +01:00
|
|
|
|
2016-09-09 22:13:22 +02:00
|
|
|
#if 0 // Tests disabled as object damage logic is unclear
|
2016-06-04 00:10:57 +02:00
|
|
|
|
2013-12-10 22:47:56 +01:00
|
|
|
BOOST_AUTO_TEST_CASE(instance_test_damage)
|
|
|
|
{
|
|
|
|
std::shared_ptr<ObjectData> object(new ObjectData);
|
2017-10-27 05:41:19 +02:00
|
|
|
InstanceObject inst(Global::get().e,
|
|
|
|
glm::vec3(0.f, 0.f, 0.f),
|
2018-02-06 20:47:31 +01:00
|
|
|
glm::quat{1.0f,0.0f,0.0f,0.0f}, nullptr,
|
2013-12-10 22:47:56 +01:00
|
|
|
glm::vec3(1.f),
|
2014-06-11 22:00:53 +02:00
|
|
|
object, nullptr, nullptr
|
2013-12-10 22:47:56 +01:00
|
|
|
);
|
2014-02-28 12:23:51 +01:00
|
|
|
GameObject::DamageInfo dmg;
|
|
|
|
dmg.type = GameObject::DamageInfo::Bullet;
|
2013-12-10 22:47:56 +01:00
|
|
|
dmg.hitpoints = 50.f;
|
2017-10-27 05:41:19 +02:00
|
|
|
|
2013-12-10 22:47:56 +01:00
|
|
|
// Set object to undamagable.
|
|
|
|
object->flags = 0;
|
2017-10-27 05:41:19 +02:00
|
|
|
|
2013-12-10 22:47:56 +01:00
|
|
|
BOOST_CHECK( ! inst.takeDamage(dmg) );
|
2017-10-27 05:41:19 +02:00
|
|
|
|
2013-12-10 22:47:56 +01:00
|
|
|
BOOST_CHECK( inst.takeDamage(dmg) );
|
2017-10-27 05:41:19 +02:00
|
|
|
|
2016-04-15 02:06:10 +02:00
|
|
|
BOOST_CHECK( inst.getHealth() < 0.f );
|
2013-12-10 22:47:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(instance_test_destroy)
|
|
|
|
{
|
|
|
|
std::shared_ptr<ObjectData> object(new ObjectData);
|
2014-06-06 16:22:26 +02:00
|
|
|
InstanceObject inst(Global::get().e,
|
2017-10-27 05:41:19 +02:00
|
|
|
glm::vec3(0.f, 0.f, 0.f),
|
2018-02-06 20:47:31 +01:00
|
|
|
glm::quat{1.0f,0.0f,0.0f,0.0f}, nullptr,
|
2013-12-10 22:47:56 +01:00
|
|
|
glm::vec3(1.f),
|
2014-06-11 22:00:53 +02:00
|
|
|
object, nullptr, nullptr
|
2013-12-10 22:47:56 +01:00
|
|
|
);
|
2014-02-28 12:23:51 +01:00
|
|
|
GameObject::DamageInfo dmg;
|
|
|
|
dmg.type = GameObject::DamageInfo::Bullet;
|
2016-04-15 02:06:10 +02:00
|
|
|
dmg.hitpoints = inst.getHealth() + 1.f;
|
2017-10-27 05:41:19 +02:00
|
|
|
|
2013-12-10 22:47:56 +01:00
|
|
|
BOOST_CHECK( inst.takeDamage(dmg) );
|
2017-10-27 05:41:19 +02:00
|
|
|
|
2016-04-15 02:06:10 +02:00
|
|
|
BOOST_CHECK( inst.getHealth() < 0.f );
|
2013-12-10 22:47:56 +01:00
|
|
|
}
|
|
|
|
|
2016-06-04 00:10:57 +02:00
|
|
|
#endif
|
|
|
|
|
2013-12-10 22:47:56 +01:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|