-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathprotocol.h
More file actions
114 lines (84 loc) · 2.95 KB
/
protocol.h
File metadata and controls
114 lines (84 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
eboard - chess client
http://www.bergo.eng.br/eboard
https://github.com/fbergo/eboard
Copyright (C) 2000-2016 Felipe Bergo
fbergo/at/gmail/dot/com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EBOARD_PROTOCOL_H
#define EBOARD_PROTOCOL_H 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "eboard.h"
#include "util.h"
#include "tstring.h"
#include "position.h"
typedef enum {
PV_premove
} ProtocolVar;
class Protocol {
public:
virtual ~Protocol();
virtual void receiveString(char *netstring)=0;
virtual void sendMove(int x1,int y1,int x2,int y2,int prom)=0;
virtual void sendDrop(piece p,int x,int y);
virtual void finalize();
virtual int hasAuthenticationPrompts();
virtual bool requiresLegalityChecking();
virtual void sendUserInput(char *line);
virtual void resign()=0;
virtual void draw()=0;
virtual void adjourn()=0;
virtual void abort()=0;
virtual void retractMove();
virtual void exaForward(int n);
virtual void exaBackward(int n);
virtual void discardGame(int gameid);
virtual void queryGameList(GameListConsumer *glc);
virtual void queryAdList(GameListConsumer *glc);
virtual void observe(int gameid);
virtual void answerAd(int adid);
virtual void refreshSeeks(bool create);
virtual void updateVar(ProtocolVar pv);
// meant for right-click menu on the clock area
virtual vector<string *> * getPlayerActions();
virtual vector<string *> * getGameActions();
virtual void callPlayerAction(char *player, string *action);
virtual void callGameAction(int gameid, string *action);
};
class NullProtocol : public Protocol {
public:
void receiveString(char *netstring);
void sendMove(int x1,int y1,int x2,int y2,int prom);
virtual void resign();
virtual void draw();
virtual void adjourn();
virtual void abort();
};
class EngineBookmark;
class EngineProtocol : public Protocol {
public:
// both run methods should return 0 in case of failure, anything
// else in case of success
// should open a dialog asking parameters for the engine
virtual int run()=0;
// should run the engine with parameters from the bookmark
virtual int run(EngineBookmark *bm)=0;
virtual void setInitialPosition(Position *p)=0;
};
#include "proto_fics.h"
#include "proto_p2p.h"
#include "proto_xboard.h"
#endif