using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 属性 - 数据
///
public class DataAttribute {
/// 力量(strength)
public virtual int Str { get; set; }
/// 敏捷(dexterity)
public virtual int Dex { get; set; }
/// 体质(constitution)
public virtual int Con { get; set; }
/// 智力(intelligence)
public virtual int Int { get; set; }
/// 感知(wisdom)
public virtual int Wis { get; set; }
/// 魅力(charisma)
public virtual int Cha { get; set; }
/// 力量调整值(strength)
public int StrModifier => Modifier(Str);
/// 敏捷调整值(dexterity)
public int DexModifier => Modifier(Dex);
/// 体质调整值(constitution)
public int ConModifier => Modifier(Con);
/// 智力调整值(intelligence)
public int IntModifier => Modifier(Int);
/// 感知调整值(wisdom)
public int WisModifier => Modifier(Wis);
/// 魅力调整值(charisma)
public int ChaModifier => Modifier(Cha);
/// 创建初始属性
public static DataAttribute Initial() {
DataAttribute attribute = new DataAttribute();
attribute.Str = Dice.RollAttribute();
attribute.Dex = Dice.RollAttribute();
attribute.Con = Dice.RollAttribute();
attribute.Int = Dice.RollAttribute();
attribute.Wis = Dice.RollAttribute();
attribute.Cha = Dice.RollAttribute();
return attribute;
}
// 计算属性调整值(属性值-10)/2 向下取整
public int Modifier(int value) {
return (int)System.Math.Floor((value - 10) / 2.0);
}
/// 添加属性
public void Add(DataAttribute value) {
Str += value.Str;
Dex += value.Dex;
Con += value.Con;
Int += value.Int;
Wis += value.Wis;
Cha += value.Cha;
}
/// 减少属性
public void Sub(DataAttribute value) {
Str -= value.Str;
Dex -= value.Dex;
Con -= value.Con;
Int -= value.Int;
Wis -= value.Wis;
Cha -= value.Cha;
}
/// 覆盖属性
public void Cover(DataAttribute value) {
Str = value.Str;
Dex = value.Dex;
Con = value.Con;
Int = value.Int;
Wis = value.Wis;
Cha = value.Cha;
}
}