diff --git a/dGame/dComponents/PetComponent.cpp b/dGame/dComponents/PetComponent.cpp index fc277f0e..2bfe8535 100644 --- a/dGame/dComponents/PetComponent.cpp +++ b/dGame/dComponents/PetComponent.cpp @@ -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 = ?;"); diff --git a/tests/dGameTests/dComponentsTests/PetComponentTests.cpp b/tests/dGameTests/dComponentsTests/PetComponentTests.cpp index 4ded6219..05eeab75 100644 --- a/tests/dGameTests/dComponentsTests/PetComponentTests.cpp +++ b/tests/dGameTests/dComponentsTests/PetComponentTests.cpp @@ -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 + +}