aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock/tattoo/tattoo_darts.h
blob: ab6b1c8204efeebf622a040ae03d3c57e60a7fd7 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef SHERLOCK_TATTOO_DARTS_H
#define SHERLOCK_TATTOO_DARTS_H

#include "common/scummsys.h"
#include "sherlock/image_file.h"

namespace Sherlock {

class SherlockEngine;

namespace Tattoo {

enum GameType { GAME_301, GAME_CRICKET, GAME_501 };

class Darts {
private:
	SherlockEngine *_vm;
	GameType _gameType;
	ImageFile *_hand1, *_hand2;
	ImageFile *_dartGraphics;
	ImageFile *_dartsLeft;
	ImageFile *_dartMap;
	ImageFile *_dartBoard;
	Common::Rect _dartInfo;
	int _cricketScore[2][7];
	int _score1, _score2;
	int _roundNum;
	int _roundScore;
	int _level;
	int _compPlay;
	Common::String _opponent;
	int _spacing;
	bool _oldDartButtons;
	int _handX;
	Common::Point _handSize;
	bool _escapePressed;

	/**
	 * Initialize game variables
	 */
	void initDarts();

	/**
	 * Load dartboard graphics
	 */
	void loadDarts();

	/**
	 * Free loaded dart images
	 */
	void closeDarts();

	/**
	 * Show the player names
	 */
	void showNames(int playerNum);

	/**
	 * Show the current scores
	 */
	void showStatus(int playerNum);

	/**
	 * Erases the power bars
	 */
	void erasePowerBars();

	/**
	 * Returns true if a mouse button or key is pressed
	 */
	bool dartHit();

	/**
	 * Shows a power bar and increments it until a key or mouse button is pressed. If the bar
	 * reaches the end, it will also end. The reached power bar number is returned.
	 * @param pt			Bar position
	 * @param color			draw color
	 * @param goToPower		If provided, input is ignored, and the bar is increased up to the specified level
	 * @param orientation	0=Horizontal, 1=Vertical
	 */
	int doPowerBar(const Common::Point &pt, byte color, int goToPower, int orientation);

	/**
	 * This is similar to doPowerBar, except it draws the player's hand moving across the 
	 * bottom of the screen to indicate the positioning of the darts
	 */
	int drawHand(int goToPower, int computer);

	/**
	 * Converts a passed co-ordinates from screen co-ordinates to an offset within the dartboard
	 */
	Common::Point convertFromScreenToScoreCoords(const Common::Point &pt) const;

	/**
	 * Return the score a dart at the given position will get
	 */
	int dartScore(const Common::Point &pt);

	/**
	 * Draw a dart travelling to the board
	 */
	void drawDartThrow(const Common::Point &dartPos, int computer);

	/**
	 * Looks for the passed number on the dartboard. If it finds it, it will return
	 * the co-ordinates of the center of the number
	 */
	int findNumberOnBoard(int aim, Common::Point &pt);

	/**
	 * Calculates a position for the comptuer wants to throw, and then calculates where they
	 * actually did throw. The computer will not always hit what it's aiming it.
	 */
	void getComputerNumber(int playerNum, Common::Point &targetPos);

	/**
	 * Throw one dart. If computer is 1 or 2, the computer will throw the dart, and user input
	 * will be ignored.
	 * @param computer		1=1st computer player, 2=2nd computer player
	 */
	int throwDart(int dartNum, int computer);

	/**
	 * This will update the number of hits for the target score, as well as updating the
	 * score if it's closed
	 */
	void doCricketScoreHits(int player, int scoreIndex, int numHits);

	/**
	 * Updates the score based upon what the dart hit
	 */
	void updateCricketScore(int player, int dartVal, int multiplier);

	/**
	 * Draw the darts left
	 */
	void drawDartsLeft(int dartNum, int computer);
public:
	Darts(SherlockEngine *vm);

	/**
	 * Play the darts game
	 */
	void playDarts(GameType gameType);
};

} // End of namespace Tattoo

} // End of namespace Sherlock

#endif