예제 #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;
        }
예제 #2
0
파일: Play.cs 프로젝트: bahilo/HiddenWord
        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);
        }
예제 #3
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
        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;
        }
예제 #4
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
 public User DeleteUser(User user)
 {
     throw new NotImplementedException();
 }
예제 #5
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
        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;
        }
예제 #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;
        }
예제 #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);
 }
예제 #8
0
 public User DeleteUser(User user)
 {
     return DALAccess.DeleteUser(user);
 }
예제 #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;
        }
예제 #10
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
        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);
        }
예제 #11
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
        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;
        }
예제 #12
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
        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;
        }
예제 #13
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
        //---------------[ 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;
        }
예제 #14
0
 public void init(User user, Setup setup, Random rd)
 {
     User = user;
     Setup = setup;
 }
예제 #15
0
 /*-------------------[ Display User Statistics ]--------------*/
 public void DisplayStatisticByUser(User user)
 {
     Display.DisplayStatisticByUser(user);
 }
예제 #16
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
        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;
        }
예제 #17
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
 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;
 }
예제 #18
0
파일: DAL.cs 프로젝트: bahilo/HiddenWord
 public User DeleteUser(User user)
 {
     return genericMethode.deleteXmlData<User>("XUsers", user.Id.ToString());
 }
예제 #19
0
 public void DisplayStatisticByUser(User user)
 {
     throw new NotImplementedException();
 }
예제 #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;
 }
예제 #21
0
 public User UpdateUser(User user)
 {
     return DALAccess.UpdateUser(user);
 }
예제 #22
0
 public User SelectUser()
 {
     User user = new User();
     user.Pseudo = read("Please enter your pseudo ");
     return user;
 }
예제 #23
0
 public void save(User user, Words word, int nbTry, Setup setup)
 {
     Bl.BlStat.insertStatistic(user.Id, word.Id, nbTry, setup.Id);
 }
예제 #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;
        }