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.
This commit is contained in:
parent
9dbc5b46f8
commit
1e4266e0cd
@ -75,6 +75,9 @@ namespace PlayerTests
|
|||||||
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"];
|
||||||
ItemDrop::drops.clear();
|
ItemDrop::drops.clear();
|
||||||
@ -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,6 +377,7 @@ bool AiL::OnUserUpdate(float fElapsedTime){
|
|||||||
InputListener::Update();
|
InputListener::Update();
|
||||||
Tutorial::Update();
|
Tutorial::Update();
|
||||||
Audio::Update();
|
Audio::Update();
|
||||||
|
if(!game->TestingModeEnabled()){
|
||||||
GameState::STATE->Draw(this);
|
GameState::STATE->Draw(this);
|
||||||
RenderMenu();
|
RenderMenu();
|
||||||
GameState::STATE->DrawOverlay(this);
|
GameState::STATE->DrawOverlay(this);
|
||||||
@ -392,7 +394,7 @@ bool AiL::OnUserUpdate(float fElapsedTime){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#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());
|
||||||
|
if(zoneData.count("UpperZone")){
|
||||||
for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){
|
for(const ZoneData&upperLevelZone:zoneData.at("UpperZone")){
|
||||||
if(geom2d::overlaps(upperLevelZone.zone,pos)){
|
if(geom2d::overlaps(upperLevelZone.zone,pos)){
|
||||||
upperLevel=true;
|
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")){
|
for(const ZoneData&lowerLevelZone:zoneData.at("LowerZone")){
|
||||||
if(geom2d::overlaps(lowerLevelZone.zone,pos)){
|
if(geom2d::overlaps(lowerLevelZone.zone,pos)){
|
||||||
upperLevel=false;
|
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…
x
Reference in New Issue
Block a user