Beispiel #1
0
        public bool GameSetup()
        {
            do
            {
                if (this.User == null || this.User.Pseudo == null || this.User.Pseudo == "")
                    this.User = Bl.BlDisplay.SelectUser();

                //if (this.Setup == null || this.Setup.MaxTry == 0)
                //{
                    try
                    {
                        Setup = Bl.BlSetup.GetSetupByStatus((int)ESetup.Active)[0];
                    }
                    catch (ApplicationException e)
                    {
                        Bl.BlDisplay.displayMessage(e.Message);
                        Bl.BlDisplay.setupMaxTry();
                        Setup = Bl.BlSetup.GetSetupByStatus((int)ESetup.Active)[0];
                    }
                //}

            } while (!SettingCheck() );

            return true;
        }
Beispiel #2
0
        public Play(IActionManager bl, ISetting setting, Random rd)
        {
            this.rd = rd;
            Bl = bl;
            Setting = setting;
            NewWord = new Words();
            User = new User();
            Setup = new Setup();

            setting.init( User, Setup, rd);
        }
Beispiel #3
0
        public Statistic getOneUserStatistics(int userId)
        {
            Statistic stat;
            Words word;
            Setup setup;
            User user;
            List<Statistic> statsList = new List<Statistic>();

            var stats = tabadapStat.GetStatisticByUserId(userId);
            stat = new Statistic();
            for (int i = 0; i < stats.Count(); i++)
            {
                word = new Words();
                setup = new Setup();
                user = new User();

                stat.WordList = new List<Words>();
                stat.UserList = new List<User>();
                stat.SetupList = new List<Setup>();
                for (int j = 0; j < stats.Rows[i].ItemArray.Count(); j++)
                {
                    user.Id = (int)stats.Rows[i].ItemArray[5];
                    user.Pseudo = (string)stats.Rows[i].ItemArray[6];

                    word.Id = (int)stats.Rows[i].ItemArray[7];
                    word.Name = (string)stats.Rows[i].ItemArray[8];

                    setup.Id = (int)stats.Rows[i].ItemArray[9];
                    setup.MaxTry = (int)stats.Rows[i].ItemArray[10];

                    /*stat.id = (int)stats.Rows[i].ItemArray[1];
                    stat.UserId = (int)stats.Rows[i].ItemArray[2];
                    stat.WordId = (int)stats.Rows[i].ItemArray[3];
                    stat.SetupId = (int)stats.Rows[i].ItemArray[4];
                    stat.NbTry = (int)stats.Rows[i].ItemArray[5];*/

                    stat.WordList.Add(word);
                    stat.SetupList.Add(setup);
                    stat.UserList.Add(user);
                }

            }

            return stat;
        }
Beispiel #4
0
 public User DeleteUser(User user)
 {
     throw new NotImplementedException();
 }
Beispiel #5
0
        private List<User> GetListUsersFromTableAdapter(HiddenWordDAL.DataModel.DsHiddenWord.usersDataTable source)
        {
            List<User> listUsers = new List<User>();
            User user;
            foreach (var row in source)
            {
                user = new User();
                user.Id = row.id;
                user.Pseudo = row.Pseudo;
                listUsers.Add(user);
            }

            return listUsers;
        }
Beispiel #6
0
        private User getUser(User user)
        {
            var checkUserRegistered = BlUser.GetUserByPseudo(user.Pseudo);
            if ( !user.Pseudo.Equals("") && checkUserRegistered.Pseudo == null)
            {
                BlUser.InsertUser(user.Pseudo);
                checkUserRegistered = BlUser.GetUserByPseudo(user.Pseudo);
            }

            checkUserRegistered.UserStats = BlStat.GetStatisticByUserId(checkUserRegistered.Id);

            foreach (var stat in checkUserRegistered.UserStats)
            {
                checkUserRegistered.UserWordsStats.Add(BlWord.GetWordsById(stat.WordId));
                checkUserRegistered.UserSetupsStats.Add(BlSetup.GetSetupById(stat.SetupId));
            }

            return checkUserRegistered;
        }
Beispiel #7
0
 public EndGame(IActionManager bl, User user, Words word, int nbTry, Setup setup)
 {
     this.Bl = bl;
     Bl.BlDisplay.endGame(word.Name);
     save(user, word, nbTry, setup);
 }
Beispiel #8
0
 public User DeleteUser(User user)
 {
     return DALAccess.DeleteUser(user);
 }
Beispiel #9
0
        public User SelectUser()
        {
            string response = "";

            this.displayEmptyLine();
            this.displayTabulation(2);
            displayMessage("\n....... USER SELECTION ......\n");
            this.displayEmptyLine();
            do
            {
                this.displayTabulation(1);
                response = readResponse("Do you have a pseudo already register? (y/n): ");
                this.displayEmptyLine();
            } while (response != "y" && response != "n");

            if (response.Equals("y"))
            {
                response = readResponse("\tPlease enter your pseudo: ");
                this.displayEmptyLine();
            }
            else
            {
                this.displayTabulation(2);
                displayMessage("....... SETTING NEW USER ......",nbEmptyLineAfter:1);
                //bool next = false;
                do
                {
                    response = readResponse("\tPlease enter your pseudo: ");
                    this.displayEmptyLine();
                } while ( response == "" );
            }
            this.displayEmptyLine();
            User user = new User();
            user.Pseudo = response;
            return user;
        }
Beispiel #10
0
        public User UpdateUser(User user)
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            param["ID"] = user.Id.ToString();
            param["pseudo"] = user.Pseudo.ToString();

            return genericMethode.updateXmlData<User>("XUsers", param);
        }
