Example #1
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);
        }
Example #2
0
        public Words DeleteWord(Words word)
        {
            Words result = DALAccess.DeleteWord(word);

            // Throwing exception for null value
            exceptionGenerator.exceptionFor<Words>(
                "delete",
                new StringBuilder().AppendFormat("Error occured while deleting the word '{0}'", word.Name).ToString(),
                result,
                isExludeNullable: true);

            return result;
        }
Example #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;
        }
Example #4
0
 public void save(User user, Words word, int nbTry, Setup setup)
 {
     Bl.BlStat.insertStatistic(user.Id, word.Id, nbTry, setup.Id);
 }
Example #5
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);
 }
Example #6
0
        /*-------------------[ Setup New Word ]--------------*/
        public Words setupNewWord()
        {
            string response = "";
            displayMessage("\t\t....... SETUP NEW WORD ......");
            this.displayEmptyLine();
            do
            {
                response = readResponse("\tPlease enter a new word: ");
                this.displayEmptyLine();
            } while (response == "");

            this.displayEmptyLine();

            Words word = new Words();
            word.Name = response;
            return word;
        }
Example #7
0
 public Words DeleteWord(Words word)
 {
     throw new NotImplementedException();
 }
Example #8
0
        public Words GetWordsByName(string name)
        {
            var words = tabadapWord.GetWordByName(name);
            Words responseWord = new Words();

            foreach (var row in words)
            {
                responseWord.Id = row.id;
                responseWord.Name = row.Name;

                break;
            }

            return responseWord;
        }
Example #9
0
        public List<Words> GetWordsData()
        {
            var words = tabadapWord.GetWords();
            Words responseWord = new Words();
            List<Words> listWords = new List<Words>();
            Words word;
            foreach (var row in words)
            {
                word = new Words();
                word.Id = row.id;
                word.Name = row.Name;
                listWords.Add(word);
            }

            return listWords;
        }
Example #10
0
        //---------------[ The word implementation ] --------------------
        public Words GetWordsById(int id)
        {
            List<XWords> paramList = new List<XWords>();
            paramList.Add(genericMethode.getXmlDataByAttribute<XWords>("XWords", "ID", id.ToString()));

            List<Words> wordsList = bindXmlDataToWord(paramList);
            Words result = new Words();
            if (result != null)
            {
                result = wordsList[0];
            }
            return result;
        }
Example #11
0
        public List<Statistic> getUsersStatistics()
        {
            //var tabadap = new usersTableAdapter();
            //var tabadapStat = new statisticTableAdapter();
            var users = tabadapUser.GetUsers();
            Statistic stat;
            Words word;
            Setup setup;
            List<User> userList = new List<User>();
            List<Statistic> statsList = new List<Statistic>();

            foreach (var row in users)
            {
                var stats = tabadapStat.GetStatisticByUserId(row.id);
                stat = new Statistic();
                stat.User.Id = row.id;
                stat.User.Pseudo = row.Pseudo;

                foreach (var rowStat in stats)
                {
                    word = new Words();
                    setup = new Setup();

                    word.Id = rowStat.wordsRow.id;
                    word.Name = rowStat.wordsRow.Name;
                    setup.Id = rowStat.setupsRow.id;
                    setup.MaxTry = rowStat.setupsRow.MaxTry;
                    stat.WordList.Add(word);
                    stat.SetupList.Add(setup);

                }

                statsList.Add(stat);

            }

            return statsList;
        }
Example #12
0
 /*-------------------[ Setup New Word ]--------------*/
 public Words setupNewWord()
 {
     string response = inputPlayerBox.Text;
     Words word = new Words();
     word.Name = read("Please enter a new word: ");
     return word;
 }
Example #13
0
 /*public string[] keepCorrectCharacter()
 {
     for (int y = 0; y < IndexColumn; y++)
     {
         if ( TrackPosition[IndexCurrentLine -1][y] == EPosition.GoodPosition )
         {
             Game[IndexCurrentLine -1][y] = Word[y].ToString();
         }
         else
         {
             Game[IndexCurrentLine - 1][y] = "_";
         }
     }
     return Game[IndexCurrentLine -1];
 }*/
 private IEnumerable<string> getCharacter(Words word)
 {
     for (int i = 0; i < Word.Count(); i++)
     {
         yield return Game[IndexCurrentLine][i];
     }
 }
Example #14
0
 public Words DeleteWord(Words word)
 {
     return genericMethode.deleteXmlData<Words>("XWords", word.Id.ToString());
 }
Example #15
0
        private List<Words> bindXmlDataToWord(List<XWords> resultList)
        {
            List<Words> listWords = new List<Words>();
            foreach (XWords result in resultList)
            {
                Words wordTmp = new Words();
                wordTmp.Id = result.ID;
                wordTmp.Name = (string)result.name;
                listWords.Add(wordTmp);
            }

            return listWords;
        }
Example #16
0
        public Words UpdateWord(Words word)
        {
            Dictionary<string, string> param = new Dictionary<string, string>();
            param["ID"] = word.Id.ToString();
            param["name"] = word.Name.ToString();

            return genericMethode.updateXmlData<Words>("XWords", param);
        }
Example #17
0
        public Words InsertWord(string name)
        {
            XWords word = new XWords();
            word.ID = genericMethode.autoIncrementXmlDataPrimaryKey("XWords", "ID");
            word.name = name;

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

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

            List<Words> wordsList = bindXmlDataToWord(paramList);
            Words result = new Words();
            if ( wordsList.Count != 0 )
            {
                result = wordsList[0];
            }
            return result;
        }
Example #18
0
        public Words GetWordsByName(string name)
        {
            List<XWords> paramList = new List<XWords>();
            paramList.Add(genericMethode.getXmlDataByValue<XWords>("XWords", name));

            List<Words> wordsList = bindXmlDataToWord(paramList);
            Words result = new Words();
            if (wordsList.Count != 0)
            {
                result = wordsList[0];
            }
            return result;
        }