From dbd35f8a2fe04342339814bcc751efa47e0b54f3 Mon Sep 17 00:00:00 2001 From: Macarthur Inbody <133794m3r@gmail.com> Date: Sat, 1 May 2021 16:34:25 -0400 Subject: [PATCH] Mobs are scaled according to tiers. And also updated the tests accordingly. --- classes/fighters/mob.hxx | 4 ++-- tests/actor_test.cpp | 46 ++++++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/classes/fighters/mob.hxx b/classes/fighters/mob.hxx index d077416..4638986 100644 --- a/classes/fighters/mob.hxx +++ b/classes/fighters/mob.hxx @@ -78,7 +78,7 @@ class Mob : public Actor { glm = 4.00; bvm = 120.00; } - this->gold_ = static_cast((this->xp_ * glm - ((dl / gm) * bvm)) * (0.50 + (this->tier_-1 / 3.00))); + this->gold_ = static_cast((this->xp_ * glm - ((dl / gm) * bvm)) * 0.50); } public: @@ -90,7 +90,7 @@ class Mob : public Actor { unsigned int tmp = this->lvl_ + 1; //based on other formulas this should make the curve OK. //tier will modify the two formulas below eventually - this->xp_ = std::lround(tmp * (tmp * (0.79 + (tier - 1 / 3.00)) + 2.00)); + this->xp_ = std::lround((tmp * (tmp * 0.79) *(1+ (tier - 1.00 / 3.25))+ 2.00)); this->gold_ = 0; this->set_gold(); this->tier_ = tier; diff --git a/tests/actor_test.cpp b/tests/actor_test.cpp index 64213d2..32f6ee9 100644 --- a/tests/actor_test.cpp +++ b/tests/actor_test.cpp @@ -25,38 +25,38 @@ int main(){ //test the first actor build if( "id: 0 Test hp:15/15 str:5/5 def:3/3" != (std::string) base_actor){ std::cout << "Base actor test failed. got '" << (std::string) base_actor; - std::cout << "\nbut we expected 'id: 0 Test hp:15/15 str:5/5 def:3/3'" << std::endl; + std::cout << "\nbut we expected 'id: 0 Test hp:15/15 str:5/5 def:3/3'\n"; tests_failed++; } else - std::cout << "Base actor test succeeded." << std::endl; + std::cout << "Base actor test succeeded.\n"; //same with the player if("id: 65535 Player hp:20/20 str:5/5 def:4/4 xp:0 g:100" != (std::string) tmp_player){ std::cout << "player creation test failed\n"; std::cout << "Expected 'id: 65535 Player hp:20/20 str:5/5 def:4/4 xp:0 g:100' but we got '"; - std::cout << (std::string) tmp_player << std::endl; + std::cout << (std::string) tmp_player << '\n'; tests_failed++; } else - std::cout << "Player creation test Passed" << std::endl; + std::cout << "Player creation test Passed\n"; //and mob - if( "id: 2 Spawn of Death hp:16/16 str:8/8 def:3/3 xp:6 g:4 tier: 1 / normal" != (std::string) tmp_mob){ + if( "id: 2 Spawn of Death hp:16/16 str:8/8 def:3/3 xp:7 g:5 tier: 1 / normal" != (std::string) tmp_mob){ std::cout << "mob creation test failed \n"; - std::cout << "Expected 'id: 2 Spawn of Death hp:16/16 str:8/8 def:3/3 xp:6 g:4 tier: 1 / normal' but we got '"; - std::cout << (std::string) tmp_mob << std::endl; + std::cout << "Expected 'id: 2 Spawn of Death hp:16/16 str:8/8 def:3/3 xp:7 g:5 tier: 1 / normal' but we got '"; + std::cout << (std::string) tmp_mob << '\n'; tests_failed++; } else - std::cout << "Mob creation test passed" << std::endl; + std::cout << "Mob creation test passed\n"; //test the damage method base_actor.damage(22); //should've killed them. if(!base_actor.is_alive()) { - std::cout << "Actor death test succeeded" << std::endl; + std::cout << "Actor death test succeeded\n"; } else { - std::cout << "Actor death test failed" << std::endl; + std::cout << "Actor death test failed\n"; tests_failed++; } @@ -65,7 +65,7 @@ int main(){ unsigned int expected_hp = tmp_mob_hp - (tmp_player.get_str() - tmp_mob.get_def()); std::cout << "Actor targetting mob test "; if(tmp_mob.get_hp() != expected_hp ){ - std::cout << "failed. Mob HP wrong expected " << expected_hp << " but got " << tmp_mob.get_hp() << std::endl; + std::cout << "failed. Mob HP wrong expected " << expected_hp << " but got " << tmp_mob.get_hp() <<'\n'; tests_failed++; } else{ @@ -77,29 +77,33 @@ int main(){ expected_hp = (tmp_player_hp - (tmp_mob.get_str() - tmp_player.get_def()) ); std::cout << "Mob targeting player test "; if(tmp_player.get_hp() != expected_hp ){ - std::cout << "failed. Expected " << expected_hp << " but got " << tmp_player.get_hp() << std::endl; + std::cout << "failed. Expected " << expected_hp << " but got " << tmp_player.get_hp() << '\n'; tests_failed++; } else{ - std::cout << "passed." << std::endl; + std::cout << "passed.\n"; } //test the tiers and scaling. Mob boss("Bossman",6,5); std::cout << "Boss creation/scaling/tier test "; - if((std::string) boss != "id: 3 Bossman hp:99/99 str:38/38 def:20/20 xp:36 g:30 tier: 6 / boss"){ - std::cout << "failed. Expected 'id: 3 Bossman hp:99/99 str:38/38 def:20/20 xp:36 g:30 tier: 6 / boss' but we got '" << (std::string) boss << "'" << std::endl; + if((std::string) boss != "id: 3 Bossman hp:115/115 str:42/42 def:24/24 xp:192 g:178 tier: 6 / boss"){ + std::cout << "failed. Expected 'id: 3 Bossman hp:115/115 str:42/42 def:24/24 xp:192 g:178 tier: 6 / boss' but we got '" << (std::string) boss << "'\n"; tests_failed++; } else - std::cout << "passed." << std::endl; + std::cout << "passed.\n"; - std::cout << "Passed " << 6 - tests_failed << "/6" << std::endl; - Player tmp_act("jon",6); - if(tests_failed != 0){ - return 1; + std::cout << "Junk Mob creation test\n"; + Mob junk_mob("Junk",0); + if((std::string) junk_mob != "id: 4 Junk hp:13/13 str:5/5 def:2/2 xp:4 g:2 tier: 0 / trash"){ + std::cout << "Test failed: Expected 'id: 4 Junk hp:13/13 str:5/5 def:2/2 xp:4 g:2 tier: 0 / trash' but we got " << (std::string) junk_mob << '\n'; + tests_failed++; } + std::cout << "Passed " << 7 - tests_failed << "/7" << std::endl; + + if(tests_failed != 0) + return 1; else return 0; - }