Beispiel #1
0
        public VanillaWorld(int portNumber, int maxConnections)
        {
            DBC = new DBCLibrary();

            WorldDatabase     = new DatabaseUnitOfWork <WorldDatabase>();
            CharacterDatabase = new DatabaseUnitOfWork <CharacterDatabase>();

            Server = new WorldServer(this);

            Components.Add(new ActionButtonComponent(this));
            Components.Add(new AuthComponent(this));
            Components.Add(new CharacterComponent(this));
            Components.Add(new ChatMessageComponent(this));
            Components.Add(new WeatherComponent(this));
            Components.Add(new EntityComponent(this));
            Components.Add(new GameObjectComponent(this));
            Components.Add(new LoginComponent(this));
            Components.Add(new LogoutComponent(this));
            Components.Add(new MailComponent(this));
            Components.Add(new MiscComponent(this));
            Components.Add(new PlayerMovementComponent(this));
            Components.Add(new SpellComponent(this));

            ChatCommands = new ChatCommandParser();

            Server.Start(portNumber, maxConnections);

            var accountCreator = new AccountCreator();

            accountCreator.CreateAccount("andrew", "password");
            accountCreator.CreateAccount("lucas", "password");
        }
Beispiel #2
0
        public string Execute(IList <string> parameters)
        {
            var username  = parameters[0];
            var password  = parameters[1];
            var firstName = parameters[2];
            var lastName  = parameters[3];

            var newUser = new User();

            newUser.Username      = username;
            newUser.Password      = password;
            newUser.FirstName     = firstName;
            newUser.LastName      = lastName;
            newUser.Authorization = Authorization.NormalUser;
            var account = AccountCreator.CreateAccount(newUser);

            newUser.Account = account;

            this.dbContext.Users.Add(newUser);

            dbContext.SaveChanges();

            this.authProvider.CurrentUsername = newUser.Username;

            return($"{newUser.Username} has successfully registered! You are now logged in.\n100 have been added to your account.\n Type a command or 'help logged user' for help to see your options.");
        }
Beispiel #3
0
        /// <summary>
        /// Create new account.
        /// </summary>
        /// <param name="accountType">type of account</param>
        /// <param name="name">name of owner</param>
        /// <param name="surname">surname of owner</param>
        /// <param name="amount">start amount of money</param>
        public void CreateNewAccount(string accountType, string name, string surname, double amount = 0)
        {
            Account account = AccountCreator.CreateAccount(accountType, GenerateId.Generate(), name, surname, amount);

            AccountRepository.Create(account.ToDalAccount());
            UnitOfWork.Commit();
            CurrentAccount = account;
        }
Beispiel #4
0
        public void Test_CreateAccount(Type t, AccountCreator.AccountType type, string id, string name, string surname, double amout, int points)
        {
            Account account = AccountCreator.CreateAccount(type, id, name, surname, amout, points);

            Assert.That(account.GetType, Is.EqualTo(t));
            Assert.That(account.Name, Is.EqualTo(name));
            Assert.That(account.Id, Is.EqualTo(id));
            Assert.That(account.Surname, Is.EqualTo(surname));
            Assert.That(account.Amount, Is.EqualTo(amout));
            Assert.That(account.Points, Is.EqualTo(points));
        }
Beispiel #5
0
        private void CreateButton_OnClick(object sender, RoutedEventArgs e)
        {
            double weight = double.Parse(WeightTextBox.Text);
            double age    = double.Parse(AgeTextBox.Text);

            if (!AccountCreator.CreateAccount(NameTextBox.Text, UserNameTextBox.Text, "123456", weight, age))
            {
                DialogBox.Show("User Exists", "The user already exists", "Okay");
            }

            Utilities.LoginContentView.Header  = "login";
            Utilities.LoginContentView.Content = new LoginContent();
        }