Beispiel #11
0
        public User InsertUser(string pseudo)
        {
            XUsers user = new XUsers();
            user.ID = genericMethode.autoIncrementXmlDataPrimaryKey("XUsers", "ID");
            user.pseudo = pseudo;

            HiddenWord hiddenWord = new HiddenWord();
            hiddenWord.Item = user;

            List<XUsers> paramList = new List<XUsers>();
            paramList.Add(genericMethode.saveXmlData<XUsers>(hiddenWord, "XUsers", user.ID.ToString()));

            List<User> usersList = bindXmlDataToUser(paramList);
            User result = new User();
            if (usersList.Count != 0)
            {
                result = usersList[0];
            }
            return result;
        }
Beispiel #12
0
        public User GetUserByPseudo(string pseudo)
        {
            List<XUsers> paramList = new List<XUsers>();
            paramList.Add(genericMethode.getXmlDataByValue<XUsers>("XUsers", pseudo));

            List<User> usersList = bindXmlDataToUser(paramList);
            User result = new User();
            if ( usersList.Count != 0 )
            {
                result = usersList[0];
            }
            return result;
        }
Beispiel #13
0
        //---------------[ The User implementation ] --------------------
        public User GetUserById(int id)
        {
            List<XUsers> paramList = new List<XUsers>();
            paramList.Add(genericMethode.getXmlDataByAttribute<XUsers>("XUsers", "ID", id.ToString()));

            List<User> usersList = bindXmlDataToUser(paramList);
            User result = new User();
            if (usersList.Count != 0)
            {
                result = usersList[0];
            }
            return result;
        }
Beispiel #14
0
 public void init(User user, Setup setup, Random rd)
 {
     User = user;
     Setup = setup;
 }
Beispiel #15
0
 /*-------------------[ Display User Statistics ]--------------*/
 public void DisplayStatisticByUser(User user)
 {
     Display.DisplayStatisticByUser(user);
 }
Beispiel #16
0
        private User GetOneUserFromTableAdapter(HiddenWordDAL.DataModel.DsHiddenWord.usersDataTable source)
        {
            User user = new User();

            foreach (var row in source)
            {
                user.Pseudo = row.Pseudo;
                user.Id = row.id;
                break;
            }
            return user;
        }
Beispiel #17
0
 private List<User> bindXmlDataToUser(List<XUsers> resultList)
 {
     List<User> userFound = new List<User>();
     foreach (XUsers result in resultList)
     {
         User userTemp = new User();
         userTemp.Id = result.ID;
         userTemp.Pseudo = (string)result.pseudo;
         userFound.Add(userTemp);
     }
     return userFound;
 }
Beispiel #18
0
 public User DeleteUser(User user)
 {
     return genericMethode.deleteXmlData<User>("XUsers", user.Id.ToString());
 }
Beispiel #19
0
 public void DisplayStatisticByUser(User user)
 {
     throw new NotImplementedException();
 }
Beispiel #20
0
 public void DisplayStatisticByUser(User user)
 {
     MyChart.Title = "Statistics of "+user.Pseudo;
     KeyValuePair<string, int>[] keyValuePair = new KeyValuePair<string, int>[user.UserStats.Count()];
     for (int i=0; i< user.UserStats.Count; i++)
     {
         keyValuePair[i] = new KeyValuePair<string, int>(user.UserWordsStats[i].Name, user.UserStats[i].NbTry);
     }
     ((AreaSeries)MyChart.Series[0]).ItemsSource = keyValuePair;
 }
Beispiel #21
0
 public User UpdateUser(User user)
 {
     return DALAccess.UpdateUser(user);
 }
Beispiel #22
0
 public User SelectUser()
 {
     User user = new User();
     user.Pseudo = read("Please enter your pseudo ");
     return user;
 }
Beispiel #23
0
 public void save(User user, Words word, int nbTry, Setup setup)
 {
     Bl.BlStat.insertStatistic(user.Id, word.Id, nbTry, setup.Id);
 }
Beispiel #24
0
        public bool SetGame()
        {
            string response = "";
            do
            {
                if (isSetting)
                    response = Bl.BlDisplay.setupMenu(); // SETTING MENU
                if (response.Equals(ESetupMenu.Exit))
                    return false;
                if (response.Equals(ESetupMenu.ChoiceOne))
                {
                    if (isSetting)
                    {
                        Bl.BlDisplay.setupNewWord();
                    }
                }
                if (response.Equals(ESetupMenu.ChoiceTwo))
                {
                    if (isSetting || this.Setup.MaxTry == 0)
                    {
                        try
                        {
                            this.Setup = Bl.BlDisplay.setupMaxTry(); // MAX TRY SETTING
                        }
                        catch (ApplicationException e)
                        {
                            Bl.BlDisplay.displayMessage(e.Message);
                            this.Setup = Bl.BlDisplay.setupMaxTry(); // MAX TRY SETTING
                        }
                    }
                }

                if (this.User == null || this.User.Pseudo == null || this.User.Pseudo == "")
                    this.User = Bl.BlDisplay.SelectUser();

                if (this.Setup == null || this.Setup.MaxTry == 0)
                {
                    try
                    {
                        Setup = Bl.BlSetup.GetSetupByStatus((int)ESetup.Active)[0];
                    }
                    catch (ApplicationException e)
                    {
                        Bl.BlDisplay.displayMessage(e.Message);
                        Bl.BlDisplay.setupMaxTry();
                        Setup = Bl.BlSetup.GetSetupByStatus((int)ESetup.Active)[0];
                    }
                }
            } while (!SettingCheck());

            return true;
        }