diff options
Diffstat (limited to 'Aktywator/Tournament.cs')
-rw-r--r-- | Aktywator/Tournament.cs | 70 |
1 files changed, 15 insertions, 55 deletions
diff --git a/Aktywator/Tournament.cs b/Aktywator/Tournament.cs index b46740b..85a2666 100644 --- a/Aktywator/Tournament.cs +++ b/Aktywator/Tournament.cs @@ -1,81 +1,41 @@ using System; using System.Collections.Generic; using System.Text; -using MySql.Data.MySqlClient; -using data = MySql.Data.MySqlClient.MySqlDataReader; namespace Aktywator { - public class Tournament + abstract public class Tournament { - private string _name; + public const int TYPE_PARY = 1; + public const int TYPE_TEAMY = 2; + public const int TYPE_RRB = 3; + public const int TYPE_UNKNOWN = 0; + + protected string _name; public string name { get { return _name; } } - private int _type; // 0-unknown, 1-Pary, 2-Teamy + protected int _type = Tournament.TYPE_UNKNOWN; // 0-unknown, 1-Pary, 2-Teamy, 3-RRB public int type { get { return _type; } } - public MySQL mysql; - - public Tournament(string name) - { - this._name = name; - mysql = new MySQL(name); - recognizeType(); - } + abstract internal void setup(); - private void recognizeType() - { - if ((mysql.selectOne("SHOW TABLES LIKE 'admin'") == "admin") - && (mysql.selectOne("SHOW FIELDS IN admin LIKE 'dnazwa'") == "dnazwa") - && (mysql.selectOne("SHOW TABLES LIKE 'zawodnicy'") == "zawodnicy")) - _type = 1; - else if ((mysql.selectOne("SHOW TABLES LIKE 'admin'") == "admin") - && (mysql.selectOne("SHOW FIELDS IN admin LIKE 'teamcnt'") == "teamcnt") - && (mysql.selectOne("SHOW TABLES LIKE 'players'") == "players")) - _type = 2; - else _type = 0; - } + abstract internal string getName(); - public override string ToString() - { - return this.name + " [" + (this.type == 1 ? 'P' : 'T') + "]"; - } + abstract public string getSectionsNum(); - public static List<Tournament> getTournaments() - { - List<Tournament> list = new List<Tournament>(); - MySQL c = new MySQL(""); - data dbs = c.select("SHOW DATABASES;"); - while (dbs.Read()) - { - Tournament t = new Tournament(dbs.GetString(0)); - if (t.type > 0) - list.Add(t); - t.mysql.close(); - } - return list; - } + abstract public string getTablesNum(); - public string getSectionsNum() - { - if (type == 1) - return mysql.selectOne("SELECT COUNT(DISTINCT seknum) FROM sektory;"); - else - return "1"; - } + abstract internal string getTypeLabel(); - public string getTablesNum() + virtual internal Dictionary<int, List<string>> getNameList() { - if (type == 1) - return mysql.selectOne("SELECT COUNT(*) FROM sektory;"); - else - return mysql.selectOne("SELECT teamcnt FROM admin;"); + return new Dictionary<int, List<string>>(); } } |