-
-
Save GuyPaddock/ff8dcba1d30b5e3751c1226f24e24e56 to your computer and use it in GitHub Desktop.
Failing Key Ability Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OpenPF2 for UE Game Logic, Copyright 2021, Guy Elsmore-Paddock. All Rights Reserved. | |
// | |
// Content from Pathfinder 2nd Edition is licensed under the Open Game License (OGL) v1.0a, subject to the following: | |
// - Open Game License v 1.0a, Copyright 2000, Wizards of the Coast, Inc. | |
// - System Reference Document, Copyright 2000, Wizards of the Coast, Inc. | |
// - Pathfinder Core Rulebook (Second Edition), Copyright 2019, Paizo Inc. | |
// Except for material designated as Product Identity, the game mechanics and logic in this file are Open Game Content, | |
// as defined in the Open Game License version 1.0a, Section 1(d) (see accompanying LICENSE.TXT). No portion of this | |
// file other than the material designated as Open Game Content may be reproduced in any form without written | |
// permission. | |
#include <GameplayEffect.h> | |
#include "Abilities/PF2AttributeSet.h" | |
#include "Tests/PF2SpecBase.h" | |
#include "Tests/PF2TestSetStrengthAsKeyAbilityGameplayEffect.h" | |
BEGIN_DEFINE_PF_SPEC(FKeyAbilityBoostSpec, | |
"OpenPF2.KeyAbilityBoosts", | |
EAutomationTestFlags::ProductFilter | EAutomationTestFlags::ApplicationContextMask) | |
const FString BlueprintPath = TEXT("/OpenPF2Core/OpenPF2/Core"); | |
const FString KeyAbilityBoostGameEffectCalc = TEXT("GE_CalcKeyAbilityBoost"); | |
const TMap<FString, FString> KeyAbilities = { | |
{ "Strength", "AbStrength" }, | |
// { "Dexterity", "AbDexterity" }, | |
// { "Constitution", "AbConstitution" }, | |
// { "Intelligence", "AbIntelligence" }, | |
// { "Wisdom", "AbWisdom" }, | |
// { "Charisma", "AbCharisma" }, | |
}; | |
TSubclassOf<UGameplayEffect> LoadGE() const; | |
TSubclassOf<UGameplayEffect> LoadKeyAbilityGE() const; | |
END_DEFINE_PF_SPEC(FKeyAbilityBoostSpec) | |
void FKeyAbilityBoostSpec::Define() | |
{ | |
BeforeEach([=, this]() | |
{ | |
this->SetupWorld(); | |
this->SetupPawn(); | |
this->BeginPlay(); | |
}); | |
AfterEach([=, this]() | |
{ | |
this->DestroyPawn(); | |
this->DestroyWorld(); | |
}); | |
for (auto& KeyAbility : this->KeyAbilities) | |
{ | |
const FString KeyAbilityName = KeyAbility.Key; | |
const FString KeyAbilityAttributeName = KeyAbility.Value; | |
Describe(FString::Format(TEXT("when the character's key ability is '{0}'"), {KeyAbilityName}), [=, this]() | |
{ | |
UPF2TestSetStrengthAsKeyAbilityGameplayEffect* TagEffect; | |
BeforeEach([this, &TagEffect, KeyAbilityAttributeName, KeyAbilityName]() | |
{ | |
const UPF2AttributeSet* AttributeSet = this->PawnAbilityComponent->GetSet<UPF2AttributeSet>(); | |
FAttributeCapture Attributes = CaptureAbilityAttributes(AttributeSet); | |
FGameplayAttributeData* KeyAbilityAttribute = Attributes[KeyAbilityAttributeName]; | |
const FString TagName = FString::Format(TEXT("KeyAbility.{0}"), {KeyAbilityName}); | |
const TSubclassOf<UGameplayEffect> &EffectBP = this->LoadGE(), | |
&KeyAbilityEffectBP = this->LoadKeyAbilityGE(); | |
// Start attributes from known values. | |
// for (const auto& AttributeCapture : Attributes) | |
// { | |
// FGameplayAttributeData* Attribute = AttributeCapture.Value; | |
// | |
// *Attribute = 0.0f; | |
// } | |
// TagEffect = NewObject<UPF2TestSetStrengthAsKeyAbilityGameplayEffect>(); | |
// | |
// this->PawnAbilityComponent->ApplyGameplayEffectToTarget( | |
// TagEffect, | |
// this->PawnAbilityComponent, | |
// 1.0f | |
// ); | |
this->PawnAbilityComponent->ApplyGameplayEffectToTarget( | |
KeyAbilityEffectBP->GetDefaultObject<UGameplayEffect>(), | |
this->PawnAbilityComponent, | |
1.0f | |
); | |
// this->ApplyUnreplicatedTag(TagName); | |
this->ApplyGameEffect(*KeyAbilityAttribute, 15.0f, EffectBP); | |
}); | |
It(FString::Format(TEXT("boosts '{0}'"), {KeyAbilityName}), [=, this]() | |
{ | |
const UPF2AttributeSet* AttributeSet = this->PawnAbilityComponent->GetSet<UPF2AttributeSet>(); | |
FAttributeCapture Attributes = CaptureAbilityAttributes(AttributeSet); | |
const FGameplayAttributeData* KeyAbilityAttribute = Attributes[KeyAbilityAttributeName]; | |
TestEqual( | |
FString::Format(TEXT("{0}.BaseValue"), {KeyAbilityName}), | |
KeyAbilityAttribute->GetBaseValue(), | |
15.0f | |
); | |
// FIXME: This always fails whenever we are using a tag-guarded attribute. Why?! | |
TestEqual( | |
FString::Format(TEXT("{0}.CurrentValue"), {KeyAbilityName}), | |
KeyAbilityAttribute->GetCurrentValue(), | |
17.0f | |
); | |
}); | |
xIt(TEXT("does not boost any other abilities"), [=, this]() | |
{ | |
const UPF2AttributeSet* AttributeSet = this->PawnAbilityComponent->GetSet<UPF2AttributeSet>(); | |
FAttributeCapture Attributes = CaptureAbilityAttributes(AttributeSet); | |
for (const auto& AttributeCapture : Attributes) | |
{ | |
FString AttributeName = AttributeCapture.Key; | |
const FGameplayAttributeData* Attribute = AttributeCapture.Value; | |
if (AttributeName != KeyAbilityAttributeName) | |
{ | |
TestEqual( | |
FString::Format(TEXT("{0}.BaseValue"), {AttributeName}), | |
Attribute->GetBaseValue(), | |
0.0f | |
); | |
TestEqual( | |
FString::Format(TEXT("{0}.CurrentValue"), {AttributeName}), | |
Attribute->GetCurrentValue(), | |
0.0f | |
); | |
} | |
} | |
}); | |
}); | |
} | |
} | |
TSubclassOf<UGameplayEffect> FKeyAbilityBoostSpec::LoadGE() const | |
{ | |
return this->LoadBlueprint<UGameplayEffect>(this->BlueprintPath, this->KeyAbilityBoostGameEffectCalc); | |
} | |
TSubclassOf<UGameplayEffect> FKeyAbilityBoostSpec::LoadKeyAbilityGE() const | |
{ | |
return this->LoadBlueprint<UGameplayEffect>(TEXT("/OpenPF2Core/OpenPF2/Core/Debug"), TEXT("GE_TestTagKeyAbility")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment