using Fantasy.Entitas;
using Fantasy.Helper;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson.Serialization.Options;

namespace NB.Game;

/// <summary>
/// 玩家基本数据
/// </summary>
public sealed class Player : Entity
{
    /// <summary>
    /// 昵称
    /// </summary>
    [BsonElement("name")] public string NickName = "";

    /// <summary>
    /// 头像
    /// </summary>
    [BsonElement("head")] public string Head = "";

    /// <summary>
    /// 国家
    /// </summary>
    [BsonElement("ccy")] public string Country = "";

    /// <summary>
    /// 等级
    /// </summary>
    [BsonElement("lv")] public int Level;

    /// <summary>
    /// 当前经验
    /// </summary>
    [BsonElement("exp")] public int Exp;
    

    /// <summary>
    /// 星数
    /// </summary>
    [BsonElement("star")] public int Star;

    /// <summary>
    /// 高光数
    /// </summary>
    [BsonElement("high")] public int Highlight;

    /// <summary>
    /// 角色vip信息
    /// </summary>
    [BsonElement("vInfo")] public PlayerVip Vip;

    /// <summary>
    /// 钱包
    /// </summary>
    [BsonElement("wallet")] public PlayerWallet Wallet;

    /// <summary>
    /// 背包
    /// </summary>
    [BsonElement("bag")] public ItemContainer ItemContainer;

    /// <summary>
    /// 鱼护
    /// </summary>
    [BsonElement("fish")] public FishContainer FishContainer;

    /// <summary>
    /// 技能
    /// </summary>
    [BsonElement("skill")] public SkillContainer SkillContainer;

    /// <summary>
    /// 成就
    /// </summary>
    [BsonElement("achievement")] public AchievementContainer AchievementContainer;

    /// <summary>
    /// 是否是vip
    /// </summary>
    [BsonIgnore]
    public bool IsVip => Vip != null && Vip.ExpirationTime > TimeHelper.Now;

    [BsonIgnore] public long SessionRunTimeId;

    /// <summary>
    /// 需要保存数据库
    /// </summary>
    [BsonIgnore] public bool NeedSave;

    /// <summary>
    /// 需要保存数据库时间
    /// </summary>
    [BsonIgnore] public long NeedSaveTime;
}