44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include <doctest/doctest.h>
|
|
#include "Components/Configs/WorldConfig.hpp"
|
|
#include "Core/WorldInstance.h"
|
|
#include "Components/Resource.hpp"
|
|
#include "Components/Inventory.hpp"
|
|
|
|
TEST_SUITE("Resource") {
|
|
TEST_CASE("basic resource gathering produces item after one tick") {
|
|
WorldConfig config{};
|
|
uint16_t stoneID = config.RegisterItem("Stone");
|
|
|
|
WorldInstance world{ config };
|
|
|
|
// Create a resource entity with gatherTicks = 1
|
|
auto entity = world.GetEcsWorld().entity();
|
|
Resource_Ore_Helper(entity, stoneID, 1);
|
|
|
|
world.ProcessFrame();
|
|
|
|
auto& inv = world.GetEcsWorld().ensure<WorldInventory>();
|
|
CHECK(inv.GetItemsAmount(stoneID) >= 1);
|
|
}
|
|
|
|
TEST_CASE("resource with 20 tick gather time produces item after 20 ticks") {
|
|
WorldConfig config{};
|
|
uint16_t stoneID = config.RegisterItem("Stone");
|
|
|
|
WorldInstance world{ config };
|
|
|
|
auto entity = world.GetEcsWorld().entity();
|
|
Resource_Ore_Helper(entity, stoneID, 20);
|
|
|
|
for (int i = 0; i < 19; ++i)
|
|
world.ProcessFrame();
|
|
|
|
auto& inv = world.GetEcsWorld().ensure<WorldInventory>();
|
|
CHECK(inv.GetItemsAmount(stoneID) == 0);
|
|
|
|
world.ProcessFrame();
|
|
|
|
CHECK(inv.GetItemsAmount(stoneID) >= 1);
|
|
}
|
|
}
|