Пример #1
0
        public static bool LoginCheck( Client cl )
        {
            using (var regcontext = new Db1Entities())
            {
                var query = from c in regcontext.Registration where c.Username == cl.UserName && c.Password == cl.EncPassword select c;
                try
                {
                    var firstOrDefault = query.FirstOrDefault();
                    var userId = firstOrDefault?.Id;

                    return userId > 0;
                }
                catch (Exception)
                {
                    // ignored
                }
            }
            return false;
        }
Пример #2
0
        public bool RegistrationCheck( Client c )
        {
            var vUserExists = UserExists(c.UserName);

            if (vUserExists)
            {
                return false;
            }
            using (var context = new Db1Entities())
            {
                var newReg = new Registration
                {
                    Username = c.UserName,
                    EMail = c.EMail,
                    Password = c.EncPassword
                };
                context.Registration.Add(newReg);
                context.SaveChanges();
            }
            return true;
        }
Пример #3
0
 public static Character GetBlankCharacter( Client client )
 {
     var c = new Character
     {
         Age = 18,
         Name = "",
         Strenght = 10,
         Intelligence = 10,
         Dexterity = 10,
         Health = 10
     };
     if (c.Strenght != null)
     {
         c.BasicLift = CalcBasicLift((int) c.Strenght);
         c.HitPoints = CalcHp((int) c.Strenght);
     }
     if (c.Intelligence != null)
     {
         c.WillPower = CalcWillPower((int) c.Intelligence);
         c.Perception = CalcPerception((int) c.Intelligence);
     }
     if (c.Health != null)
     {
         c.FatiguePoints = CalcBaseFatiguePoints((int) c.Health);
         if (c.Dexterity != null)
         {
             c.BasicSpeed = CalcBasicSpeed((int) c.Health, (int) c.Dexterity);
         }
     }
     if (c.BasicSpeed != null)
     {
         c.BasicMove = CalcBasicMove((double) c.BasicSpeed);
     }
     c.PlayerName = client.UserName;
     c.PointTotal = 100;
     var context = new Db1Entities();
     c.PlayerId = ( from cn in context.Registration where cn.Username == client.UserName select cn.Id ).FirstOrDefault();
     return c;
 }
Пример #4
0
 //Test
 public void MenuItemClick( object sender, RoutedEventArgs e )
 {
     var selectedItem = LbUserOnline.SelectedItem as ListBoxItem;
     if (selectedItem == null)
     {
         return;
     }
     var kickclient = new Client
     {
         UserName = selectedItem.Content.ToString()
     };
     SwnService.CurrentService.KickSelectedUser(kickclient);
 }