ScummVM API documentation
tictactoe.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ASYLUM_PUZZLES_TICTACTOE_H
23#define ASYLUM_PUZZLES_TICTACTOE_H
24
25#include "asylum/puzzles/puzzle.h"
26
27namespace Asylum {
28
29class AsylumEngine;
30
31class PuzzleTicTacToe : public Puzzle {
32public:
35
36private:
37 enum GameStatus {
38 kStatus0,
39 kStatusFree,
40 kStatusNeedBlocking
41 };
42
43 uint32 _ticker;
44 uint32 _frameIndex;
45 uint32 _frameCount;
46 int32 _currentPos;
47 bool _gameOver;
48 int32 _winLine;
49
50 uint32 _solveDelay;
51 uint32 _brokenLines;
52
53 char _board[9];
54 uint32 _moveList[40];
55 uint32 _numberOfPossibleMoves;
56
58 // Event Handling
60 bool init(const AsylumEvent &evt);
61 void updateScreen();
62 bool mouseLeftDown(const AsylumEvent &evt);
63 bool exitPuzzle();
64
66 // Init & update
68 void clearBoard();
69 void drawField();
70 void getTwoEmpty(uint32 field1, uint32 field2, uint32 field3);
71
73 // Game
75 bool computerThinks();
76 GameStatus returnLineData(uint32 field1, uint32 field2, uint32 field3, char mark, uint32 *counterX, uint32 *counterO) const;
77 bool expandLine();
78 bool tryNewLine();
79 uint32 returnEmptySlot(uint32 position1, uint32 position2, uint position3) const;
80 bool checkWin();
81 int32 lookForAWinner();
82 bool strategy(char mark);
83 bool tryToWin() { return strategy('X'); }
84 bool tryNotToLose() { return strategy('O'); }
85 bool arbitraryPlacement();
86 void computerMoves();
87};
88
89} // End of namespace Asylum
90
91#endif // ASYLUM_PUZZLES_TICTACTOE_H
Definition: asylum.h:73
Definition: puzzle.h:41
Definition: tictactoe.h:31
Definition: eventhandler.h:43