Add tests for CDR checking. Move Game State initialize change to Main Menu into the actual initialization function instead of hiding inside the Game State's Initialize function. 78/78 tests passing.

removeExposedPackKey
sigonasr2 5 months ago
parent 9dbc5b46f8
commit 1e4266e0cd
  1. 25
      Adventures in Lestoria Tests/PlayerTests.cpp
  2. 5
      Adventures in Lestoria/AdventuresInLestoria.cpp
  3. 2
      Adventures in Lestoria/GameState.cpp
  4. 1
      Adventures in Lestoria/Minimap.cpp
  5. 4
      Adventures in Lestoria/Player.cpp
  6. 2
      Adventures in Lestoria/Version.h

@ -75,6 +75,9 @@ namespace PlayerTests
Tutorial::Initialize();
Stats::InitializeDamageReductionTable();
GameState::Initialize();
GameState::STATE=GameState::states.at(States::State::GAME_RUN);
#pragma region Setup a fake test map and test monster
game->MAP_DATA["CAMPAIGN_1_1"];
ItemDrop::drops.clear();
@ -90,7 +93,9 @@ namespace PlayerTests
Menu::themes.SetInitialized();
GFX.SetInitialized();
}
TEST_METHOD_CLEANUP(CleanupTests){
testGame->EndGame();
}
TEST_METHOD(PlayerAlive){
Assert::IsTrue(player->IsAlive());
}
@ -416,5 +421,23 @@ namespace PlayerTests
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
Assert::AreEqual(2.f,player->GetMoveSpdMult(),L"100% Move Spd should double the move speed from 100% to 200%");
}
TEST_METHOD(CDRStatEquipCheck){
std::weak_ptr<Item>setArmor{Inventory::AddItem("Test Armor2"s)};
Assert::AreEqual(0.f,player->GetCooldownReductionPct(),L"CDR is 0%");
Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
Assert::AreEqual(1.f,player->GetCooldownReductionPct(),L"Player should have 100% CDR");
testKey->bHeld=true; //Force the key to be held down for testing purposes.
player->CheckAndPerformAbility(player->GetAbility1(),testKeyboardInput);
player->CheckAndPerformAbility(player->GetAbility2(),testKeyboardInput);
player->CheckAndPerformAbility(player->GetAbility3(),testKeyboardInput);
player->CheckAndPerformAbility(player->GetAbility4(),testKeyboardInput);
game->OnUserUpdate(0.01f); //Let 0.01 seconds go by. All abilities should be off cooldown.
Assert::AreEqual(0.f,player->GetAbility1().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
Assert::AreEqual(0.f,player->GetAbility2().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
Assert::AreEqual(0.f,player->GetAbility3().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
Assert::AreEqual(0.f,player->GetAbility4().cooldown,L"Using an ability with 100% CDR should result in a 0 second cooldown.");
}
};
}

@ -304,6 +304,7 @@ bool AiL::OnUserCreate(){
ChangePlayerClass(WARRIOR);
GameState::Initialize();
GameState::ChangeState(States::MAIN_MENU);
Unlock::Initialize();
ItemDrop::Initialize();
@ -376,6 +377,7 @@ bool AiL::OnUserUpdate(float fElapsedTime){
InputListener::Update();
Tutorial::Update();
Audio::Update();
if(!game->TestingModeEnabled()){
GameState::STATE->Draw(this);
RenderMenu();
GameState::STATE->DrawOverlay(this);
@ -392,7 +394,7 @@ bool AiL::OnUserUpdate(float fElapsedTime){
}
}
#endif
if(QuitRequested())EndGame();
}
return !gameEnd;
}
@ -1014,7 +1016,6 @@ void AiL::RenderTile(TileRenderData&tileSheet,Pixel col){
}
void AiL::RenderWorld(float fElapsedTime){
LayerTag*bridgeLayer=nullptr;
bool bridgeLayerFade=false;
Player*pl=GetPlayer();

@ -56,8 +56,6 @@ void GameState::Initialize(){
NEW_STATE(States::STORY,State_Story);
NEW_STATE(States::GAME_HUB,State_GameHub);
NEW_STATE(States::DEATH,State_Death);
GameState::ChangeState(States::MAIN_MENU);
}
void GameState::_ChangeState(States::State newState){

@ -186,6 +186,7 @@ void Minimap::Update(){
}
void Minimap::UpdateChunk(const MapName map,const vi2d chunkPos,const InitialLoad initialLoad){
if(game->TestingModeEnabled())return;
loadedChunks[map].insert(std::format("{}_{}",chunkPos.x,chunkPos.y));
if(game->GetCurrentMapName()!=map)return; //Don't update the minimap when the map name doesn't match the current map.

@ -875,16 +875,20 @@ void Player::Moved(MoveFlag::MoveFlag flags){
}
}
const std::map<std::string,std::vector<ZoneData>>&zoneData=game->GetZones(game->GetCurrentLevel());
if(zoneData.count("UpperZone")){
for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){
if(geom2d::overlaps(upperLevelZone.zone,pos)){
upperLevel=true;
}
}
}else if(!game->TestingModeEnabled())ERR(std::format("WARNING! Map {} is missing Upper Zones! THIS SHOULD NOT BE HAPPENING!",game->GetCurrentMapDisplayName()));
if(zoneData.count("LowerZone")){
for(const ZoneData&lowerLevelZone:zoneData.at("LowerZone")){
if(geom2d::overlaps(lowerLevelZone.zone,pos)){
upperLevel=false;
}
}
}else if(!game->TestingModeEnabled())ERR(std::format("WARNING! Map {} is missing Lower Zones! THIS SHOULD NOT BE HAPPENING!",game->GetCurrentMapDisplayName()));
EnvironmentalAudio::UpdateEnvironmentalAudio();
if(!std::isfinite(pos.x)){

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_PATCH 3
#define VERSION_BUILD 9928
#define VERSION_BUILD 9937
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save