Ejemplo n.º 1
0
        public string buildQuestionToFirstLevel()
        {
            Random rnd = new Random();
            //For mixing the choices between with skills and without.
            int chooseWithSkills = rnd.Next(100) % 10;

            if (chooseWithSkills < 4)
            {
                string skillParameter = "";
                if ((skillParameter = getSkill("song")) != null)
                {
                    this.songForQuiestion = db.GetSongByID(skillParameter);
                }
                else if (((skillParameter = getSkill("artist")) != null) && (songForQuiestion == null))
                {
                    this.songForQuiestion = db.GetRandomSongByArtistID(skillParameter);
                }
                else if (((skillParameter = getSkill("year")) != null) && (songForQuiestion == null))
                {
                    this.songForQuiestion = db.GetRandomSongByYear(skillParameter, false);
                }
                //If there is no skill - choose question by other random parameter
            }
            if (this.songForQuiestion == null)
            {
                do
                {
                    int chooseQuestionMethod = rnd.Next(1, 4); // creates a number between 1 and 3
                    switch (chooseQuestionMethod)
                    {
                    case 1:
                        this.songForQuiestion = this.db.GetSongOfArtistByPopularity(0.8, 1);
                        break;

                    case 2:
                        this.songForQuiestion = this.db.GetRandomTopSongSkillsSong();
                        break;

                    case 3:
                        this.songForQuiestion = this.db.GetRandomTopYearSkillsSong();
                        break;
                    }
                } while (this.songForQuiestion == null);
            }

            this.Question = this.Question.Replace("<artist_name>", this.songForQuiestion.Artist_name);
            this.Question = this.Question.Replace("<year>", this.songForQuiestion.Year.ToString());
            return(this.Question);
        }
Ejemplo n.º 2
0
 public string buildClue()
 {
     if (buildClueBySongsSkills() == true)
     {
         return(this.Clue);
     }
     //If there is no compatible clue,taking a song of popular artist that released at the same year and give it as clue.
     else
     {
         Song songForClue = null;
         songForClue = db.GetRandomSongByYear(this.albumForQuestion.Year.ToString(), true);
         if (songForClue != null)
         {
             this.Clue = this.Clue.Replace("<song_name>", songForClue.Song_name);
             this.Clue = this.Clue.Replace("<artist_name>", songForClue.Artist_name);
         }
         //TODO : Fix this problem!
         else
         {
             this.Clue = "PROBLEM WITH CLUE ABOUT SONG FROM" + albumForQuestion.Year.ToString();
         }
         return(this.Clue);
     }
 }