Example #1
0
File: Game.cs Project: jonasvdd/T2R
        /******************************
         * Initializing
         *******************************/

        private static void initializeComponents()
        {
            string textFilePath = Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory())) + @"\Data\DataEncr.txt";

            //http://stackoverflow.com/questions/14549766/how-to-get-my-project-path
            ExtensionMethods.niceLayout("INITIALIZING ELEMENTS");
            InitializeObjects.readDataFromTextFile(textFilePath, '\t', citylist, LongDestDeck, NormDestDeck, tracks);
            InitializeObjects.addTrainCards(trainCardDeck);
            foreach (City stad in citylist)
            {
                Program.logboek.WriteLine(stad.ToString());
                ExtensionMethods.niceLayout("");
            }

            ExtensionMethods.niceLayout("Start Game");
            Program.logboek.WriteLine("SHUFFLING CARDS");
            CardMethods <LongDestCard> .shuffle(LongDestDeck);

            Program.logboek.WriteLine("\tlong destination cards shuffled");
            CardMethods <NormDestCard> .shuffle(NormDestDeck);

            Program.logboek.WriteLine("\tnormal destination cards shuffled");
            CardMethods <TrainCard> .shuffle(trainCardDeck);

            Program.logboek.WriteLine("\ttraincards shuffled");
        }
Example #2
0
File: Game.cs Project: jonasvdd/T2R
        private void initializePlayers(List <foto> pics)
        {
            ExtensionMethods.niceLayout("initialziing players");
            Program.logboek.WriteLine("asking input from playerform");
            FormDataObject      data = new FormDataObject();
            AmountofPlayersForm form = new AmountofPlayersForm(pics, data);

            /******************************
             * Ask user here how many and if he wants to play with intelligent bots bl
             *******************************/

            form.ShowDialog();
            int realplayers = data.getReal();
            int coOps       = data.getCoOps();

            Program.logboek.WriteLine("real players:\t" + realplayers);
            Program.logboek.WriteLine("Robots:\t" + coOps);

            ExtensionMethods.niceLayout("Adding Players and deviding the cards");
            InitializeObjects.addPlayers(players, pics, realplayers, coOps, citylist, tracks);
            CardMethods <AbstrDestCard> .devideCards(players, LongDestDeck, NormDestDeck, trainCardDeck);

            foreach (Player player in players)
            {
                Program.logboek.WriteLine(player.ToString());
            }

            ExtensionMethods.niceLayout("remaining cards");
            Program.logboek.WriteLine(trainCardDeck.ToArray().Length + " traincards");
            Program.logboek.WriteLine(NormDestDeck.ToArray().Length + " normdestcards");
            Program.logboek.WriteLine(LongDestDeck.ToArray().Length + " longdestcards");
        }
Example #3
0
        public LoginViewModel()
        {
            LockedVisibility        = "Visible";
            UnLockedVisibility      = "Collapsed";
            ServerUpdatesVisibility = "Collapsed";

            CleanUp();
            Singleton.Agency = new LocalAgencyService(true).GetLocalAgency();
            InitializeObjects.InitializeWebSecurity();

            _unitOfWork = new UnitOfWork(DbContextUtil.GetDbContextInstance());
            var currentSetting = XmlSerializerCustom.GetUserSetting();

            User = new UserDTO
            {
                UserName = currentSetting.UserName,
                //Password = Properties.Settings.Default.Password
            };
        }
        private void DirectLogin()
        {
            try
            {
                InitializeObjects.InitializeWebSecurity();

                var currentSetting = XmlSerializerCustom.GetUserSetting();
                var userDTO        = new UserDTO
                {
                    UserName = currentSetting.UserName,
                    Password = currentSetting.Password
                };

                var userExists = false;

                if (!string.IsNullOrEmpty(userDTO.UserName) && !string.IsNullOrEmpty(userDTO.Password))
                {
                    userExists = Membership.ValidateUser(userDTO.UserName, userDTO.Password);
                }

                if (!userExists)
                {
                    new Login().Show();
                }
                else
                {
                    Singleton.Agency = new LocalAgencyService(true).GetLocalAgency();
                    int     userId = WebSecurity.GetUserId(userDTO.UserName);
                    UserDTO user   = new UserService(true).GetUser(userId);

                    if (user == null)
                    {
                        MessageBox.Show("Incorrect UserName/Password", "Error Logging",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                        userDTO.Password = "";
                    }
                    else
                    {
                        Singleton.User          = user;
                        Singleton.User.Password = userDTO.Password;
                        Singleton.UserRoles     = new UserRolesModel();

                        Singleton.Setting = new UnitOfWork(DbContextUtil.GetDbContextInstance())
                                            .Repository <SettingDTO>()
                                            .FindById(1);


                        switch (user.Status)
                        {
                        case UserTypes.Waiting:
                            new ChangePassword(userDTO.Password).Show();
                            break;

                        case UserTypes.Active:
                        {
                            NotifyUtility.ShowCustomBalloon("PinnaFace", "Welcome to PinnaFace", 4000);
                            new MainWindow().Show();
                        }
                        break;

                        default:
                            MessageBox.Show("Login Failed", "Error Logging", MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                            break;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + Environment.NewLine + exception.InnerException);
            }
        }