semi update the unit tests

This commit is contained in:
jadebenn 2024-03-31 21:49:59 -05:00
parent 50b207405c
commit 657fb35560
2 changed files with 39 additions and 5 deletions

View File

@ -153,11 +153,11 @@ void PetComponent::SetPetAiState(PetAiState newState) {
}
void PetComponent::OnUse(Entity* originator) {
LOG("PET USE!");
LOG_DEBUG("PET USE!");
if (IsReadyToInteract()) {
switch (GetAbility()) {
case ePetAbilityType::DigAtPosition: // Treasure dig TODO: FIX ICON
case ePetAbilityType::DigAtPosition: // Treasure dig
StartInteractTreasureDig();
break;
@ -170,8 +170,7 @@ void PetComponent::OnUse(Entity* originator) {
}
}
// TODO: Rewrite everything below this comment
// The minigame logic beneath this comment should be rewritten... eventually
if (m_Owner != LWOOBJID_EMPTY) return;
if (m_Tamer != LWOOBJID_EMPTY) {
@ -201,7 +200,7 @@ void PetComponent::OnUse(Entity* originator) {
std::string buildFile;
// TODO: MOVE THIS OUT OF THE COMPONENT
// It may make sense to move this minigame-specific logic into another file
if (cached == buildCache.end()) {
auto query = CDClientDatabase::CreatePreppedStmt(
"SELECT ValidPiecesLXF, PuzzleModelLot, Timelimit, NumValidPieces, imagCostPerBuild FROM TamingBuildPuzzles WHERE NPCLot = ?;");

View File

@ -99,3 +99,38 @@ TEST_F(PetTest, PetComponentFlagTest) {
ASSERT_FALSE(petComponent->HasFlag(SPAWNING));
ASSERT_FALSE(petComponent->HasFlag(SPAWNING, NOT_WAITING, TAMEABLE, BEING_TAMED));
}
TEST_F(PetTest, PetAiState) {
const auto initialState = petComponent->GetPetAiState();
ASSERT_EQ(initialState, PetAiState::spawn);
petComponent->SetPetAiState(PetAiState::follow);
ASSERT_EQ(PetAiState::follow, petComponent->GetPetAiState());
petComponent->SetPetAiState(PetAiState::idle);
ASSERT_EQ(PetAiState::idle, petComponent->GetPetAiState());
petComponent->SetPetAiState(PetAiState::interact);
ASSERT_EQ(PetAiState::interact, petComponent->GetPetAiState());
petComponent->SetPetAiState(PetAiState::despawn);
ASSERT_EQ(PetAiState::despawn, petComponent->GetPetAiState());
}
// Test the pet use logic
TEST_F(PetTest, PetUse) {
ASSERT_FALSE(petComponent->IsReadyToInteract());
petComponent->SetIsReadyToInteract(true);
ASSERT_TRUE(petComponent->IsReadyToInteract());
// Test bouncer logic
ASSERT_FALSE(petComponent->IsHandlingInteraction());
petComponent->SetAbility(ePetAbilityType::JumpOnObject);
ASSERT_EQ(petComponent->GetAbility(), ePetAbilityType::JumpOnObject);
petComponent->SetInteractType(PetInteractType::bouncer);
petComponent->OnUse(baseEntity);
// need to add a destroyable component to the test entity and test the imagination drain
}