示例#1
0
 //methods for getting score
 private string GetScoreOutputText(int score, int bonus, ShScoringMethod method)
 {
     if (method == ShScoringMethod.Manual)
     {
         return(bonus.ToString());
     }
     else
     {
         return(score.ToString() + " " + GetBonusOutputText(bonus, method));
     }
 }
示例#2
0
 public static bool IsScoreDescending(ShScoringMethod method)
 {
     if (method == ShScoringMethod.Peehs1 || method == ShScoringMethod.Peehs2)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
示例#3
0
 public static string GetCorrectText(ShScoringMethod method, bool correct)
 {
     if (method == ShScoringMethod.Sheep || method == ShScoringMethod.Heep ||
         method == ShScoringMethod.Manual)
     {
         return(correct ? "Valid" : "Invalid");
     }
     else
     {
         return(correct ? "Correct" : "Incorrect");
     }
 }
示例#4
0
        private string GetBonusOutputText(int bonus, ShScoringMethod method)
        {
            if (bonus == 0)
            {
                return("");
            }

            string bonuscolor = "Blue";

            if ((bonus < 0) ^ (method == ShScoringMethod.Peehs2 ||
                               method == ShScoringMethod.Peehs1))
            {
                bonuscolor = "Red";
            }

            return("[COLOR=\"" + bonuscolor + "\"](" + (bonus > 0 ? "+" : "") + bonus + ")[/COLOR]");
        }
示例#5
0
        //change scoring method and set checkmarks in menu
        private void SetScoringMethod(ShScoringMethod method)
        {
            curScoreMethod = method;
            if (sg != null)
            {
                sg.Method = method;
            }

            sheepToolStripMenuItem1.Checked         = false;
            scoringMethod1ToolStripMenuItem.Checked = false;
            scoringMethod2ToolStripMenuItem.Checked = false;
            heepToolStripMenuItem.Checked           = false;
            manualToolStripMenuItem.Checked         = false;
            kangarooToolStripMenuItem.Checked       = false;

            if (method == ShScoringMethod.Sheep)
            {
                sheepToolStripMenuItem1.Checked = true;
            }
            if (method == ShScoringMethod.Peehs1)
            {
                scoringMethod1ToolStripMenuItem.Checked = true;
            }
            if (method == ShScoringMethod.Peehs2)
            {
                scoringMethod2ToolStripMenuItem.Checked = true;
            }
            if (method == ShScoringMethod.Heep)
            {
                heepToolStripMenuItem.Checked = true;
            }
            if (method == ShScoringMethod.Kangaroo)
            {
                kangarooToolStripMenuItem.Checked = true;
            }
            if (method == ShScoringMethod.Manual)
            {
                manualToolStripMenuItem.Checked = true;
            }

            sheep_modified = true;
            SetTextForAllTreenodes();
        }
示例#6
0
        //read data from xmlreader
        public void ReadFromXML(XmlReader xr)
        {
            Questions.Clear();
            Players.Clear();
            Method = ShScoringMethod.Sheep;

            #region xrread

            while (xr.Read())
            {
                if (xr.IsStartElement())
                {
                    switch (xr.Name)
                    {
                    case "ScoringMethod":
                        Method = (ShScoringMethod)Enum.Parse(typeof(ShScoringMethod),
                                                             xr.ReadElementString());
                        break;

                    case "Question":
                        int qindex = Convert.ToInt32(xr["GameIndex"]);
                        while (Questions.Count < qindex + 1)
                        {
                            Questions.Add(new ShQuestion(this, "(blank)"));
                        }
                        Questions[qindex].Text = xr.ReadElementString();
                        break;

                    case "Player":
                        int pindex = Convert.ToInt32(xr["GameIndex"]);
                        while (Players.Count < pindex + 1)
                        {
                            Players.Add(new ShPlayer(this, "(blank)"));
                        }
                        Players[pindex].Name = xr.ReadElementString();
                        break;

                    case "Group":
                        //assuming that question and player have already been
                        //completely read in as they should be at the start
                        //of the xml file
                        int     group_q_index  = Convert.ToInt32(xr["QuestionIndex"]);
                        bool    tempcorrect    = Convert.ToBoolean(xr["Correct"]);
                        int     tempgroupbonus = Convert.ToInt32(xr["GroupBonus"]);
                        ShGroup newGroup       = new ShGroup(this.Questions[group_q_index], "");
                        Questions[group_q_index].Groups.Add(newGroup);

                        XmlReader subxr = xr.ReadSubtree();

                        while (subxr.Read())
                        {
                            if (subxr.IsStartElement())
                            {
                                switch (subxr.Name)
                                {
                                case "Text":
                                    newGroup.Text = subxr.ReadElementString();
                                    break;

                                case "Answer":
                                    int      ans_p_index  = Convert.ToInt32(subxr["PlayerIndex"]);
                                    int      tempansbonus = Convert.ToInt32(subxr["AnswerBonus"]);
                                    string   anstext      = xr.ReadElementString();
                                    ShAnswer newAns       = new ShAnswer(newGroup,
                                                                         Players[ans_p_index], anstext);
                                    newGroup.Answers.Add(newAns);
                                    Players[ans_p_index].Answers.Add(newAns);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }
            #endregion
        }
示例#7
0
 //constructort 1
 public ShGame()
 {
     Questions = new List <ShQuestion>();
     Players   = new List <ShPlayer>();
     Method    = ShScoringMethod.Sheep;
 }