Пример #1
0
        private Account CreateNewAccount(string name, string password)
        {
            var ac = Account.CreateAccount(name, password, 20);

            AccountCache.Add(ac);
            Directory.CreateDirectory(Directory.GetParent(accountFilePath).FullName);
            GameSerializer.SaveToFile(accountFilePath, AccountCache);
            return(ac);
        }
Пример #2
0
 private void ReadAccounts()
 {
     if (File.Exists(accountFilePath))
     {
         AccountCache = GameSerializer.ReadFromFile <List <Account> >(accountFilePath);
     }
     else
     {
         AccountCache = new List <Account>();
         GameSerializer.SaveToFile(accountFilePath, AccountCache);
     }
 }
Пример #3
0
        public Account LogIn(string name, string password)
        {
            var a = AccountCache.FirstOrDefault(ac => ac.playerName == name);

            if (a is null)
            {
                return(null);
            }
            var s = GameSerializer.GetHash(password);

            if (s != a.passwordHash)
            {
                Debug.Log($"hash '{s}' != password '{password}'");
                return(null);
            }
            SessionAccount = a;
            GameSlotCache  = GetGameSlots(a).ToList();
            return(a);
        }
Пример #4
0
 public static Account CreateAccount(string playerName, string password, int age)
 {
     return(new Account(playerName, GameSerializer.GetHash(password), age));
 }