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
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (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, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "graphics/cursorman.h"
24 #include "tsage/dialogs.h"
25 #include "tsage/tsage.h"
26 #include "tsage/staticres.h"
27 #include "tsage/ringworld2/ringworld2_outpost.h"
28
29 namespace TsAGE {
30
31 namespace Ringworld2 {
32
33 /*--------------------------------------------------------------------------
34 * Scene 1337 - Card game
35 *
36 *--------------------------------------------------------------------------*/
37
Card()38 Scene1337::Card::Card() {
39 _cardId = 0;
40 _stationPos = Common::Point(0, 0);
41 }
42
synchronize(Serializer & s)43 void Scene1337::Card::synchronize(Serializer &s) {
44 _card.synchronize(s);
45
46 s.syncAsSint16LE(_cardId);
47 s.syncAsSint16LE(_stationPos.x);
48 s.syncAsSint16LE(_stationPos.y);
49 }
50
isIn(Common::Point pt)51 bool Scene1337::Card::isIn(Common::Point pt) {
52 if ((_stationPos.x > pt.x) || (_stationPos.x + 24 < pt.x))
53 return false;
54
55 if ((_stationPos.y > pt.y) || (_stationPos.y + 24 < pt.y))
56 return false;
57
58 return true;
59 }
60
GameBoardSide()61 Scene1337::GameBoardSide::GameBoardSide() {
62 _card1Pos = Common::Point(0, 0);
63 _card2Pos = Common::Point(0, 0);
64 _card3Pos = Common::Point(0, 0);
65 _card4Pos = Common::Point(0, 0);
66 _frameNum = 0;
67 }
68
synchronize(Serializer & s)69 void Scene1337::GameBoardSide::synchronize(Serializer &s) {
70 SceneHotspot::synchronize(s);
71
72 for (int i = 0; i < 4; i++)
73 _handCard[i].synchronize(s);
74
75 for (int i = 0; i < 8; i++)
76 _outpostStation[i].synchronize(s);
77
78 _delayCard.synchronize(s);
79 _emptyStationPos.synchronize(s);
80
81 s.syncAsSint16LE(_card1Pos.x);
82 s.syncAsSint16LE(_card1Pos.y);
83 s.syncAsSint16LE(_card2Pos.x);
84 s.syncAsSint16LE(_card2Pos.y);
85 s.syncAsSint16LE(_card3Pos.x);
86 s.syncAsSint16LE(_card3Pos.y);
87 s.syncAsSint16LE(_card4Pos.x);
88 s.syncAsSint16LE(_card4Pos.y);
89 s.syncAsSint16LE(_frameNum);
90 }
91
Scene1337()92 Scene1337::Scene1337() {
93 _autoplay = false;
94 _cardsAvailableNumb = 0;
95 _currentDiscardIndex = 0;
96
97 for (int i = 0; i < 100; i++)
98 _availableCardsPile[i] = 0;
99
100 _shuffleEndedFl = false;
101 _currentPlayerNumb = 0;
102 _actionPlayerIdx = 0;
103 _actionVictimIdx = 0;
104 _showPlayerTurn = false;
105 _displayHelpFl = false;
106 _winnerId = -1;
107 _instructionsDisplayedFl = false;
108 _instructionsWaitCount = 0;
109
110 _delayedFunction = nullptr;
111 _actionCard1 = nullptr;
112 _actionCard2 = nullptr;
113 _actionCard3 = nullptr;
114
115 _cursorCurRes = 0;
116 _cursorCurStrip = 0;
117 _cursorCurFrame = 0;
118 }
119
synchronize(Serializer & s)120 void Scene1337::synchronize(Serializer &s) {
121 _actionCard1->synchronize(s);
122 _actionCard2->synchronize(s);
123 _actionCard3->synchronize(s);
124 _animatedCard.synchronize(s);
125 _shuffleAnimation.synchronize(s);
126 _discardedPlatformCard.synchronize(s);
127 _selectedCard.synchronize(s);
128 _discardPile.synchronize(s);
129 _stockCard.synchronize(s);
130 _aSound1.synchronize(s);
131 _aSound2.synchronize(s);
132 _helpIcon.synchronize(s);
133 _stockPile.synchronize(s);
134 _actionItem.synchronize(s);
135 _currentPlayerArrow.synchronize(s);
136
137 for (int i = 0; i < 4; i++)
138 _gameBoardSide[i].synchronize(s);
139
140 for (int i = 0; i < 8; i++) {
141 _upperDisplayCard[i].synchronize(s);
142 _lowerDisplayCard[i].synchronize(s);
143 }
144
145 // TODO s.syncPointer(_delayedFunction);
146 s.syncAsByte(_autoplay);
147 s.syncAsByte(_shuffleEndedFl);
148 s.syncAsByte(_showPlayerTurn);
149 s.syncAsByte(_displayHelpFl);
150 s.syncAsByte(_instructionsDisplayedFl);
151 s.syncAsSint16LE(_currentDiscardIndex);
152 s.syncAsSint16LE(_cardsAvailableNumb);
153 s.syncAsSint16LE(_currentPlayerNumb);
154 s.syncAsSint16LE(_actionPlayerIdx);
155 s.syncAsSint16LE(_actionVictimIdx);
156 s.syncAsSint16LE(_winnerId);
157 s.syncAsSint16LE(_instructionsWaitCount);
158 s.syncAsSint16LE(_cursorCurRes);
159 s.syncAsSint16LE(_cursorCurStrip);
160 s.syncAsSint16LE(_cursorCurFrame);
161
162 for (int i = 0; i < 100; i++)
163 s.syncAsSint16LE(_availableCardsPile[i]);
164
165 }
166
waitFrames(int32 frameCount)167 void Scene1337::Action1337::waitFrames(int32 frameCount) {
168 uint32 firstFrameNumber = g_globals->_events.getFrameNumber();
169 uint32 curFrame = firstFrameNumber;
170 uint32 destFrame = firstFrameNumber + frameCount;
171
172 while ((curFrame < destFrame) && !g_vm->shouldQuit()) {
173 TsAGE::Event event;
174 g_globals->_events.getEvent(event);
175 curFrame = g_globals->_events.getFrameNumber();
176 }
177
178 // CHECKME: The original is calling _eventManager.waitEvent();
179 }
180
181 /**
182 * Display instructions
183 */
signal()184 void Scene1337::Action1::signal() {
185 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
186
187 switch (_actionIndex++) {
188 case 1: {
189 scene->actionDisplay(1331, 6, 159, 10, 1, 200, 0, 7, 0, 154, 154);
190 R2_GLOBALS._sceneObjects->draw();
191 scene->actionDisplay(1331, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154);
192 scene->actionDisplay(1331, 8, 159, 10, 1, 200, 0, 7, 0, 154, 154);
193
194 scene->_gameBoardSide[1]._outpostStation[0]._cardId = 2;
195 scene->_gameBoardSide[1]._outpostStation[0]._card.postInit();
196 scene->_gameBoardSide[1]._outpostStation[0]._card.setVisage(1332);
197 scene->_gameBoardSide[1]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[1]._outpostStation[0]._stationPos, 0);
198 scene->_gameBoardSide[1]._outpostStation[0]._card.setStrip(2);
199 scene->_gameBoardSide[1]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[1]._outpostStation[0]._cardId);
200 scene->_gameBoardSide[1]._outpostStation[0]._card.fixPriority(170);
201 scene->setAnimationInfo(&scene->_gameBoardSide[1]._outpostStation[0]);
202
203 scene->_gameBoardSide[1]._outpostStation[1]._cardId = 3;
204 scene->_gameBoardSide[1]._outpostStation[1]._card.postInit();
205 scene->_gameBoardSide[1]._outpostStation[1]._card.setVisage(1332);
206 scene->_gameBoardSide[1]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[1]._outpostStation[1]._stationPos, 0);
207 scene->_gameBoardSide[1]._outpostStation[1]._card.setStrip(2);
208 scene->_gameBoardSide[1]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[1]._outpostStation[1]._cardId);
209 scene->_gameBoardSide[1]._outpostStation[1]._card.fixPriority(170);
210 scene->setAnimationInfo(&scene->_gameBoardSide[1]._outpostStation[1]);
211
212 scene->_gameBoardSide[2]._outpostStation[0]._cardId = 4;
213 scene->_gameBoardSide[2]._outpostStation[0]._card.postInit();
214 scene->_gameBoardSide[2]._outpostStation[0]._card.setVisage(1332);
215 scene->_gameBoardSide[2]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[0]._stationPos, 0);
216 scene->_gameBoardSide[2]._outpostStation[0]._card.setStrip(2);
217 scene->_gameBoardSide[2]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[0]._cardId);
218 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[0]);
219
220 scene->_gameBoardSide[3]._outpostStation[0]._cardId = 5;
221 scene->_gameBoardSide[3]._outpostStation[0]._card.postInit();
222 scene->_gameBoardSide[3]._outpostStation[0]._card.setVisage(1332);
223 scene->_gameBoardSide[3]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[0]._stationPos, 0);
224 scene->_gameBoardSide[3]._outpostStation[0]._card.setStrip(2);
225 scene->_gameBoardSide[3]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[0]._cardId);
226 scene->_gameBoardSide[3]._outpostStation[0]._card.fixPriority(170);
227 scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[0]);
228
229 scene->_gameBoardSide[3]._outpostStation[1]._cardId = 6;
230 scene->_gameBoardSide[3]._outpostStation[1]._card.postInit();
231 scene->_gameBoardSide[3]._outpostStation[1]._card.setVisage(1332);
232 scene->_gameBoardSide[3]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[1]._stationPos, 0);
233 scene->_gameBoardSide[3]._outpostStation[1]._card.setStrip(2);
234 scene->_gameBoardSide[3]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[1]._cardId);
235 scene->_gameBoardSide[3]._outpostStation[1]._card.fixPriority(170);
236 scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[1]);
237
238 scene->_gameBoardSide[3]._outpostStation[2]._cardId = 7;
239 scene->_gameBoardSide[3]._outpostStation[2]._card.postInit();
240 scene->_gameBoardSide[3]._outpostStation[2]._card.setVisage(1332);
241 scene->_gameBoardSide[3]._outpostStation[2]._card.setPosition(scene->_gameBoardSide[3]._outpostStation[2]._stationPos, 0);
242 scene->_gameBoardSide[3]._outpostStation[2]._card.setStrip(2);
243 scene->_gameBoardSide[3]._outpostStation[2]._card.setFrame(scene->_gameBoardSide[3]._outpostStation[2]._cardId);
244 scene->_gameBoardSide[3]._outpostStation[2]._card.fixPriority(170);
245 scene->setAnimationInfo(&scene->_gameBoardSide[3]._outpostStation[2]);
246
247 scene->_gameBoardSide[0]._outpostStation[0]._cardId = 8;
248 scene->_gameBoardSide[0]._outpostStation[0]._card.postInit();
249 scene->_gameBoardSide[0]._outpostStation[0]._card.setVisage(1332);
250 scene->_gameBoardSide[0]._outpostStation[0]._card.setPosition(scene->_gameBoardSide[0]._outpostStation[0]._stationPos, 0);
251 scene->_gameBoardSide[0]._outpostStation[0]._card.setStrip(2);
252 scene->_gameBoardSide[0]._outpostStation[0]._card.setFrame(scene->_gameBoardSide[0]._outpostStation[0]._cardId);
253 scene->_gameBoardSide[0]._outpostStation[0]._card.fixPriority(170);
254 scene->setAnimationInfo(&scene->_gameBoardSide[0]._outpostStation[0]);
255
256 scene->_gameBoardSide[0]._outpostStation[1]._cardId = 9;
257 scene->_gameBoardSide[0]._outpostStation[1]._card.postInit();
258 scene->_gameBoardSide[0]._outpostStation[1]._card.setVisage(1332);
259 scene->_gameBoardSide[0]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[0]._outpostStation[1]._stationPos, 0);
260 scene->_gameBoardSide[0]._outpostStation[1]._card.setStrip(2);
261 scene->_gameBoardSide[0]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[0]._outpostStation[1]._cardId);
262 scene->_gameBoardSide[0]._outpostStation[1]._card.fixPriority(170);
263 scene->setAnimationInfo(&scene->_gameBoardSide[0]._outpostStation[1]);
264
265 R2_GLOBALS._sceneObjects->draw();
266
267 waitFrames(60);
268 scene->actionDisplay(1331, 9, 159, 10, 1, 200, 0, 7, 0, 154, 154);
269
270 scene->_gameBoardSide[2]._outpostStation[1]._cardId = 2;
271 scene->_gameBoardSide[2]._outpostStation[1]._card.postInit();
272 scene->_gameBoardSide[2]._outpostStation[1]._card.setVisage(1332);
273 scene->_gameBoardSide[2]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
274 scene->_gameBoardSide[2]._outpostStation[1]._card.setStrip(2);
275 scene->_gameBoardSide[2]._outpostStation[1]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[1]._cardId);
276 scene->_gameBoardSide[2]._outpostStation[1]._card.fixPriority(170);
277 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
278
279 scene->_gameBoardSide[2]._outpostStation[2]._cardId = 3;
280 scene->_gameBoardSide[2]._outpostStation[2]._card.postInit();
281 scene->_gameBoardSide[2]._outpostStation[2]._card.setVisage(1332);
282 scene->_gameBoardSide[2]._outpostStation[2]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[2]._stationPos, 0);
283 scene->_gameBoardSide[2]._outpostStation[2]._card.setStrip(2);
284 scene->_gameBoardSide[2]._outpostStation[2]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[2]._cardId);
285 scene->_gameBoardSide[2]._outpostStation[2]._card.fixPriority(170);
286 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[2]);
287
288 scene->_gameBoardSide[2]._outpostStation[3]._cardId = 5;
289 scene->_gameBoardSide[2]._outpostStation[3]._card.postInit();
290 scene->_gameBoardSide[2]._outpostStation[3]._card.setVisage(1332);
291 scene->_gameBoardSide[2]._outpostStation[3]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[3]._stationPos, 0);
292 scene->_gameBoardSide[2]._outpostStation[3]._card.setStrip(2);
293 scene->_gameBoardSide[2]._outpostStation[3]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[3]._cardId);
294 scene->_gameBoardSide[2]._outpostStation[3]._card.fixPriority(170);
295 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[3]);
296
297 scene->_gameBoardSide[2]._outpostStation[4]._cardId = 6;
298 scene->_gameBoardSide[2]._outpostStation[4]._card.postInit();
299 scene->_gameBoardSide[2]._outpostStation[4]._card.setVisage(1332);
300 scene->_gameBoardSide[2]._outpostStation[4]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[4]._stationPos, 0);
301 scene->_gameBoardSide[2]._outpostStation[4]._card.setStrip(2);
302 scene->_gameBoardSide[2]._outpostStation[4]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[4]._cardId);
303 scene->_gameBoardSide[2]._outpostStation[4]._card.fixPriority(170);
304 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[4]);
305
306 scene->_gameBoardSide[2]._outpostStation[5]._cardId = 7;
307 scene->_gameBoardSide[2]._outpostStation[5]._card.postInit();
308 scene->_gameBoardSide[2]._outpostStation[5]._card.setVisage(1332);
309 scene->_gameBoardSide[2]._outpostStation[5]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[5]._stationPos, 0);
310 scene->_gameBoardSide[2]._outpostStation[5]._card.setStrip(2);
311 scene->_gameBoardSide[2]._outpostStation[5]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[5]._cardId);
312 scene->_gameBoardSide[2]._outpostStation[5]._card.fixPriority(170);
313 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[5]);
314
315 scene->_gameBoardSide[2]._outpostStation[6]._cardId = 8;
316 scene->_gameBoardSide[2]._outpostStation[6]._card.postInit();
317 scene->_gameBoardSide[2]._outpostStation[6]._card.setVisage(1332);
318 scene->_gameBoardSide[2]._outpostStation[6]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[6]._stationPos, 0);
319 scene->_gameBoardSide[2]._outpostStation[6]._card.setStrip(2);
320 scene->_gameBoardSide[2]._outpostStation[6]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[6]._cardId);
321 scene->_gameBoardSide[2]._outpostStation[6]._card.fixPriority(170);
322 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[6]);
323
324 scene->_gameBoardSide[2]._outpostStation[7]._cardId = 9;
325 scene->_gameBoardSide[2]._outpostStation[7]._card.postInit();
326 scene->_gameBoardSide[2]._outpostStation[7]._card.setVisage(1332);
327 scene->_gameBoardSide[2]._outpostStation[7]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[7]._stationPos, 0);
328 scene->_gameBoardSide[2]._outpostStation[7]._card.setStrip(2);
329 scene->_gameBoardSide[2]._outpostStation[7]._card.setFrame(scene->_gameBoardSide[2]._outpostStation[7]._cardId);
330 scene->_gameBoardSide[2]._outpostStation[7]._card.fixPriority(170);
331 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[7]);
332
333 scene->_aSound1.play(62);
334
335 R2_GLOBALS._sceneObjects->draw();
336
337 waitFrames(120);
338 scene->_gameBoardSide[2]._outpostStation[0]._card.remove();
339 scene->_gameBoardSide[2]._outpostStation[1]._card.remove();
340 scene->_gameBoardSide[2]._outpostStation[2]._card.remove();
341 scene->_gameBoardSide[2]._outpostStation[3]._card.remove();
342 scene->_gameBoardSide[2]._outpostStation[4]._card.remove();
343 scene->_gameBoardSide[2]._outpostStation[5]._card.remove();
344 scene->_gameBoardSide[2]._outpostStation[6]._card.remove();
345 scene->_gameBoardSide[2]._outpostStation[7]._card.remove();
346
347 scene->_gameBoardSide[1]._outpostStation[0]._card.remove();
348 scene->_gameBoardSide[1]._outpostStation[1]._card.remove();
349
350 scene->_gameBoardSide[3]._outpostStation[0]._card.remove();
351 scene->_gameBoardSide[3]._outpostStation[1]._card.remove();
352 scene->_gameBoardSide[3]._outpostStation[2]._card.remove();
353
354 scene->_gameBoardSide[0]._outpostStation[0]._card.remove();
355 scene->_gameBoardSide[0]._outpostStation[1]._card.remove();
356
357 scene->_stockPile.setup(1332, 5, 1);
358 scene->_stockPile.setPosition(Common::Point(162, 95));
359 scene->_stockPile.setPriority(110);
360 scene->_stockPile._effect = EFFECT_SHADED;
361 scene->_stockPile.show();
362
363 scene->_gameBoardSide[1]._handCard[0]._card.postInit();
364 scene->_gameBoardSide[1]._handCard[0]._card.setVisage(1332);
365 scene->_gameBoardSide[1]._handCard[0]._card.setPosition(scene->_gameBoardSide[1]._handCard[0]._stationPos, 0);
366 scene->_gameBoardSide[1]._handCard[0]._card.setStrip(1);
367 scene->_gameBoardSide[1]._handCard[0]._card.setFrame(4);
368 scene->_gameBoardSide[1]._handCard[0]._card.fixPriority(170);
369
370 scene->_gameBoardSide[1]._handCard[1]._card.postInit();
371 scene->_gameBoardSide[1]._handCard[1]._card.setVisage(1332);
372 scene->_gameBoardSide[1]._handCard[1]._card.setPosition(scene->_gameBoardSide[1]._handCard[1]._stationPos, 0);
373 scene->_gameBoardSide[1]._handCard[1]._card.setStrip(1);
374 scene->_gameBoardSide[1]._handCard[1]._card.setFrame(4);
375 scene->_gameBoardSide[1]._handCard[1]._card.fixPriority(170);
376
377 scene->_gameBoardSide[1]._handCard[2]._card.postInit();
378 scene->_gameBoardSide[1]._handCard[2]._card.setVisage(1332);
379 scene->_gameBoardSide[1]._handCard[2]._card.setPosition(scene->_gameBoardSide[1]._handCard[2]._stationPos, 0);
380 scene->_gameBoardSide[1]._handCard[2]._card.setStrip(1);
381 scene->_gameBoardSide[1]._handCard[2]._card.setFrame(4);
382 scene->_gameBoardSide[1]._handCard[2]._card.fixPriority(170);
383
384 scene->_gameBoardSide[2]._handCard[0]._cardId = 30;
385 scene->_gameBoardSide[2]._handCard[0]._card.postInit();
386 scene->_gameBoardSide[2]._handCard[0]._card.setVisage(1332);
387 scene->_gameBoardSide[2]._handCard[0]._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
388 scene->_gameBoardSide[2]._handCard[0]._card.setStrip(1);
389 scene->_gameBoardSide[2]._handCard[0]._card.setFrame(2);
390 scene->_gameBoardSide[2]._handCard[0]._card.fixPriority(170);
391 scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[0]);
392
393 scene->_gameBoardSide[2]._handCard[1]._cardId = 16;
394 scene->_gameBoardSide[2]._handCard[1]._card.postInit();
395 scene->_gameBoardSide[2]._handCard[1]._card.setVisage(1332);
396 scene->_gameBoardSide[2]._handCard[1]._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
397 scene->_gameBoardSide[2]._handCard[1]._card.setStrip(1);
398 scene->_gameBoardSide[2]._handCard[1]._card.setFrame(2);
399 scene->_gameBoardSide[2]._handCard[1]._card.fixPriority(170);
400 scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[1]);
401
402 scene->_gameBoardSide[2]._handCard[2]._cardId = 1;
403 scene->_gameBoardSide[2]._handCard[2]._card.postInit();
404 scene->_gameBoardSide[2]._handCard[2]._card.setVisage(1332);
405 scene->_gameBoardSide[2]._handCard[2]._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
406 scene->_gameBoardSide[2]._handCard[2]._card.setStrip(1);
407 scene->_gameBoardSide[2]._handCard[2]._card.setFrame(2);
408 scene->_gameBoardSide[2]._handCard[2]._card.fixPriority(170);
409 scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[2]);
410
411 scene->_gameBoardSide[3]._handCard[0]._card.postInit();
412 scene->_gameBoardSide[3]._handCard[0]._card.setVisage(1332);
413 scene->_gameBoardSide[3]._handCard[0]._card.setPosition(scene->_gameBoardSide[3]._handCard[0]._stationPos, 0);
414 scene->_gameBoardSide[3]._handCard[0]._card.setStrip(1);
415 scene->_gameBoardSide[3]._handCard[0]._card.setFrame(3);
416 scene->_gameBoardSide[3]._handCard[0]._card.fixPriority(170);
417
418 scene->_gameBoardSide[3]._handCard[1]._card.postInit();
419 scene->_gameBoardSide[3]._handCard[1]._card.setVisage(1332);
420 scene->_gameBoardSide[3]._handCard[1]._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos, 0);
421 scene->_gameBoardSide[3]._handCard[1]._card.setStrip(1);
422 scene->_gameBoardSide[3]._handCard[1]._card.setFrame(3);
423 scene->_gameBoardSide[3]._handCard[1]._card.fixPriority(170);
424
425 scene->_gameBoardSide[3]._handCard[2]._card.postInit();
426 scene->_gameBoardSide[3]._handCard[2]._card.setVisage(1332);
427 scene->_gameBoardSide[3]._handCard[2]._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
428 scene->_gameBoardSide[3]._handCard[2]._card.setStrip(1);
429 scene->_gameBoardSide[3]._handCard[2]._card.setFrame(3);
430 scene->_gameBoardSide[3]._handCard[2]._card.fixPriority(170);
431
432 scene->_gameBoardSide[0]._handCard[0]._card.postInit();
433 scene->_gameBoardSide[0]._handCard[0]._card.setVisage(1332);
434 scene->_gameBoardSide[0]._handCard[0]._card.setPosition(scene->_gameBoardSide[0]._handCard[0]._stationPos, 0);
435 scene->_gameBoardSide[0]._handCard[0]._card.setStrip(1);
436 scene->_gameBoardSide[0]._handCard[0]._card.setFrame(2);
437 scene->_gameBoardSide[0]._handCard[0]._card.fixPriority(170);
438
439 scene->_gameBoardSide[0]._handCard[1]._card.postInit();
440 scene->_gameBoardSide[0]._handCard[1]._card.setVisage(1332);
441 scene->_gameBoardSide[0]._handCard[1]._card.setPosition(scene->_gameBoardSide[0]._handCard[1]._stationPos, 0);
442 scene->_gameBoardSide[0]._handCard[1]._card.setStrip(1);
443 scene->_gameBoardSide[0]._handCard[1]._card.setFrame(2);
444 scene->_gameBoardSide[0]._handCard[1]._card.fixPriority(170);
445
446 scene->_gameBoardSide[0]._handCard[2]._card.postInit();
447 scene->_gameBoardSide[0]._handCard[2]._card.setVisage(1332);
448 scene->_gameBoardSide[0]._handCard[2]._card.setPosition(scene->_gameBoardSide[0]._handCard[2]._stationPos, 0);
449 scene->_gameBoardSide[0]._handCard[2]._card.setStrip(1);
450 scene->_gameBoardSide[0]._handCard[2]._card.setFrame(2);
451 scene->_gameBoardSide[0]._handCard[2]._card.fixPriority(170);
452
453 R2_GLOBALS._sceneObjects->draw();
454
455 scene->actionDisplay(1331, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154);
456 scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
457 scene->_animatedCard._card.show();
458 scene->_aSound2.play(61);
459
460 Common::Point pt(91, 174);
461 NpcMover *mover = new NpcMover();
462 scene->_animatedCard._card.addMover(mover, &pt, this);
463 }
464 break;
465 case 2: {
466 scene->_gameBoardSide[2]._handCard[3]._cardId = 2;
467 scene->_gameBoardSide[2]._handCard[3]._card.postInit();
468 scene->_gameBoardSide[2]._handCard[3]._card.setVisage(1332);
469 scene->_gameBoardSide[2]._handCard[3]._card.setPosition(scene->_gameBoardSide[2]._handCard[3]._stationPos, 0);
470 scene->_gameBoardSide[2]._handCard[3]._card.setStrip(1);
471 scene->_gameBoardSide[2]._handCard[3]._card.setFrame(2);
472 scene->_gameBoardSide[2]._handCard[3]._card.fixPriority(170);
473
474 scene->_animatedCard._card.hide();
475 scene->setAnimationInfo(&scene->_gameBoardSide[2]._handCard[3]);
476
477 R2_GLOBALS._sceneObjects->draw();
478
479 waitFrames(60);
480 scene->actionDisplay(1331, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
481 scene->actionDisplay(1331, 12, 159, 10, 1, 200, 0, 7, 0, 154, 154);
482
483 scene->_gameBoardSide[2]._outpostStation[1]._cardId = 1;
484 scene->_gameBoardSide[2]._outpostStation[1]._card.postInit();
485 scene->_gameBoardSide[2]._outpostStation[1]._card.setVisage(1332);
486 scene->_gameBoardSide[2]._outpostStation[1]._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
487 scene->_gameBoardSide[2]._outpostStation[1]._card.hide();
488
489 scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[2]._card._strip);
490 scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._card._frame);
491 scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
492
493 scene->_gameBoardSide[2]._handCard[2]._cardId = 0;
494 scene->_gameBoardSide[2]._handCard[2]._card.remove();
495
496 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
497 scene->_animatedCard._card.show();
498
499 NpcMover *mover = new NpcMover();
500 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._outpostStation[1]._stationPos, this);
501 }
502 break;
503 case 3: {
504 scene->_animatedCard._card.hide();
505 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
506 scene->_aSound1.play(59);
507
508 R2_GLOBALS._sceneObjects->draw();
509
510 waitFrames(60);
511 scene->actionDisplay(1331, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154);
512
513 scene->_gameBoardSide[2]._outpostStation[1]._cardId = scene->_gameBoardSide[2]._handCard[3]._cardId;
514
515 scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[3]._card._strip);
516 scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[3]._card._frame);
517
518 scene->_gameBoardSide[2]._handCard[3]._cardId = 0;
519 scene->_gameBoardSide[2]._handCard[3]._card.remove();
520
521 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[3]._stationPos, 0);
522 scene->_animatedCard._card.show();
523
524 NpcMover *mover = new NpcMover();
525 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._outpostStation[1]._stationPos, this);
526 }
527 break;
528 case 4: {
529 scene->_animatedCard._card.hide();
530 scene->setAnimationInfo(&scene->_gameBoardSide[2]._outpostStation[1]);
531 scene->_aSound1.play(59);
532
533 scene->_discardPile._cardId = 1;
534 scene->_discardPile._card.hide();
535
536 scene->_animatedCard._card.setStrip(5);
537 scene->_animatedCard._card.setFrame(1);
538 scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
539 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._outpostStation[1]._stationPos, 0);
540 scene->_animatedCard._card.show();
541
542 NpcMover *mover = new NpcMover();
543 scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
544 }
545 break;
546 case 5: {
547 scene->_animatedCard._card.hide();
548
549 scene->_discardPile._card.postInit();
550 scene->_discardPile._card.setVisage(1332);
551 scene->_discardPile._card.setPosition(scene->_discardPile._stationPos, 0);
552 scene->setAnimationInfo(&scene->_discardPile);
553 scene->_aSound2.play(61);
554
555 R2_GLOBALS._sceneObjects->draw();
556
557 waitFrames(60);
558 scene->actionDisplay(1331, 14, 159, 10, 1, 200, 0, 7, 0, 154, 154);
559
560 scene->_gameBoardSide[2]._delayCard._card.postInit();
561 scene->_gameBoardSide[2]._delayCard._card.setVisage(1332);
562 scene->_gameBoardSide[2]._delayCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
563 scene->_gameBoardSide[2]._delayCard._card.hide();
564
565 scene->_gameBoardSide[3]._handCard[2]._cardId = 0;
566 scene->_gameBoardSide[3]._handCard[2].remove();
567
568 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
569 scene->_animatedCard._card.show();
570
571 NpcMover *mover = new NpcMover();
572 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
573 }
574 break;
575 case 6: {
576 scene->_animatedCard._card.hide();
577 scene->_gameBoardSide[2]._delayCard._cardId = 21;
578 scene->setAnimationInfo(&scene->_gameBoardSide[2]._delayCard);
579 scene->_aSound1.play(57);
580
581 R2_GLOBALS._sceneObjects->draw();
582
583 waitFrames(60);
584 scene->actionDisplay(1331, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154);
585
586 int tmpVal = 15;
587 int i = -1;
588
589 for (i = 0; i <= 7; i++) {
590 tmpVal += 29;
591
592 scene->_upperDisplayCard[i].postInit();
593 scene->_upperDisplayCard[i].setVisage(1332);
594 scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 90), 0);
595 scene->_upperDisplayCard[i].setStrip(3);
596 scene->_upperDisplayCard[i].fixPriority(190);
597
598 scene->_lowerDisplayCard[i].postInit();
599 scene->_lowerDisplayCard[i].setVisage(1332);
600 scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 90), 0);
601 scene->_lowerDisplayCard[i].setStrip(7);
602 scene->_lowerDisplayCard[i].setFrame(1);
603 scene->_lowerDisplayCard[i].fixPriority(180);
604 }
605
606 scene->_upperDisplayCard[0].setFrame(1);
607 scene->_upperDisplayCard[1].setFrame(3);
608 scene->_upperDisplayCard[2].setFrame(6);
609 scene->_upperDisplayCard[3].setFrame(8);
610 scene->_upperDisplayCard[4].setFrame(9);
611 scene->_upperDisplayCard[5].setFrame(10);
612 scene->_upperDisplayCard[6].setFrame(11);
613 scene->_upperDisplayCard[7].setFrame(12);
614
615 R2_GLOBALS._sceneObjects->draw();
616
617 waitFrames(240);
618
619 scene->_upperDisplayCard[0].remove();
620 scene->_upperDisplayCard[1].remove();
621 scene->_upperDisplayCard[2].remove();
622 scene->_upperDisplayCard[3].remove();
623 scene->_upperDisplayCard[4].remove();
624 scene->_upperDisplayCard[5].remove();
625 scene->_upperDisplayCard[6].remove();
626 scene->_upperDisplayCard[7].remove();
627
628 scene->_lowerDisplayCard[0].remove();
629 scene->_lowerDisplayCard[1].remove();
630 scene->_lowerDisplayCard[2].remove();
631 scene->_lowerDisplayCard[3].remove();
632 scene->_lowerDisplayCard[4].remove();
633 scene->_lowerDisplayCard[5].remove();
634 scene->_lowerDisplayCard[6].remove();
635 scene->_lowerDisplayCard[7].remove();
636
637 scene->_discardPile._cardId = scene->_gameBoardSide[2]._delayCard._cardId;
638
639 scene->_gameBoardSide[2]._delayCard._cardId = 0;
640 scene->_gameBoardSide[2]._delayCard._card.remove();
641
642 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
643 scene->_animatedCard._card.show();
644
645 NpcMover *mover = new NpcMover();
646 scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
647 }
648 break;
649 case 7: {
650 scene->_animatedCard._card.hide();
651 scene->setAnimationInfo(&scene->_discardPile);
652 scene->_aSound2.play(61);
653
654 R2_GLOBALS._sceneObjects->draw();
655
656 scene->_gameBoardSide[2]._delayCard._card.postInit();
657 scene->_gameBoardSide[2]._delayCard._card.setVisage(1332);
658 scene->_gameBoardSide[2]._delayCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
659 scene->_gameBoardSide[2]._delayCard._card.hide();
660
661 scene->_gameBoardSide[3]._handCard[1]._cardId = 0;
662 scene->_gameBoardSide[3]._handCard[1].remove();
663
664 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos, 0);
665 scene->_animatedCard._card.show();
666
667 NpcMover *mover = new NpcMover();
668 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
669 }
670 break;
671 case 8: {
672 scene->_animatedCard._card.hide();
673 scene->_gameBoardSide[2]._delayCard._cardId = 14;
674 scene->setAnimationInfo(&scene->_gameBoardSide[2]._delayCard);
675 scene->_aSound1.play(57);
676
677 R2_GLOBALS._sceneObjects->draw();
678
679 scene->actionDisplay(1331, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154);
680 int tmpVal = 72;
681 int i = -1;
682
683 for (i = 0; i <= 3; i++) {
684 tmpVal += 29;
685 scene->_upperDisplayCard[i].postInit();
686 scene->_upperDisplayCard[i].setVisage(1332);
687 scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 71), 0);
688 scene->_upperDisplayCard[i].setStrip(3);
689 scene->_upperDisplayCard[i].fixPriority(190);
690
691 scene->_lowerDisplayCard[i].postInit();
692 scene->_lowerDisplayCard[i].setVisage(1332);
693 scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 71), 0);
694 scene->_lowerDisplayCard[i].setStrip(7);
695 scene->_lowerDisplayCard[i].setFrame(1);
696 scene->_lowerDisplayCard[i].fixPriority(180);
697 }
698
699 scene->_upperDisplayCard[0].setFrame(2);
700 scene->_upperDisplayCard[1].setFrame(5);
701 scene->_upperDisplayCard[2].setFrame(7);
702 scene->_upperDisplayCard[3].setFrame(15);
703
704 R2_GLOBALS._sceneObjects->draw();
705
706 waitFrames(240);
707 scene->actionDisplay(1331, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154);
708
709 tmpVal = 72;
710 for (i = 4; i <= 7; i++) {
711 tmpVal += 29;
712
713 scene->_upperDisplayCard[i].postInit();
714 scene->_upperDisplayCard[i].setVisage(1332);
715 scene->_upperDisplayCard[i].setPosition(Common::Point(tmpVal, 100), 0);
716 scene->_upperDisplayCard[i].setStrip(4);
717 scene->_upperDisplayCard[i].fixPriority(190);
718
719 scene->_lowerDisplayCard[i].postInit();
720 scene->_lowerDisplayCard[i].setVisage(1332);
721 scene->_lowerDisplayCard[i].setPosition(Common::Point(tmpVal, 100), 0);
722 scene->_lowerDisplayCard[i].setStrip(7);
723 scene->_lowerDisplayCard[i].setFrame(1);
724 scene->_lowerDisplayCard[i].fixPriority(180);
725 }
726
727 scene->_upperDisplayCard[4].setFrame(1);
728 scene->_upperDisplayCard[5].setFrame(5);
729 scene->_upperDisplayCard[6].setFrame(7);
730 scene->_upperDisplayCard[7].setFrame(3);
731
732 R2_GLOBALS._sceneObjects->draw();
733
734 waitFrames(240);
735
736 scene->_upperDisplayCard[0].remove();
737 scene->_upperDisplayCard[1].remove();
738 scene->_upperDisplayCard[2].remove();
739 scene->_upperDisplayCard[3].remove();
740 scene->_upperDisplayCard[4].remove();
741 scene->_upperDisplayCard[5].remove();
742 scene->_upperDisplayCard[6].remove();
743 scene->_upperDisplayCard[7].remove();
744
745 scene->_lowerDisplayCard[0].remove();
746 scene->_lowerDisplayCard[1].remove();
747 scene->_lowerDisplayCard[2].remove();
748 scene->_lowerDisplayCard[3].remove();
749 scene->_lowerDisplayCard[4].remove();
750 scene->_lowerDisplayCard[5].remove();
751 scene->_lowerDisplayCard[6].remove();
752 scene->_lowerDisplayCard[7].remove();
753
754 scene->_discardPile._cardId = scene->_gameBoardSide[2]._handCard[0]._cardId;
755
756 scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[0]._card._strip);
757 scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._card._frame);
758 scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
759
760 scene->_gameBoardSide[2]._handCard[0]._cardId = 0;
761 scene->_gameBoardSide[2]._handCard[0]._card.remove();
762
763 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
764 scene->_animatedCard._card.show();
765
766 NpcMover *mover = new NpcMover();
767 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[2]._delayCard._stationPos, this);
768 }
769 break;
770 case 9: {
771 scene->_aSound1.play(58);
772 scene->_gameBoardSide[2]._delayCard._cardId = 0;
773 scene->_gameBoardSide[2]._delayCard.remove();
774 scene->_animatedCard._card.setStrip(5);
775 scene->_animatedCard._card.setFrame(1);
776 scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
777 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._delayCard._stationPos, 0);
778 scene->_animatedCard._card.show();
779
780 NpcMover *mover = new NpcMover();
781 scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
782 }
783 break;
784 case 10: {
785 scene->_animatedCard._card.hide();
786 scene->setAnimationInfo(&scene->_discardPile);
787 scene->_aSound2.play(61);
788
789 R2_GLOBALS._sceneObjects->draw();
790 scene->actionDisplay(1331, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154);
791
792 scene->_upperDisplayCard[0].postInit();
793 scene->_upperDisplayCard[0].setVisage(1332);
794 scene->_upperDisplayCard[0].setPosition(Common::Point(131, 71), 0);
795 scene->_upperDisplayCard[0].fixPriority(190);
796 scene->_upperDisplayCard[0].setStrip(3);
797 scene->_upperDisplayCard[0].setFrame(4);
798
799 scene->_lowerDisplayCard[0].postInit();
800 scene->_lowerDisplayCard[0].setVisage(1332);
801 scene->_lowerDisplayCard[0].setPosition(Common::Point(131, 71), 0);
802 scene->_lowerDisplayCard[0].setStrip(7);
803 scene->_lowerDisplayCard[0].setFrame(1);
804 scene->_lowerDisplayCard[0].fixPriority(180);
805
806 scene->_upperDisplayCard[1].postInit();
807 scene->_upperDisplayCard[1].setVisage(1332);
808 scene->_upperDisplayCard[1].setPosition(Common::Point(160, 71), 0);
809 scene->_upperDisplayCard[1].fixPriority(190);
810 scene->_upperDisplayCard[1].setStrip(3);
811 scene->_upperDisplayCard[1].setFrame(16);
812
813 scene->_lowerDisplayCard[1].postInit();
814 scene->_lowerDisplayCard[1].setVisage(1332);
815 scene->_lowerDisplayCard[1].setPosition(Common::Point(160, 71), 0);
816 scene->_lowerDisplayCard[1].setStrip(7);
817 scene->_lowerDisplayCard[1].setFrame(1);
818 scene->_lowerDisplayCard[1].fixPriority(180);
819
820 scene->_upperDisplayCard[2].postInit();
821 scene->_upperDisplayCard[2].setVisage(1332);
822 scene->_upperDisplayCard[2].setPosition(Common::Point(131, 100), 0);
823 scene->_upperDisplayCard[2].fixPriority(190);
824 scene->_upperDisplayCard[2].setStrip(4);
825 scene->_upperDisplayCard[2].setFrame(4);
826
827 scene->_lowerDisplayCard[2].postInit();
828 scene->_lowerDisplayCard[2].setVisage(1332);
829 scene->_lowerDisplayCard[2].setPosition(Common::Point(131, 100), 0);
830 scene->_lowerDisplayCard[2].setStrip(7);
831 scene->_lowerDisplayCard[2].setFrame(1);
832 scene->_lowerDisplayCard[2].fixPriority(180);
833
834 scene->_upperDisplayCard[3].postInit();
835 scene->_upperDisplayCard[3].setVisage(1332);
836 scene->_upperDisplayCard[3].setPosition(Common::Point(160, 100), 0);
837 scene->_upperDisplayCard[3].fixPriority(190);
838 scene->_upperDisplayCard[3].setStrip(4);
839 scene->_upperDisplayCard[3].setFrame(2);
840
841 scene->_lowerDisplayCard[3].postInit();
842 scene->_lowerDisplayCard[3].setVisage(1332);
843 scene->_lowerDisplayCard[3].setPosition(Common::Point(160, 100), 0);
844 scene->_lowerDisplayCard[3].setStrip(7);
845 scene->_lowerDisplayCard[3].setFrame(1);
846 scene->_lowerDisplayCard[3].fixPriority(180);
847
848 R2_GLOBALS._sceneObjects->draw();
849
850 waitFrames(240);
851
852 scene->_upperDisplayCard[0].remove();
853 scene->_upperDisplayCard[1].remove();
854 scene->_upperDisplayCard[2].remove();
855 scene->_upperDisplayCard[3].remove();
856
857 scene->_lowerDisplayCard[0].remove();
858 scene->_lowerDisplayCard[1].remove();
859 scene->_lowerDisplayCard[2].remove();
860 scene->_lowerDisplayCard[3].remove();
861
862 scene->_currentPlayerArrow.setFrame(1);
863 scene->_currentPlayerArrow.show();
864 scene->_currentPlayerArrow.animate(ANIM_MODE_2, NULL);
865
866 R2_GLOBALS._sceneObjects->draw();
867
868 scene->actionDisplay(1331, 19, 159, 10, 1, 220, 0, 7, 0, 154, 154);
869
870 scene->_currentPlayerArrow.hide();
871
872 scene->actionDisplay(1331, 20, 159, 10, 1, 220, 0, 7, 0, 154, 154);
873 scene->actionDisplay(1331, 21, 159, 10, 1, 220, 0, 7, 0, 154, 154);
874
875 scene->_discardPile._cardId = scene->_gameBoardSide[2]._handCard[1]._cardId;
876
877 scene->_animatedCard._card.setStrip(scene->_gameBoardSide[2]._handCard[1]._card._strip);
878 scene->_animatedCard._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._card._frame);
879 scene->_animatedCard._card.animate(ANIM_MODE_NONE, NULL);
880
881 scene->_gameBoardSide[2]._handCard[1]._cardId = 0;
882 scene->_gameBoardSide[2]._handCard[1]._card.remove();
883
884 scene->_animatedCard._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
885 scene->_animatedCard._card.show();
886
887 NpcMover *mover = new NpcMover();
888 scene->_animatedCard._card.addMover(mover, &scene->_discardPile._stationPos, this);
889 }
890 break;
891 case 11: {
892 scene->_animatedCard._card.hide();
893 scene->setAnimationInfo(&scene->_discardPile);
894 scene->_aSound2.play(61);
895 scene->_animatedCard._card.setStrip(5);
896 scene->_animatedCard._card.setFrame(1);
897 scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
898
899 R2_GLOBALS._sceneObjects->draw();
900
901 scene->actionDisplay(1331, 22, 159, 10, 1, 200, 0, 7, 0, 154, 154);
902
903 int i = -1;
904 for (i = 0; i <= 3; i ++) {
905 scene->_gameBoardSide[3]._handCard[i]._cardId = 0;
906 scene->_gameBoardSide[3]._handCard[i]._card.remove();
907
908 scene->_gameBoardSide[2]._handCard[i]._cardId = 0;
909 scene->_gameBoardSide[2]._handCard[i]._card.remove();
910
911 scene->_gameBoardSide[0]._handCard[i]._cardId = 0;
912 scene->_gameBoardSide[0]._handCard[i]._card.remove();
913
914 scene->_gameBoardSide[1]._handCard[i]._cardId = 0;
915 scene->_gameBoardSide[1]._handCard[i]._card.remove();
916 }
917
918 for (i = 0; i <= 7; i++) {
919 scene->_gameBoardSide[3]._outpostStation[i]._cardId = 0;
920 scene->_gameBoardSide[3]._outpostStation[i]._card.remove();
921
922 scene->_gameBoardSide[2]._outpostStation[i]._cardId = 0;
923 scene->_gameBoardSide[2]._outpostStation[i]._card.remove();
924
925 scene->_gameBoardSide[0]._outpostStation[i]._cardId = 0;
926 scene->_gameBoardSide[0]._outpostStation[i]._card.remove();
927
928 scene->_gameBoardSide[1]._outpostStation[i]._cardId = 0;
929 scene->_gameBoardSide[1]._outpostStation[i]._card.remove();
930 }
931
932 scene->_gameBoardSide[2]._delayCard._cardId = 0;
933 scene->_gameBoardSide[2]._delayCard._card.remove();
934
935 scene->_discardPile._cardId = 0;
936 scene->_discardPile._card.remove();
937
938 scene->_stockPile.remove();
939 }
940 // fall through
941 case 0:
942 R2_GLOBALS._sceneObjects->draw();
943 signal();
944 break;
945 case 12:
946 scene->suggestInstructions();
947 remove();
948 break;
949 default:
950 break;
951 }
952 }
953
954 /**
955 * Shuffle cards animation
956 */
signal()957 void Scene1337::Action2::signal() {
958 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
959
960 switch (_actionIndex++) {
961 case 0:
962 scene->_shuffleAnimation._card.postInit();
963 scene->_shuffleAnimation._card.setVisage(1332);
964 scene->_shuffleAnimation._card.setStrip(8);
965 scene->_shuffleAnimation._card.setFrame(1);
966 scene->_shuffleAnimation._card.fixPriority(300);
967 scene->_shuffleAnimation._card.setPosition(Common::Point(156, 108));
968
969 scene->_discardPile._card.remove();
970 scene->_discardPile._cardId = 0;
971
972 scene->_aSound1.play(60);
973 scene->_shuffleAnimation._card.animate(ANIM_MODE_5, this);
974 break;
975 case 1:
976 scene->_shuffleAnimation._card.setFrame(1);
977
978 scene->_aSound1.play(60);
979 scene->_shuffleAnimation._card.animate(ANIM_MODE_5, this);
980 break;
981 case 2: {
982 Common::Point pt(156, 108);
983 NpcMover *mover = new NpcMover();
984 scene->_shuffleAnimation._card.addMover(mover, &pt, this);
985 }
986 break;
987 case 3:
988 scene->_shuffleAnimation._card.remove();
989 scene->_stockPile.setup(1332, 5, 1);
990 scene->_stockPile.setPosition(Common::Point(162, 95));
991 scene->_stockPile.setPriority(110);
992 scene->_stockPile._effect = EFFECT_SHADED;
993 scene->_stockPile.show();
994 scene->_shuffleEndedFl = true;
995 break;
996 default:
997 break;
998 }
999 }
1000
1001 /**
1002 * Deal cards
1003 */
signal()1004 void Scene1337::Action3::signal() {
1005 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1006
1007 scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
1008
1009 switch (_actionIndex++) {
1010 case 0: {
1011 scene->_animatedCard._card._moveDiff = Common::Point(30, 30);
1012 scene->_animatedCard._card.setVisage(1332);
1013 scene->_animatedCard._card.setStrip(5);
1014 scene->_animatedCard._card.setFrame(1);
1015 scene->_animatedCard._card.fixPriority(400);
1016 scene->_animatedCard._card.animate(ANIM_MODE_2, NULL);
1017 scene->_aSound2.play(61);
1018
1019 Common::Point pt(283, 146);
1020 NpcMover *mover = new NpcMover();
1021 scene->_animatedCard._card.addMover(mover, &pt, this);
1022
1023 scene->_animatedCard._card.show();
1024 scene->_gameBoardSide[1]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1025 }
1026 break;
1027 case 1: {
1028 scene->_gameBoardSide[1]._handCard[0]._card.postInit();
1029 scene->_gameBoardSide[1]._handCard[0]._card._moveDiff = Common::Point(30, 30);
1030 scene->_gameBoardSide[1]._handCard[0]._card.setVisage(1332);
1031 scene->_gameBoardSide[1]._handCard[0]._card.setPosition(scene->_gameBoardSide[1]._handCard[0]._stationPos, 0);
1032 scene->_gameBoardSide[1]._handCard[0]._card.setStrip(1);
1033 scene->_gameBoardSide[1]._handCard[0]._card.setFrame(4);
1034 scene->_gameBoardSide[1]._handCard[0]._card.fixPriority(170);
1035 scene->_aSound2.play(61);
1036
1037 Common::Point pt(10, 174);
1038 NpcMover *mover = new NpcMover();
1039 scene->_animatedCard._card.addMover(mover, &pt, this);
1040
1041 scene->_gameBoardSide[2]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1042 }
1043 break;
1044 case 2: {
1045 scene->_gameBoardSide[2]._handCard[0]._card.postInit();
1046 scene->_gameBoardSide[2]._handCard[0]._card._moveDiff = Common::Point(30, 30);
1047 scene->_gameBoardSide[2]._handCard[0]._card.setVisage(1332);
1048 scene->_gameBoardSide[2]._handCard[0]._card.setPosition(scene->_gameBoardSide[2]._handCard[0]._stationPos, 0);
1049 scene->_gameBoardSide[2]._handCard[0]._card.fixPriority(170);
1050 if (scene->_gameBoardSide[2]._handCard[0]._cardId > 25) {
1051 scene->_gameBoardSide[2]._handCard[0]._card.setStrip(4);
1052 scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 25);
1053 } else if (scene->_gameBoardSide[2]._handCard[0]._cardId > 9) {
1054 scene->_gameBoardSide[2]._handCard[0]._card.setStrip(3);
1055 scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId - 9);
1056 } else {
1057 scene->_gameBoardSide[2]._handCard[0]._card.setStrip(2);
1058 scene->_gameBoardSide[2]._handCard[0]._card.setFrame(scene->_gameBoardSide[2]._handCard[0]._cardId);
1059 }
1060 scene->_aSound2.play(61);
1061
1062 Common::Point pt(14, 14);
1063 NpcMover *mover = new NpcMover();
1064 scene->_animatedCard._card.addMover(mover, &pt, this);
1065
1066 scene->_gameBoardSide[3]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1067 }
1068 break;
1069 case 3: {
1070 scene->_gameBoardSide[3]._handCard[0]._card.postInit();
1071 scene->_gameBoardSide[3]._handCard[0]._card._moveDiff = Common::Point(30, 30);
1072 scene->_gameBoardSide[3]._handCard[0]._card.setVisage(1332);
1073 scene->_gameBoardSide[3]._handCard[0]._card.setPosition(scene->_gameBoardSide[3]._handCard[0]._stationPos, 0);
1074 scene->_gameBoardSide[3]._handCard[0]._card.setStrip(1);
1075 scene->_gameBoardSide[3]._handCard[0]._card.setFrame(3);
1076 scene->_gameBoardSide[3]._handCard[0]._card.fixPriority(170);
1077 scene->_aSound2.play(61);
1078
1079 Common::Point pt(280, 5);
1080 NpcMover *mover = new NpcMover();
1081 scene->_animatedCard._card.addMover(mover, &pt, this);
1082
1083 scene->_gameBoardSide[0]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1084 }
1085 break;
1086 case 4: {
1087 scene->_gameBoardSide[0]._handCard[0]._card.postInit();
1088 scene->_gameBoardSide[0]._handCard[0]._card._moveDiff = Common::Point(30,30);
1089 scene->_gameBoardSide[0]._handCard[0]._card.setVisage(1332);
1090 scene->_gameBoardSide[0]._handCard[0]._card.setPosition(scene->_gameBoardSide[0]._handCard[0]._stationPos, 0);
1091 scene->_gameBoardSide[0]._handCard[0]._card.setStrip(5);
1092 scene->_gameBoardSide[0]._handCard[0]._card.setFrame(1);
1093 scene->_gameBoardSide[0]._handCard[0]._card.fixPriority(170);
1094 scene->_aSound2.play(61);
1095
1096 Common::Point pt(283, 124);
1097 NpcMover *mover = new NpcMover();
1098 scene->_animatedCard._card.addMover(mover, &pt, this);
1099
1100 scene->_gameBoardSide[1]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1101 }
1102 break;
1103 case 5: {
1104 scene->_gameBoardSide[1]._handCard[1]._card.postInit();
1105 scene->_gameBoardSide[1]._handCard[1]._card._moveDiff = Common::Point(30, 30);
1106 scene->_gameBoardSide[1]._handCard[1]._card.setVisage(1332);
1107 scene->_gameBoardSide[1]._handCard[1]._card.setPosition(scene->_gameBoardSide[1]._handCard[1]._stationPos, 0);
1108 scene->_gameBoardSide[1]._handCard[1]._card.setStrip(1);
1109 scene->_gameBoardSide[1]._handCard[1]._card.setFrame(4);
1110 scene->_gameBoardSide[1]._handCard[1]._card.fixPriority(170);
1111 scene->_aSound2.play(61);
1112
1113 Common::Point pt(37, 174);
1114 NpcMover *mover = new NpcMover();
1115 scene->_animatedCard._card.addMover(mover, &pt, this);
1116
1117 scene->_gameBoardSide[2]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1118 }
1119 break;
1120 case 6: {
1121 scene->_gameBoardSide[2]._handCard[1]._card.postInit();
1122 scene->_gameBoardSide[2]._handCard[1]._card._moveDiff = Common::Point(30, 30);
1123 scene->_gameBoardSide[2]._handCard[1]._card.setVisage(1332);
1124 scene->_gameBoardSide[2]._handCard[1]._card.setPosition(scene->_gameBoardSide[2]._handCard[1]._stationPos, 0);
1125 scene->_gameBoardSide[2]._handCard[1]._card.fixPriority(170);
1126
1127 if (scene->_gameBoardSide[2]._handCard[1]._cardId > 25) {
1128 scene->_gameBoardSide[2]._handCard[1]._card.setStrip(4);
1129 scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 25);
1130 } else if (scene->_gameBoardSide[2]._handCard[1]._cardId > 9) {
1131 scene->_gameBoardSide[2]._handCard[1]._card.setStrip(3);
1132 scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId - 9);
1133 } else {
1134 scene->_gameBoardSide[2]._handCard[1]._card.setStrip(2);
1135 scene->_gameBoardSide[2]._handCard[1]._card.setFrame(scene->_gameBoardSide[2]._handCard[1]._cardId);
1136 }
1137
1138 scene->_aSound2.play(61);
1139
1140 Common::Point pt(14, 36);
1141 NpcMover *mover = new NpcMover();
1142 scene->_animatedCard._card.addMover(mover, &pt, this);
1143
1144 scene->_gameBoardSide[3]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1145 }
1146 break;
1147 case 7: {
1148 scene->_gameBoardSide[3]._handCard[1]._card.postInit();
1149 scene->_gameBoardSide[3]._handCard[1]._card._moveDiff = Common::Point(30, 30);
1150 scene->_gameBoardSide[3]._handCard[1]._card.setVisage(1332);
1151 scene->_gameBoardSide[3]._handCard[1]._card.setPosition(scene->_gameBoardSide[3]._handCard[1]._stationPos);
1152 scene->_gameBoardSide[3]._handCard[1]._card.setStrip(1);
1153 scene->_gameBoardSide[3]._handCard[1]._card.setFrame(3);
1154 scene->_gameBoardSide[3]._handCard[1]._card.fixPriority(170);
1155 scene->_aSound2.play(61);
1156
1157 Common::Point pt(253, 5);
1158 NpcMover *mover = new NpcMover();
1159 scene->_animatedCard._card.addMover(mover, &pt, this);
1160
1161 scene->_gameBoardSide[0]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1162 }
1163 break;
1164 case 8: {
1165 scene->_gameBoardSide[0]._handCard[1]._card.postInit();
1166 scene->_gameBoardSide[0]._handCard[1]._card._moveDiff = Common::Point(30, 30);
1167 scene->_gameBoardSide[0]._handCard[1]._card.setVisage(1332);
1168 scene->_gameBoardSide[0]._handCard[1]._card.setPosition(scene->_gameBoardSide[0]._handCard[1]._stationPos, 0);
1169 scene->_gameBoardSide[0]._handCard[1]._card.setStrip(5);
1170 scene->_gameBoardSide[0]._handCard[1]._card.setFrame(1);
1171 scene->_gameBoardSide[0]._handCard[1]._card.fixPriority(170);
1172 scene->_aSound2.play(61);
1173
1174 Common::Point pt(283, 102);
1175 NpcMover *mover = new NpcMover();
1176 scene->_animatedCard._card.addMover(mover, &pt, this);
1177
1178 scene->_gameBoardSide[1]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1179 }
1180 break;
1181 case 9: {
1182 scene->_gameBoardSide[1]._handCard[2]._card.postInit();
1183 scene->_gameBoardSide[1]._handCard[2]._card._moveDiff = Common::Point(30, 30);
1184 scene->_gameBoardSide[1]._handCard[2]._card.setVisage(1332);
1185 scene->_gameBoardSide[1]._handCard[2]._card.setPosition(scene->_gameBoardSide[1]._handCard[2]._stationPos, 0);
1186 scene->_gameBoardSide[1]._handCard[2]._card.setStrip(1);
1187 scene->_gameBoardSide[1]._handCard[2]._card.setFrame(4);
1188 scene->_gameBoardSide[1]._handCard[2]._card.fixPriority(170);
1189 scene->_aSound2.play(61);
1190
1191 Common::Point pt(64, 174);
1192 NpcMover *mover = new NpcMover();
1193 scene->_animatedCard._card.addMover(mover, &pt, this);
1194
1195 scene->_gameBoardSide[2]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1196 }
1197 break;
1198 case 10: {
1199 scene->_gameBoardSide[2]._handCard[2]._card.postInit();
1200 scene->_gameBoardSide[2]._handCard[2]._card._moveDiff = Common::Point(30, 30);
1201 scene->_gameBoardSide[2]._handCard[2]._card.setVisage(1332);
1202 scene->_gameBoardSide[2]._handCard[2]._card.setPosition(scene->_gameBoardSide[2]._handCard[2]._stationPos, 0);
1203 scene->_gameBoardSide[2]._handCard[2]._card.fixPriority(170);
1204
1205 if (scene->_gameBoardSide[2]._handCard[2]._cardId > 25) {
1206 scene->_gameBoardSide[2]._handCard[2]._card.setStrip(4);
1207 scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 25);
1208 } else if (scene->_gameBoardSide[2]._handCard[2]._cardId > 9) {
1209 scene->_gameBoardSide[2]._handCard[2]._card.setStrip(3);
1210 scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId - 9);
1211 } else {
1212 scene->_gameBoardSide[2]._handCard[2]._card.setStrip(2);
1213 scene->_gameBoardSide[2]._handCard[2]._card.setFrame(scene->_gameBoardSide[2]._handCard[2]._cardId);
1214 }
1215
1216 scene->_aSound2.play(61);
1217
1218 Common::Point pt(14, 58);
1219 NpcMover *mover = new NpcMover();
1220 scene->_animatedCard._card.addMover(mover, &pt, this);
1221
1222 scene->_gameBoardSide[3]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1223 }
1224 break;
1225 case 11: {
1226 scene->_gameBoardSide[3]._handCard[2]._card.postInit();
1227 scene->_gameBoardSide[3]._handCard[2]._card._moveDiff = Common::Point(30, 30);
1228 scene->_gameBoardSide[3]._handCard[2]._card.setVisage(1332);
1229 scene->_gameBoardSide[3]._handCard[2]._card.setPosition(scene->_gameBoardSide[3]._handCard[2]._stationPos, 0);
1230 scene->_gameBoardSide[3]._handCard[2]._card.setStrip(1);
1231 scene->_gameBoardSide[3]._handCard[2]._card.setFrame(3);
1232 scene->_gameBoardSide[3]._handCard[2]._card.fixPriority(170);
1233 scene->_aSound2.play(61);
1234
1235 Common::Point pt(226, 5);
1236 NpcMover *mover = new NpcMover();
1237 scene->_animatedCard._card.addMover(mover, &pt, this);
1238
1239 scene->_gameBoardSide[0]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1240 }
1241 break;
1242 case 12:
1243 scene->_gameBoardSide[0]._handCard[2]._card.postInit();
1244 scene->_gameBoardSide[0]._handCard[2]._card._moveDiff = Common::Point(30, 30);
1245 scene->_gameBoardSide[0]._handCard[2]._card.setVisage(1332);
1246 scene->_gameBoardSide[0]._handCard[2]._card.setPosition(scene->_gameBoardSide[0]._handCard[2]._stationPos, 0);
1247 scene->_gameBoardSide[0]._handCard[2]._card.setStrip(5);
1248 scene->_gameBoardSide[0]._handCard[2]._card.setFrame(1);
1249 scene->_gameBoardSide[0]._handCard[2]._card.fixPriority(170);
1250 scene->_animatedCard._card.hide();
1251 default:
1252 break;
1253 }
1254
1255 if (_actionIndex > 12) {
1256 scene->_currentPlayerNumb = 0;
1257 R2_GLOBALS._sceneObjects->draw();
1258 scene->actionDisplay(1330, 0, 159, 10, 1, 200, 0, 7, 0, 154, 154);
1259 scene->handleNextTurn();
1260 } else if (_actionIndex >= 1) {
1261 scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
1262 scene->_cardsAvailableNumb--;
1263 }
1264 }
1265
1266 /**
1267 * Action used to handle the other players' turn
1268 */
signal()1269 void Scene1337::Action4::signal() {
1270 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1271
1272 switch (_actionIndex++) {
1273 case 0:
1274 if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId == 0)
1275 && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
1276 if (scene->_cardsAvailableNumb < 0)
1277 scene->shuffleCards();
1278 scene->_animatedCard._card.setPosition(Common::Point(162, 95), 0);
1279 scene->_animatedCard._card.show();
1280 scene->_aSound2.play(61);
1281
1282 NpcMover *mover = new NpcMover();
1283 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos, this);
1284
1285 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1286 scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
1287 scene->_cardsAvailableNumb--;
1288
1289 if (scene->_cardsAvailableNumb < 0)
1290 scene->_stockPile.remove();
1291 } else {
1292 // Self call, forcing next actionIndex
1293 signal();
1294 }
1295 break;
1296 case 1:
1297 if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.x)
1298 && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card1Pos.y) ) {
1299 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.postInit();
1300 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card._moveDiff = Common::Point(30, 30);
1301 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setVisage(1332);
1302 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._stationPos, 0);
1303 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setStrip(1);
1304 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
1305 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]._card.fixPriority(170);
1306 }
1307
1308 if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
1309 scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[0]);
1310
1311 scene->_animatedCard._card.hide();
1312 if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._cardId == 0)
1313 && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
1314 if (scene->_cardsAvailableNumb < 0)
1315 scene->shuffleCards();
1316 scene->_animatedCard._card.setPosition(Common::Point(162, 95));
1317 scene->_animatedCard._card.show();
1318
1319 scene->_aSound2.play(61);
1320
1321 NpcMover *mover = new NpcMover();
1322 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos, this);
1323
1324 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1325 scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
1326 scene->_cardsAvailableNumb--;
1327 if (scene->_cardsAvailableNumb < 0)
1328 scene->_stockPile.remove();
1329 } else
1330 signal();
1331 break;
1332 case 2:
1333 if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.x)
1334 && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card2Pos.y) ) {
1335 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.postInit();
1336 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card._moveDiff = Common::Point(30, 30);
1337 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setVisage(1332);
1338 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._stationPos, 0);
1339 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setStrip(1);
1340 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
1341 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]._card.fixPriority(170);
1342 }
1343
1344 if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
1345 scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[1]);
1346
1347 scene->_animatedCard._card.hide();
1348 if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId == 0)
1349 && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
1350 if (scene->_cardsAvailableNumb < 0)
1351 scene->shuffleCards();
1352 scene->_animatedCard._card.setPosition(Common::Point(162, 95));
1353 scene->_animatedCard._card.show();
1354
1355 scene->_aSound2.play(61);
1356
1357 NpcMover *mover = new NpcMover();
1358 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos, this);
1359
1360 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1361 scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
1362 scene->_cardsAvailableNumb--;
1363 if (scene->_cardsAvailableNumb < 0)
1364 scene->_stockPile.remove();
1365 } else
1366 signal();
1367 break;
1368 case 3:
1369 if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.x)
1370 && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card3Pos.y) ) {
1371 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.postInit();
1372 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card._moveDiff = Common::Point(30, 30);
1373 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setVisage(1332);
1374 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._stationPos, 0);
1375 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setStrip(1);
1376 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
1377 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]._card.fixPriority(170);
1378 }
1379
1380 if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
1381 scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[2]);
1382
1383 scene->_animatedCard._card.hide();
1384 if ( (scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId == 0)
1385 && (!scene->isStationCard(scene->_gameBoardSide[scene->_currentPlayerNumb]._delayCard._cardId))) {
1386 if (scene->_cardsAvailableNumb < 0)
1387 scene->shuffleCards();
1388 scene->_animatedCard._card.setPosition(Common::Point(162, 95));
1389 scene->_animatedCard._card.show();
1390
1391 scene->_aSound2.play(61);
1392
1393 NpcMover *mover = new NpcMover();
1394 scene->_animatedCard._card.addMover(mover, &scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos, this);
1395
1396 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._cardId = scene->_availableCardsPile[scene->_cardsAvailableNumb];
1397 scene->_availableCardsPile[scene->_cardsAvailableNumb] = 0;
1398 scene->_cardsAvailableNumb--;
1399 if (scene->_cardsAvailableNumb < 0)
1400 scene->_stockPile.remove();
1401 } else
1402 signal();
1403 break;
1404 case 4:
1405 if ( (scene->_animatedCard._card._position.x == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.x)
1406 && (scene->_animatedCard._card._position.y == scene->_gameBoardSide[scene->_currentPlayerNumb]._card4Pos.y) ) {
1407 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.postInit();
1408 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card._moveDiff = Common::Point(30, 30);
1409 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setVisage(1332);
1410 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setPosition(scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._stationPos, 0);
1411 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setStrip(1);
1412 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.setFrame(scene->_gameBoardSide[scene->_currentPlayerNumb]._frameNum);
1413 scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]._card.fixPriority(170);
1414 }
1415
1416 if ((R2_GLOBALS._debugCardGame) || (scene->_currentPlayerNumb == 2))
1417 scene->setAnimationInfo(&scene->_gameBoardSide[scene->_currentPlayerNumb]._handCard[3]);
1418
1419 scene->_animatedCard._card.hide();
1420 switch (scene->_currentPlayerNumb) {
1421 case 0:
1422 scene->handlePlayer0();
1423 break;
1424 case 1:
1425 scene->handlePlayer1();
1426 break;
1427 case 2:
1428 scene->handleAutoplayPlayer2();
1429 break;
1430 case 3:
1431 scene->handlePlayer3();
1432 break;
1433 default:
1434 break;
1435 }
1436 break;
1437 default:
1438 break;
1439 }
1440 }
1441
1442 /**
1443 * Animations for discarding a card
1444 */
signal()1445 void Scene1337::Action5::signal() {
1446 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1447
1448 switch (_actionIndex++) {
1449 case 0: {
1450 scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard1->_cardId;
1451 scene->_currentDiscardIndex--;
1452 if (!g_globals->_sceneObjects->contains(&scene->_discardPile._card)) {
1453 // The first discarded card makes the pile appear
1454 scene->_discardPile._card.postInit();
1455 scene->_discardPile._card.hide();
1456 scene->_discardPile._card.setVisage(1332);
1457 scene->_discardPile._card.setPosition(scene->_discardPile._stationPos, 0);
1458 scene->_discardPile._card.fixPriority(170);
1459 }
1460
1461 scene->_discardPile._cardId = scene->_actionCard1->_cardId;
1462 scene->_actionCard1->_cardId = 0;
1463 scene->_actionCard1->_card.remove();
1464
1465 if (scene->_actionCard1 == &scene->_selectedCard) {
1466 scene->setCursorData(5, 1, 4);
1467 scene->subC4CEC();
1468 }
1469 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
1470 scene->_animatedCard._card.show();
1471 Common::Point pt(128, 95);
1472 NpcMover *mover = new NpcMover();
1473 scene->_animatedCard._card.addMover(mover, &pt, this);
1474 }
1475 break;
1476 case 1:
1477 scene->_animatedCard._card.hide();
1478 scene->setAnimationInfo(&scene->_discardPile);
1479 scene->_aSound2.play(61);
1480 scene->handleNextTurn();
1481 break;
1482 default:
1483 break;
1484 }
1485 }
1486
1487 /**
1488 * Animations for playing a platform card
1489 */
signal()1490 void Scene1337::Action6::signal() {
1491 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1492
1493 switch (_actionIndex++) {
1494 case 0: {
1495 scene->_actionCard2->_cardId = 1;
1496 scene->_actionCard2->_card.postInit();
1497 scene->_actionCard2->_card.hide();
1498 scene->_actionCard2->_card.setVisage(1332);
1499 scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos);
1500 scene->_actionCard2->_card.fixPriority(170);
1501
1502 scene->_actionCard1->_cardId = 0;
1503 scene->_actionCard1->_card.remove();
1504
1505 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos);
1506 scene->_animatedCard._card.show();
1507
1508 NpcMover *mover = new NpcMover();
1509 scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
1510 }
1511 break;
1512 case 1:
1513 scene->_animatedCard._card.hide();
1514 scene->setAnimationInfo(scene->_actionCard2);
1515 scene->_aSound1.play(59);
1516 if (scene->_actionCard1 == &scene->_selectedCard) {
1517 scene->setCursorData(5, 1, 4);
1518 scene->subC4CEC();
1519 }
1520 scene->handleNextTurn();
1521 break;
1522 default:
1523 break;
1524 }
1525 }
1526
1527 /**
1528 * Upgrade platform to station by playing a station card on top of it
1529 */
signal()1530 void Scene1337::Action7::signal() {
1531 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1532
1533 switch (_actionIndex++) {
1534 case 0: {
1535 scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
1536
1537 scene->_actionCard1->_cardId = 0;
1538 scene->_actionCard1->_card.remove();
1539
1540 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
1541 scene->_animatedCard._card.show();
1542 NpcMover *mover = new NpcMover();
1543 scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
1544 }
1545 break;
1546 case 1:
1547 if (scene->_actionCard1 == &scene->_selectedCard) {
1548 scene->setCursorData(5, 1, 4);
1549 scene->subC4CEC();
1550 }
1551 scene->setAnimationInfo(scene->_actionCard2);
1552 scene->_aSound1.play(59);
1553 scene->_discardedPlatformCard._cardId = 1;
1554 scene->_discardedPlatformCard._stationPos = scene->_actionCard2->_stationPos;
1555 scene->_discardedPlatformCard._card.postInit();
1556 scene->_discardedPlatformCard._card.hide();
1557 scene->_discardedPlatformCard._card._flags = OBJFLAG_HIDING;
1558
1559 scene->discardCard(&scene->_discardedPlatformCard);
1560 break;
1561 default:
1562 break;
1563 }
1564 }
1565
1566 // Remove a delay card
signal()1567 void Scene1337::Action8::signal() {
1568 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1569
1570 switch (_actionIndex++) {
1571 case 0: {
1572 scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
1573 scene->_currentDiscardIndex--;
1574
1575 scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
1576 scene->_actionCard1->_card.remove();
1577
1578 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
1579 scene->_animatedCard._card.show();
1580
1581 NpcMover *mover = new NpcMover();
1582 scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
1583 }
1584 break;
1585 case 1:
1586 scene->_animatedCard._card.hide();
1587
1588 if (scene->_actionCard1 == &scene->_selectedCard) {
1589 scene->setCursorData(5, 1, 4);
1590 scene->subC4CEC();
1591 }
1592 scene->setAnimationInfo(scene->_actionCard2);
1593 scene->_aSound1.play(58);
1594 scene->discardCard(scene->_actionCard2);
1595 break;
1596 default:
1597 break;
1598 }
1599 }
1600
1601 // Play delay card
signal()1602 void Scene1337::Action9::signal() {
1603 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1604
1605 switch (_actionIndex++) {
1606 case 0: {
1607 scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
1608 scene->_actionCard2->_card.postInit();
1609 scene->_actionCard2->_card.hide();
1610 scene->_actionCard2->_card.setVisage(1332);
1611 scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos, 0);
1612 scene->_actionCard2->_card.fixPriority(170);
1613
1614 scene->_actionCard1->_cardId = 0;
1615 scene->_actionCard1->_card.remove();
1616
1617 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
1618 scene->_animatedCard._card.show();
1619
1620 NpcMover *mover = new NpcMover();
1621 scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
1622 }
1623 break;
1624 case 1:
1625 scene->_animatedCard._card.hide();
1626 scene->setAnimationInfo(scene->_actionCard2);
1627 scene->_aSound1.play(57);
1628
1629 if (scene->_actionCard1 == &scene->_selectedCard) {
1630 scene->setCursorData(5, 1, 4);
1631 scene->subC4CEC();
1632 }
1633
1634 scene->handleNextTurn();
1635 break;
1636 default:
1637 break;
1638 }
1639 }
1640
1641 // Play a card on the central outpost.
1642 // This card is either a counter-trick card or a meteor card
signal()1643 void Scene1337::Action10::signal() {
1644 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1645
1646 switch (_actionIndex++) {
1647 case 0: {
1648 scene->_actionCard3->_card.postInit();
1649 scene->_actionCard3->_card.hide();
1650 scene->_actionCard3->_card.setVisage(1332);
1651 scene->_actionCard3->_card.setPosition(scene->_actionCard3->_stationPos, 0);
1652 scene->_actionCard3->_card.fixPriority(170);
1653 scene->_actionCard3->_cardId = scene->_actionCard1->_cardId;
1654
1655 scene->_actionCard1->_cardId = 0;
1656 scene->_actionCard1->_card.remove();
1657
1658 if (scene->_actionCard1 == &scene->_selectedCard) {
1659 scene->setCursorData(5, 1, 4);
1660 scene->subC4CEC();
1661 }
1662
1663 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
1664 scene->_animatedCard._card.show();
1665 NpcMover *mover = new NpcMover();
1666 scene->_animatedCard._card.addMover(mover, &scene->_actionCard3->_stationPos, this);
1667 }
1668 break;
1669 case 1: {
1670 scene->_animatedCard._card.hide();
1671 scene->setAnimationInfo(scene->_actionCard3);
1672 scene->_aSound1.play(57);
1673
1674 bool found = false;
1675 int indexFound = -1;
1676
1677 switch (scene->_actionPlayerIdx) {
1678 case 0:
1679 for (indexFound = 0; indexFound < 3; indexFound++) {
1680 // Check for the presence of an interceptor card
1681 if (scene->_gameBoardSide[0]._handCard[indexFound]._cardId == 29) {
1682 found = true;
1683 break;
1684 }
1685 }
1686 break;
1687 case 1:
1688 for (indexFound = 0; indexFound < 3; indexFound++) {
1689 // Check for the presence of an interceptor card
1690 if (scene->_gameBoardSide[1]._handCard[indexFound]._cardId == 29) {
1691 found = true;
1692 break;
1693 }
1694 }
1695 break;
1696 case 2:
1697 for (indexFound = 0; indexFound < 3; indexFound++) {
1698 // Check for the presence of an interceptor card
1699 if (scene->_gameBoardSide[2]._handCard[indexFound]._cardId == 29) {
1700 found = true;
1701 break;
1702 }
1703 }
1704 break;
1705 case 3:
1706 for (indexFound = 0; indexFound < 3; indexFound++) {
1707 // Check for the presence of an interceptor card
1708 if (scene->_gameBoardSide[3]._handCard[indexFound]._cardId == 29) {
1709 found = true;
1710 break;
1711 }
1712 }
1713 break;
1714 default:
1715 break;
1716 }
1717
1718 bool found2 = false;
1719
1720 if (found) {
1721 switch (scene->_actionPlayerIdx) {
1722 case 0:
1723 scene->playInterceptorCard(&scene->_gameBoardSide[0]._handCard[indexFound], scene->_actionCard3);
1724 found2 = true;
1725 break;
1726 case 1:
1727 scene->playInterceptorCard(&scene->_gameBoardSide[1]._handCard[indexFound], scene->_actionCard3);
1728 found2 = true;
1729 break;
1730 case 2:
1731 scene->subC4CD2();
1732 if (MessageDialog::show(USE_INTERCEPTOR, NO_MSG, YES_MSG) == 0)
1733 scene->subC4CEC();
1734 else {
1735 scene->playInterceptorCard(&scene->_gameBoardSide[2]._handCard[indexFound], scene->_actionCard3);
1736 found2 = true;
1737 }
1738 break;
1739 case 3:
1740 scene->playInterceptorCard(&scene->_gameBoardSide[3]._handCard[indexFound], scene->_actionCard3);
1741 found2 = true;
1742 break;
1743 default:
1744 break;
1745 }
1746 }
1747
1748 if (found2)
1749 break;
1750
1751 if (scene->_actionPlayerIdx == 2) {
1752 int stationCount = 0;
1753 for (int i = 0; i <= 7; i++) {
1754 if (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0)
1755 ++stationCount;
1756 }
1757
1758 if (stationCount <= 1) {
1759 for (int i = 0; i <= 7; i++) {
1760 if (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0) {
1761 scene->_actionCard2 = &scene->_gameBoardSide[2]._outpostStation[i];
1762 break;
1763 }
1764 }
1765 } else {
1766 scene->subC4CD2();
1767
1768 found2 = false;
1769 while (!found2) {
1770 scene->actionDisplay(1330, 130, 159, 10, 1, 200, 0, 7, 0, 154, 154);
1771
1772 // Wait for a mouse or keypress
1773 Event event;
1774 while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
1775 g_globals->_scenePalette.signalListeners();
1776 R2_GLOBALS._sceneObjects->draw();
1777 g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
1778 }
1779
1780 scene->_selectedCard._stationPos = event.mousePos;
1781
1782 for (int i = 0; i <= 7; i++) {
1783 if (scene->_gameBoardSide[2]._outpostStation[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[2]._outpostStation[i]._cardId != 0)) {
1784 scene->_actionCard2 = &scene->_gameBoardSide[2]._outpostStation[i];
1785 found2 = true;
1786 break;
1787 }
1788 }
1789 }
1790 scene->subC4CEC();
1791 }
1792 }
1793
1794 scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
1795 scene->_currentDiscardIndex--;
1796 scene->_actionCard2->_cardId = 0;
1797 scene->_actionCard2->_card.remove();
1798
1799 scene->_animatedCard._card.setPosition(scene->_actionCard2->_stationPos, 0);
1800 scene->_animatedCard._card.show();
1801
1802 NpcMover *mover = new NpcMover();
1803 scene->_animatedCard._card.addMover(mover, &scene->_actionCard3->_stationPos, this);
1804 }
1805 break;
1806 case 2:
1807 scene->_animatedCard._card.hide();
1808 scene->discardCard(scene->_actionCard3);
1809 break;
1810 default:
1811 break;
1812 }
1813 }
1814
1815 // Use Thief card (#25) and pick a card from the opponent
signal()1816 void Scene1337::Action11::signal() {
1817 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
1818
1819 switch (_actionIndex++) {
1820 case 0: {
1821 scene->_actionCard2->_card.postInit();
1822 scene->_actionCard2->_card.hide();
1823 scene->_actionCard2->_card.setVisage(1332);
1824 scene->_actionCard2->_card.setPosition(scene->_actionCard2->_stationPos, 0);
1825 scene->_actionCard2->_card.fixPriority(170);
1826 scene->_actionCard2->_cardId = 25;
1827
1828 if (scene->_actionPlayerIdx == 2) {
1829 scene->_animatedCard._card.setPosition(scene->_actionCard2->_stationPos, 0);
1830 scene->setCursorData(5, 1, 4);
1831 } else {
1832 scene->_actionCard1->_cardId = 0;
1833 scene->_actionCard1->_card.remove();
1834 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
1835 }
1836 scene->_animatedCard._card.show();
1837
1838 NpcMover *mover = new NpcMover();
1839 scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
1840 }
1841 break;
1842 case 1: {
1843 scene->_animatedCard._card.hide();
1844 scene->setAnimationInfo(scene->_actionCard2);
1845 scene->_aSound1.play(57);
1846
1847 bool found = false;
1848 bool noAction = true;
1849
1850 int i = -1;
1851
1852 switch (scene->_actionVictimIdx) {
1853 case 0:
1854 for (i = 0; i <= 3; i++) {
1855 if (scene->_gameBoardSide[0]._handCard[i]._cardId == 27) {
1856 found = true;
1857 break;
1858 }
1859 }
1860
1861 if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
1862 scene->_actionCard1 = &scene->_gameBoardSide[0]._handCard[i];
1863 scene->_actionCard2 = &scene->_gameBoardSide[0]._emptyStationPos;
1864 if (scene->_actionPlayerIdx != 0) {
1865 int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
1866 scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
1867 }
1868 scene->_actionItem.setAction(&scene->_action12);
1869 noAction = false;
1870 }
1871 break;
1872 case 1:
1873 for (i = 0; i <= 3; i++) {
1874 if (scene->_gameBoardSide[1]._handCard[i]._cardId == 27) {
1875 found = true;
1876 break;
1877 }
1878 }
1879
1880 if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
1881 scene->_actionCard1 = &scene->_gameBoardSide[1]._handCard[i];
1882 scene->_actionCard2 = &scene->_gameBoardSide[1]._emptyStationPos;
1883 if (scene->_actionPlayerIdx != 1) {
1884 int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
1885 scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
1886 }
1887 scene->_actionItem.setAction(&scene->_action12);
1888 noAction = false;
1889 }
1890 break;
1891 case 2:
1892 for (i = 0; i <= 3; i++) {
1893 if (scene->_gameBoardSide[2]._handCard[i]._cardId == 27) {
1894 found = true;
1895 break;
1896 }
1897 }
1898
1899 if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
1900 scene->subC4CD2();
1901 if (MessageDialog::show(USE_DOUBLE_AGENT, NO_MSG, YES_MSG) == 0)
1902 scene->subC4CEC();
1903 else {
1904 scene->subC4CEC();
1905 scene->_actionCard1 = &scene->_gameBoardSide[2]._handCard[i];
1906 scene->_actionCard2 = &scene->_gameBoardSide[2]._emptyStationPos;
1907 if (scene->_actionPlayerIdx != 2) {
1908 int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
1909 scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
1910 }
1911 scene->_actionItem.setAction(&scene->_action12);
1912 noAction = false;
1913 }
1914 }
1915 break;
1916 case 3:
1917 for (i = 0; i <= 3; i++) {
1918 if (scene->_gameBoardSide[3]._handCard[i]._cardId == 27) {
1919 found = true;
1920 break;
1921 }
1922 }
1923
1924 if ((found) && (scene->getRandomCardFromHand(scene->_actionPlayerIdx) != -1)) {
1925 scene->_actionCard1 = &scene->_gameBoardSide[3]._handCard[i];
1926 scene->_actionCard2 = &scene->_gameBoardSide[3]._emptyStationPos;
1927 if (scene->_actionPlayerIdx != 3) {
1928 int tmpVal = scene->getRandomCardFromHand(scene->_actionPlayerIdx);
1929 scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionPlayerIdx]._handCard[tmpVal];
1930 }
1931 scene->_actionItem.setAction(&scene->_action12);
1932 noAction = false;
1933 }
1934 break;
1935 default:
1936 break;
1937 }
1938
1939 if (!noAction)
1940 break;
1941
1942 if (scene->_actionPlayerIdx == 2) {
1943 int count = 0;
1944 if (scene->_actionVictimIdx != 2) {
1945 for (i = 0; i <= 3; i++) {
1946 if (scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i]._cardId != 0)
1947 ++count;
1948 }
1949 }
1950
1951 if (count > 1) {
1952 scene->subC4CD2();
1953
1954 found = false;
1955 while (!found) {
1956 switch (scene->_actionVictimIdx) {
1957 case 0:
1958 scene->actionDisplay(1330, 131, 159, 10, 1, 200, 0, 7, 0, 154, 154);
1959 break;
1960 case 1:
1961 scene->actionDisplay(1330, 132, 159, 10, 1, 200, 0, 7, 0, 154, 154);
1962 break;
1963 case 3:
1964 scene->actionDisplay(1330, 133, 159, 10, 1, 200, 0, 7, 0, 154, 154);
1965 break;
1966 default:
1967 break;
1968 }
1969
1970 Event event;
1971 while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
1972 g_globals->_scenePalette.signalListeners();
1973 R2_GLOBALS._sceneObjects->draw();
1974 g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
1975 }
1976
1977 scene->_selectedCard._stationPos = event.mousePos;
1978
1979 found = false;
1980
1981 if (scene->_actionVictimIdx != 2) {
1982 for (i = 0; i <= 3; i++) {
1983 if (scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i]._cardId != 0)) {
1984 scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[i];
1985 found = true;
1986 break;
1987 }
1988 }
1989 }
1990 } // while
1991 scene->_displayHelpFl = true;
1992 scene->subC4CEC();
1993 } else if (scene->_actionVictimIdx != 2) {
1994 int tmpVal = scene->getRandomCardFromHand(scene->_actionVictimIdx);
1995 scene->_actionCard3 = &scene->_gameBoardSide[scene->_actionVictimIdx]._handCard[tmpVal];
1996 }
1997 }
1998
1999 scene->_actionCard1->_card.postInit();
2000 scene->_actionCard1->_card.hide();
2001 scene->_actionCard1->_card.setVisage(1332);
2002 scene->_actionCard1->_card.setPosition(scene->_actionCard1->_stationPos, 0);
2003 scene->_actionCard1->_card.fixPriority(170);
2004 scene->_actionCard1->_card.setStrip2(1);
2005 scene->_actionCard1->_cardId = scene->_actionCard3->_cardId;
2006
2007 scene->_actionCard3->_cardId = 0;
2008 scene->_actionCard3->_card.remove();
2009
2010 scene->_animatedCard._card.setPosition(scene->_actionCard3->_stationPos, 0);
2011 scene->_animatedCard._card.show();
2012
2013 NpcMover *mover = new NpcMover();
2014 scene->_animatedCard._card.addMover(mover, &scene->_actionCard1->_stationPos, this);
2015 }
2016 break;
2017 case 2:
2018 scene->_animatedCard._card.hide();
2019 switch (scene->_actionPlayerIdx) {
2020 case 0:
2021 scene->_actionCard1->_card.setFrame2(2);
2022 scene->_actionCard1->_card.show();
2023 break;
2024 case 1:
2025 scene->_actionCard1->_card.setFrame2(4);
2026 scene->_actionCard1->_card.show();
2027 break;
2028 case 3:
2029 scene->_actionCard1->_card.setFrame2(3);
2030 scene->_actionCard1->_card.show();
2031 break;
2032 default:
2033 scene->setAnimationInfo(scene->_actionCard1);
2034 break;
2035 }
2036
2037 scene->_currentPlayerNumb--;
2038 scene->_showPlayerTurn = false;
2039 scene->discardCard(scene->_actionCard2);
2040 break;
2041 default:
2042 break;
2043 }
2044 }
2045
2046 // Pick a card in opponent hand
signal()2047 void Scene1337::Action12::signal() {
2048 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
2049
2050 switch (_actionIndex++) {
2051 case 0:
2052 signal();
2053 break;
2054 case 1: {
2055 scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
2056 scene->_currentDiscardIndex++;
2057 scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
2058 scene->_actionCard1->_cardId = 0;
2059 scene->_actionCard1->_card.remove();
2060 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
2061 scene->_animatedCard._card.show();
2062
2063 NpcMover *mover = new NpcMover();
2064 scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
2065 }
2066 break;
2067 case 2:
2068 scene->_animatedCard._card.hide();
2069 scene->setAnimationInfo(scene->_actionCard2);
2070 scene->_aSound1.play(58);
2071 if (scene->_actionVictimIdx == 2) {
2072 int count = 0;
2073 int i = -1;
2074 switch (scene->_actionPlayerIdx) {
2075 case 0:
2076 for (i = 0; i <= 3; i++) {
2077 if (scene->_gameBoardSide[0]._handCard[i]._cardId != 0)
2078 ++count;
2079 }
2080 break;
2081 case 1:
2082 for (i = 0; i <= 3; i++) {
2083 // The original game was counting in the hand of player 3, which is obviously wrong
2084 if (scene->_gameBoardSide[1]._handCard[i]._cardId != 0)
2085 ++count;
2086 }
2087 break;
2088 case 3:
2089 for (i = 0; i <= 3; i++) {
2090 if (scene->_gameBoardSide[3]._handCard[i]._cardId != 0)
2091 ++count;
2092 }
2093 break;
2094 default:
2095 break;
2096 }
2097
2098 if (count > 1) {
2099 scene->subC4CD2();
2100
2101 bool found = false;
2102
2103 while (!found) {
2104 switch (scene->_actionPlayerIdx) {
2105 case 0:
2106 scene->actionDisplay(1330, 131, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2107 break;
2108 case 1:
2109 scene->actionDisplay(1330, 132, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2110 break;
2111 case 3:
2112 scene->actionDisplay(1330, 133, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2113 break;
2114 default:
2115 break;
2116 }
2117
2118 Event event;
2119 while (!g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN | EVENT_KEYPRESS) && !g_vm->shouldQuit()) {
2120 g_globals->_scenePalette.signalListeners();
2121 R2_GLOBALS._sceneObjects->draw();
2122 g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
2123 }
2124
2125 scene->_selectedCard._stationPos = event.mousePos;
2126
2127 switch (scene->_actionPlayerIdx) {
2128 case 0:
2129 for (i = 0; i <= 3; i++) {
2130 if (scene->_gameBoardSide[0]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[0]._handCard[i]._cardId != 0)) {
2131 found = true;
2132 scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[i];
2133 break;
2134 }
2135 }
2136 break;
2137 case 1:
2138 for (i = 0; i <= 3; i++) {
2139 if (scene->_gameBoardSide[1]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[1]._handCard[i]._cardId != 0)) {
2140 found = true;
2141 scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[i];
2142 break;
2143 }
2144 }
2145 break;
2146 case 3:
2147 for (i = 0; i <= 3; i++) {
2148 if (scene->_gameBoardSide[3]._handCard[i].isIn(scene->_selectedCard._stationPos) && (scene->_gameBoardSide[3]._handCard[i]._cardId != 0)) {
2149 found = true;
2150 scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[i];
2151 break;
2152 }
2153 }
2154 break;
2155 default:
2156 break;
2157 }
2158 }
2159 scene->subC4CEC();
2160 } else {
2161 switch (scene->_actionPlayerIdx) {
2162 case 0:
2163 scene->_actionCard3 = &scene->_gameBoardSide[0]._handCard[scene->getRandomCardFromHand(0)];
2164 break;
2165 case 1:
2166 scene->_actionCard3 = &scene->_gameBoardSide[1]._handCard[scene->getRandomCardFromHand(1)];
2167 break;
2168 case 3:
2169 scene->_actionCard3 = &scene->_gameBoardSide[3]._handCard[scene->getRandomCardFromHand(3)];
2170 break;
2171 default:
2172 break;
2173 }
2174 }
2175
2176 scene->_actionCard1->_card.postInit();
2177 scene->_actionCard1->_card.hide();
2178 scene->_actionCard1->_card.setVisage(1332);
2179 scene->_actionCard1->_card.setPosition(scene->_actionCard1->_stationPos);
2180 scene->_actionCard1->_card.fixPriority(170);
2181 scene->_actionCard1->_card.setStrip2(1);
2182 scene->_actionCard1->_cardId = scene->_actionCard3->_cardId;
2183
2184 scene->_actionCard3->_cardId = 0;
2185 scene->_actionCard3->_card.remove();
2186
2187 scene->_animatedCard._card.setPosition(scene->_actionCard3->_stationPos);
2188 scene->_animatedCard._card.show();
2189 scene->_aSound1.play(57);
2190
2191 NpcMover *mover = new NpcMover();
2192 scene->_animatedCard._card.addMover(mover, &scene->_actionCard1->_stationPos, this);
2193 }
2194 break;
2195 case 3:
2196 scene->_animatedCard._card.hide();
2197 switch (scene->_actionVictimIdx) {
2198 case 0:
2199 scene->_actionCard1->_card.setFrame2(2);
2200 scene->_actionCard1->_card.show();
2201 break;
2202 case 1:
2203 scene->_actionCard1->_card.setFrame2(4);
2204 scene->_actionCard1->_card.show();
2205 break;
2206 case 3:
2207 scene->_actionCard1->_card.setFrame2(3);
2208 scene->_actionCard1->_card.show();
2209 break;
2210 default:
2211 scene->setAnimationInfo(scene->_actionCard1);
2212 break;
2213 }
2214 scene->discardCard(scene->_actionCard2);
2215 break;
2216 default:
2217 break;
2218 }
2219 }
2220
2221 // Handle the animations of the interceptor card
signal()2222 void Scene1337::Action13::signal() {
2223 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
2224
2225 switch (_actionIndex++) {
2226 case 0: {
2227 scene->_availableCardsPile[scene->_currentDiscardIndex] = scene->_actionCard2->_cardId;
2228 scene->_currentDiscardIndex--;
2229
2230 scene->_actionCard2->_cardId = scene->_actionCard1->_cardId;
2231
2232 scene->_actionCard1->_cardId = 0;
2233 scene->_actionCard1->_card.remove();
2234
2235 scene->_animatedCard._card.setPosition(scene->_actionCard1->_stationPos, 0);
2236 scene->_animatedCard._card.show();
2237
2238 NpcMover *mover = new NpcMover();
2239 scene->_animatedCard._card.addMover(mover, &scene->_actionCard2->_stationPos, this);
2240 }
2241 break;
2242 case 1:
2243 scene->_animatedCard._card.hide();
2244 scene->setAnimationInfo(scene->_actionCard2);
2245 scene->_aSound1.play(58);
2246 signal();
2247 break;
2248 case 2:
2249 scene->discardCard(scene->_actionCard2);
2250 break;
2251 default:
2252 break;
2253 }
2254 }
2255
postInit(SceneObjectList * OwnerList)2256 void Scene1337::postInit(SceneObjectList *OwnerList) {
2257 // In the original, may be found in subPostInit.
2258 // Without it, enableControl asserts
2259 loadScene(1330);
2260 R2_GLOBALS._uiElements._active = false;
2261 SceneExt::postInit();
2262 //
2263
2264 // Hide the user interface
2265 BF_GLOBALS._interfaceY = SCREEN_HEIGHT;
2266 R2_GLOBALS._uiElements._visible = false;
2267
2268 R2_GLOBALS._player.enableControl();
2269 R2_GLOBALS._player._canWalk = false;
2270 R2_GLOBALS._player._uiEnabled = false;
2271
2272 _delayedFunction = nullptr;
2273
2274 _actionCard1 = nullptr;
2275 _actionCard2 = nullptr;
2276 _actionCard3 = nullptr;
2277
2278 _gameBoardSide[2]._handCard[0]._stationPos = Common::Point(10, 174);
2279 _gameBoardSide[2]._handCard[1]._stationPos = Common::Point(37, 174);
2280 _gameBoardSide[2]._handCard[2]._stationPos = Common::Point(64, 174);
2281 _gameBoardSide[2]._handCard[3]._stationPos = Common::Point(91, 174);
2282
2283 _gameBoardSide[2]._outpostStation[0]._stationPos = Common::Point(119, 174);
2284 _gameBoardSide[2]._outpostStation[1]._stationPos = Common::Point(119, 148);
2285 _gameBoardSide[2]._outpostStation[2]._stationPos = Common::Point(119, 122);
2286 _gameBoardSide[2]._outpostStation[3]._stationPos = Common::Point(145, 122);
2287 _gameBoardSide[2]._outpostStation[4]._stationPos = Common::Point(171, 122);
2288 _gameBoardSide[2]._outpostStation[5]._stationPos = Common::Point(171, 148);
2289 _gameBoardSide[2]._outpostStation[6]._stationPos = Common::Point(171, 174);
2290 _gameBoardSide[2]._outpostStation[7]._stationPos = Common::Point(145, 174);
2291
2292 _gameBoardSide[2]._delayCard._stationPos = Common::Point(199, 174);
2293
2294 _gameBoardSide[2]._emptyStationPos._stationPos = Common::Point(145, 148);
2295
2296 _gameBoardSide[2]._card1Pos = Common::Point(10, 174);
2297 _gameBoardSide[2]._card2Pos = Common::Point(37, 174);
2298 _gameBoardSide[2]._card3Pos = Common::Point(64, 174);
2299 _gameBoardSide[2]._card4Pos = Common::Point(91, 174);
2300 _gameBoardSide[2]._frameNum = 2;
2301
2302 _gameBoardSide[3]._handCard[0]._stationPos = Common::Point(14, 14);
2303 _gameBoardSide[3]._handCard[1]._stationPos = Common::Point(14, 36);
2304 _gameBoardSide[3]._handCard[2]._stationPos = Common::Point(14, 58);
2305 _gameBoardSide[3]._handCard[3]._stationPos = Common::Point(14, 80);
2306
2307 _gameBoardSide[3]._outpostStation[0]._stationPos = Common::Point(37, 66);
2308 _gameBoardSide[3]._outpostStation[1]._stationPos = Common::Point(63, 66);
2309 _gameBoardSide[3]._outpostStation[2]._stationPos = Common::Point(89, 66);
2310 _gameBoardSide[3]._outpostStation[3]._stationPos = Common::Point(89, 92);
2311 _gameBoardSide[3]._outpostStation[4]._stationPos = Common::Point(89, 118);
2312 _gameBoardSide[3]._outpostStation[5]._stationPos = Common::Point(63, 118);
2313 _gameBoardSide[3]._outpostStation[6]._stationPos = Common::Point(37, 118);
2314 _gameBoardSide[3]._outpostStation[7]._stationPos = Common::Point(37, 92);
2315
2316 _gameBoardSide[3]._delayCard._stationPos = Common::Point(37, 145);
2317
2318 _gameBoardSide[3]._emptyStationPos._stationPos = Common::Point(63, 92);
2319
2320 _gameBoardSide[3]._card1Pos = Common::Point(14, 14);
2321 _gameBoardSide[3]._card2Pos = Common::Point(14, 36);
2322 _gameBoardSide[3]._card3Pos = Common::Point(14, 58);
2323 _gameBoardSide[3]._card4Pos = Common::Point(14, 80);
2324 _gameBoardSide[3]._frameNum = 3;
2325
2326 _gameBoardSide[0]._handCard[0]._stationPos = Common::Point(280, 5);
2327 _gameBoardSide[0]._handCard[1]._stationPos = Common::Point(253, 5);
2328 _gameBoardSide[0]._handCard[2]._stationPos = Common::Point(226, 5);
2329 _gameBoardSide[0]._handCard[3]._stationPos = Common::Point(199, 5);
2330
2331 _gameBoardSide[0]._outpostStation[0]._stationPos = Common::Point(171, 16);
2332 _gameBoardSide[0]._outpostStation[1]._stationPos = Common::Point(171, 42);
2333 _gameBoardSide[0]._outpostStation[2]._stationPos = Common::Point(171, 68);
2334 _gameBoardSide[0]._outpostStation[3]._stationPos = Common::Point(145, 68);
2335 _gameBoardSide[0]._outpostStation[4]._stationPos = Common::Point(119, 68);
2336 _gameBoardSide[0]._outpostStation[5]._stationPos = Common::Point(119, 42);
2337 _gameBoardSide[0]._outpostStation[6]._stationPos = Common::Point(119, 16);
2338 _gameBoardSide[0]._outpostStation[7]._stationPos = Common::Point(145, 16);
2339
2340 _gameBoardSide[0]._delayCard._stationPos = Common::Point(91, 16);
2341
2342 _gameBoardSide[0]._emptyStationPos._stationPos = Common::Point(145, 42);
2343
2344 _gameBoardSide[0]._card1Pos = Common::Point(280, 5);
2345 _gameBoardSide[0]._card2Pos = Common::Point(253, 5);
2346 _gameBoardSide[0]._card3Pos = Common::Point(226, 5);
2347 _gameBoardSide[0]._card4Pos = Common::Point(199, 5);
2348 _gameBoardSide[0]._frameNum = 2;
2349
2350 _gameBoardSide[1]._handCard[0]._stationPos = Common::Point(283, 146);
2351 _gameBoardSide[1]._handCard[1]._stationPos = Common::Point(283, 124);
2352 _gameBoardSide[1]._handCard[2]._stationPos = Common::Point(283, 102);
2353 _gameBoardSide[1]._handCard[3]._stationPos = Common::Point(283, 80);
2354
2355 _gameBoardSide[1]._outpostStation[0]._stationPos = Common::Point(253, 122);
2356 _gameBoardSide[1]._outpostStation[1]._stationPos = Common::Point(227, 122);
2357 _gameBoardSide[1]._outpostStation[2]._stationPos = Common::Point(201, 122);
2358 _gameBoardSide[1]._outpostStation[3]._stationPos = Common::Point(201, 96);
2359 _gameBoardSide[1]._outpostStation[4]._stationPos = Common::Point(201, 70);
2360 _gameBoardSide[1]._outpostStation[5]._stationPos = Common::Point(227, 70);
2361 _gameBoardSide[1]._outpostStation[6]._stationPos = Common::Point(253, 70);
2362 _gameBoardSide[1]._outpostStation[7]._stationPos = Common::Point(253, 96);
2363
2364 _gameBoardSide[1]._delayCard._stationPos = Common::Point(253, 43);
2365
2366 _gameBoardSide[1]._emptyStationPos._stationPos = Common::Point(227, 96);
2367
2368 _gameBoardSide[1]._card1Pos = Common::Point(283, 146);
2369 _gameBoardSide[1]._card2Pos = Common::Point(283, 124);
2370 _gameBoardSide[1]._card3Pos = Common::Point(283, 102);
2371 _gameBoardSide[1]._card4Pos = Common::Point(283, 80);
2372 _gameBoardSide[1]._frameNum = 4;
2373
2374 subPostInit();
2375
2376 _stockPile.postInit();
2377 }
2378
remove()2379 void Scene1337::remove() {
2380 if (R2_GLOBALS._v57709 > 1) {
2381 subD1917();
2382 subD1940(false);
2383 }
2384
2385 R2_GLOBALS._uiElements._active = true;
2386 R2_GLOBALS._uiElements._visible = true;
2387 SceneExt::remove();
2388 }
2389
process(Event & event)2390 void Scene1337::process(Event &event) {
2391 if (event.eventType == EVENT_BUTTON_DOWN) {
2392 if (event.btnState == BTNSHIFT_RIGHT) {
2393 updateCursorId(R2_GLOBALS._mouseCursorId, true);
2394 event.handled = true;
2395 } else if (_delayedFunction) {
2396 FunctionPtrType tmpFctPtr = _delayedFunction;
2397 _delayedFunction = nullptr;
2398 (this->*tmpFctPtr)();
2399 event.handled = true;
2400 }
2401 } else if (event.eventType == EVENT_KEYPRESS) {
2402 if (event.kbd.keycode == Common::KEYCODE_SPACE) {
2403 if (_delayedFunction) {
2404 FunctionPtrType tmpFctPtr = _delayedFunction;
2405 _delayedFunction = nullptr;
2406 (this->*tmpFctPtr)();
2407 event.handled = true;
2408 }
2409 } else
2410 warning("Fixme: Find proper keycode value");
2411 }
2412
2413 if (!event.handled)
2414 Scene::process(event);
2415 }
2416
dispatch()2417 void Scene1337::dispatch() {
2418 if (!_instructionsDisplayedFl) {
2419 ++_instructionsWaitCount;
2420 if (_instructionsWaitCount == 4) {
2421 _instructionsDisplayedFl = true;
2422 suggestInstructions();
2423 }
2424 }
2425
2426 // The following code is in the original in sceneHandler::process(),
2427 // which is terrible as it's checked in every scene of the game.
2428 setCursorData(5, _cursorCurStrip, _cursorCurFrame);
2429 //
2430
2431 Scene::dispatch();
2432 }
2433
actionDisplay(int resNum,int lineNum,int x,int y,int keepOnScreen,int width,int textMode,int fontNum,int colFG,int colBGExt,int colFGExt)2434 void Scene1337::actionDisplay(int resNum, int lineNum, int x, int y, int keepOnScreen, int width, int textMode, int fontNum, int colFG, int colBGExt, int colFGExt) {
2435 // TODO: Check if it's normal that arg5 is unused and replaced by an hardcoded 0 value
2436 // May hide an original bug
2437
2438 SceneItem::display(resNum, lineNum, SET_X, x, SET_Y, y, SET_KEEP_ONSCREEN, 0,
2439 SET_WIDTH, width, SET_POS_MODE, -1, SET_TEXT_MODE, textMode,
2440 SET_FONT, fontNum, SET_FG_COLOR, colFG, SET_EXT_BGCOLOR, colBGExt,
2441 SET_EXT_FGCOLOR, colFGExt, LIST_END);
2442 }
2443
setAnimationInfo(Card * card)2444 void Scene1337::setAnimationInfo(Card *card) {
2445 if (!card)
2446 return;
2447
2448 if (card->_cardId > 25) {
2449 card->_card.setStrip2(4);
2450 card->_card.setFrame(card->_cardId - 25);
2451 } else if (card->_cardId > 9) {
2452 card->_card.setStrip2(3);
2453 card->_card.setFrame(card->_cardId - 9);
2454 } else {
2455 card->_card.setStrip2(2);
2456 card->_card.setFrame(card->_cardId);
2457 }
2458
2459 card->_card.show();
2460 R2_GLOBALS._sceneObjects->draw();
2461 }
2462
handleNextTurn()2463 void Scene1337::handleNextTurn() {
2464 switch (_winnerId) {
2465 case -1:
2466 ++_currentPlayerNumb;
2467 if (_currentPlayerNumb > 3)
2468 _currentPlayerNumb = 0;
2469
2470 if (_showPlayerTurn) {
2471 _currentPlayerArrow.show();
2472 switch (_currentPlayerNumb) {
2473 case 0:
2474 _currentPlayerArrow.setStrip(3);
2475 break;
2476 case 1:
2477 _currentPlayerArrow.setStrip(4);
2478 break;
2479 case 2:
2480 subD1975(174, 107);
2481 _currentPlayerArrow.setStrip(1);
2482 break;
2483 case 3:
2484 subC4CEC();
2485 _currentPlayerArrow.setStrip(2);
2486 break;
2487 default:
2488 break;
2489 }
2490
2491 if (!_autoplay)
2492 _delayedFunction = &Scene1337::handlePlayerTurn;
2493 else
2494 handlePlayerTurn();
2495 } else {
2496 handlePlayerTurn();
2497 }
2498 break;
2499 case 0:
2500 _aSound2.play(62);
2501 actionDisplay(1330, 135, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2502 actionDisplay(1330, 121, 20, 99, 1, 136, 0, 7, 0, 172, 172);
2503 actionDisplay(1330, 122, 300, 99, 1, 136, 0, 7, 0, 117, 117);
2504 R2_GLOBALS._sceneObjects->draw();
2505 actionDisplay(1330, 123, 159, 134, 1, 200, 0, 7, 0, 105, 105);
2506 break;
2507 case 1:
2508 _aSound2.play(62);
2509 actionDisplay(1330, 151, 300, 99, 1, 136, 0, 7, 0, 117, 117);
2510 actionDisplay(1330, 118, 20, 99, 1, 136, 0, 7, 0, 172, 172);
2511 actionDisplay(1330, 119, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2512 R2_GLOBALS._sceneObjects->draw();
2513 actionDisplay(1330, 120, 159, 134, 1, 200, 0, 7, 0, 105, 105);
2514 break;
2515 case 2:
2516 _aSound2.play(62);
2517 actionDisplay(1330, 134, 159, 134, 1, 200, 0, 7, 0, 105, 105);
2518 actionDisplay(1330, 124, 20, 99, 1, 136, 0, 7, 0, 172, 172);
2519 actionDisplay(1330, 126, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2520 R2_GLOBALS._sceneObjects->draw();
2521 actionDisplay(1330, 125, 300, 99, 1, 136, 0, 7, 0, 117, 117);
2522 break;
2523 case 3:
2524 _aSound2.play(62);
2525 actionDisplay(1330, 150, 20, 99, 1, 136, 0, 7, 0, 172, 172);
2526 actionDisplay(1330, 115, 300, 99, 1, 136, 0, 7, 0, 117, 117);
2527 actionDisplay(1330, 116, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2528 R2_GLOBALS._sceneObjects->draw();
2529 actionDisplay(1330, 117, 159, 134, 1, 200, 0, 7, 0, 105, 105);
2530 break;
2531 default:
2532 break;
2533 }
2534
2535 if (_winnerId != -1)
2536 R2_GLOBALS._sceneManager.changeScene(125);
2537
2538 }
2539
handlePlayerTurn()2540 void Scene1337::handlePlayerTurn() {
2541 if (_showPlayerTurn)
2542 _currentPlayerArrow.hide();
2543
2544 switch (_currentPlayerNumb) {
2545 case 2:
2546 subC4CD2();
2547 if (_displayHelpFl)
2548 actionDisplay(1330, 114, 159, 10, 1, 200, 0, 7, 0, 154, 154);
2549 _displayHelpFl = false;
2550 // fall through
2551 case 0:
2552 // fall through
2553 case 1:
2554 // fall through
2555 case 3:
2556 _actionItem.setAction(&_action4);
2557 default:
2558 break;
2559 }
2560
2561 _showPlayerTurn = true;
2562
2563 }
2564
isStationCard(int cardId)2565 bool Scene1337::isStationCard(int cardId) {
2566 switch (cardId) {
2567 case 10:
2568 // No break on purpose
2569 case 12:
2570 // No break on purpose
2571 case 15:
2572 // No break on purpose
2573 case 17:
2574 // No break on purpose
2575 case 18:
2576 // No break on purpose
2577 case 19:
2578 // No break on purpose
2579 case 20:
2580 // No break on purpose
2581 case 21:
2582 return true;
2583 default:
2584 return false;
2585 }
2586 }
2587
isStopConstructionCard(int cardId)2588 bool Scene1337::isStopConstructionCard(int cardId) {
2589 switch (cardId) {
2590 case 11:
2591 // No break on purpose
2592 case 14:
2593 // No break on purpose
2594 case 16:
2595 // No break on purpose
2596 case 24:
2597 return true;
2598 default:
2599 return false;
2600 }
2601 }
2602
getStationId(int playerId,int handCardId)2603 int Scene1337::getStationId(int playerId, int handCardId) {
2604 if ((_gameBoardSide[playerId]._handCard[handCardId]._cardId > 1) && (_gameBoardSide[playerId]._handCard[handCardId]._cardId <= 9))
2605 return handCardId;
2606
2607 return -1;
2608 }
2609
findPlatformCardInHand(int playerId)2610 int Scene1337::findPlatformCardInHand(int playerId) {
2611 for (int i = 0; i <= 3; i++) {
2612 if (_gameBoardSide[playerId]._handCard[i]._cardId == 1)
2613 return i;
2614 }
2615
2616 return -1;
2617 }
2618
findMeteorCardInHand(int playerId)2619 int Scene1337::findMeteorCardInHand(int playerId) {
2620 for (int i = 0; i <= 3; i++) {
2621 if (_gameBoardSide[playerId]._handCard[i]._cardId == 13)
2622 return i;
2623 }
2624
2625 return -1;
2626 }
2627
findThieftCardInHand(int playerId)2628 int Scene1337::findThieftCardInHand(int playerId) {
2629 for (int i = 0; i <= 3; i++) {
2630 if (_gameBoardSide[playerId]._handCard[i]._cardId == 25)
2631 return i;
2632 }
2633
2634 return -1;
2635 }
2636
isDelayCard(int cardId)2637 int Scene1337::isDelayCard(int cardId) {
2638 switch (cardId) {
2639 case 11:
2640 // No break on purpose
2641 case 14:
2642 // No break on purpose
2643 case 16:
2644 // No break on purpose
2645 case 24:
2646 return cardId;
2647 break;
2648 default:
2649 return -1;
2650 break;
2651 }
2652 }
2653
getStationCardId(int cardId)2654 int Scene1337::getStationCardId(int cardId) {
2655 switch (cardId) {
2656 case 10:
2657 // No break on purpose
2658 case 12:
2659 // No break on purpose
2660 case 15:
2661 // No break on purpose
2662 case 17:
2663 // No break on purpose
2664 case 18:
2665 // No break on purpose
2666 case 19:
2667 // No break on purpose
2668 case 20:
2669 // No break on purpose
2670 case 21:
2671 return cardId;
2672 default:
2673 return -1;
2674 }
2675 }
2676
handlePlayer01Discard(int playerId)2677 void Scene1337::handlePlayer01Discard(int playerId) {
2678 switch (playerId) {
2679 case 0:
2680 for (int i = 0; i <= 3; i++) {
2681 if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
2682 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2683 return;
2684 }
2685 }
2686
2687 for (int i = 0; i <= 3; i++) {
2688 if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
2689 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2690 return;
2691 }
2692 }
2693
2694 for (int i = 0; i <= 3; i++) {
2695 // Outpost Card
2696 if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) {
2697 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2698 return;
2699 }
2700 }
2701
2702 for (int i = 0; i <= 3; i++) {
2703 if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) {
2704 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2705 return;
2706 }
2707 }
2708
2709 for (int i = 0; i <= 3; i++) {
2710 // Station Card
2711 if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) {
2712 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2713 return;
2714 }
2715 }
2716
2717 for (int i = 0; i <= 3; i++) {
2718 // Thief card
2719 if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) {
2720 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2721 return;
2722 }
2723 }
2724
2725 for (int i = 0; i <= 3; i++) {
2726 // Meteor Card
2727 if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) {
2728 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2729 return;
2730 }
2731 }
2732 break;
2733 case 1:
2734 for (int i = 0; i <= 3; i++) {
2735 if ((_gameBoardSide[playerId]._handCard[i]._cardId >= 26) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 33)) {
2736 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2737 return;
2738 }
2739 }
2740
2741 for (int i = 0; i <= 3; i++) {
2742 // Station Card
2743 if (_gameBoardSide[playerId]._handCard[i]._cardId == 1) {
2744 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2745 return;
2746 }
2747 }
2748
2749 for (int i = 0; i <= 3; i++) {
2750 // Outpost Card
2751 if ((_gameBoardSide[playerId]._handCard[i]._cardId > 1) && (_gameBoardSide[playerId]._handCard[i]._cardId <= 9)) {
2752 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2753 return;
2754 }
2755 }
2756
2757 for (int i = 0; i <= 3; i++) {
2758 if (getStationCardId(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
2759 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2760 return;
2761 }
2762 }
2763
2764 for (int i = 0; i <= 3; i++) {
2765 if (isDelayCard(_gameBoardSide[playerId]._handCard[i]._cardId) != -1) {
2766 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2767 return;
2768 }
2769 }
2770
2771 for (int i = 0; i <= 3; i++) {
2772 // Thief card
2773 if (_gameBoardSide[playerId]._handCard[i]._cardId == 25) {
2774 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2775 return;
2776 }
2777 }
2778
2779 for (int i = 0; i <= 3; i++) {
2780 // Meteor Card
2781 if (_gameBoardSide[playerId]._handCard[i]._cardId == 13) {
2782 discardCard(&_gameBoardSide[playerId]._handCard[i]);
2783 return;
2784 }
2785 }
2786
2787 break;
2788 default:
2789 break;
2790 }
2791 }
2792
playThieftCard(int playerId,Card * card,int victimId)2793 void Scene1337::playThieftCard(int playerId, Card *card, int victimId) {
2794 _actionPlayerIdx = playerId;
2795 _actionVictimIdx = victimId;
2796
2797 int randIndx;
2798
2799 for (;;) {
2800 randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
2801 if (_gameBoardSide[victimId]._handCard[randIndx]._cardId != 0)
2802 break;
2803 }
2804
2805 _actionCard1 = card;
2806 _actionCard2 = &_gameBoardSide[victimId]._emptyStationPos;
2807 _actionCard3 = &_gameBoardSide[victimId]._handCard[randIndx];
2808
2809 _actionItem.setAction(&_action11);
2810 }
2811
getPreventionCardId(int cardId)2812 int Scene1337::getPreventionCardId(int cardId) {
2813 int retVal;
2814
2815 switch (cardId) {
2816 case 10:
2817 retVal = 2;
2818 break;
2819 case 12:
2820 retVal = 3;
2821 break;
2822 case 15:
2823 retVal = 5;
2824 break;
2825 case 17:
2826 retVal = 9;
2827 break;
2828 case 18:
2829 retVal = 6;
2830 break;
2831 case 19:
2832 retVal = 4;
2833 break;
2834 case 20:
2835 retVal = 8;
2836 break;
2837 case 21:
2838 retVal = 7;
2839 break;
2840 default:
2841 retVal = -1;
2842 }
2843
2844 return retVal;
2845 }
2846
isAttackPossible(int victimId,int cardId)2847 bool Scene1337::isAttackPossible(int victimId, int cardId) {
2848 if (victimId < 0 || victimId >= ARRAYSIZE(_gameBoardSide))
2849 error("Scene1337::isAttackPossible() victimId:%d out of range 0 to %d", victimId, ARRAYSIZE(_gameBoardSide)-1);
2850
2851 for (int i = 0; i <= 7; i++) {
2852 if (_gameBoardSide[victimId]._outpostStation[i]._cardId != 0) {
2853 if (getPreventionCardId(cardId) == _gameBoardSide[victimId]._outpostStation[i]._cardId)
2854 return false;
2855 }
2856 }
2857 return true;
2858 }
2859
getPlayerWithOutpost(int playerId)2860 int Scene1337::getPlayerWithOutpost(int playerId) {
2861 int randPlayerId = R2_GLOBALS._randomSource.getRandomNumber(3);
2862
2863 for (int i = 0; i <= 3; i++) {
2864 if (randPlayerId != playerId) {
2865 for (int j = 0; j <= 7; j++) {
2866 if (_gameBoardSide[randPlayerId]._outpostStation[j]._cardId != 0)
2867 return randPlayerId;
2868 }
2869 }
2870
2871 if (playerId == 1) {
2872 randPlayerId--;
2873 if (randPlayerId < 0)
2874 randPlayerId = 3;
2875 } else {
2876 ++randPlayerId;
2877 if (randPlayerId > 3)
2878 randPlayerId = 0;
2879 }
2880 }
2881
2882 return -1;
2883 }
2884
checkAntiDelayCard(int delayCardId,int cardId)2885 bool Scene1337::checkAntiDelayCard(int delayCardId, int cardId) {
2886 if ((delayCardId == 11) && (cardId == 26)) // Diplomacy
2887 return true;
2888
2889 if ((delayCardId == 14) && (cardId == 30)) // Cure
2890 return true;
2891
2892 if ((delayCardId == 16) && (cardId == 32)) // Agreement
2893 return true;
2894
2895 if ((delayCardId == 24) && (cardId == 28)) // Innovation
2896 return true;
2897
2898 return false;
2899 }
2900
playStationCard(Card * station,Card * platform)2901 void Scene1337::playStationCard(Card *station, Card *platform) {
2902 _actionCard1 = station;
2903 _actionCard2 = platform;
2904 _actionItem.setAction(&_action7);
2905 }
2906
getRandomCardFromHand(int playerId)2907 int Scene1337::getRandomCardFromHand(int playerId) {
2908 if ( (_gameBoardSide[playerId]._handCard[0]._cardId == 0)
2909 && (_gameBoardSide[playerId]._handCard[1]._cardId == 0)
2910 && (_gameBoardSide[playerId]._handCard[2]._cardId == 0)
2911 && (_gameBoardSide[playerId]._handCard[3]._cardId == 0))
2912 return -1;
2913
2914 int randIndx;
2915 for (;;) {
2916 randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
2917 if (_gameBoardSide[playerId]._handCard[randIndx]._cardId != 0)
2918 break;
2919 }
2920
2921 return randIndx;
2922 }
2923
playPlatformCard(Card * card,Card * dest)2924 void Scene1337::playPlatformCard(Card *card, Card *dest) {
2925 _actionCard1 = card;
2926 _actionCard2 = dest;
2927
2928 _actionItem.setAction(&_action6);
2929 }
2930
playDelayCard(Card * card,Card * dest)2931 void Scene1337::playDelayCard(Card *card, Card *dest) {
2932 _actionCard1 = card;
2933 _actionCard2 = dest;
2934
2935 _actionItem.setAction(&_action9);
2936 }
2937
playAntiDelayCard(Card * card,Card * dest)2938 void Scene1337::playAntiDelayCard(Card *card, Card *dest) {
2939 _actionCard1 = card;
2940 _actionCard2 = dest;
2941
2942 _actionItem.setAction(&_action8);
2943
2944 // WORKAROUND: Restore the default cursor and for a call to signal.
2945 // This works around the cursor caching we got rid of, and avoid
2946 // the game ends in an eternal loop when a player reacts to another player
2947 // attack.
2948 setCursorData(5, 1, 4);
2949 signal();
2950 }
2951
2952
getStationCard(int playerId)2953 Scene1337::Card *Scene1337::getStationCard(int playerId) {
2954 for (int i = 0; i <= 7; i++) {
2955 if ((_gameBoardSide[playerId]._outpostStation[i]._cardId >= 1) && (_gameBoardSide[playerId]._outpostStation[i]._cardId <= 9))
2956 return &_gameBoardSide[playerId]._outpostStation[i];
2957 }
2958
2959 return nullptr;
2960 }
2961
playCentralOutpostCard(Card * card,int playerId)2962 void Scene1337::playCentralOutpostCard(Card *card, int playerId) {
2963 _actionCard1 = card;
2964 _actionCard2 = getStationCard(playerId);
2965 _actionCard3 = &_gameBoardSide[playerId]._emptyStationPos;
2966 _actionPlayerIdx = playerId;
2967 _actionItem.setAction(&_action10);
2968 }
2969
discardCard(Card * card)2970 void Scene1337::discardCard(Card *card) {
2971 _actionCard1 = card;
2972
2973 _actionItem.setAction(&_action5);
2974 }
2975
subC4CD2()2976 void Scene1337::subC4CD2() {
2977 if (R2_GLOBALS._v57709 > 0) {
2978 subD1917();
2979 subD1940(false); // _v5780C--
2980 }
2981 }
2982
subC4CEC()2983 void Scene1337::subC4CEC() {
2984 if (R2_GLOBALS._v57709 == 0) {
2985 subD18F5();
2986 subD1940(true); // _v5780C++
2987 }
2988 }
2989
2990 // Play Interceptor card
playInterceptorCard(Card * subObj1,Card * subObj2)2991 void Scene1337::playInterceptorCard(Card *subObj1, Card *subObj2) {
2992 _actionCard1 = subObj1;
2993 _actionCard2 = subObj2;
2994
2995 _actionItem.setAction(&_action13);
2996 }
2997
displayDialog(int dialogNumb)2998 void Scene1337::displayDialog(int dialogNumb) {
2999 switch (dialogNumb - 1) {
3000 case 0:
3001 actionDisplay(1330, 53, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3002 break;
3003 case 1:
3004 actionDisplay(1330, 57, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3005 break;
3006 case 2:
3007 actionDisplay(1330, 58, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3008 break;
3009 case 3:
3010 actionDisplay(1330, 59, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3011 break;
3012 case 4:
3013 actionDisplay(1330, 60, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3014 break;
3015 case 5:
3016 actionDisplay(1330, 61, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3017 break;
3018 case 6:
3019 actionDisplay(1330, 62, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3020 break;
3021 case 7:
3022 actionDisplay(1330, 63, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3023 break;
3024 case 8:
3025 actionDisplay(1330, 64, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3026 break;
3027 case 9:
3028 actionDisplay(1330, 65, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3029 break;
3030 case 10:
3031 actionDisplay(1330, 67, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3032 break;
3033 case 11:
3034 actionDisplay(1330, 69, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3035 break;
3036 case 12:
3037 actionDisplay(1330, 71, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3038 actionDisplay(1330, 72, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3039 actionDisplay(1330, 73, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3040 break;
3041 case 13:
3042 actionDisplay(1330, 79, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3043 break;
3044 case 14:
3045 actionDisplay(1330, 81, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3046 break;
3047 case 15:
3048 actionDisplay(1330, 83, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3049 break;
3050 case 16:
3051 actionDisplay(1330, 85, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3052 break;
3053 case 17:
3054 actionDisplay(1330, 87, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3055 break;
3056 case 18:
3057 actionDisplay(1330, 89, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3058 break;
3059 case 19:
3060 actionDisplay(1330, 91, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3061 break;
3062 case 20:
3063 actionDisplay(1330, 93, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3064 break;
3065 case 23:
3066 actionDisplay(1330, 95, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3067 break;
3068 case 24:
3069 actionDisplay(1330, 97, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3070 break;
3071 case 25:
3072 actionDisplay(1330, 104, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3073 break;
3074 case 26:
3075 actionDisplay(1330, 105, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3076 actionDisplay(1330, 106, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3077 break;
3078 case 27:
3079 actionDisplay(1330, 110, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3080 break;
3081 case 28:
3082 actionDisplay(1330, 108, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3083 actionDisplay(1330, 109, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3084 break;
3085 case 29:
3086 actionDisplay(1330, 111, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3087 break;
3088 case 31:
3089 actionDisplay(1330, 112, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3090 break;
3091 default:
3092 break;
3093 }
3094 }
3095
subPostInit()3096 void Scene1337::subPostInit() {
3097 R2_GLOBALS._v57709 = 0;
3098 R2_GLOBALS._v5780C = 0;
3099 updateCursorId(1, false);
3100 subD1940(true); // _v5780C++
3101 subD18F5();
3102
3103 // loadScene(1330);
3104 // SceneExt::postInit();
3105
3106 R2_GLOBALS._scenePalette.addRotation(224, 235, 1);
3107
3108 _availableCardsPile[0] = 1;
3109 _availableCardsPile[1] = 1;
3110 _availableCardsPile[2] = 1;
3111 _availableCardsPile[3] = 1;
3112 _availableCardsPile[4] = 1;
3113 _availableCardsPile[5] = 1;
3114 _availableCardsPile[6] = 1;
3115 _availableCardsPile[7] = 1;
3116 _availableCardsPile[8] = 26;
3117 _availableCardsPile[9] = 2;
3118 _availableCardsPile[10] = 2;
3119 _availableCardsPile[11] = 2;
3120 _availableCardsPile[12] = 2;
3121 _availableCardsPile[13] = 2;
3122 _availableCardsPile[14] = 26;
3123 _availableCardsPile[15] = 3;
3124 _availableCardsPile[16] = 3;
3125 _availableCardsPile[17] = 3;
3126 _availableCardsPile[18] = 3;
3127 _availableCardsPile[19] = 3;
3128 _availableCardsPile[20] = 28;
3129 _availableCardsPile[21] = 4;
3130 _availableCardsPile[22] = 4;
3131 _availableCardsPile[23] = 4;
3132 _availableCardsPile[24] = 4;
3133 _availableCardsPile[25] = 4;
3134 _availableCardsPile[26] = 28;
3135 _availableCardsPile[27] = 5;
3136 _availableCardsPile[28] = 5;
3137 _availableCardsPile[29] = 5;
3138 _availableCardsPile[30] = 5;
3139 _availableCardsPile[31] = 5;
3140 _availableCardsPile[32] = 30;
3141 _availableCardsPile[33] = 6;
3142 _availableCardsPile[34] = 6;
3143 _availableCardsPile[35] = 6;
3144 _availableCardsPile[36] = 6;
3145 _availableCardsPile[37] = 6;
3146 _availableCardsPile[38] = 30;
3147 _availableCardsPile[39] = 7;
3148 _availableCardsPile[40] = 7;
3149 _availableCardsPile[41] = 7;
3150 _availableCardsPile[42] = 7;
3151 _availableCardsPile[43] = 7;
3152 _availableCardsPile[44] = 32;
3153 _availableCardsPile[45] = 8;
3154 _availableCardsPile[46] = 8;
3155 _availableCardsPile[47] = 8;
3156 _availableCardsPile[48] = 8;
3157 _availableCardsPile[49] = 8;
3158 _availableCardsPile[50] = 32;
3159 _availableCardsPile[51] = 9;
3160 _availableCardsPile[52] = 9;
3161 _availableCardsPile[53] = 9;
3162 _availableCardsPile[54] = 9;
3163 _availableCardsPile[55] = 9;
3164 _availableCardsPile[56] = 10;
3165 _availableCardsPile[57] = 11;
3166 _availableCardsPile[58] = 12;
3167 _availableCardsPile[59] = 13;
3168 _availableCardsPile[60] = 13;
3169 _availableCardsPile[61] = 14;
3170 _availableCardsPile[62] = 15;
3171 _availableCardsPile[63] = 16;
3172 _availableCardsPile[64] = 17;
3173 _availableCardsPile[65] = 18;
3174 _availableCardsPile[66] = 19;
3175 _availableCardsPile[67] = 20;
3176 _availableCardsPile[68] = 21;
3177 _availableCardsPile[69] = 26;
3178 _availableCardsPile[70] = 28;
3179 _availableCardsPile[71] = 24;
3180 _availableCardsPile[72] = 25;
3181 _availableCardsPile[73] = 25;
3182 _availableCardsPile[74] = 25;
3183 _availableCardsPile[75] = 25;
3184 _availableCardsPile[76] = 26;
3185 _availableCardsPile[77] = 26;
3186 _availableCardsPile[78] = 26;
3187 _availableCardsPile[79] = 27;
3188 _availableCardsPile[80] = 27;
3189 _availableCardsPile[81] = 28;
3190 _availableCardsPile[82] = 28;
3191 _availableCardsPile[83] = 28;
3192 _availableCardsPile[84] = 29;
3193 _availableCardsPile[85] = 29;
3194 _availableCardsPile[86] = 29;
3195 _availableCardsPile[87] = 30;
3196 _availableCardsPile[88] = 30;
3197 _availableCardsPile[89] = 30;
3198 _availableCardsPile[90] = 30;
3199 _availableCardsPile[91] = 32;
3200 _availableCardsPile[92] = 1;
3201 _availableCardsPile[93] = 32;
3202 _availableCardsPile[94] = 32;
3203 _availableCardsPile[95] = 32;
3204 _availableCardsPile[96] = 1;
3205 _availableCardsPile[97] = 1;
3206 _availableCardsPile[98] = 1;
3207 _availableCardsPile[99] = 0;
3208
3209 _cardsAvailableNumb = 98;
3210 _currentDiscardIndex = 98; // CHECKME: Would make more sense at pos 99
3211
3212 _discardPile._cardId = 0;
3213 _discardPile._stationPos = Common::Point(128, 95);
3214
3215 _stockCard._cardId = 0;
3216 _stockCard._stationPos = Common::Point(162, 95);
3217
3218 _selectedCard._cardId = 0;
3219
3220 _animatedCard._card.postInit();
3221 _animatedCard._card.setVisage(1332);
3222 _animatedCard._card.setStrip(5);
3223 _animatedCard._card.setFrame(1);
3224 _animatedCard._card._moveDiff = Common::Point(10, 10);
3225 _animatedCard._card.fixPriority(400);
3226 _animatedCard._card.setPosition(Common::Point(128, 95), 0);
3227 _animatedCard._card.animate(ANIM_MODE_2, NULL);
3228 _animatedCard._card.hide();
3229
3230 _currentPlayerArrow.postInit();
3231 _currentPlayerArrow.setVisage(1334);
3232 _currentPlayerArrow.setStrip(1);
3233 _currentPlayerArrow.setFrame(1);
3234 _currentPlayerArrow._numFrames = 12;
3235 _currentPlayerArrow.fixPriority(500);
3236 _currentPlayerArrow.setPosition(Common::Point(174, 107), 0);
3237 _currentPlayerArrow.animate(ANIM_MODE_2, NULL);
3238 _currentPlayerArrow.hide();
3239
3240 _showPlayerTurn = true;
3241 _displayHelpFl = false;
3242 _winnerId = -1;
3243
3244 _helpIcon.postInit();
3245 _helpIcon.setup(9531, 1, 1);
3246 _helpIcon.setPosition(Common::Point(249, 168));
3247 _helpIcon.setPriority(155);
3248 _helpIcon._effect = EFFECT_NONE;
3249 _helpIcon.show();
3250
3251 _autoplay = false;
3252 _instructionsDisplayedFl = false;
3253 _instructionsWaitCount = 0;
3254 }
3255
suggestInstructions()3256 void Scene1337::suggestInstructions() {
3257 if (R2_GLOBALS._v57709 > 0)
3258 subD1917();
3259
3260 if (MessageDialog::show(NEED_INSTRUCTIONS, NO_MSG, YES_MSG) == 0) {
3261 if (R2_GLOBALS._v57709 == 0)
3262 subD18F5();
3263 dealCards();
3264 } else {
3265 if (R2_GLOBALS._v57709 == 0)
3266 subD18F5();
3267 displayInstructions();
3268 }
3269 }
3270
displayInstructions()3271 void Scene1337::displayInstructions() {
3272 _actionItem.setAction(&_action1);
3273 }
3274
shuffleCards()3275 void Scene1337::shuffleCards() {
3276 R2_GLOBALS._sceneObjects->draw();
3277
3278 // Remove holes in card pile
3279 for (int i = 0; i <= 98; i++) {
3280 if (_availableCardsPile[i] == 0) {
3281 for (int j = i + 1; j <= 98; j ++) {
3282 if (_availableCardsPile[j] != 0) {
3283 _availableCardsPile[i] = _availableCardsPile[j];
3284 _availableCardsPile[j] = 0;
3285 break;
3286 }
3287 }
3288 }
3289 }
3290
3291 // Compute the number of available cards
3292 for (int i = 0; i <= 99; i ++) {
3293 if (_availableCardsPile[i] == 0) {
3294 // CHECKME: This will fail if i == 0, which shouldn't happen
3295 // as we don't shuffle cards when no card is available.
3296 _cardsAvailableNumb = i - 1;
3297 _currentDiscardIndex = 98; // CHECKME: Would make more sense at pos 99
3298 break;
3299 }
3300 }
3301
3302 for (int i = 0; i < 2000; i ++) {
3303 int randIndx = R2_GLOBALS._randomSource.getRandomNumber(_cardsAvailableNumb);
3304 int swap = _availableCardsPile[0];
3305 _availableCardsPile[0] = _availableCardsPile[randIndx];
3306 _availableCardsPile[randIndx] = swap;
3307 }
3308
3309 _shuffleEndedFl = false;
3310
3311 // Shuffle cards
3312 _animatedCard._card.setAction(&_action2);
3313
3314 while(!_shuffleEndedFl && !g_vm->shouldQuit()) {
3315 g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject);
3316 g_globals->_scenePalette.signalListeners();
3317 R2_GLOBALS._sceneObjects->draw();
3318 g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
3319 }
3320 }
3321
dealCards()3322 void Scene1337::dealCards() {
3323 _animatedCard._card._moveDiff = Common::Point(30, 30);
3324 shuffleCards();
3325
3326 // Deal cards
3327 _actionItem.setAction(&_action3);
3328 }
3329
showOptionsDialog()3330 void Scene1337::showOptionsDialog() {
3331 // Display menu with "Auto Play", "New Game", "Quit" and "Continue"
3332 OptionsDialog::show();
3333 }
3334
handleClick(int arg1,Common::Point pt)3335 void Scene1337::handleClick(int arg1, Common::Point pt) {
3336 int curReg = R2_GLOBALS._sceneRegions.indexOf(g_globals->_events._mousePos);
3337
3338 if (arg1 == 3) {
3339 bool found = false;
3340 int i;
3341 for (i = 0; i <= 7; i++) {
3342 if ( _gameBoardSide[2]._outpostStation[i].isIn(pt)
3343 || _gameBoardSide[0]._outpostStation[i].isIn(pt)
3344 || _gameBoardSide[1]._outpostStation[i].isIn(pt)
3345 || _gameBoardSide[3]._outpostStation[i].isIn(pt) ) {
3346 found = true;
3347 break;
3348 }
3349 }
3350
3351 if (found) {
3352 switch (curReg) {
3353 case 5:
3354 if (_gameBoardSide[2]._outpostStation[i]._cardId != 0)
3355 displayDialog(_gameBoardSide[2]._outpostStation[i]._cardId);
3356 else
3357 actionDisplay(1330, 20, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3358 break;
3359 case 10:
3360 if (_gameBoardSide[3]._outpostStation[i]._cardId != 0)
3361 displayDialog(_gameBoardSide[3]._outpostStation[i]._cardId);
3362 else
3363 actionDisplay(1330, 22, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3364 break;
3365 case 15:
3366 if (_gameBoardSide[0]._outpostStation[i]._cardId != 0)
3367 displayDialog(_gameBoardSide[0]._outpostStation[i]._cardId);
3368 else
3369 actionDisplay(1330, 21, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3370 break;
3371 case 20:
3372 if (_gameBoardSide[1]._outpostStation[i]._cardId != 0)
3373 displayDialog(_gameBoardSide[1]._outpostStation[i]._cardId);
3374 else
3375 actionDisplay(1330, 23, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3376 break;
3377 default:
3378 break;
3379 }
3380 } else if ( _gameBoardSide[2]._delayCard.isIn(pt)
3381 || _gameBoardSide[0]._delayCard.isIn(pt)
3382 || _gameBoardSide[1]._delayCard.isIn(pt)
3383 || _gameBoardSide[3]._delayCard.isIn(pt) ) {
3384 switch (curReg) {
3385 case 5:
3386 if (_gameBoardSide[2]._delayCard._cardId != 0)
3387 displayDialog(_gameBoardSide[2]._delayCard._cardId);
3388 else
3389 actionDisplay(1330, 10, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3390 break;
3391 case 10:
3392 if (_gameBoardSide[3]._delayCard._cardId != 0)
3393 displayDialog(_gameBoardSide[3]._delayCard._cardId);
3394 else
3395 actionDisplay(1330, 16, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3396 break;
3397 case 15:
3398 if (_gameBoardSide[0]._delayCard._cardId != 0)
3399 displayDialog(_gameBoardSide[0]._delayCard._cardId);
3400 else
3401 actionDisplay(1330, 13, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3402 break;
3403 case 20:
3404 if (_gameBoardSide[1]._delayCard._cardId != 0)
3405 displayDialog(_gameBoardSide[1]._delayCard._cardId);
3406 else
3407 actionDisplay(1330, 18, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3408 break;
3409 default:
3410 break;
3411 }
3412 } else if (_discardPile.isIn(pt)) {
3413 if (_discardPile._cardId != 0)
3414 displayDialog(_discardPile._cardId);
3415 else
3416 actionDisplay(1330, 7, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3417 } else if (_helpIcon._bounds.contains(pt))
3418 actionDisplay(1330, 43, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3419 else if (_stockCard.isIn(pt))
3420 actionDisplay(1330, 4, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3421 else if ( (_gameBoardSide[2]._emptyStationPos.isIn(pt))
3422 || (_gameBoardSide[3]._emptyStationPos.isIn(pt))
3423 || (_gameBoardSide[0]._emptyStationPos.isIn(pt))
3424 || (_gameBoardSide[1]._emptyStationPos.isIn(pt)) )
3425 actionDisplay(1330, 32, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3426 else if (_gameBoardSide[2]._handCard[0].isIn(pt))
3427 displayDialog(_gameBoardSide[2]._handCard[0]._cardId);
3428 else if (_gameBoardSide[2]._handCard[1].isIn(pt))
3429 displayDialog(_gameBoardSide[2]._handCard[1]._cardId);
3430 else if (_gameBoardSide[2]._handCard[2].isIn(pt))
3431 displayDialog(_gameBoardSide[2]._handCard[2]._cardId);
3432 else if (_gameBoardSide[2]._handCard[3].isIn(pt))
3433 displayDialog(_gameBoardSide[2]._handCard[3]._cardId);
3434 else if ((curReg >= 6) && (curReg <= 9))
3435 actionDisplay(1330, 29, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3436 else if ((curReg >= 11) && (curReg <= 14))
3437 actionDisplay(1330, 31, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3438 else if ((curReg >= 16) && (curReg <= 19))
3439 actionDisplay(1330, 30, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3440 else {
3441 switch (curReg) {
3442 case 0:
3443 actionDisplay(1330, 2, 159, 134, 1, 200, 0, 7, 0, 105, 105);
3444 break;
3445 case 5:
3446 actionDisplay(1330, 25, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3447 break;
3448 case 10:
3449 actionDisplay(1330, 27, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3450 break;
3451 case 15:
3452 actionDisplay(1330, 26, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3453 break;
3454 case 20:
3455 actionDisplay(1330, 28, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3456 break;
3457 case 21:
3458 actionDisplay(1330, 24, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3459 break;
3460 default:
3461 break;
3462 }
3463 }
3464 }
3465
3466 if (arg1 != 1)
3467 return;
3468
3469 for (int i = 0; i <= 7; i++) {
3470 if (_gameBoardSide[2]._outpostStation[i].isIn(pt)) {
3471 switch (_gameBoardSide[2]._outpostStation[i]._cardId) {
3472 case 0:
3473 actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3474 break;
3475 case 1:
3476 actionDisplay(1330, 54, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3477 break;
3478 default:
3479 actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3480 break;
3481 }
3482 return;
3483 }
3484 if (_gameBoardSide[0]._outpostStation[i].isIn(pt)) {
3485 switch (_gameBoardSide[0]._outpostStation[i]._cardId) {
3486 case 0:
3487 actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3488 break;
3489 default:
3490 actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3491 break;
3492 }
3493 return;
3494 }
3495 if (_gameBoardSide[1]._outpostStation[i].isIn(pt)) {
3496 switch (_gameBoardSide[1]._outpostStation[i]._cardId) {
3497 case 0:
3498 actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
3499 break;
3500 default:
3501 actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
3502 break;
3503 }
3504 return;
3505 }
3506 if (_gameBoardSide[3]._outpostStation[i].isIn(pt)) {
3507 switch (_gameBoardSide[3]._outpostStation[i]._cardId) {
3508 case 0:
3509 actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
3510 break;
3511 default:
3512 actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
3513 break;
3514 }
3515 return;
3516 }
3517 }
3518
3519 if (_gameBoardSide[2]._delayCard.isIn(pt)) {
3520 // The original uses _gameBoardSide[0], which is obviously a bug.
3521 if (_gameBoardSide[2]._delayCard._cardId != 0)
3522 actionDisplay(1330, 39, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3523 else
3524 actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3525
3526 return;
3527 }
3528 if (_gameBoardSide[3]._delayCard.isIn(pt)) {
3529 if (_gameBoardSide[3]._delayCard._cardId != 0)
3530 actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
3531 else
3532 actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
3533
3534 return;
3535 }
3536 if (_gameBoardSide[1]._delayCard.isIn(pt)) {
3537 if (_gameBoardSide[1]._delayCard._cardId != 0)
3538 actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
3539 else
3540 actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
3541
3542 return;
3543 }
3544 if (_gameBoardSide[0]._delayCard.isIn(pt)) {
3545 if (_gameBoardSide[0]._delayCard._cardId != 0)
3546 actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3547 else
3548 actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3549
3550 return;
3551 }
3552 if (_gameBoardSide[3]._emptyStationPos.isIn(pt)) {
3553 actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
3554 return;
3555 }
3556 if (_gameBoardSide[1]._emptyStationPos.isIn(pt)) {
3557 actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
3558 return;
3559 }
3560 if (_gameBoardSide[0]._emptyStationPos.isIn(pt)) {
3561 actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3562 return;
3563 }
3564
3565 if (_helpIcon._bounds.contains(pt)) {
3566 showOptionsDialog();
3567 return;
3568 }
3569
3570 if (_discardPile.isIn(pt))
3571 actionDisplay(1330, 9, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3572 else if (_stockCard.isIn(pt))
3573 actionDisplay(1330, 5, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3574 else {
3575 switch (curReg) {
3576 case 0:
3577 actionDisplay(1330, 3, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3578 break;
3579 case 6:
3580 // no break on purpose
3581 case 7:
3582 // no break on purpose
3583 case 8:
3584 // no break on purpose
3585 case 9:
3586 actionDisplay(1330, 145, 20, 99, 1, 136, 0, 7, 0, 172, 172);
3587 break;
3588 case 10:
3589 actionDisplay(1330, 147, 20, 99, 1, 136, 0, 7, 0, 172, 172);
3590 break;
3591 case 11:
3592 // no break on purpose
3593 case 12:
3594 // no break on purpose
3595 case 13:
3596 // no break on purpose
3597 case 14:
3598 actionDisplay(1330, 1, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3599 break;
3600 case 16:
3601 // no break on purpose
3602 case 17:
3603 // no break on purpose
3604 case 18:
3605 // no break on purpose
3606 case 19:
3607 actionDisplay(1330, 144, 300, 99, 1, 136, 0, 7, 0, 117, 117);
3608 break;
3609 case 20:
3610 actionDisplay(1330, 146, 300, 99, 1, 136, 0, 7, 0, 117, 117);
3611 break;
3612 default:
3613 actionDisplay(1330, 11, 159, 10, 1, 200, 0, 7, 0, 154, 154);
3614 break;
3615 }
3616 }
3617 }
3618
handlePlayer0()3619 void Scene1337::handlePlayer0() {
3620 if (_gameBoardSide[0]._delayCard._cardId != 0) {
3621 switch (_gameBoardSide[0]._delayCard._cardId) {
3622 case 10:
3623 //No break on purpose
3624 case 12:
3625 //No break on purpose
3626 case 15:
3627 //No break on purpose
3628 case 17:
3629 //No break on purpose
3630 case 18:
3631 //No break on purpose
3632 case 19:
3633 //No break on purpose
3634 case 20:
3635 //No break on purpose
3636 case 21:
3637 discardCard(&_gameBoardSide[0]._delayCard);
3638 return;
3639 default:
3640 for (int i = 0; i <= 3; i++) {
3641 if (checkAntiDelayCard(_gameBoardSide[0]._delayCard._cardId, _gameBoardSide[0]._handCard[i]._cardId)) {
3642 playAntiDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[0]._delayCard);
3643 return;
3644 }
3645 }
3646
3647 break;
3648 }
3649 }
3650
3651 for (int i = 0; i <= 3; i++) {
3652 int tmpVal = getStationId(0, i);
3653
3654 if (tmpVal != -1) {
3655 bool stationAlreadyPresentFl = false;
3656 for (int j = 0; j <= 7; j++) {
3657 if (_gameBoardSide[0]._outpostStation[j]._cardId == _gameBoardSide[0]._handCard[tmpVal]._cardId) {
3658 stationAlreadyPresentFl = true;
3659 break;
3660 }
3661 }
3662
3663 if (!stationAlreadyPresentFl) {
3664 for (int j = 0; j <= 7; j++) {
3665 if ((_gameBoardSide[0]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) {
3666 int stationCount = 0;
3667 for (int k = 0; k <= 7; k++) {
3668 if ((_gameBoardSide[0]._outpostStation[k]._cardId > 1) && (_gameBoardSide[0]._outpostStation[k]._cardId <= 9)) {
3669 ++stationCount;
3670 }
3671 }
3672
3673 if (stationCount == 7)
3674 _winnerId = 0;
3675
3676 playStationCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[j]);
3677 return;
3678 }
3679 }
3680 }
3681 }
3682 }
3683
3684 int tmpVal = findPlatformCardInHand(0);
3685
3686 if (tmpVal != -1) {
3687 for (int i = 0; i <= 7; i++) {
3688 if ((_gameBoardSide[0]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[0]._delayCard._cardId)) {
3689 playPlatformCard(&_gameBoardSide[0]._handCard[tmpVal], &_gameBoardSide[0]._outpostStation[i]);
3690 return;
3691 }
3692 }
3693 }
3694
3695 int meteorCardId = findMeteorCardInHand(0);
3696 if (meteorCardId != -1) {
3697 for (int i = 0; i <= 7; i++) {
3698 if (_gameBoardSide[2]._outpostStation[i]._cardId != 0) {
3699 playCentralOutpostCard(&_gameBoardSide[0]._handCard[meteorCardId], 2);
3700 return;
3701 }
3702 }
3703 }
3704
3705 int thieftId = findThieftCardInHand(0);
3706 if (thieftId != -1) {
3707 if ( (_gameBoardSide[2]._handCard[0]._cardId != 0)
3708 || (_gameBoardSide[2]._handCard[1]._cardId != 0)
3709 || (_gameBoardSide[2]._handCard[2]._cardId != 0)
3710 || (_gameBoardSide[2]._handCard[3]._cardId != 0) ) {
3711 playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 2);
3712 return;
3713 }
3714 }
3715
3716 for (int i = 0; i <= 3; i++) {
3717 if ((isDelayCard(_gameBoardSide[0]._handCard[i]._cardId) != -1)
3718 && (_gameBoardSide[2]._delayCard._cardId == 0)
3719 && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) {
3720 playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard);
3721 return;
3722 }
3723 }
3724
3725 for (int i = 0; i <= 3; i++) {
3726 if ((getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1)
3727 && (_gameBoardSide[2]._delayCard._cardId == 0)
3728 && isAttackPossible(2, _gameBoardSide[0]._handCard[i]._cardId)) {
3729 playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[2]._delayCard);
3730 return;
3731 }
3732 }
3733
3734 meteorCardId = findMeteorCardInHand(0);
3735 int victimId = getPlayerWithOutpost(0);
3736
3737 if ((meteorCardId != -1) && (victimId != -1)) {
3738 playCentralOutpostCard(&_gameBoardSide[0]._handCard[meteorCardId], victimId);
3739 return;
3740 }
3741
3742 thieftId = findThieftCardInHand(0);
3743 if (thieftId != -1) {
3744 if ( (_gameBoardSide[1]._handCard[0]._cardId != 0)
3745 || (_gameBoardSide[1]._handCard[1]._cardId != 0)
3746 || (_gameBoardSide[1]._handCard[2]._cardId != 0)
3747 || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) {
3748 playThieftCard(0, &_gameBoardSide[0]._handCard[thieftId], 1);
3749 return;
3750 }
3751 }
3752
3753 for (int i = 0; i <= 3; i++) {
3754 if (getStationCardId(_gameBoardSide[0]._handCard[i]._cardId) != -1) {
3755 if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) {
3756 playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard);
3757 return;
3758 }
3759
3760 if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) {
3761 playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard);
3762 return;
3763 }
3764 }
3765 }
3766
3767 for (int i = 0; i <= 3; i++) {
3768 tmpVal = isDelayCard(_gameBoardSide[0]._handCard[i]._cardId);
3769 if (tmpVal != -1) {
3770 if ((_gameBoardSide[1]._delayCard._cardId == 0) && isAttackPossible(1, _gameBoardSide[0]._handCard[i]._cardId)) {
3771 playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[1]._delayCard);
3772 return;
3773 }
3774
3775 if ((_gameBoardSide[3]._delayCard._cardId == 0) && isAttackPossible(3, _gameBoardSide[0]._handCard[i]._cardId)) {
3776 playDelayCard(&_gameBoardSide[0]._handCard[i], &_gameBoardSide[3]._delayCard);
3777 return;
3778 }
3779 }
3780 }
3781
3782 handlePlayer01Discard(0);
3783 }
3784
handlePlayer1()3785 void Scene1337::handlePlayer1() {
3786 if (this->_gameBoardSide[1]._delayCard._cardId != 0) {
3787 switch (_gameBoardSide[1]._delayCard._cardId) {
3788 case 10:
3789 // No break on purpose
3790 case 12:
3791 // No break on purpose
3792 case 15:
3793 // No break on purpose
3794 case 17:
3795 // No break on purpose
3796 case 18:
3797 // No break on purpose
3798 case 19:
3799 // No break on purpose
3800 case 20:
3801 // No break on purpose
3802 case 21:
3803 discardCard(&_gameBoardSide[1]._delayCard);
3804 return;
3805 default:
3806 for (int i = 0; i <= 3; i++) {
3807 if (checkAntiDelayCard(_gameBoardSide[1]._delayCard._cardId, _gameBoardSide[1]._handCard[i]._cardId)) {
3808 playAntiDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[1]._delayCard);
3809 return;
3810 }
3811 }
3812 break;
3813 }
3814 }
3815
3816 for (int i = 0; i <= 3; i++) {
3817 int tmpIndx = getStationId(1, i);
3818 if (tmpIndx == -1)
3819 break;
3820
3821 int tmpVal = 0;
3822 for (int j = 0; j <= 7; j++) {
3823 if (_gameBoardSide[1]._outpostStation[j]._cardId == _gameBoardSide[1]._handCard[tmpIndx]._cardId) {
3824 tmpVal = 1;
3825 break;
3826 }
3827 }
3828
3829 if (tmpVal == 0)
3830 break;
3831
3832 for (int j = 0; j <= 7; j++) {
3833 if ((_gameBoardSide[1]._outpostStation[j]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) {
3834 int stationCount = 0;
3835 for (int k = 0; k <= 7; k++) {
3836 if ((_gameBoardSide[1]._outpostStation[k]._cardId > 1) && (_gameBoardSide[1]._outpostStation[k]._cardId <= 9))
3837 ++stationCount;
3838 }
3839
3840 if (stationCount == 7)
3841 _winnerId = 1;
3842
3843 playStationCard(&_gameBoardSide[1]._handCard[tmpIndx], &_gameBoardSide[1]._outpostStation[j]);
3844 return;
3845 }
3846 }
3847 }
3848
3849 int normalCardId = findPlatformCardInHand(1);
3850 if (normalCardId != -1) {
3851 for (int i = 0; i <= 7; i++) {
3852 if ((_gameBoardSide[1]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[1]._delayCard._cardId)) {
3853 playPlatformCard(&_gameBoardSide[1]._handCard[normalCardId], &_gameBoardSide[1]._outpostStation[i]);
3854 return;
3855 }
3856 }
3857 }
3858
3859 int meterorCardId = findMeteorCardInHand(1);
3860 int victimId = getPlayerWithOutpost(1);
3861
3862 if ((meterorCardId != -1) && (victimId != -1)) {
3863 playCentralOutpostCard(&_gameBoardSide[1]._handCard[meterorCardId], victimId);
3864 return;
3865 }
3866
3867 int thieftId = findThieftCardInHand(1);
3868 if (thieftId != -1) {
3869 int playerIdFound = -1;
3870 int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
3871 for (int i = 0; i <= 3; i++) {
3872 if (rndVal != 1) {
3873 if ( (_gameBoardSide[rndVal]._handCard[0]._cardId != 0)
3874 || (_gameBoardSide[rndVal]._handCard[1]._cardId != 0)
3875 || (_gameBoardSide[rndVal]._handCard[2]._cardId != 0)
3876 || (_gameBoardSide[rndVal]._handCard[3]._cardId != 0)) {
3877 playerIdFound = rndVal;
3878 break;
3879 }
3880 }
3881 // The original was only updating in the rndVal block,
3882 // which was a bug as the checks were stopping at this point
3883 rndVal--;
3884 if (rndVal < 0)
3885 rndVal = 3;
3886 }
3887
3888 if (playerIdFound != -1) {
3889 playThieftCard(1, &_gameBoardSide[1]._handCard[thieftId], playerIdFound);
3890 return;
3891 }
3892 }
3893
3894 for (int i = 0; i <= 3; i++) {
3895 int tmpVal = isDelayCard(_gameBoardSide[1]._handCard[i]._cardId);
3896 if (tmpVal != -1) {
3897 victimId = -1;
3898 int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
3899
3900 for (int j = 0; j <= 3; j++) {
3901 if (rndVal != 1) {
3902 if ((_gameBoardSide[rndVal]._delayCard._cardId == 0) && isAttackPossible(rndVal, _gameBoardSide[1]._handCard[i]._cardId))
3903 victimId = rndVal;
3904 }
3905
3906 if (victimId != -1) {
3907 playDelayCard(&_gameBoardSide[1]._handCard[i], &_gameBoardSide[victimId]._delayCard);
3908 return;
3909 } else {
3910 rndVal--;
3911 if (rndVal < 0)
3912 rndVal = 3;
3913 }
3914 }
3915 }
3916 }
3917
3918 for (int j = 0; j <= 3; j++) {
3919 if (getStationCardId(_gameBoardSide[1]._handCard[j]._cardId) != -1) {
3920 victimId = -1;
3921 int rndVal = R2_GLOBALS._randomSource.getRandomNumber(3);
3922 for (int l = 0; l <= 3; l++) {
3923 if (rndVal != 1) {
3924 if ((_gameBoardSide[rndVal]._delayCard._cardId == 0) && (_gameBoardSide[1]._handCard[j]._cardId == 1))
3925 victimId = rndVal;
3926 }
3927 if (victimId != -1) {
3928 playDelayCard(&_gameBoardSide[1]._handCard[j], &_gameBoardSide[victimId]._delayCard);
3929 return;
3930 } else {
3931 rndVal--;
3932 if (rndVal < 0)
3933 rndVal = 3;
3934 }
3935 }
3936 }
3937 }
3938
3939 handlePlayer01Discard(1);
3940 }
3941
handlePlayer3()3942 void Scene1337::handlePlayer3() {
3943 if (_gameBoardSide[3]._delayCard._cardId != 0) {
3944 switch (_gameBoardSide[3]._delayCard._cardId) {
3945 case 10:
3946 // No break on purpose
3947 case 12:
3948 // No break on purpose
3949 case 15:
3950 // No break on purpose
3951 case 17:
3952 // No break on purpose
3953 case 18:
3954 // No break on purpose
3955 case 19:
3956 // No break on purpose
3957 case 20:
3958 // No break on purpose
3959 case 21:
3960 discardCard(&_gameBoardSide[3]._delayCard);
3961 return;
3962 default:
3963 for (int i = 0; i <= 3; i++) {
3964 if (checkAntiDelayCard(_gameBoardSide[3]._delayCard._cardId, _gameBoardSide[3]._handCard[i]._cardId)) {
3965 playAntiDelayCard(&_gameBoardSide[3]._handCard[i], &_gameBoardSide[3]._delayCard);
3966 return;
3967 }
3968 }
3969 break;
3970 }
3971 }
3972
3973 int randIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
3974 if (_gameBoardSide[3]._handCard[randIndx]._cardId == 1) {
3975 // Station Card
3976 for (int i = 0; i <= 7; i++) {
3977 if ((_gameBoardSide[3]._outpostStation[i]._cardId == 0) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) {
3978 playPlatformCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]);
3979 return;
3980 }
3981 }
3982 } else if (_gameBoardSide[3]._handCard[randIndx]._cardId <= 9) {
3983 // Outpost Card
3984 for (int i = 0; i <= 7; i++) {
3985 if (_gameBoardSide[3]._outpostStation[i]._cardId == _gameBoardSide[3]._handCard[randIndx]._cardId) {
3986 discardCard(&_gameBoardSide[3]._handCard[randIndx]);
3987 return;
3988 }
3989 }
3990
3991 for (int i = 0; i <= 7; i++) {
3992 if ((_gameBoardSide[3]._outpostStation[i]._cardId == 1) && !isStopConstructionCard(_gameBoardSide[3]._delayCard._cardId)) {
3993 int stationCount = 0;
3994 for (int j = 0; j <= 7; j++) {
3995 if ((_gameBoardSide[3]._outpostStation[j]._cardId > 1) && (_gameBoardSide[3]._outpostStation[j]._cardId <= 9))
3996 ++stationCount;
3997 }
3998
3999 if (stationCount == 7)
4000 _winnerId = 3;
4001
4002 playStationCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[3]._outpostStation[i]);
4003 return;
4004 }
4005 }
4006 } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 13) {
4007 // Meteor Card
4008 int victimId = getPlayerWithOutpost(3);
4009
4010 if (victimId != -1) {
4011 playCentralOutpostCard(&_gameBoardSide[3]._handCard[randIndx], victimId);
4012 return;
4013 }
4014 } else if (_gameBoardSide[3]._handCard[randIndx]._cardId == 25) {
4015 // Thief card
4016 int victimId = -1;
4017 int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
4018
4019 for (int i = 0; i <= 3; i++) {
4020 if ( (tmpRandIndx != 3)
4021 && ( (_gameBoardSide[tmpRandIndx]._handCard[0]._cardId != 0)
4022 || (_gameBoardSide[tmpRandIndx]._handCard[1]._cardId != 0)
4023 || (_gameBoardSide[tmpRandIndx]._handCard[2]._cardId != 0)
4024 || (_gameBoardSide[tmpRandIndx]._handCard[3]._cardId != 0) )) {
4025 victimId = tmpRandIndx;
4026 break;
4027 }
4028
4029 ++tmpRandIndx;
4030 if (tmpRandIndx > 3)
4031 tmpRandIndx = 0;
4032 }
4033
4034 if (victimId != -1) {
4035 playThieftCard(3, &_gameBoardSide[3]._handCard[randIndx], victimId);
4036 return;
4037 }
4038 } else {
4039 switch (_gameBoardSide[3]._handCard[randIndx]._cardId) {
4040 case 10:
4041 // No break on purpose
4042 case 11:
4043 // No break on purpose
4044 case 12:
4045 // No break on purpose
4046 case 14:
4047 // No break on purpose
4048 case 15:
4049 // No break on purpose
4050 case 16:
4051 // No break on purpose
4052 case 17:
4053 // No break on purpose
4054 case 18:
4055 // No break on purpose
4056 case 19:
4057 // No break on purpose
4058 case 20:
4059 // No break on purpose
4060 case 21:
4061 // No break on purpose
4062 case 24: {
4063 int victimId = -1;
4064 int tmpRandIndx = R2_GLOBALS._randomSource.getRandomNumber(3);
4065
4066 for (int i = 0; i <= 3; i++) {
4067 if (tmpRandIndx != 3) {
4068 if ((_gameBoardSide[tmpRandIndx]._delayCard._cardId == 0)
4069 && isAttackPossible(tmpRandIndx, _gameBoardSide[3]._handCard[randIndx]._cardId))
4070 victimId = tmpRandIndx;
4071 }
4072
4073 ++tmpRandIndx;
4074 if (tmpRandIndx > 3)
4075 tmpRandIndx = 0;
4076
4077 if (victimId != -1)
4078 break;
4079 }
4080
4081 if (victimId != -1) {
4082 // Useless second identical check skipped
4083 playDelayCard(&_gameBoardSide[3]._handCard[randIndx], &_gameBoardSide[victimId]._delayCard);
4084 return;
4085 }
4086 }
4087 default:
4088 break;
4089 }
4090 }
4091
4092 discardCard(&_gameBoardSide[3]._handCard[randIndx]);
4093 }
4094
handleAutoplayPlayer2()4095 void Scene1337::handleAutoplayPlayer2() {
4096 if (getStationCardId(this->_gameBoardSide[2]._delayCard._cardId) == -1)
4097 _delayedFunction = &Scene1337::handlePlayer2;
4098 else
4099 discardCard(&_gameBoardSide[2]._delayCard);
4100 }
4101
handlePlayer2()4102 void Scene1337::handlePlayer2() {
4103 _selectedCard._stationPos = g_globals->_events._mousePos;
4104
4105 if (R2_GLOBALS._v57810 == 200) {
4106 // Hand
4107 int i;
4108 for (i = 0; i < 4; i++) {
4109 if ((_gameBoardSide[2]._handCard[i].isIn(_selectedCard._stationPos)) && (_gameBoardSide[2]._handCard[i]._cardId != 0)) {
4110 Card *handcard = &_gameBoardSide[2]._handCard[i];
4111 _selectedCard._cardId = handcard->_cardId;
4112 _selectedCard._stationPos = handcard->_stationPos;
4113 //warning("_selectedCard._actorName = handcard->_actorName;");
4114 //warning("_selectedCard._fieldE = handcard->_fieldE;");
4115 //warning("_selectedCard._field10 = handcard->_field10;");
4116 //warning("_selectedCard._field12 = handcard->_field12;");
4117 //warning("_selectedCard._field14 = handcard->_field14;");
4118 //warning("_selectedCard._field16 = handcard->_field16;");
4119 _selectedCard._sceneRegionId = handcard->_sceneRegionId;
4120 _selectedCard._position = handcard->_position;
4121 _selectedCard._yDiff = handcard->_yDiff;
4122 _selectedCard._bounds = handcard->_bounds;
4123 _selectedCard._resNum = handcard->_resNum;
4124 _selectedCard._lookLineNum = handcard->_lookLineNum;
4125 _selectedCard._talkLineNum = handcard->_talkLineNum;
4126 _selectedCard._useLineNum = handcard->_useLineNum;
4127 _selectedCard._action = handcard->_action;
4128 //warning("_selectedCard._field0 = handcard->_field0;");
4129 _selectedCard._card._updateStartFrame = handcard->_card._updateStartFrame;
4130 _selectedCard._card._walkStartFrame = handcard->_card._walkStartFrame;
4131 _selectedCard._card._oldPosition = handcard->_card._oldPosition;
4132 _selectedCard._card._percent = handcard->_card._percent;
4133 _selectedCard._card._priority = handcard->_card._priority;
4134 _selectedCard._card._angle = handcard->_card._angle;
4135 _selectedCard._card._flags = handcard->_card._flags;
4136 _selectedCard._card._xe = handcard->_card._xe;
4137 _selectedCard._card._xs = handcard->_card._xs;
4138 _selectedCard._card._paneRects[0] = handcard->_card._paneRects[0];
4139 _selectedCard._card._paneRects[1] = handcard->_card._paneRects[1];
4140 _selectedCard._card._visage = handcard->_card._visage;
4141 _selectedCard._card._objectWrapper = handcard->_card._objectWrapper;
4142 _selectedCard._card._strip = handcard->_card._strip;
4143 _selectedCard._card._animateMode = handcard->_card._animateMode;
4144 _selectedCard._card._frame = handcard->_card._frame;
4145 _selectedCard._card._endFrame = handcard->_card._endFrame;
4146 _selectedCard._card._loopCount = handcard->_card._loopCount;
4147 _selectedCard._card._frameChange = handcard->_card._frameChange;
4148 _selectedCard._card._numFrames = handcard->_card._numFrames;
4149 _selectedCard._card._regionIndex = handcard->_card._regionIndex;
4150 _selectedCard._card._mover = handcard->_card._mover;
4151 _selectedCard._card._moveDiff = handcard->_card._moveDiff;
4152 _selectedCard._card._moveRate = handcard->_card._moveRate;
4153 _selectedCard._card._actorDestPos = handcard->_card._actorDestPos;
4154 _selectedCard._card._endAction = handcard->_card._endAction;
4155 _selectedCard._card._regionBitList = handcard->_card._regionBitList;
4156 // _selectedCard._object1._actorName = handcard->_object1._actorName;
4157 //warning("_selectedCard._card._fieldE = handcard->_card._fieldE;");
4158 //warning("_selectedCard._card._field10 = handcard->_card._field10;");
4159 //warning("_selectedCard._card._field12 = handcard->_card._field12;");
4160 //warning("_selectedCard._card._field14 = handcard->_card._field14;");
4161 //warning("_selectedCard._card._field16 = handcard->_card._field16;");
4162
4163 _gameBoardSide[2]._handCard[i]._cardId = 0;
4164 _gameBoardSide[2]._handCard[i]._card.remove();
4165 break;
4166 }
4167 }
4168
4169 if (i == 4) {
4170 handleClick(1, _selectedCard._stationPos);
4171 handleAutoplayPlayer2();
4172 return;
4173 } else {
4174 setCursorData(1332, _selectedCard._card._strip, _selectedCard._card._frame);
4175 R2_GLOBALS._sceneObjects->draw();
4176 }
4177 } else if (R2_GLOBALS._v57810 == 300) {
4178 // Eye
4179 handleClick(3, _selectedCard._stationPos);
4180 handleAutoplayPlayer2();
4181 return;
4182 } else {
4183 // The original code is calling a function full of dead code.
4184 // Only this message remains after a cleanup.
4185 MessageDialog::show(WRONG_ANSWER_MSG, OK_BTN_STRING);
4186 //
4187 handleAutoplayPlayer2();
4188 return;
4189 }
4190
4191 Event event;
4192 bool found;
4193 for (;;) {
4194 if ( ((g_globals->_events.getEvent(event, EVENT_BUTTON_DOWN)) && (event.btnState == BTNSHIFT_RIGHT))
4195 || (g_globals->_events.getEvent(event, EVENT_KEYPRESS)) ){
4196 _selectedCard._stationPos = g_globals->_events._mousePos;
4197 found = false;
4198
4199 for (int i = 0; i <= 3; i ++) {
4200 if (_gameBoardSide[2]._handCard[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4201 if (_gameBoardSide[2]._handCard[i]._cardId == 0) {
4202 _gameBoardSide[2]._handCard[i]._cardId = _selectedCard._cardId;
4203 _gameBoardSide[2]._handCard[i]._card.postInit();
4204 _gameBoardSide[2]._handCard[i]._card.hide();
4205 _gameBoardSide[2]._handCard[i]._card.setVisage(1332);
4206 _gameBoardSide[2]._handCard[i]._card.setPosition(_gameBoardSide[2]._handCard[i]._stationPos, 0);
4207 _gameBoardSide[2]._handCard[i]._card.fixPriority(170);
4208 setAnimationInfo(&_gameBoardSide[2]._handCard[i]);
4209 setCursorData(5, 1, 4);
4210 _currentPlayerNumb--;
4211 _showPlayerTurn = false;
4212 handleNextTurn();
4213 return;
4214 } else {
4215 actionDisplay(1330, 127, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4216 found = true;
4217 }
4218 break;
4219 }
4220 }
4221
4222 if (!found) {
4223 if (_discardPile.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4224 discardCard(&_selectedCard);
4225 return;
4226 } else if (_selectedCard._cardId == 1) {
4227 bool isInCardFl = false;
4228 int i;
4229 for (i = 0; i <= 7; i++) {
4230 if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4231 isInCardFl = true;
4232 break;
4233 }
4234 }
4235
4236 if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 0)) {
4237 if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) {
4238 actionDisplay(1330, 55, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4239 } else {
4240 playPlatformCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]);
4241 return;
4242 }
4243 } else {
4244 actionDisplay(1330, 56, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4245 }
4246 } else if (_selectedCard._cardId <= 9) {
4247 bool isInCardFl = false;
4248 int i;
4249 for (i = 0; i <= 7; i++) {
4250 if (_gameBoardSide[2]._outpostStation[i].isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4251 isInCardFl = true;
4252 break;
4253 }
4254 }
4255 if ((isInCardFl) && (_gameBoardSide[2]._outpostStation[i]._cardId == 1)) {
4256 isInCardFl = false;
4257 for (int j = 0; j <= 7; j++) {
4258 if (_selectedCard._cardId == _gameBoardSide[2]._outpostStation[j]._cardId) {
4259 isInCardFl = true;
4260 break;
4261 }
4262 }
4263 if (isInCardFl) {
4264 // This station is already in place
4265 actionDisplay(1330, 34, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4266 } else if (isDelayCard(_gameBoardSide[2]._delayCard._cardId) != -1) {
4267 // You must eliminate your delay before you can play a station
4268 actionDisplay(1330, 35, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4269 } else {
4270 int stationCount = 0;
4271 for (int k = 0; k <= 7; k++) {
4272 if ((_gameBoardSide[2]._outpostStation[k]._cardId > 1) && (_gameBoardSide[2]._outpostStation[k]._cardId <= 9))
4273 ++stationCount;
4274 }
4275
4276 if (stationCount == 7)
4277 _winnerId = 2;
4278
4279 playStationCard(&_selectedCard, &_gameBoardSide[2]._outpostStation[i]);
4280 return;
4281 }
4282 } else {
4283 actionDisplay(1330, 37, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4284 }
4285 } else if ((_selectedCard._cardId == 26) || (_selectedCard._cardId == 30) ||(_selectedCard._cardId == 32) || (_selectedCard._cardId == 28)) {
4286 // Check anti-delay card (26 = Diplomacy, 28 = Innovation, 30 = Cure, 32 = Agreement)
4287 if (_gameBoardSide[2]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4288 actionDisplay(1330, 42, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4289 } else if (checkAntiDelayCard(_gameBoardSide[2]._delayCard._cardId, _selectedCard._cardId)) {
4290 playAntiDelayCard(&_selectedCard, &_gameBoardSide[2]._delayCard);
4291 return;
4292 } else {
4293 if (_gameBoardSide[2]._delayCard._cardId != 0) {
4294 switch (_gameBoardSide[2]._delayCard._cardId) {
4295 case 11:
4296 actionDisplay(1330, 68, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4297 break;
4298 case 14:
4299 actionDisplay(1330, 80, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4300 break;
4301 case 16:
4302 actionDisplay(1330, 84, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4303 break;
4304 case 24:
4305 actionDisplay(1330, 96, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4306 break;
4307 default:
4308 break;
4309 }
4310 } else {
4311 actionDisplay(1330, 41, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4312 }
4313 }
4314 } else if ((getStationCardId(_selectedCard._cardId) == -1) && (isDelayCard(_selectedCard._cardId) == -1)) {
4315 if (_selectedCard._cardId == 13) {
4316 // Meteor Card
4317 if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4318 for (int k = 0; k <= 7; k++) {
4319 if (_gameBoardSide[0]._outpostStation[k]._cardId != 0) {
4320 playCentralOutpostCard(&_selectedCard, 0);
4321 return;
4322 }
4323 }
4324 actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4325 } else if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4326 for (int k = 0; k <= 7; k++) {
4327 if (_gameBoardSide[3]._outpostStation[k]._cardId != 0) {
4328 playCentralOutpostCard(&_selectedCard, 3);
4329 return;
4330 }
4331 }
4332 actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4333 } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4334 for (int k = 0; k <= 7; k++) {
4335 if (_gameBoardSide[1]._outpostStation[k]._cardId == 0) {
4336 playCentralOutpostCard(&_selectedCard, 1);
4337 return;
4338 }
4339 }
4340 actionDisplay(1330, 74, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4341 } else {
4342 actionDisplay(1330, 128, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4343 }
4344 } else if (_selectedCard._cardId == 25) {
4345 // Thief card
4346 if (_gameBoardSide[0]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4347 if ( (_gameBoardSide[0]._handCard[0]._cardId != 0)
4348 || (_gameBoardSide[0]._handCard[1]._cardId != 0)
4349 || (_gameBoardSide[0]._handCard[2]._cardId != 0)
4350 || (_gameBoardSide[0]._handCard[3]._cardId != 0) ) {
4351 int k;
4352 for (k = 0; k <= 3; k++){
4353 if (_gameBoardSide[2]._handCard[k]._cardId == 0)
4354 break;
4355 }
4356 playThieftCard(2, &_gameBoardSide[2]._handCard[k], 0);
4357 return;
4358 } else {
4359 actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4360 }
4361 } else if (_gameBoardSide[1]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4362 if ( (_gameBoardSide[1]._handCard[0]._cardId != 0)
4363 || (_gameBoardSide[1]._handCard[1]._cardId != 0)
4364 || (_gameBoardSide[1]._handCard[2]._cardId != 0)
4365 || (_gameBoardSide[1]._handCard[3]._cardId != 0) ) {
4366 int k;
4367 for (k = 0; k <= 3; k++){
4368 if (_gameBoardSide[2]._handCard[k]._cardId == 0)
4369 break;
4370 }
4371 playThieftCard(2, &_gameBoardSide[2]._handCard[k], 1);
4372 return;
4373 } else {
4374 actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4375 }
4376 }
4377
4378 if (_gameBoardSide[3]._emptyStationPos.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4379 if ( (_gameBoardSide[3]._handCard[0]._cardId != 0)
4380 || (_gameBoardSide[3]._handCard[1]._cardId != 0)
4381 || (_gameBoardSide[3]._handCard[2]._cardId != 0)
4382 || (_gameBoardSide[3]._handCard[3]._cardId != 0) ) {
4383 int k;
4384 for (k = 0; k <= 3; k++){
4385 if (_gameBoardSide[2]._handCard[k]._cardId == 0)
4386 break;
4387 }
4388 playThieftCard(2, &_gameBoardSide[2]._handCard[k], 3);
4389 return;
4390 } else {
4391 actionDisplay(1330, 99, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4392 }
4393 } else {
4394 actionDisplay(1330, 129, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4395 }
4396 } else if (_selectedCard._cardId == 29) {
4397 // Interceptor cards are used to prevent collision
4398 actionDisplay(1330, 136, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4399 } else if (_selectedCard._cardId == 27) {
4400 actionDisplay(1330, 137, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4401 }
4402 } else if (_gameBoardSide[0]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4403 if (_gameBoardSide[0]._delayCard._cardId != 0) {
4404 actionDisplay(1330, 15, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4405 } else if (!isAttackPossible(0, _selectedCard._cardId)) {
4406 switch (_selectedCard._cardId) {
4407 case 10:
4408 actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4409 break;
4410 case 12:
4411 actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4412 break;
4413 case 15:
4414 actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4415 break;
4416 case 17:
4417 actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4418 break;
4419 case 18:
4420 actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4421 break;
4422 case 19:
4423 actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4424 break;
4425 case 20:
4426 actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4427 break;
4428 case 21:
4429 actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4430 break;
4431 default:
4432 break;
4433 }
4434 } else {
4435 playDelayCard(&_selectedCard, &_gameBoardSide[0]._delayCard);
4436 return;
4437 }
4438 } else if (_gameBoardSide[3]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4439 if (_gameBoardSide[3]._delayCard._cardId != 0) {
4440 actionDisplay(1330, 17, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4441 } else if (!isAttackPossible(3, _selectedCard._cardId)) {
4442 switch (_selectedCard._cardId) {
4443 case 10:
4444 actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4445 break;
4446 case 12:
4447 actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4448 break;
4449 case 15:
4450 actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4451 break;
4452 case 17:
4453 actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4454 break;
4455 case 18:
4456 actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4457 break;
4458 case 19:
4459 actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4460 break;
4461 case 20:
4462 actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4463 break;
4464 case 21:
4465 actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4466 break;
4467 default:
4468 break;
4469 }
4470 } else {
4471 playDelayCard(&_selectedCard, &_gameBoardSide[3]._delayCard);
4472 return;
4473 }
4474 } else if (_gameBoardSide[1]._delayCard.isIn(Common::Point(_selectedCard._stationPos.x + 12, _selectedCard._stationPos.y + 12))) {
4475 if (_gameBoardSide[1]._delayCard._cardId != 0) {
4476 actionDisplay(1330, 19, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4477 } else if (!isAttackPossible(1, _selectedCard._cardId)) {
4478 switch (_selectedCard._cardId) {
4479 case 10:
4480 actionDisplay(1330, 66, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4481 break;
4482 case 12:
4483 actionDisplay(1330, 70, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4484 break;
4485 case 15:
4486 actionDisplay(1330, 82, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4487 break;
4488 case 17:
4489 actionDisplay(1330, 86, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4490 break;
4491 case 18:
4492 actionDisplay(1330, 88, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4493 break;
4494 case 19:
4495 actionDisplay(1330, 90, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4496 break;
4497 case 20:
4498 actionDisplay(1330, 92, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4499 break;
4500 case 21:
4501 actionDisplay(1330, 94, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4502 break;
4503 default:
4504 break;
4505 }
4506 } else {
4507 playDelayCard(&_selectedCard, &_gameBoardSide[1]._delayCard);
4508 return;
4509 }
4510 } else {
4511 actionDisplay(1330, 38, 159, 10, 1, 200, 0, 7, 0, 154, 154);
4512 }
4513 }
4514 } else {
4515 g_globals->_scenePalette.signalListeners();
4516 R2_GLOBALS._sceneObjects->draw();
4517 g_globals->_events.delay(g_globals->_sceneHandler->_delayTicks);
4518 }
4519
4520 g_globals->_sceneObjects->recurse(SceneHandler::dispatchObject);
4521 }
4522 }
4523
updateCursorId(int cursorId,bool updateFl)4524 void Scene1337::updateCursorId(int cursorId, bool updateFl) {
4525 if ((R2_GLOBALS._v57709 != 0) || (R2_GLOBALS._v5780C != 0))
4526 return;
4527
4528 R2_GLOBALS._mouseCursorId = cursorId;
4529
4530 if (updateFl) {
4531 R2_GLOBALS._mouseCursorId++;
4532
4533 if (R2_GLOBALS._mouseCursorId < 1)
4534 R2_GLOBALS._mouseCursorId = 2;
4535
4536 if (R2_GLOBALS._mouseCursorId > 2)
4537 R2_GLOBALS._mouseCursorId = 1;
4538 }
4539
4540 // The original was using an intermediate function to call setCursorData.
4541 // It has been removed to improve readability
4542 if (R2_GLOBALS._mouseCursorId == 1) {
4543 R2_GLOBALS._v57810 = 200;
4544 setCursorData(5, 1, 4);
4545 } else if (R2_GLOBALS._mouseCursorId == 2) {
4546 R2_GLOBALS._v57810 = 300;
4547 setCursorData(5, 1, 5);
4548 } else {
4549 R2_GLOBALS._v57810 = 0;
4550 setCursorData(5, 0, 0);
4551 }
4552 }
4553
setCursorData(int resNum,int rlbNum,int frameNum)4554 void Scene1337::setCursorData(int resNum, int rlbNum, int frameNum) {
4555 _cursorCurRes = resNum;
4556 _cursorCurStrip = rlbNum;
4557 _cursorCurFrame = frameNum;
4558
4559 if (!frameNum) {
4560 // Should be a hardcoded cursor displaying only a dot.
4561 // FIXME: Use another cursor when possible
4562 R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);
4563 } else {
4564 // TODO: The original was using some resource caching, which was useless and complex
4565 // and which has been removed. This cursor behavior clearly made intensive use of this caching...
4566 // We now have to find a way to cache these cursor pointers and avoid loading them multiple times per seconds
4567 uint size;
4568 byte *cursor = g_resourceManager->getSubResource(resNum, rlbNum, frameNum, &size);
4569 // Decode the cursor
4570 GfxSurface s = surfaceFromRes(cursor);
4571
4572 Graphics::Surface surface = s.lockSurface();
4573 const byte *cursorData = (const byte *)surface.getPixels();
4574 CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor);
4575 s.unlockSurface();
4576
4577 DEALLOCATE(cursor);
4578 }
4579 }
4580
subD18F5()4581 void Scene1337::subD18F5() {
4582 if (R2_GLOBALS._v57709 == 0)
4583 // The original restores a copy of the default cursor (the hand), which isn't possible with our implementation
4584 // We reload that cursor instead.
4585 setCursorData(5, 1, 4);
4586
4587 ++R2_GLOBALS._v57709;
4588 }
4589
subD1917()4590 void Scene1337::subD1917() {
4591 if (R2_GLOBALS._v57709 != 0) {
4592 R2_GLOBALS._v57709--;
4593 if (R2_GLOBALS._v57709 == 0) {
4594 // The original was using an intermediate function to call setCursorData.
4595 // It has been removed to improve readability
4596 setCursorData(5, _cursorCurStrip, _cursorCurFrame);
4597 }
4598 }
4599 }
4600
subD1940(bool flag)4601 void Scene1337::subD1940(bool flag) {
4602 if (flag)
4603 ++R2_GLOBALS._v5780C;
4604 else if (R2_GLOBALS._v5780C != 0)
4605 --R2_GLOBALS._v5780C;
4606 }
4607
subD1975(int arg1,int arg2)4608 void Scene1337::subD1975(int arg1, int arg2) {
4609 // No implementation required in ScummVM: Mouse handling with tons of caching
4610 }
4611
show()4612 void Scene1337::OptionsDialog::show() {
4613 OptionsDialog *dlg = new OptionsDialog();
4614 dlg->draw();
4615
4616 // Show the dialog
4617 GfxButton *btn = dlg->execute(NULL);
4618
4619 // Figure out the new selected character
4620 if (btn == &dlg->_quitGame)
4621 R2_GLOBALS._sceneManager.changeScene(125);
4622 else if (btn == &dlg->_restartGame)
4623 R2_GLOBALS._sceneManager.changeScene(1330);
4624
4625 // Remove the dialog
4626 dlg->remove();
4627 delete dlg;
4628 }
4629
OptionsDialog()4630 Scene1337::OptionsDialog::OptionsDialog() {
4631 // Set the elements text
4632 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
4633 _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
4634 _restartGame.setText(START_NEW_CARD_GAME);
4635 _quitGame.setText(QUIT_CARD_GAME);
4636 _continueGame.setText(CONTINUE_CARD_GAME);
4637
4638 // Set position of the elements
4639 _autoplay._bounds.moveTo(5, 2);
4640 _restartGame._bounds.moveTo(5, _autoplay._bounds.bottom + 2);
4641 _quitGame._bounds.moveTo(5, _restartGame._bounds.bottom + 2);
4642 _continueGame._bounds.moveTo(5, _quitGame._bounds.bottom + 2);
4643
4644 // Add the items to the dialog
4645 addElements(&_autoplay, &_restartGame, &_quitGame, &_continueGame, NULL);
4646
4647 // Set the dialog size and position
4648 frame();
4649 _bounds.collapse(-6, -6);
4650 setCenter(160, 100);
4651 }
4652
execute(GfxButton * defaultButton)4653 GfxButton *Scene1337::OptionsDialog::execute(GfxButton *defaultButton) {
4654 _gfxManager.activate();
4655
4656 // Event loop
4657 GfxButton *selectedButton = NULL;
4658
4659 bool breakFlag = false;
4660 while (!g_vm->shouldQuit() && !breakFlag) {
4661 Event event;
4662 while (g_globals->_events.getEvent(event) && !breakFlag) {
4663 // Adjust mouse positions to be relative within the dialog
4664 event.mousePos.x -= _gfxManager._bounds.left;
4665 event.mousePos.y -= _gfxManager._bounds.top;
4666
4667 for (GfxElementList::iterator i = _elements.begin(); i != _elements.end(); ++i) {
4668 if ((*i)->process(event))
4669 selectedButton = static_cast<GfxButton *>(*i);
4670 }
4671
4672 if (selectedButton == &_autoplay) {
4673 // Toggle Autoplay
4674 selectedButton = NULL;
4675 Scene1337 *scene = (Scene1337 *)R2_GLOBALS._sceneManager._scene;
4676 scene->_autoplay = !scene->_autoplay;
4677
4678 _autoplay.setText(scene->_autoplay ? AUTO_PLAY_ON : AUTO_PLAY_OFF);
4679 _autoplay.draw();
4680 } else if (selectedButton) {
4681 breakFlag = true;
4682 break;
4683 } else if (!event.handled) {
4684 if ((event.eventType == EVENT_KEYPRESS) && (event.kbd.keycode == Common::KEYCODE_ESCAPE)) {
4685 selectedButton = NULL;
4686 breakFlag = true;
4687 break;
4688 }
4689 }
4690 }
4691
4692 g_system->delayMillis(10);
4693 GLOBALS._screen.update();
4694 }
4695
4696 _gfxManager.deactivate();
4697 return selectedButton;
4698 }
4699
4700 } // End of namespace Ringworld2
4701 } // End of namespace TsAGE
4702