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/TeamyTournament.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/TeamyTournament.cs')
-rw-r--r-- | Aktywator/TeamyTournament.cs | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/Aktywator/TeamyTournament.cs b/Aktywator/TeamyTournament.cs new file mode 100644 index 0000000..8da063d --- /dev/null +++ b/Aktywator/TeamyTournament.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Text; +using MySql.Data.MySqlClient; + +namespace Aktywator +{ + class TeamyTournament : MySQLTournament + { + public TeamyTournament(string name, int type = Tournament.TYPE_TEAMY) + : base(name, type) + { + this._type = Tournament.TYPE_TEAMY; + } + + override internal string getTypeLabel() + { + return "Teamy"; + } + + override public string getSectionsNum() + { + return "1"; + } + + override public string getTablesNum() + { + return this.mysql.selectOne("SELECT teamcnt FROM admin;"); + } + + override internal Dictionary<int, List<string>> getNameList() + { + Dictionary<int, List<String>> teams = new Dictionary<int, List<string>>(); + MySqlDataReader dbData = this.mysql.select(MainForm.teamNames.getQuery()); + while (dbData.Read()) + { + List<string> names = new List<string>(); + names.Add(dbData.IsDBNull(1) ? " " : dbData.GetString(1)); + names.Add(dbData.IsDBNull(2) ? " " : dbData.GetString(2)); + teams.Add(dbData.GetInt32(0), names); + } + dbData.Close(); + return teams; + } + + private int rounds = 0; + internal int getRoundsNum() + { + if (this.rounds == 0) + { + this.rounds = Int32.Parse(this.mysql.selectOne("SELECT roundcnt FROM admin")); + } + return this.rounds; + } + + private int segments = 0; + internal int getSegmentsNum() + { + if (this.segments == 0) + { + this.segments = Int32.Parse(this.mysql.selectOne("SELECT segmentsperround FROM admin")); + } + return this.segments; + } + + internal List<int> getCurrentSegment() + { + MySqlDataReader finished = this.mysql.select("SELECT rnd, segm FROM admin"); + List<int> segment = new List<int>(); + finished.Read(); + segment.Add(finished.GetInt32(0)); + segment.Add(finished.GetInt32(1)); + segment[1]++; + if (segment[1] > this.getSegmentsNum()) { + segment[0]++; + segment[1] = 1; + if (segment[0] > this.getRoundsNum()) + { + segment[0] = this.getRoundsNum(); + segment[1] = this.getSegmentsNum(); + } + } + if (segment[0] < 1) + { + segment[0] = 1; + } + if (segment[1] < 1) + { + segment[1] = 1; + } + finished.Close(); + return segment; + } + } +} |