Ejemplo n.º 1
0
        public int DeserializeCharacters()
        {
            var management = new CharacterManagement();

            Characters = management.DeserializeCharacters();

            return(Characters.Count);
        }
Ejemplo n.º 2
0
        public int SerializeCharacters()
        {
            var management = new CharacterManagement();

            management.CheckFolder();

            for (var n = 0; n < Characters.Count; n++)
            {
                management.Serialize(Characters[n]);
            }

            return(Characters.Count);
        }
Ejemplo n.º 3
0
        public int SaveCharacters()
        {
            // -1 = Database fechada.
            var result     = -1;
            var saved      = 0;
            var management = new CharacterManagement();
            var database   = new DBGameDatabase();
            var dbError    = database.Open();

            if (dbError.Number > 0)
            {
                WriteLog(LogType.System, $"Failed to save characters", LogColor.Red);
                WriteLog(LogType.System, $"Error Number: {dbError.Number}", LogColor.Red);
                WriteLog(LogType.System, $"Error Message: {dbError.Message}", LogColor.Red);
            }
            else
            {
                // 0 = Database aberta ou Sem personagens para salvar.
                result = 0;

                for (var n = 0; n < Characters.Count; n++)
                {
                    if (Characters[n].NeedSave)
                    {
                        management.SaveCharacter(ref database, Characters[n]);
                        saved++;
                    }

                    result = saved;
                }

                database.Close();
            }

            return(result);
        }