Ejemplo n.º 1
0
		public static void setScore(PlayerMatch match, string token)
		{
			token = token.ToLower();
			if (token.Contains("default"))
			{
				match.Defaulted = true;
				token = token.Replace("default", "");
			}
			List<Set> sets = BaseMatchParser.parseMatchScore(token);
			match.Score.Sets.AddRange(sets);
		}
Ejemplo n.º 2
0
		public static PlayerMatch ToPlayerMatch(this Match source, int playerID)
		{
			var match = new PlayerMatch();
			match.ID = source.ID;
			match.Date = source.Date;
			match.EventID = source.EventID;
			//playerMatch.EventName = match.ev
			//TennisEvent TennisEvent = Match.Events.Find(Match.EventID);
			//TennisEvent TennisEvent = TennisEvent.Get(Match.EventID);
			//playerMatch.EventName = TennisEvent.Name;
			//playerMatch.ClassID = TennisEvent.ClassificationID;
			//playerMatch.ClassName = "";

			match.Result = (playerID == source.WinnerID ? "W" : "L");
			match.OpponentID = (playerID == source.WinnerID ? source.LoserID : source.WinnerID);
			//playerMatch.OpponentName = Player.Get(_OpponentID).FullName;
			match.Score.Sets.AddRange(source.Score.Sets);
			return match;
		}
Ejemplo n.º 3
0
		public static void setResult(PlayerMatch match, string token)
		{
			if (match.Result != "")
				throw new FormatException("Match result is specified twice.");
			match.Result = token.Substring(0, 1).ToUpper();
		}
Ejemplo n.º 4
0
		public static PlayerMatch parseMatch(this string matchString)
		{
			var match = new PlayerMatch();
			var matchDate = match.Date;
			var delimiter = matchString.Contains("\t") ? "\t" : matchString.Contains(",") ? "," : " ";
			var array = matchString.Split(delimiter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

			foreach (var token in array)
			{
				if (isVictoryIndicator(token))
				{
					if (match.Result != "")
						throw new FormatException("Match result is specified twice.");
					match.Result = token.Substring(0, 1).ToUpper();
				}
				else if (isScore(token))
				{
					List<Set> sets = BaseMatchParser.parseMatchScore(token);
					match.Score.Sets.AddRange(sets);
				}
				else if (DateTime.TryParse(token, out matchDate))
				{
					if (!token.ToUpper().Contains('M'))
					{
						if (match.Date != DateTime.MinValue)
						{
							//we already have the time, add the date
							match.Date = matchDate + match.Date.TimeOfDay;
						}
						else
						{
							//set the date and default the time to 6am
							match.Date = matchDate + new TimeSpan(6, 0, 0);
						}
					}
					else
					{
						if (match.Date != DateTime.MinValue)
						{
							//we already have the date, add the time
							match.Date = match.Date.Date + matchDate.TimeOfDay;
						}
						else
						{
							//given just the time, DateTime.TryParse deaults to today's date
							match.Date = matchDate;
						}
					}
				}
				else if (token.ToLower() == "default")
				{
					match.Defaulted = true;
				}
				else if (token.ToLower() == "am" || token.ToLower() == "pm")
				{
					throw new FormatException("Space-delimited rows cannot contain spaces in date-time values.");
				}
				else
				{
					if (match.OpponentName.Length > 0)
						match.OpponentName += " ";
					match.OpponentName += token;
				}
			}
			return match;
		}
Ejemplo n.º 5
0
		public static PlayerMatch parseMatchMultiLine(this string matchString)
		{
			var match = new PlayerMatch();
			return match;
		}