Exemple #1
0
        public string SaveCharacter()
        {
            IECharacter newChar = new IECharacter();

            newChar.CharacterName   = CharacterName;
            newChar.PlayerName      = PlayerName;
            newChar.Background      = Background;
            newChar.Alignment       = Alignment;
            newChar.Religion        = Religion;
            newChar.Experience      = Experience;
            newChar.Copper          = Copper;
            newChar.Silver          = Silver;
            newChar.Elisium         = Elisium;
            newChar.Gold            = Gold;
            newChar.Platinum        = Platinum;
            newChar.HitDice         = HitDice;
            newChar.PlayerClassList = PlayerClassList;
            newChar.FeatsNtraits    = FeatsNtraits;
            newChar.EquipmentList   = EquipmentList;
            newChar.AttackList      = AttackList;
            newChar.AllStats        = CharacterStats.AllStats;
            newChar.Proficiencies   = CharacterStats.Proficiencies;
            newChar.Speed           = CharacterStats.Speed;
            newChar.Age             = CharacterStats.Age;
            newChar.Height          = CharacterStats.Height;
            newChar.Weight          = CharacterStats.Weight;
            string json = JsonConvert.SerializeObject(newChar);

            return(json);
        }
Exemple #2
0
        public void LoadCharacter(string json)
        {
            IECharacter newChar = JsonConvert.DeserializeObject <IECharacter>(json);

            CharacterName   = newChar.CharacterName;
            PlayerName      = newChar.PlayerName;
            Background      = newChar.Background;
            Alignment       = newChar.Alignment;
            Religion        = newChar.Religion;
            Experience      = newChar.Experience;
            Copper          = newChar.Copper;
            Silver          = newChar.Silver;
            Elisium         = newChar.Elisium;
            Gold            = newChar.Gold;
            Platinum        = newChar.Platinum;
            HitDice         = newChar.HitDice;
            PlayerClassList = newChar.PlayerClassList;
            FeatsNtraits    = newChar.FeatsNtraits;
            EquipmentList   = newChar.EquipmentList;
            AttackList      = newChar.AttackList;
            foreach (Stat pStat in CharacterStats.AllStats)
            {
                foreach (Stat ieStat in newChar.AllStats)
                {
                    if (pStat.Name.Equals(ieStat.Name))
                    {
                        pStat.StatBase = ieStat.StatBase;
                        break;
                    }
                }
            }
            CharacterStats.Proficiencies = newChar.Proficiencies;
            CharacterStats.Speed         = newChar.Speed;
            CharacterStats.Age           = newChar.Age;
            CharacterStats.Height        = newChar.Height;
            CharacterStats.Weight        = newChar.Weight;
        }