diff options
author | Michał Zimniewicz <michzimny@users.noreply.github.com> | 2017-12-06 23:57:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-06 23:57:31 +0100 |
commit | 80cd31c1c8e7cef2cfbf6148df3d9ec2d2a23279 (patch) | |
tree | 4071e574a3e611cf4d8a19e231ff7ecc659949fa /Aktywator/RRBTournament.cs | |
parent | 83e064ccb67f0b68b1f947026301cd3905d06a3c (diff) | |
parent | f12d2b996b165d66f4c32eef4a3bdfb89309670d (diff) |
Merge pull request #29 from michzimny/1.1-beta
Scalenie gałęzi beta do master
Diffstat (limited to 'Aktywator/RRBTournament.cs')
-rw-r--r-- | Aktywator/RRBTournament.cs | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Aktywator/RRBTournament.cs b/Aktywator/RRBTournament.cs new file mode 100644 index 0000000..48040ee --- /dev/null +++ b/Aktywator/RRBTournament.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Xml; +using System.IO; + +namespace Aktywator +{ + class RRBTournament : Tournament + { + private XmlDocument _xml; + + 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() + { + string tName = this._xml.SelectSingleNode("//ustawienia/nazwa").InnerText.Trim(); + return tName.Length > 0 ? tName : Path.GetFileName(this._name); + } + + override public string getSectionsNum() + { + List<string> sections = new List<string>(); + 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<int, List<string>> getNameList() + { + this._xml.Load(this._name); + Dictionary<int, List<string>> names = new Dictionary<int, List<string>>(); + foreach (XmlNode pair in this._xml.SelectNodes("//lista/para")) + { + int pairNo = Int32.Parse(pair.SelectSingleNode("numer").InnerText); + names.Add(pairNo, new List<string>()); + foreach (XmlNode player in pair.SelectNodes("gracz/nazwisko")) + { + names[pairNo].Add(player.InnerText); + } + } + + foreach (KeyValuePair<int, List<string>> pair in names) + { + while (pair.Value.Count < 2) + { + pair.Value.Add(" "); + } + } + return names; + } + } +} |