29 lines
709 B
C#
29 lines
709 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
public struct Attribute
|
|
{
|
|
public long Base;
|
|
|
|
public Attribute(long stat) { Base = stat; }
|
|
|
|
/// <summary>
|
|
/// Calculates the stat value with accumulated buff and debuff modifiers.
|
|
/// </summary>
|
|
/// <returns>(base + baseBonus) * (100% + permyriadBonus) + flatBonus, bounded below by 0.</returns>
|
|
public long Calc(EffectSO effect)
|
|
{
|
|
var r = Base + effect.Base;
|
|
var m = effect.Permyriad + 10000;
|
|
r = r * (m / 10000) + (r / 10000) * (m % 10000) + effect.Flat;
|
|
if (r <= 0)
|
|
{
|
|
return 0;
|
|
}
|
|
return r;
|
|
}
|
|
}
|