From 618dad37ac9fa986facdcc21c1faa277f760dcb2 Mon Sep 17 00:00:00 2001 From: emkael Date: Sun, 30 Jul 2017 03:39:44 +0200 Subject: Data retrieval from RRB tournament files --- Aktywator/RRBTournament.cs | 83 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Aktywator/RRBTournament.cs (limited to 'Aktywator/RRBTournament.cs') diff --git a/Aktywator/RRBTournament.cs b/Aktywator/RRBTournament.cs new file mode 100644 index 0000000..d35e8f3 --- /dev/null +++ b/Aktywator/RRBTournament.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using System.IO; + +namespace Aktywator +{ + class RRBTournament : Tournament + { + private XmlDocument _xml; + private string p; + + public RRBTournament(string name) + { + this._name = name; + this._type = Tournament.TYPE_RRB; + } + + override internal void setup() + { + this._xml = new XmlDocument(); + this._xml.Load(this._name); + } + + override internal string getName() + { + return this._xml.SelectSingleNode("//ustawienia/nazwa").InnerText; + } + + override public string getSectionsNum() + { + List sections = new List(); + foreach (XmlNode table in this._xml.SelectNodes("//monitor/stoly/stol")) + { + string section = table.SelectSingleNode("sektor").InnerText; + if (!sections.Contains(section)) + { + sections.Add(section); + } + } + return sections.Count.ToString(); + } + + override public string getTablesNum() + { + return this._xml.SelectNodes("//monitor/stoly/stol").Count.ToString(); + } + + override internal string getTypeLabel() + { + return "RRBridge"; + } + + override internal Dictionary> getNameList() + { + Dictionary> names = new Dictionary>(); + foreach (XmlNode pair in this._xml.SelectNodes("//lista/para")) + { + int pairNo = Int32.Parse(pair.SelectSingleNode("numer").InnerText); + names.Add(pairNo, new List()); + foreach (XmlNode player in pair.SelectNodes("gracz/nazwisko")) + { + string[] name = player.InnerText.Trim().Split(' '); + if (name.Length > 0) + { + name[0] = name[0][0].ToString(); + names[pairNo].Add(String.Join(" ", name)); + } + } + } + + foreach (KeyValuePair> pair in names) + { + while (pair.Value.Count < 2) + { + pair.Value.Add(""); + } + } + return names; + } + } +} -- cgit v1.2.3