Example #1
0
        public void ICanCreateAMatch()
        {
            var match = new Match(7, 501);

            Assert.AreEqual(7, match.BestOfLegs);
            Assert.AreEqual(501, match.LegStartScore);
        }
Example #2
0
        public override bool IsValid(Match match)
        {
            var nextDecision = match.PendingDecisions.First();

            return nextDecision.PlayerIndex == this._playerIndex
                && nextDecision.Type == DecisionType.ChooseMergeOrder;
        }
Example #3
0
        public override void Apply(Match match)
        {
            if (!this.IsValid(match))
            {
                return;
            }

            match.PendingDecisions.Dequeue();

            if (this._stocks.Count>0)
            {
                Console.WriteLine("   [{0}] Purchasing stock in: ",match.Players[this._playerIndex].Member.Name);

                foreach (var stock in _stocks)
                {
                    match.Players[_playerIndex].AddStock(stock.Key, stock.Value);

                    var price = Engine.GetStockPrice(stock.Key, match);
                    Console.WriteLine("      - {1}x {0} - spending {2:C}", stock.Key, stock.Value, stock.Value * price);
                    match.Players[_playerIndex].Money -= stock.Value * price;
                    match.AvailableStock[stock.Key] -= stock.Value;
                }
            }
            else
            {
                Console.WriteLine("   No active chains to purchase stock in");
            }
            if (match.PendingDecisions.Count == 0)
                match.CurrentPhase = MatchPhase.DrawingTile;
        }
Example #4
0
        /// <summary>
        /// Extracts the matches of this pattern from <paramref name="source" />.
        /// </summary>
        /// <param name="fileName">The name of the file associated with <paramref name="source" />.</param>
        /// <param name="source">The source string</param>
        /// <returns>
        /// A collection of found matches.
        /// </returns>
        public MatchCollection Extract(string fileName, string source)
        {
            MatchCollection resultMatches = new MatchCollection();
            LineCounter lineCounter = new LineCounter(source);

            RegexMatch regexMatch = scanner.Match(source);
            while (regexMatch.Success)
            {
                Match match = new Match();
                match["Path"] = Path.GetDirectoryName(fileName);
                match["File"] = Path.GetFileName(fileName);
                match["LineNumber"] = lineCounter.CountTo(regexMatch.Index).InvariantToString();
                foreach (string groupName in scanner.GetGroupNames())
                {
                    // ignore default-names like '0', '1' ... as produced
                    // by the Regex class
                    if (Char.IsLetter(groupName[0]) || (groupName[0] == '_'))
                    {
                        match[groupName] = ConcatenateCaptures(regexMatch.Groups[groupName]);
                    }
                }
                resultMatches.Add(match);
                regexMatch = regexMatch.NextMatch();
            }
            return resultMatches;
        }
 public override IEnumerable<Tuple<ShapeNode, ShapeNode>> Apply(Match<Word, ShapeNode> match, Word output)
 {
     FeatureStruct fs = _simpleCtxt.FeatureStruct.DeepClone();
     fs.ReplaceVariables(match.VariableBindings);
     ShapeNode newNode = output.Shape.Add(fs);
     return Tuple.Create((ShapeNode) null, newNode).ToEnumerable();
 }
        public void TranslationCandidatesDefaultValue_Match()
        {
            Match match;

            match = new Match();
            Assert.IsFalse(match.HasReferenceTranslation, "HasReferenceTranslation is incorrect.");
            Assert.IsNull(match.Id, "Id is incorrect.");
            Assert.IsNull(match.MatchQuality, "MatchQuality is incorrect.");
            Assert.IsNull(match.MatchSuitability, "MatchSuitability is incorrect.");
            Assert.IsNull(match.Metadata, "Metadata is incorrect.");
            Assert.IsNull(match.Origin, "Origin is incorrect.");
            Assert.IsNull(match.OriginalData, "OriginalData is incorrect.");
            Assert.IsNull(match.Similarity, "Similarity is incorrect.");
            Assert.IsNull(match.Source, "Source is incorrect.");
            Assert.IsNull(match.SourceReference, "SourceReference is incorrect.");
            Assert.IsNull(match.SubType, "SubType is incorrect.");
            Assert.IsNull(match.Target, "Target is incorrect.");
            Assert.AreEqual(MatchType.TranslationMemory, match.Type, "Type is incorrect.");

            match = new Match("sourcereference");
            Assert.IsFalse(match.HasReferenceTranslation, "HasReferenceTranslation is incorrect.");
            Assert.IsNull(match.Id, "Id is incorrect.");
            Assert.IsNull(match.MatchQuality, "MatchQuality is incorrect.");
            Assert.IsNull(match.MatchSuitability, "MatchSuitability is incorrect.");
            Assert.IsNull(match.Metadata, "Metadata is incorrect.");
            Assert.IsNull(match.Origin, "Origin is incorrect.");
            Assert.IsNull(match.OriginalData, "OriginalData is incorrect.");
            Assert.IsNull(match.Similarity, "Similarity is incorrect.");
            Assert.IsNull(match.Source, "Source is incorrect.");
            Assert.AreEqual("sourcereference", match.SourceReference, "SourceReference is incorrect.");
            Assert.IsNull(match.SubType, "SubType is incorrect.");
            Assert.IsNull(match.Target, "Target is incorrect.");
            Assert.AreEqual(MatchType.TranslationMemory, match.Type, "Type is incorrect.");
        }
