summaryrefslogtreecommitdiff
path: root/Aktywator/Tournament.cs
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-07-30 00:51:34 +0200
committeremkael <emkael@tlen.pl>2017-07-30 00:51:34 +0200
commitc826889695c08a76c0e4c4f5d8ae126a3eb09ab6 (patch)
tree0ecfbda705a6be5f4d29470aca2c594029cc8f69 /Aktywator/Tournament.cs
parent04f325bbb2f9cfcfdf699b28057651f4a6a50541 (diff)
Tournament info code refactored for incoming generalization
Diffstat (limited to 'Aktywator/Tournament.cs')
-rw-r--r--Aktywator/Tournament.cs37
1 files changed, 30 insertions, 7 deletions
diff --git a/Aktywator/Tournament.cs b/Aktywator/Tournament.cs
index b46740b..ec45c15 100644
--- a/Aktywator/Tournament.cs
+++ b/Aktywator/Tournament.cs
@@ -8,6 +8,10 @@ namespace Aktywator
{
public class Tournament
{
+ public const int TYPE_PARY = 1;
+ public const int TYPE_TEAMY = 2;
+ public const int TYPE_UNKNOWN = 0;
+
private string _name;
public string name
{
@@ -34,17 +38,17 @@ namespace Aktywator
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;
+ _type = Tournament.TYPE_PARY;
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;
+ _type = Tournament.TYPE_TEAMY;
+ else _type = Tournament.TYPE_UNKNOWN;
}
public override string ToString()
{
- return this.name + " [" + (this.type == 1 ? 'P' : 'T') + "]";
+ return this.name + " [" + (this.type == Tournament.TYPE_PARY ? 'P' : 'T') + "]";
}
public static List<Tournament> getTournaments()
@@ -55,7 +59,7 @@ namespace Aktywator
while (dbs.Read())
{
Tournament t = new Tournament(dbs.GetString(0));
- if (t.type > 0)
+ if (t.type > Tournament.TYPE_UNKNOWN)
list.Add(t);
t.mysql.close();
}
@@ -64,7 +68,7 @@ namespace Aktywator
public string getSectionsNum()
{
- if (type == 1)
+ if (type == Tournament.TYPE_PARY)
return mysql.selectOne("SELECT COUNT(DISTINCT seknum) FROM sektory;");
else
return "1";
@@ -72,11 +76,30 @@ namespace Aktywator
public string getTablesNum()
{
- if (type == 1)
+ if (type == Tournament.TYPE_PARY)
return mysql.selectOne("SELECT COUNT(*) FROM sektory;");
else
return mysql.selectOne("SELECT teamcnt FROM admin;");
}
+
+ internal void setup()
+ {
+ if (this.mysql != null)
+ {
+ this.mysql.close();
+ this.mysql.connect();
+ }
+ }
+
+ internal string getName()
+ {
+ return this.name;
+ }
+
+ internal string getTypeLabel()
+ {
+ return this._type == Tournament.TYPE_PARY ? "Pary" : "Teamy";
+ }
}
}