// Fill out your copyright notice in the Description page of Project Settings.


#include "Data/GameplayStatEffect.h"
#include "Components/StatForgeComponent.h"

float FGameplayStatEffectMod::GetModValue(UStatForgeComponent* StatComponent, const TMap<FName, float>& DataValueMap) const
{
	switch (CalculationType) {
	case EGameplayStatEffectModCalculation::Flat:
		return FlatValue;
	case EGameplayStatEffectModCalculation::CalculationClass:
		{
			if (!StatCalculationClass) return 0.f;
				
			UStatEffectModCalculation* Calc = NewObject<UStatEffectModCalculation>(StatComponent, StatCalculationClass);
			return Calc->GetValue(StatComponent);
		}
	case EGameplayStatEffectModCalculation::DataValue:
		{
			if (const float* Value = DataValueMap.Find(DataValueName))
			{
				return *Value;
			}
		}
	}
	return 0.f;
}