Example #7
0
 public Goal(int id, int minutes, Match match, int idPlayer)
 {
     Id = id;
     Minutes = minutes;
     Match = match;
     Player = createPlayer(idPlayer);
 }
        public override int PointsEarned(MatchResult outcome, Match MatchOfWeek)
        {
            int Multiple = outcome.Match == MatchOfWeek ? 2 : 1;

            if (outcome.Winner != null && !outcome.Winner.Equals(Winner))
                return 0;

            //Is a stoppage!
            if (outcome.ResultType.HasRounds)
            {
                if (outcome.Round == Round)
                {
                    return ((3 + 5) * Multiple);
                }
                else if (outcome.Round <= Round + 1 && outcome.Round >= Round - 1)
                {
                    return ((3 + 3) * Multiple);
                }
                else if (outcome.Round <= Round + 2 && outcome.Round >= Round - 2)
                {
                    return ((3 + 1) * Multiple);
                }
                else
                {
                    return (3 * Multiple);
                }
            }

            return 0;
        }
 /// <summary>  
 /// 将Json序列化的时间由/Date(....)转为字符串
 /// </summary>
 private string ConvertJsonDateToDateString(Match m)
 {
     string result = string.Empty;
     DateTime dt = new DateTime(1970, 1, 1);
     dt = dt.AddMilliseconds(long.Parse(m.Groups[1].Value)).ToLocalTime();
     return dt.ToString(FormateStr);
 }
