示例#1
0
        public void ToString_Box_Task()
        {
            VoteLine vote = new VoteLine("", "☒", "Hat", "A basic vote line", MarkerType.Vote, 100);

            Assert.AreEqual("[☒][Hat] A basic vote line", vote.ToString());
        }
示例#2
0
        public void ToComparableString_Basic()
        {
            VoteLine vote = new VoteLine("", "X", "", "A basic vote line", MarkerType.Vote, 100);

            Assert.AreEqual("[] A basic vote line", vote.ToComparableString());
        }
示例#3
0
        public void ToString_Rank_Task()
        {
            VoteLine vote = new VoteLine("", "#2", "Color", "A basic vote line", MarkerType.Rank, 2);

            Assert.AreEqual("[#2][Color] A basic vote line", vote.ToString());
        }
示例#4
0
        public void ToString_Score_Task()
        {
            VoteLine vote = new VoteLine("", "77%", "Cape", "A basic vote line", MarkerType.Score, 77);

            Assert.AreEqual("[77%][Cape] A basic vote line", vote.ToString());
        }
示例#5
0
        public void ToString_Basic_Marker_Task()
        {
            VoteLine vote = new VoteLine("", "x", "Orb-us", "A basic vote line", MarkerType.Vote, 100);

            Assert.AreEqual("[x][Orb-us] A basic vote line", vote.ToString());
        }
示例#6
0
        public void ToString_Basic_Prefix_Task()
        {
            VoteLine vote = new VoteLine("-", "X", "Orbus?", "A basic vote line", MarkerType.Vote, 100);

            Assert.AreEqual("-[X][Orbus?] A basic vote line", vote.ToString());
        }
示例#7
0
        public void Construct_Empty()
        {
            VoteLine vote = new VoteLine("", "", "", "", MarkerType.None, 0);

            Assert.AreEqual(VoteLine.Empty, vote);
        }
        public void addPlayers()
        {
            this.wallScrollArea.clearControls();
            int y = 0;

            this.lineList.Clear();
            int yourVotes = 0;

            if (this.provinceMembers != null)
            {
                foreach (ParishMember member in this.provinceMembers)
                {
                    if (member.userID == RemoteServices.Instance.UserID)
                    {
                        yourVotes = member.numSpareVotes;
                        break;
                    }
                }
                this.provinceMembers.Sort(this.parishMemberComparer);
                int position = 0;
                foreach (ParishMember member2 in this.provinceMembers)
                {
                    VoteLine control = new VoteLine();
                    if (y != 0)
                    {
                        y += 5;
                    }
                    control.Position = new Point(0, y);
                    int numVotesReceived = member2.numVotesReceived;
                    if (numVotesReceived > this.voteCap)
                    {
                        numVotesReceived = this.voteCap;
                    }
                    control.init(member2.userName, member2.userID, member2.rank, member2.points, this.votingAllowed, member2.numSpareVotes, numVotesReceived, member2.areaID, member2.factionID, yourVotes, position, this);
                    this.wallScrollArea.addControl(control);
                    y += control.Height;
                    this.lineList.Add(control);
                    position++;
                }
            }
            this.wallScrollArea.Size = new Size(this.wallScrollArea.Width, y);
            if (y < this.wallScrollBar.Height)
            {
                this.wallScrollBar.Visible = false;
            }
            else
            {
                this.wallScrollBar.Visible         = true;
                this.wallScrollBar.NumVisibleLines = this.wallScrollBar.Height;
                this.wallScrollBar.Max             = y - this.wallScrollBar.Height;
            }
            this.wallScrollArea.invalidate();
            this.wallScrollBar.invalidate();
            this.stewardLabel.Text = SK.Text("ParishWallPanel_Governor", "Governor") + " : " + this.currentLeaderName;
            this.m_userIDOnCurrent = this.currentLeaderID;
            TimeSpan span = (TimeSpan)(VillageMap.getCurrentServerTime() - this.lastProclamationTime);

            if (this.currentLeaderID == RemoteServices.Instance.UserID)
            {
                this.proclamationButton.Visible = true;
                if (span.TotalDays >= 3.0)
                {
                    this.proclamationButton.Enabled = true;
                    this.proclamationLabel.Visible  = false;
                }
                else
                {
                    this.proclamationButton.Enabled = false;
                    this.proclamationLabel.Visible  = true;
                }
            }
            else
            {
                this.proclamationButton.Visible = false;
                this.proclamationLabel.Visible  = false;
            }
            this.update();
        }
