using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public struct Attribute
{
[SerializeField]
private long _base;
public Attribute(long stat)
{
_base = stat;
}
///
/// Permanently increase the stat value.
///
/// Increase amount.
public void LevelUp(long by)
{
_base += by;
}
///
/// Calculates the stat value with accumulated buff and debuff modifiers.
///
/// Additive bonus applied before multiplicative scaling.
/// Multiplicative scaling in hundredths of a percent. E.g., 625 permyriad corresponds to 6.25%.
/// Additive bonus applied after multiplicative scaling.
/// (base + baseBonus) * (100% + permyriadBonus) + flatBonus, bounded below by 0.
public long Calc(long baseBonus, long permyriadBonus, long flatBonus)
{
var r = _base + baseBonus;
var m = permyriadBonus + 10000;
r = r * (m / 10000) + (r / 10000) * (m % 10000) + flatBonus;
if (r <= 0)
{
return 0;
}
return r;
}
}