00001 #include "game.h" 00002 00003 Game::Game(void) 00004 { 00005 } 00006 00007 Game::Game(int ID, Team* team1, Team* team2, int result[2]) 00008 : ID(ID), team1(team1), team2(team2) { 00009 this->result.score[0] = result[0]; 00010 this->result.score[1] = result[1]; 00011 } 00012 00013 Game::Game(int ID, Team* team1, Team* team2, int result[2], Game* leftChild, Game* rightChild) 00014 : ID(ID), team1(team1), team2(team2), leftChild(leftChild), rightChild(rightChild) { 00015 this->result.score[0] = result[0]; 00016 this->result.score[1] = result[1]; 00017 } 00018 00019 Game::Game(int ID, Team* team1, Team* team2, int result[2], QString date, QString descr) 00020 : ID(ID), team1(team1), team2(team2), date(date), descr(descr) { 00021 this->result.score[0] = result[0]; 00022 this->result.score[1] = result[1]; 00023 } 00024 00025 00026 Game::~Game(void) 00027 { 00028 } 00029 00030 int Game::getID(void) const 00031 { 00032 return ID; 00033 } 00034 00035 void Game::setBracket(int y0, int dy, int ylink, int level, int dir, int dashOffset, QPen pen) 00036 { 00037 bracket.y0 = y0; 00038 bracket.dy = dy; 00039 bracket.ylink = ylink; 00040 bracket.level = level; 00041 bracket.dir = dir; 00042 bracket.dashOffset = dashOffset; 00043 bracket.pen = pen; 00044 } 00045 00046 void Game::setBracket(int y0, int dy, int ylink, int dashOffset) 00047 { 00048 bracket.y0 = y0; 00049 bracket.dy = dy; 00050 bracket.ylink = ylink; 00051 bracket.dashOffset = dashOffset; 00052 } 00053 00054 struct Game::Bracket Game::getBracket(void) const 00055 { 00056 return bracket; 00057 } 00058 00059 void Game::setTeams(Team* team1, Team* team2) 00060 { 00061 this->team1 = team1; 00062 this->team2 = team2; 00063 } 00064 00065 void Game::setTeam(int teamnum, Team* team) 00066 { 00067 if (teamnum==1) 00068 team1 = team; 00069 else 00070 team2 = team; 00071 } 00072 00073 Team* Game::getTeam(int teamnum) const 00074 { 00075 if (teamnum==1) 00076 return team1; 00077 else 00078 return team2; 00079 } 00080 00081 00082 QString Game::getDate(void) 00083 { 00084 return date; 00085 } 00086 00087 QString Game::getDescr(void) 00088 { 00089 return descr; 00090 } 00091 00092 struct Game::Result Game::getResult(void) const 00093 { 00094 return result; 00095 } 00096 00097 void Game::setResult(int score[2]) 00098 { 00099 result.score[0] = score[0]; 00100 result.score[1] = score[1]; 00101 } 00102 00103 int Game::getState(void) const 00104 { 00105 if(result.score[0]>result.score[1]) 00106 return Game::WINTEAM1; 00107 else if(result.score[0]<result.score[1]) 00108 return Game::WINTEAM2; 00109 else 00110 return Game::UNDECIDED; 00111 } 00112 00113 void Game::setChilds(Game* leftChild, Game* rightChild) 00114 { 00115 this->leftChild = leftChild; 00116 this->rightChild = rightChild; 00117 } 00118 00119 Game* Game::getChild(int dir) const 00120 { 00121 if(dir == Game::LEFTCHILD) 00122 return leftChild; 00123 else 00124 return rightChild; 00125 } 00126 00127 bool Game::isChildGamesDecided(void) 00128 { 00129 if(leftChild == Game::UNDEFINED) 00130 return true; 00131 else 00132 { 00133 if(leftChild->getState() != Game::UNDECIDED && rightChild->getState() != Game::UNDECIDED) 00134 return true; 00135 else 00136 return false; 00137 } 00138 } 00139 00140 int Game::getTeam1(void) 00141 { 00142 return team1->getId(); 00143 } 00144 00145 int Game::getTeam2(void) 00146 { 00147 return team2->getId(); 00148 } 00149 00150 Team* Game::getTeam1Direct(void) 00151 { 00152 return team1; 00153 } 00154 00155 Team* Game::getTeam2Direct(void) 00156 { 00157 return team2; 00158 } 00159 00160 void Game::setPen(QPen pen) 00161 { 00162 bracket.pen = pen; 00163 } 00164 00165 void Game::setPenColor(int val) 00166 { 00167 bracket.pen.setColor(QColor(val,val,val)); 00168 }