Debian Codegraph @

src/network/matchnegotiationstate.h

raw symbols SCIP
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 class PlayerListing;
24 class MatchRequest;
25 class GameData;
26
27 class MatchNegotiationState
28 {
29 public:
30 MatchNegotiationState(void) : state(MSNONE), player(0), opponent(QString()), game_number(0), negotiation_broken(false), match_request(0) {};
31
32 bool broken(void) { return negotiation_broken; };
33 PlayerListing * getPlayerListing(void) { return player; };
34 unsigned short getGameId(void) { return game_number; };
35 void setGameId(unsigned short id) { game_number = id; };
36 void setCountingVerification(unsigned short v) { counting_verification = v; };
37 unsigned short getCountingVerification(void) { return counting_verification; };
38 QString & getOpponent(void) { return opponent; };
39 void setPlayer(PlayerListing * p) { player = p; };
40
41 bool newMatchAllowed(void);
42 bool canEnterRematchAdjourned(void);
43 bool inGame(void);
44 bool isOurGame(unsigned short id);
45 bool sentMatchInvite(void);
46 bool sentMatchOfferPending(void);
47 bool justCreatedRoom(void);
48 bool waitingForRoomNumber(void);
49 bool sentJoinRoom(void) { return waitingForMatchOffer(); };
50 bool waitingForMatchOffer(void);
51 bool startMatchAcceptable(void);
52 bool isOngoingMatch(unsigned short id);
53 bool isOngoingMatch(void);
54 bool sentCreateRoom(void);
55 bool sentMatchOffer(void);
56 bool twoPasses(void);
57 bool counting(void);
58 bool sentDoneCounting(void);
59 bool receivedDoneCounting(void);
60 bool doneCounting(void);
61 bool sentRematch(void);
62 bool sentRematchAccept(void);
63 bool sentAdjournResume(void);
64 bool opponentDisconnected(void);
65 bool opponentRejoining(void);
66 void setupRematchAdjourned(unsigned short id, QString opponent_name);
67 void reset(void);
68 void sendMatchInvite(PlayerListing * p);
69 void sendMatchAccept(PlayerListing *);
70 void sendMatchOfferPending(void);
71 void sendCreateRoom(void);
72 void sendJoinRoom(unsigned short id);
73 void createdRoom(unsigned short id);
74 void offerMatchTerms(MatchRequest * mr);
75 void modifyMatchTerms(MatchRequest * mr);
76 void acceptMatchTerms(MatchRequest * mr);
77 void startMatch(void);
78 void incrementPasses(void);
79 void enterScoreMode(void);
80 void sendDoneCounting(void);
81 void receiveDoneCounting(void);
82 void setDoneCounting(void);
83 void sendMatchModeRequest(void);
84 void sendRematch(PlayerListing * p);
85 void sendRematchAccept(void);
86 void opponentDisconnect(void);
87 void sendAdjournResume(void);
88 void opponentRejoins(void);
89 void opponentReconnect(void);
90 void swapColors(void);
91 bool verifyPlayer(PlayerListing * p);
92 bool verifyMatchRequest(MatchRequest & mr);
93 bool verifyGameData(GameData & g);
94 bool verifyCountDoneMessage(unsigned short v);
95
96 private:
97 enum MSSTATE { MSNONE, MSINVITE, MSACCEPTINVITE, MSSENTCREATEROOM, MSCREATEDROOM, MSJOINEDROOM,
98 MSMATCHOFFERPENDING,
99 MSMATCHOFFER, MSMATCHMODIFY, MSMATCHACCEPT,
100 MSSTARTMATCH, MSONGOINGMATCH,
101 MSONEPASS, MSTWOPASS, MSTHREEPASS,
102 MSCOUNTING, MSSENTDONECOUNTING, MSRECEIVEDDONECOUNTING, MSDONECOUNTING,
103 MSMATCHMODEREQUEST,
104 MSMATCHFINISHED,
105 MSSENTREMATCH, MSSENTREMATCHACCEPT, MSREMATCH,
106 MSOPPONENTDISCONNECT, MSOPPONENTREJOINING, MSSENTADJOURNRESUME, MSREMATCHADJOURNED } state;
107 MSSTATE getState(void) { return state; };
108
109
110 PlayerListing * player;
111 QString opponent;
112 unsigned short game_number;
113
114 bool negotiation_broken;
115 MatchRequest * match_request;
116 unsigned short counting_verification;
117 };