| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2009 by The qGo Project * |
| 3 | * * |
| 4 | * This file is part of qGo. * |
| 5 | * * |
| 6 | * qGo is free software: you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, see <http://www.gnu.org/licenses/> * |
| 18 | * or write to the Free Software Foundation, Inc., * |
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | |
| 23 | #ifndef PLAYERGAMELISTING_H |
| 24 | #define PLAYERGAMELISTING_H |
| 25 | |
| 26 | #include <QString> |
| 27 | |
| 28 | class GameData; |
| 29 | |
| 30 | /* Private constructors and destructors ensure that only the |
| 31 | * friend class Room |
| 32 | * can create or destroy instances of these classes */ |
| 33 | |
| 34 | class PlayerListing |
| 35 | { |
| 36 | private: |
| 37 | PlayerListing() : id(0), |
| 38 | online(false), |
| 39 | name(""), |
| 40 | notnickname(""), |
| 41 | info(""), |
| 42 | idletime(""), |
| 43 | seconds_idle(0), |
| 44 | rank(""), |
| 45 | rank_score(0), |
| 46 | country(""), |
| 47 | wins(0), |
| 48 | losses(0), |
| 49 | rated_games(0), |
| 50 | observing(0), |
| 51 | playing(0), |
| 52 | extInfo(""), |
| 53 | email_address(""), |
| 54 | nmatch(0), |
| 55 | nmatch_handicapMin(0), |
| 56 | specialbyte(0), |
| 57 | pro(false), |
| 58 | dialog_opened(false), |
| 59 | game_dialog_opened(false), |
| 60 | friendWatchType(none), |
| 61 | notify(false), |
| 62 | hidden(false) {} |
| 63 | ~PlayerListing() {} |
| 64 | friend class Room; |
| 65 | public: |
| 66 | unsigned short id; |
| 67 | bool online; |
| 68 | QString name; |
| 69 | QString notnickname; |
| 70 | QString info; |
| 71 | QString idletime; |
| 72 | unsigned int seconds_idle; //for sorting |
| 73 | //maybe should be in int form, but we just display, no calculations |
| 74 | QString rank; |
| 75 | unsigned int rank_score; //for sorting, rating points |
| 76 | QString country; |
| 77 | unsigned char country_id; |
| 78 | unsigned int wins; |
| 79 | unsigned int losses; |
| 80 | unsigned int rated_games; |
| 81 | unsigned int observing; //used by IGS and ORO, so not ready to get rid of it |
| 82 | std::vector <unsigned short> room_list; //used by Tygem et al. |
| 83 | unsigned int playing; |
| 84 | QString extInfo; |
| 85 | QString email_address; |
| 86 | |
| 87 | /* I should really use MatchRequest structure somehow for this: FIXME */ |
| 88 | bool nmatch; |
| 89 | TimeSystem nmatch_timeSystem; |
| 90 | bool nmatch_white, nmatch_black, nmatch_nigiri; |
| 91 | int nmatch_timeMin, nmatch_timeMax; |
| 92 | int nmatch_BYMin, nmatch_BYMax; |
| 93 | int nmatch_stonesMin, nmatch_stonesMax; |
| 94 | QString nmatch_settings; |
| 95 | int nmatch_handicapMin, nmatch_handicapMax; |
| 96 | unsigned char specialbyte; //ORO weirdness personalchat |
| 97 | bool pro; |
| 98 | bool dialog_opened; |
| 99 | bool game_dialog_opened; |
| 100 | enum FriendWatchType { none, friended, watched, blocked } friendWatchType; |
| 101 | bool notify; |
| 102 | bool hidden; |
| 103 | }; |
| 104 | |
| 105 | /* We need to alter copy constructor to have and respect a bit field. |
| 106 | * this is heavy, but I think its necessary... unless we get the |
| 107 | * existing listing before change and update.*/ |
| 108 | class GameListing |
| 109 | { |
| 110 | private: |
| 111 | GameListing() : running(false), |
| 112 | moves(0), |
| 113 | board_size(19), |
| 114 | handicap(0), |
| 115 | komi(6.5), |
| 116 | white(0), |
| 117 | black(0), |
| 118 | _white_name("-"), |
| 119 | _black_name("-"), |
| 120 | _white_rank("-"), |
| 121 | _black_rank("-"), |
| 122 | _white_rank_score(0), |
| 123 | _black_rank_score(0), |
| 124 | observers(0), |
| 125 | result(""), |
| 126 | By(""), FR(""), comment(""), |
| 127 | flags(IN_PROGRESS), |
| 128 | rated(0), |
| 129 | owner_id(0), |
| 130 | isRoomOnly(false), |
| 131 | isBroadcast(false), |
| 132 | isBetting(false), |
| 133 | isLocked(false), |
| 134 | gameData(NULL) {} |
| 135 | ~GameListing() {} |
| 136 | friend class Room; |
| 137 | public: |
| 138 | bool running; |
| 139 | unsigned int number; |
| 140 | unsigned short game_code; //ORO join games code FIXME |
| 141 | unsigned int moves; |
| 142 | unsigned int board_size; |
| 143 | unsigned int handicap; |
| 144 | float komi; |
| 145 | PlayerListing * white; |
| 146 | PlayerListing * black; |
| 147 | QString _white_name; |
| 148 | QString _black_name; |
| 149 | QString _white_rank; |
| 150 | QString _black_rank; |
| 151 | unsigned int _white_rank_score; |
| 152 | unsigned int _black_rank_score; |
| 153 | const QString & white_name(void) const |
| 154 | { |
| 155 | if(white) |
| 156 | return white->name; |
| 157 | else |
| 158 | return _white_name; |
| 159 | } |
| 160 | const QString & white_rank(void) const |
| 161 | { |
| 162 | if(white) |
| 163 | return white->rank; |
| 164 | else |
| 165 | return _white_rank; |
| 166 | } |
| 167 | unsigned int white_rank_score(void) const //for sorting |
| 168 | { |
| 169 | if(white) |
| 170 | return white->rank_score; |
| 171 | else |
| 172 | return _white_rank_score; |
| 173 | } |
| 174 | const QString & black_name(void) const |
| 175 | { |
| 176 | if(black) |
| 177 | return black->name; |
| 178 | else |
| 179 | return _black_name; |
| 180 | } |
| 181 | const QString & black_rank(void) const |
| 182 | { |
| 183 | if(black) |
| 184 | return black->rank; |
| 185 | else |
| 186 | return _black_rank; |
| 187 | } |
| 188 | unsigned int black_rank_score(void) const //for sorting |
| 189 | { |
| 190 | if(black) |
| 191 | return black->rank_score; |
| 192 | else |
| 193 | return _black_rank_score; |
| 194 | } |
| 195 | |
| 196 | unsigned int observers; |
| 197 | QString result; |
| 198 | GameMode gameType; //this needs to be consistent |
| 199 | QString By; //these two need to be changed somehow |
| 200 | QString FR; |
| 201 | QString comment; |
| 202 | /* Other possibilities for flags: |
| 203 | * NO_FLAG, BROADCAST, CHAT_ROOM */ |
| 204 | enum Flags { BLACK_WON, WHITE_WON, IN_PROGRESS, REVIEW, LOOKING } flags; |
| 205 | bool rated; |
| 206 | unsigned short owner_id; //this is if we're treating them as rooms |
| 207 | bool isRoomOnly; |
| 208 | bool isBroadcast; |
| 209 | bool isBetting; |
| 210 | bool isLocked; |
| 211 | bool white_first_flag; |
| 212 | std::vector <PlayerListing *> observer_list; |
| 213 | GameData * gameData; |
| 214 | /* Also need byomi time, one color go, running, private, flags, ranked, etc.*/ |
| 215 | }; |
| 216 | #endif //PLAYERGAMELISTINGS_H |