示例#9
0
        public void Time_VoteLine_Parsing_and_Construction()
        {
            using (var rp = new RegionProfiler("Warm up"))
            {
            }

            string   input1, input2, input3, input4;
            string?  line1, line2, line3, line4;
            string?  prefix, marker, task, content;
            VoteLine?vote1, vote2, vote3, vote4;
            object   o1, o2, o3, o4;

            input1 = "It depends, but the general trend is that it's easier once you've done it once. So, one day you're at 5 San and you killed a Witch by binding it's existence to a giant, abstract clock made of your own crystallized blood, dooming it to die when it strikes twelve.";
            input2 = "[X][Other] Ask about the time you \"met\" before. Make sure she remembers it.";
            input3 = "[X] Ask about the time you \"met\" before. Make sure she remembers it.";
            input4 = "[x][To Do?] 『b』A 『url='http://example.com/image.jpg'』normal『/url』 day at the beach.『/b』";

            using (var rp = new RegionProfiler("Baseline with empty vote lines"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    o1 = VoteLine.Empty;
                    o2 = VoteLine.Empty;
                    o3 = VoteLine.Empty;
                    o4 = VoteLine.Empty;
                }
            }

            using (var rp = new RegionProfiler("Time constructing vote lines"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    vote1 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                    vote2 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                    vote3 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                    vote4 = new VoteLine("", "X", "", "Ask about the time you \"met\" before. Make sure she remembers it.", MarkerType.Vote, 100);
                }
            }

            using (var rp = new RegionProfiler("Time parsing lines"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    vote1 = VoteLineParser.ParseLine(input1);
                    vote2 = VoteLineParser.ParseLine(input2);
                    vote3 = VoteLineParser.ParseLine(input3);
                    vote4 = VoteLineParser.ParseLine(input4);
                }
            }

            using (var rp = new RegionProfiler("Time parsing strings"))
            {
                for (int i = 0; i < 2500; i++)
                {
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input1)).Success)
                    {
                        line1 = VoteString.CleanVoteLineBBCode(input1);
                        VoteString.GetVoteComponents(line1, out prefix, out marker, out task, out content);
                    }
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input2)).Success)
                    {
                        line2 = VoteString.CleanVoteLineBBCode(input2);
                        VoteString.GetVoteComponents(line2, out prefix, out marker, out task, out content);
                    }
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input3)).Success)
                    {
                        line3 = VoteString.CleanVoteLineBBCode(input3);
                        VoteString.GetVoteComponents(line3, out prefix, out marker, out task, out content);
                    }
                    if (voteLineRegex.Match(VoteString.RemoveBBCode(input4)).Success)
                    {
                        line4 = VoteString.CleanVoteLineBBCode(input4);
                        VoteString.GetVoteComponents(line4, out prefix, out marker, out task, out content);
                    }
                }
            }

            using (var rp = new RegionProfiler("Comparing parsed lines"))
            {
                vote1 = VoteLineParser.ParseLine(input1);
                vote2 = VoteLineParser.ParseLine(input2);
                vote3 = VoteLineParser.ParseLine(input3);
                vote4 = VoteLineParser.ParseLine(input4);

                for (int i = 0; i < 2500; i++)
                {
                    if (vote1 == vote4 || vote2 == vote3)
                    {
                        o1 = new object();
                    }
                }
            }

            using (var rp = new RegionProfiler("Comparing parsed lines"))
            {
                if (voteLineRegex.Match(VoteString.RemoveBBCode(input1)).Success)
                {
                    line1 = VoteString.CleanVoteLineBBCode(input1);
                }
                else
                {
                    line1 = null;
                }

                if (voteLineRegex.Match(VoteString.RemoveBBCode(input2)).Success)
                {
                    line2 = VoteString.CleanVoteLineBBCode(input2);
                }
                else
                {
                    line2 = null;
                }

                if (voteLineRegex.Match(VoteString.RemoveBBCode(input3)).Success)
                {
                    line3 = VoteString.CleanVoteLineBBCode(input3);
                }
                else
                {
                    line3 = null;
                }

                if (voteLineRegex.Match(VoteString.RemoveBBCode(input4)).Success)
                {
                    line4 = VoteString.CleanVoteLineBBCode(input4);
                }
                else
                {
                    line4 = null;
                }

                for (int i = 0; i < 2500; i++)
                {
                    if (
                        //Agnostic.StringComparer.Equals(VoteString.GetVoteContent(line1), VoteString.GetVoteContent(line2)) ||
                        Agnostic.StringComparer.Equals(VoteString.GetVoteContent(line3 !), VoteString.GetVoteContent(line4 !))
                        )
                    {
                        o1 = new object();
                    }
                }
            }


            VoteLine vote = new VoteLine("", "", "", "", MarkerType.None, 0);

            Assert.AreEqual(VoteLine.Empty, vote);
        }