Example #10
0
        private static void ReplaceMatch(Match scMatch, int monitorHeight, string scConfigContent, string scFolderPath, string fileName)
        {
            if (scMatch.Success)
            {
                string fullString = scMatch.Captures[0].Value;

                string variablesName = scMatch.Groups[1].Captures[0].Value;
                string delimiter = scMatch.Groups[2].Captures[0].Value;
                string valueEnclosingCharacter = scMatch.Groups[3].Captures[0].Value;
                int configHeight = int.Parse(scMatch.Groups[4].Captures[0].Value);

                if (configHeight != monitorHeight)
                {
                    Console.WriteLine("Current Height: {0}", configHeight);
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("Changing to {0}", monitorHeight);
                    scConfigContent = scConfigContent.Replace(fullString, string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}{2}", variablesName, delimiter, valueEnclosingCharacter, monitorHeight));
                    Console.ForegroundColor = ConsoleColor.Green;
                    WriteAllText(scFolderPath, fileName, scConfigContent);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Everthing is already goooood to gooo!!!");
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Something bad happened to the config file... go check it!");
                Console.ReadLine();
            }
        }
Example #11
0
        /// <summary>
        ///   Clusters Two INodes together, sets new root/parent/left and right edges
        /// </summary>
        /// <param name="left"> Node on the left </param>
        /// <param name="right"> Node on the Right </param>
        /// <param name="match"> Inverted or Not Inverted </param>
        /// <param name="matchData"> Optional MatchData variable, store clustering information </param>
        public Cluster(INode left, INode right, Match match = Match.NonInverted, MatchData matchData = null)
        {
            if (match == Match.Impossible)
            {
                throw new ArgumentException("Match is apparently impossible why are you trying?");
            }

            // Now Build the new nodes
            _left = left;
            _right = right;
            _matchData = matchData;
            _size = left.Size() + right.Size();
            _leftedge = left.LeftEdge();
            _rightedge = right.RightEdge();

            // Set the parents accordingly
            left.Parent(this);
            right.Parent(this);
            _parent = null;

            // change the roots
            _left.Root(this);
            _right.Root(this);

            // Update Count
            Id = _count++;
        }
        public Match CreateMatch(DateTime matchDate, TimeSpan time, Venue venue, CompetitionMatchType matchType,
            Competition competition, Team homeTeam, Team awayTeam)
        {
            if (homeTeam.GetType() == awayTeam.GetType())
            {
                Match match = new Match();

                match.MatchDate = matchDate;
                match.MatchTime = time;
                match.Venue = venue;
                match.CompetitionMatchType = matchType;
                match.Competition = competition;
                match.HomeTeam = homeTeam;
                match.AwayTeam = awayTeam;

                context.Matches.Add(match);
                context.SaveChanges();

                return match;
            }
            else
            {
                return null;
            }
        }
        public MatchCollectionTest()
        {
            Match<char> match;

             try
             {
            match = new Match<char> ("0123456789".ToListCursor (), 0, 10, true);
             }
             catch (Exception e)
             {
            Assert.Inconclusive (e.ToString ());
            throw;
             }
             m_allDigitsMatch = match;

             try
             {
            match = new Match<char> ("0123456789".ToListCursor (), 0, 0, false);
             }
             catch (Exception e)
             {
            Assert.Inconclusive (e.ToString ());
            throw;
             }
             m_noDigitsMatch = match;
        }
Example #14
0
 public void ICannotAdd2PlayersToAMatchWithTheSameName()
 {
     var match = new Match(7, 501);
     var player = new Player("Andy");
     match.AddPlayer(player);
     match.AddPlayer(player);
 }
    public override void ProcessRequest(HttpContext context, Match match)
    {
        context.Response.Cache.SetCacheability(HttpCacheability.NoCache);

        try
        {
            PccConfig.LoadConfig("pcc.config");
            string searchTermsId = GetStringFromUrl(context, match, "SearchTermsId");
            // make sure target directory exists
            String targetDir = System.IO.Path.GetDirectoryName(PccConfig.SearchTermsPath);
            if (!System.IO.Directory.Exists(targetDir))
            {
                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                context.Response.Write("SearchTermsPath does not exist or is not configured correctly in pcc.config");
                context.Response.ContentType = "text/plain";
                return;
            }
            string searchTermsFileName = Path.Combine(targetDir, searchTermsId);
            using (FileStream searchStream = new FileStream(searchTermsFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                searchStream.CopyTo(context.Response.OutputStream);
            }

            context.Response.ContentType = "application/json;charset=utf-8";
            context.Response.StatusCode = (int)HttpStatusCode.OK;
        }
        catch(Exception e)
        {
            context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            context.Response.Write(e.Message);
            context.Response.ContentType = "text/plain";
            return;
        }
    }
        private bool IsUnapplicationNonvacuous(Match<Word, ShapeNode> match, IEnumerable<FeatureStruct> rhsAntiFSs)
        {
            int i = 0;
            foreach (FeatureStruct fs in rhsAntiFSs)
            {
                ShapeNode node = match.GroupCaptures["target" + i].Span.GetStart(match.Matcher.Direction);
                foreach (SymbolicFeature sf in fs.Features.OfType<SymbolicFeature>())
                {
                    SymbolicFeatureValue sfv = fs.GetValue(sf);
                    SymbolicFeatureValue nodeSfv;
                    if (node.Annotation.FeatureStruct.TryGetValue(sf, out nodeSfv))
                    {
                        if (sfv.IsVariable)
                        {
                            SymbolicFeatureValue varSfv;
                            if (!match.VariableBindings.TryGetValue(sfv.VariableName, out varSfv) || !nodeSfv.IsSupersetOf(varSfv, !sfv.Agree))
                                return true;
                        }
                        else if (!nodeSfv.IsSupersetOf(sfv))
                        {
                            return true;
                        }
                    }
                }
                i++;
            }

            return false;
        }
Example #17
0
 public void selectChoice(Match.RPS choice)
 {
     if(currentMatch != null)
     {
         currentMatch.setPlayerChoice(this, choice);
     }
 }
Example #18
0
		public override bool DoMatch(INode other, Match match)
		{
			if (other == null || other.IsNull)
				return true;
			else
				return childNode.DoMatch(other, match);
		}
Example #19
0
 public Goal(int id, int minutes, Match match, Player player)
 {
     Id = id;
     Minutes = minutes;
     Match = match;
     Player = player;
 }
Example #20
0
        static Match FindContainingAllTokensInOrder(string s, int startIndex, int endIndex, string[] tokens)
        {
            int firstTokenStart;
            int lastTokenEnd;

            if (tokens.Length == 0)
            {
                return null;
            }
            firstTokenStart = s.IndexOf(tokens[0], startIndex, endIndex - startIndex);
            if (firstTokenStart == -1)
            {
                return null;
            }

            lastTokenEnd = firstTokenStart + tokens[0].Length;
            for (int i = 1; i < tokens.Length; i++)
            {
                lastTokenEnd = s.IndexOf(tokens[i], lastTokenEnd, endIndex - lastTokenEnd);
                if (lastTokenEnd == -1)
                {
                    return null;
                }
                lastTokenEnd += tokens[i].Length;
            }

            Match ret = new Match();
            ret.Index = firstTokenStart;
            ret.EndIndex = lastTokenEnd;
            return ret;
        }
Example #21
0
 public MatchEditor(Match m, Player[] playerList)
 {
     this.oldMatch = m;
     this.thisMatch = m.Clone();
     this.players = playerList;
     InitializeComponent();
 }
Example #22
0
		public override bool DoMatch(INode other, Match match)
		{
			var last = match.Get (referencedGroupName).Last ();
			if (last == null && other == null)
				return true;
			return last.IsMatch(other);
		}
Example #23
0
		public override bool DoMatch(INode other, Match match)
		{
			if (other == null || other.IsNull)
				return this.MinCount <= 0;
			else
				return this.MaxCount >= 1 && childNode.DoMatch(other, match);
		}
Example #24
0
    public void ShouldBeUsableToSearchForMatches(Cloud cloud)
    {
        Login2NewUsers(cloud, (gamer1, gamer2) => {
            string queryStr = "public:true AND owner_id:" + gamer1.GamerId;
            Match[] matches = new Match[2];

            gamer1.Matches.Create(maxPlayers: 2)
            .Then(match1 => {
                Bundle matchProp = Bundle.CreateObject("public", true, "owner_id", gamer1.GamerId);
                matches[0] = match1;
                // Index the match
                return cloud.Index("matches").IndexObject(match1.MatchId, matchProp, Bundle.Empty);
            })
            .Then(indexResult => {
                // Create another match
                return gamer1.Matches.Create(maxPlayers: 2);
            })
            .Then(match2 => {
                // Index it
                matches[1] = match2;
                return cloud.Index("matches").IndexObject(match2.MatchId, Bundle.CreateObject("public", false), Bundle.Empty);
            })
            .Then(indexResult2 => {
                // Check that we can find match1 by looking for public matches
                return cloud.Index("matches").Search(queryStr);
            })
            .Then(found => {
                Assert(found.Hits.Count == 1, "Should find one match");
                Assert(found.Hits[0].ObjectId == matches[0].MatchId, "Should find one match");
            })
            .CompleteTestIfSuccessful();
        });
    }
Example #25
0
        /**
        *   Generates a label with text, a picturebox and another label.
        *   @parentPanel The panel that should add the created panel to it's controls.
        *   @team The team object containing data that'll be displayed such as the teams name and logo.
        *   @match The match object containing data that should be displayed.
        **/
        private void generateLabel(Panel parentPanel, Team team, Match match)
        {
            int _teamScore;
            if (match._team1 == team) {
                _teamScore = match._team1Score;
            } else {
                _teamScore = match._team2score;
            }

            Label labelname = new System.Windows.Forms.Label();
            labelname.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel, ((byte)(0)));
            labelname.Name = team._name;
            labelname.Size = new System.Drawing.Size(250, 15);
            labelname.Dock = System.Windows.Forms.DockStyle.Top;
            labelname.Text = String.Format("{0}", team._name);
            labelname.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(207)))), ((int)(((byte)(207)))), ((int)(((byte)(207)))));

            PictureBox pb = new PictureBox();
            pb.Size = new System.Drawing.Size(15, 15);
            pb.Dock = DockStyle.Right;
            pb.Image = team.getTeamLogo();

            Label score = new Label();
            score.Text = _teamScore.ToString();
            score.Dock = DockStyle.Right;
            score.Size = new System.Drawing.Size(15, 15);

            labelname.Controls.Add(score);
            labelname.Controls.Add(pb);
            parentPanel.Controls.Add(labelname);
        }
        public string Get()
        {
            using (var DBContext = new HeartstatDBDataContext())
            {
                for(int i = 0; i < 10; i++){

                Match seedMatch = new Match
                {
                    User = "TestUser"+i.ToString(),
                    UserClass = "Druid",
                    SubClass = "Ramp",
                    OpponentClass = "Warlock",
                    OpponentSubClass = "Zoo",
                    MatchResult = false,
                    PlayerRank = 18,
                    Season = 5,
                    Created = DateTime.Now,
                    Comment = "Paska peli",
                    UserId = "1111-1111111-1111-111"
                };
                DBContext.Matches.InsertOnSubmit(seedMatch);
                }
                try
                {
                    DBContext.SubmitChanges();
                    return "Database seed completed";
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }

            }
        }
 /// <summary>
 /// Returns a boolean representation of the value associated with the 
 /// IsMobile property.
 /// </summary>
 /// <param name="match">a Match object</param>
 /// <returns>
 /// A boolean representation of the value for IsMobile
 /// </returns>        
 public static bool getIsMobileBool(Match match)
 {
     if (match["IsMobile"].ToString() == "True")
         return true;
     else
         return false;
 }
 public PointTotal(Match m, bool home)
 {
     if (home)
        this.points = (m.HomeGoals);
     else
         this.points = (m.AwayGoals);
 }
