Add in Unit test to cover Issue#129 and resolve it. Release Build 13511.
All checks were successful
Emscripten Build / Build_and_Deploy_Web_Build (push) Successful in 7m1s
Emscripten Build / UnitTesting (push) Successful in 8m40s

This commit is contained in:
AMay 2026-05-04 02:12:40 -05:00
parent 13d31b2ebc
commit 94c87a100a
4 changed files with 25 additions and 5 deletions

View File

@ -3847,7 +3847,7 @@ const std::weak_ptr<Item>AiL::GetLoadoutItem(int slot){
void AiL::RestockLoadoutItems(){
for(int slot=0;slot<GetLoadoutSize();slot++){
if(!ISBLANK(GetLoadoutItem(slot))){
if(!GetLoadoutItem(slot).expired()&&GetLoadoutItem(slot).lock()->it!=nullptr){
SetLoadoutItem(slot,GetLoadoutItem(slot).lock()->ActualName());
//Set the loadout slot selection for this loadout item.

View File

@ -677,11 +677,9 @@ uint32_t Item::Amt()const{
return amt;
};
const std::string&Item::ActualName()const{
if(_IsBlank())return BLANK_ITEM_NAME;
return it->Name();
};
const std::string Item::DisplayName()const{
if(_IsBlank())return BLANK_ITEM_NAME;
std::string name=ActualName();
if(IsEquippable()&&EnhancementLevel()>0){
name+=" [#00FF00+"+std::to_string(EnhancementLevel())+"#FFFFFF]";

View File

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1
#define VERSION_MINOR 3
#define VERSION_PATCH 0
#define VERSION_BUILD 13506
#define VERSION_BUILD 13511
#define stringify(a) stringify_(a)
#define stringify_(a) #a

View File

@ -440,4 +440,26 @@ TEST(ItemTests,"ConsumedLoadoutSlotTest"){
REQUIRE(!usedItemResult2);
game->SetLoadoutItem(2,"Boar Meat");
}
TEST(ItemTests,"LoadoutSlotRefillsAfterLevelTest"){
Inventory::AddItem("Health Potion"s,100);
Inventory::AddItem("Mana Potion"s,100);
Inventory::AddItem("Elixir of the Wind"s,100);
Inventory::AddItem("Boar Meat"s,3);
game->SetLoadoutItem(0,"Health Potion");
game->SetLoadoutItem(1,"Mana Potion");
game->SetLoadoutItem(2,"Elixir of the Wind");
REQUIRE(game->GetLoadoutItem(0).lock()->Amt()==(uint32_t)"Player.Item Loadout Limit"_I);
REQUIRE(game->GetLoadoutItem(1).lock()->Amt()==(uint32_t)"Player.Item Loadout Limit"_I);
REQUIRE(game->GetLoadoutItem(2).lock()->Amt()==(uint32_t)"Player.Item Loadout Limit"_I);
for(int i:std::ranges::iota_view(0U,(uint32_t)"Player.Item Loadout Limit"_I)){
game->UseLoadoutItem(0);
game->UseLoadoutItem(1);
Game::Update(std::max(game->GetLoadoutItem(0).lock()->CooldownTime(),game->GetLoadoutItem(1).lock()->CooldownTime()));
}
REQUIRE(game->GetLoadoutItem(0).lock()->Amt()==0);
REQUIRE(game->GetLoadoutItem(1).lock()->Amt()==0);
game->RestockLoadoutItems();
REQUIRE(game->GetLoadoutItem(0).lock()->Amt()==(uint32_t)"Player.Item Loadout Limit"_I);
REQUIRE(game->GetLoadoutItem(1).lock()->Amt()==(uint32_t)"Player.Item Loadout Limit"_I);
REQUIRE(game->GetLoadoutItem(2).lock()->Amt()==(uint32_t)"Player.Item Loadout Limit"_I);
}