summaryrefslogtreecommitdiffstats
path: root/knights/match.h
blob: 3feb2517a4b7629f35685ba993f4572e3d7b4555 (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/***************************************************************************
                          match.h  -  description
                             -------------------
    begin                : Mon Jul 2 2001
    copyright            : (C) 2003 by Troy Corbin Jr.
    email                : tcorbin@users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef MATCH_H
#define MATCH_H

#include <tqwidget.h>
#include "resource.h"
#include "match_param.h"
#include "command.h"
#include "chessclock.h"
#include "logic.h"
#include "pgn.h"

class board_base;

class match : public TQWidget
{
   Q_OBJECT
  

	private:
		resource			*Resource;
		board_base		*Board;
		pgn						*Record;
		logic					*Logic;
		chessclock		*Clock;
		ChessMove			chessMove;
		ChessMove			preMove;
		bool					preMoved;
		bool					Modified;
		bool					Paused;
		bool					Loading;
		bool					JustMoved;
		bool					Current;
		int						myID;
		int						StatusCode;
		int						loadTimer;
		TQString				StatusMessage;
		char					ICSGameMode;
		char					Draw_Offered[2];

	public:
									match(TQWidget *parent, match_param *param, resource *Rsrc);
									~match();
		char					inputOnMove( bool reverse=FALSE );
		char					input( char army );
		TQString				url( void );
		void					flip( void );
		void					retract( void );
		void					requestHint( void );
		void					recvCMD( const Command &cmd );
		void					setVisibility( const bool vis );
		void					setPaused( const bool State );
									/* Inline Function */
		int						getID( void )
												{ return myID; }
		void					setID( const int &ID )
												{ myID = ID; }
		TQString				caption( void )
												{ return Record->caption(); }
		char					onMove( void )
												{ return Logic->OnMove; }
		bool					modified( void )
												{ return Modified; }
		bool					paused( void )
												{ return Paused; }
		bool					flag( const bool &Army )
												{ return Clock->Flag[Army]; }
		void					setCurrent( const bool &State )
												{ Current = State; }
		void					print( void )
												{ Record->print(); }
		bool					loading( void )
												{ return Loading; }
		int						centiseconds( const bool &Army )
												{ return Clock->getCentiseconds( Army ); }
		TQStringList*	notation( void )
												{ return Record->notation(); }
		void					setModified( const bool &state )
												{ Modified = state; }
		void					resendStatusBar( void )
												{ emit setStatusBar( StatusCode, StatusMessage ); }
		match_param*	getParam( void )
												{ return Record->Param; }

	public slots:
		void					tick( void );
		void					resize( void );
		void					redraw( void );
		TQString				clock( bool );
		bool					save( TQString );
		bool					load( const TQString URL, const int pos=0 );
		void					loadSpecial( void );
		void					slot_Select( int );
		void					slot_Preview( int );
		void					slot_flagFell( const bool );
		void					review( const int );
		void					parseMatchParam( void );
		void					saveStatusBar( const int &ID, const TQString &MSG )
												{ StatusCode = ID; StatusMessage = MSG; }

	protected slots:
		bool					move( ChessMove );

	signals:
		void					setNotation( void );
		void					setClocks( void );
		void					setStatusBar( const int &ID, const TQString &MSG=TQString() );
		void					sendCMD( const Command& );

	protected:
		bool					move( void );
		void					clearSelections( void );
		void					drawPosition( const int );
		void					playSound( const int );
		void					_retract( void );
};

#endif