Example #29
0
        public override CompetitorRanks GenerateResult(MatchStrategy matchStrategy, List<Competitor> competitors)
        {
            List<Match> matches = new List<Match>();

            if (competitors.Count % 2 != 0)
                throw new ArgumentException("Collection count must be even.", "competitors");

            // generate the results for the competitors
            // note that the competitors are paired in this round by the order they're in in the List object
            // pairing first with last, second with second-to-last, etc.
            for (int index = 0; index < competitors.Count / 2; index++)
            {
                int mirrorIndex = competitors.Count - (index + 1);

                Competitor competitorA = competitors[index];
                Competitor competitorB = competitors[mirrorIndex];

                Match match = new Match(matchStrategy, WinsToClinchMatch);
                match.Run(competitorA, competitorB);
                matches.Add(match);
            }

            Matches = matches;

            CompetitorPoints tournamentRoundPoints = AccumulateMatchPoints(matches);
            return tournamentRoundPoints.GetCompetitorRanks();
        }
        public void TestMatchObject() {
            var o = new Match() as object;

            Assert.IsTrue(o.IsPropertyMatch<Match, string>("Prop1", mm => mm.Prop1));
            Assert.IsTrue(o.IsPropertyMatch<Match, int>("Prop2", mm => mm.Prop2));
            Assert.IsTrue(o.IsPropertyMatch<Match, Match>("Prop3", mm => mm.Prop3));
            Assert.IsTrue(o.IsPropertyMatch<Match, int?>("Prop4", mm => mm.Prop4));

            Assert.IsFalse(o.IsPropertyMatch<Match, string>("Prop2", mm => mm.Prop1));
            Assert.IsFalse(o.IsPropertyMatch<Match, int>("Something", mm => mm.Prop2));
            Assert.IsFalse(o.IsPropertyMatch<Match, int>("", mm => mm.Prop2));
            Assert.IsFalse(o.IsPropertyMatch<Match, int>(null, mm => mm.Prop2));

            var oo = new Object();

            Assert.IsFalse(oo.IsPropertyMatch<Match, string>("Prop1", mm => mm.Prop1));
            Assert.IsFalse(oo.IsPropertyMatch<Match, int>("Prop2", mm => mm.Prop2));
            Assert.IsFalse(oo.IsPropertyMatch<Match, Match>("Prop3", mm => mm.Prop3));
            Assert.IsFalse(oo.IsPropertyMatch<Match, int?>("Prop4", mm => mm.Prop4));

            Assert.IsFalse(oo.IsPropertyMatch<Match, string>("Prop2", mm => mm.Prop1));
            Assert.IsFalse(oo.IsPropertyMatch<Match, int>("Something", mm => mm.Prop2));
            Assert.IsFalse(oo.IsPropertyMatch<Match, int>("", mm => mm.Prop2));
            Assert.IsFalse(oo.IsPropertyMatch<Match, int>(null, mm => mm.Prop2));
        }