示例#1
0
 public string GetPhrase(string key)
 {
     if (Phrases.ContainsKey(key))
     {
         return(Phrases[key]);
     }
     return(string.Format("Phrase '{0}' is not defined", key));
 }
示例#2
0
        public string GetStatus(int proTotal, int conTotal)
        {
            float votes      = proTotal + conTotal;
            float proPercent = (float)proTotal / votes;

            short margin = 0;

            if (proPercent >= 0 && proPercent < .25)
            {
                margin = 3;
            }
            else if (proPercent >= .25 && proPercent < .4)
            {
                margin = 2;
            }
            else if (proPercent >= .4 && proPercent < .5)
            {
                margin = 1;
            }
            else if (proPercent == .5)
            {
                margin = 0;
            }
            else if (proPercent > .5 && proPercent < .61)
            {
                margin = -1;
            }
            else if (proPercent >= .61 && proPercent < .76)
            {
                margin = -2;
            }
            else if (proPercent >= .76)
            {
                margin = -3;
            }

            if (proTotal == conTotal && !Phrases.ContainsKey(0))
            {
                return("We have a tie (until someone votes)");
            }
            else
            {
                if (this.IsProCon)
                {
                    if (PhraseIs)
                    {
                        return(string.Format("{0} is {1}",
                                             (this.Name == string.Empty) ? "[No Name Yet]" : this.Name.TrimEnd(new char[2] {
                            '?', '!'
                        }), this.Phrases[margin]));
                    }
                    else
                    {
                        return(this.Phrases[margin]);
                    }
                }
                else
                {
                    short absMargin = Math.Abs(margin);
                    if (PhraseIs)
                    {
                        return(((proTotal > conTotal) ? this.ProName : this.ConName) +
                               " is " + this.Phrases[absMargin]);
                    }
                    else
                    {
                        return(((proTotal > conTotal) ? this.ProName : this.ConName) +
                               " is " + this.Phrases[absMargin] + " " +
                               ((proTotal < conTotal) ? this.ProName : this.ConName));
                    }
                }
            }
        }