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. 35
      Adventures in Lestoria/AdventuresInLestoria.cpp
  3. 2
      Adventures in Lestoria/GameState.cpp
  4. 1
      Adventures in Lestoria/Minimap.cpp
  5. 20
      Adventures in Lestoria/Player.cpp
  6. 2
      Adventures in Lestoria/Version.h

@ -74,6 +74,9 @@ namespace PlayerTests
Menu::InitializeMenus(); Menu::InitializeMenus();
Tutorial::Initialize(); Tutorial::Initialize();
Stats::InitializeDamageReductionTable(); Stats::InitializeDamageReductionTable();
GameState::Initialize();
GameState::STATE=GameState::states.at(States::State::GAME_RUN);
#pragma region Setup a fake test map and test monster #pragma region Setup a fake test map and test monster
game->MAP_DATA["CAMPAIGN_1_1"]; game->MAP_DATA["CAMPAIGN_1_1"];
@ -90,7 +93,9 @@ namespace PlayerTests
Menu::themes.SetInitialized(); Menu::themes.SetInitialized();
GFX.SetInitialized(); GFX.SetInitialized();
} }
TEST_METHOD_CLEANUP(CleanupTests){
testGame->EndGame();
}
TEST_METHOD(PlayerAlive){ TEST_METHOD(PlayerAlive){
Assert::IsTrue(player->IsAlive()); Assert::IsTrue(player->IsAlive());
} }
@ -416,5 +421,23 @@ namespace PlayerTests
Inventory::EquipItem(setArmor,EquipSlot::ARMOR); Inventory::EquipItem(setArmor,EquipSlot::ARMOR);
Assert::AreEqual(2.f,player->GetMoveSpdMult(),L"100% Move Spd should double the move speed from 100% to 200%"); 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); ChangePlayerClass(WARRIOR);
GameState::Initialize(); GameState::Initialize();
GameState::ChangeState(States::MAIN_MENU);
Unlock::Initialize(); Unlock::Initialize();
ItemDrop::Initialize(); ItemDrop::Initialize();
@ -376,23 +377,24 @@ bool AiL::OnUserUpdate(float fElapsedTime){
InputListener::Update(); InputListener::Update();
Tutorial::Update(); Tutorial::Update();
Audio::Update(); Audio::Update();
GameState::STATE->Draw(this); if(!game->TestingModeEnabled()){
RenderMenu(); GameState::STATE->Draw(this);
GameState::STATE->DrawOverlay(this); RenderMenu();
RenderFadeout(); GameState::STATE->DrawOverlay(this);
LoadingScreen::Draw(); RenderFadeout();
RenderVersionInfo(); LoadingScreen::Draw();
#ifndef __EMSCRIPTEN__ RenderVersionInfo();
if(Discord){ #ifndef __EMSCRIPTEN__
auto result=Discord->RunCallbacks(); if(Discord){
if(result!=::discord::Result::Ok){ auto result=Discord->RunCallbacks();
LOG("Discord Error Code "<<int(result)); if(result!=::discord::Result::Ok){
delete Discord; LOG("Discord Error Code "<<int(result));
Discord=nullptr; delete Discord;
Discord=nullptr;
}
} }
} #endif
#endif }
if(QuitRequested())EndGame();
return !gameEnd; return !gameEnd;
} }
@ -1014,7 +1016,6 @@ void AiL::RenderTile(TileRenderData&tileSheet,Pixel col){
} }
void AiL::RenderWorld(float fElapsedTime){ void AiL::RenderWorld(float fElapsedTime){
LayerTag*bridgeLayer=nullptr; LayerTag*bridgeLayer=nullptr;
bool bridgeLayerFade=false; bool bridgeLayerFade=false;
Player*pl=GetPlayer(); Player*pl=GetPlayer();

@ -56,8 +56,6 @@ void GameState::Initialize(){
NEW_STATE(States::STORY,State_Story); NEW_STATE(States::STORY,State_Story);
NEW_STATE(States::GAME_HUB,State_GameHub); NEW_STATE(States::GAME_HUB,State_GameHub);
NEW_STATE(States::DEATH,State_Death); NEW_STATE(States::DEATH,State_Death);
GameState::ChangeState(States::MAIN_MENU);
} }
void GameState::_ChangeState(States::State newState){ 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){ 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)); 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. 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()); const std::map<std::string,std::vector<ZoneData>>&zoneData=game->GetZones(game->GetCurrentLevel());
for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){ if(zoneData.count("UpperZone")){
if(geom2d::overlaps(upperLevelZone.zone,pos)){ for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){
upperLevel=true; 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()));
for(const ZoneData&lowerLevelZone:zoneData.at("LowerZone")){ if(zoneData.count("LowerZone")){
if(geom2d::overlaps(lowerLevelZone.zone,pos)){ for(const ZoneData&lowerLevelZone:zoneData.at("LowerZone")){
upperLevel=false; 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(); EnvironmentalAudio::UpdateEnvironmentalAudio();
if(!std::isfinite(pos.x)){ if(!std::isfinite(pos.x)){

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

Loading…
Cancel
Save