public static IgsPlayerInfo Parse(string line) { var playerInfo = new IgsPlayerInfo(); var slashRegularExpression = new Regex(@"\s*/\s*"); var spacesRegularExpression = new Regex(@"\s+"); try { var item = line.Substring(0, 26); line = line.Remove(0, 28); playerInfo.Name = item.Substring(0, 10); playerInfo.Name = playerInfo.Name.Substring(playerInfo.Name.LastIndexOf(' ') + 1); playerInfo.Info = item.Substring(12); item = line.Substring(0, 7); line = line.Remove(0, 7); playerInfo.Country = item; line = slashRegularExpression.Replace(line, " "); var data = spacesRegularExpression.Split(line); playerInfo.Rank = new IGSRank(data[1]); playerInfo.GamesWon = Convert.ToInt32(data[2]); playerInfo.GamesLost = Convert.ToInt32(data[3]); if (data[4] == "-") { playerInfo.GameObserving = 0; } else { playerInfo.GameObserving = Convert.ToInt32(data[4]); } if (data[5] == "-") { playerInfo.GamePlaying = 0; } else { playerInfo.GamePlaying = Convert.ToInt32(data[5]); } playerInfo.TimeIdle = data[6]; playerInfo.Flags = data[7]; playerInfo.Language = data[8]; } catch (FormatException) { throw new IGSParseException("Corrupted game info: " + line); } catch (IndexOutOfRangeException) { throw new IGSParseException("Corrupted game info: " + line); } return(playerInfo); }
private void ReadPlayersList(List <string> lines) { Players = new IgsPlayerInfo[lines.Count - 1]; for (var i = 1; i < lines.Count; i++) { var line = lines[i]; var playerInfo = IgsPlayerInfo.Parse(line); Players[lines.IndexOf(line) - 1] = playerInfo; } OnPlayersListUpdated(EventArgs.Empty); }
private void LoadStats(object sender, EventArgs args) { IgsPlayerInfo stats = serverInfo.PlayerStats; if (stats.Name == name) { WriteLine("Name:\r\n\t" + stats.Name); WriteLine("Rank:\r\n\t" + stats.Rank.ToString()); WriteLine("Wins:\r\n\t" + stats.GamesWon.ToString()); WriteLine("Losses:\r\n\t" + stats.GamesLost.ToString()); WriteLine("Language:\r\n\t" + stats.Language); WriteLine("County:\r\n\t" + stats.Country); WriteLine("Info:\r\n\t" + stats.Info); } }
public MatchDialog(MatchRequest request, IgsPlayerInfo stats) : this(request) { if (Environment.OSVersion.Platform == PlatformID.WinCE) { userNameTextBox.Width = 0; var statsButton = new Button() { Text = "?", Height = userNameTextBox.Height, Width = userNameTextBox.Height }; var innerTable = new LayoutTable(1, 2); innerTable.Fill(userNameTextBox, statsButton); innerTable.FixRows(); innerTable.FixColumns(1); table.PutLayout(innerTable, 0, 1); table.Apply(this, this.ClientRectangle); statsButton.Click += delegate { notification.Visible = true; }; notification = new Notification() { Text = "<html><body><form method='GET' action='notify'><hr/>" + "Name: " + stats.Name + "<br/>Rank: " + stats.Rank.ToString() + "<br/>Wins/Losses: " + stats.GamesWon + "/" + stats.GamesLost + "<hr/></form></body></html>", Caption = "Stats of " + stats.Name, InitialDuration = 10, Icon = ConfigManager.GetIcon("game") }; } }
private void ReadInfo(List <string> lines) { info = new IgsPlayerInfo(); if (lines[0].StartsWith("Player:")) { var firstLine = lines[0]; var name = firstLine.Substring( firstLine.IndexOf(' '), firstLine.Length - firstLine.IndexOf(' ')).TrimStart(' '); if (name == client.CurrentAccount.Name) { //9 Verbose Bell Quiet Shout Automail Open Looking Client Kibitz Chatter //9 Off Off On On Off On On On On On var toggles = lines[lines.Count - 1].Replace(" ", "").Split('O'); ToggleSettings = new IGSToggleSettings(toggles[6] == "n", toggles[7] == "n", toggles[9] == "n"); OnToggleSettingsUpdated(EventArgs.Empty); } else { foreach (var line in lines) { var type = line.Substring(0, line.IndexOf(' ')); var data = line.Substring( line.IndexOf(' '), line.Length - line.IndexOf(' ')).TrimStart(' '); switch (type) { case "Player:": info.Name = data; break; case "Language:": info.Language = data; break; case "Rating:": info.Rank = new IGSRank(data.Split(' ')[0]); break; case "Wins:": info.GamesWon = Convert.ToInt32(data); break; case "Losses:": info.GamesLost = Convert.ToInt32(data); break; case "Country:": info.Country = data; break; case "Info:": info.Info = data; break; } } OnPlayerStatsUpdated(EventArgs.Empty); } } }