Skip to content

Commit

Permalink
Mobs are scaled according to tiers. And also updated the tests accord…
Browse files Browse the repository at this point in the history
…ingly.
  • Loading branch information
133794m3r committed May 1, 2021
1 parent 2af394b commit dbd35f8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions classes/fighters/mob.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Mob : public Actor {
glm = 4.00;
bvm = 120.00;
}
this->gold_ = static_cast<unsigned int>((this->xp_ * glm - ((dl / gm) * bvm)) * (0.50 + (this->tier_-1 / 3.00)));
this->gold_ = static_cast<unsigned int>((this->xp_ * glm - ((dl / gm) * bvm)) * 0.50);
}
public:

Expand All @@ -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;
Expand Down
46 changes: 25 additions & 21 deletions tests/actor_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand All @@ -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{
Expand All @@ -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;


}

0 comments on commit dbd35f8

Please sign in to comment.