1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* This code is based on the original source code of Lord Avalot d'Argent version 1.3.
* Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
*/
#include "avalanche/avalanche.h"
#include "avalanche/nim.h"
namespace Avalanche {
const char * const Nim::kNames[2] = {"Avalot", "Dogfood"};
Nim::Nim(AvalancheEngine *vm) {
_vm = vm;
_playedNim = 0;
}
void Nim::resetVariables() {
_playedNim = 0;
}
void Nim::synchronize(Common::Serializer &sz) {
if (sz.isLoading() && sz.getVersion() < 2)
return;
sz.syncAsByte(_playedNim);
}
void Nim::playNim() {
if (_vm->_wonNim) { // Already won the game.
_vm->_dialogs->displayScrollChain('Q', 6);
return;
}
if (!_vm->_askedDogfoodAboutNim) {
_vm->_dialogs->displayScrollChain('Q', 84);
return;
}
_vm->_dialogs->displayScrollChain('Q', 3);
_playedNim++;
_vm->fadeOut();
_vm->_graphics->saveScreen();
CursorMan.showMouse(false);
setup();
board();
CursorMan.showMouse(true);
do {
startMove();
if (_dogfoodsTurn)
dogFood();
else
takeSome();
_stones[_row] -= _number;
showChanges();
} while (_stonesLeft != 0);
endOfGame(); // Winning sequence is A1, B3, B1, C1, C1, btw.
_vm->fadeOut();
CursorMan.showMouse(false);
_vm->_graphics->restoreScreen();
_vm->_graphics->removeBackup();
CursorMan.showMouse(true);
_vm->fadeIn();
if (_dogfoodsTurn) {
// Dogfood won - as usual.
if (_playedNim == 1) // Your first game.
_vm->_dialogs->displayScrollChain('Q', 4); // Goody! Play me again?
else
_vm->_dialogs->displayScrollChain('Q', 5); // Oh, look at that! I've won again!
_vm->decreaseMoney(4); // And you've just lost 4d!
} else {
// You won - strange!
_vm->_dialogs->displayScrollChain('Q', 7);
_vm->_objects[kObjectLute - 1] = true;
_vm->refreshObjectList();
_vm->_wonNim = true;
_vm->_background->draw(-1, -1, 0); // Show the settle with no lute on it.
// 7 points for winning!
_vm->incScore(7);
}
if (_playedNim == 1) {
// 3 points for playing your 1st game.
_vm->incScore(3);
}
}
void Nim::chalk(int x,int y, Common::String z) {
warning("STUB: Nim::chalk()");
}
void Nim::setup() {
warning("STUB: Nim::setup()");
}
void Nim::plotStone(byte x,byte y) {
warning("STUB: Nim::plotStone()");
}
void Nim::board() {
warning("STUB: Nim::board()");
}
void Nim::startMove() {
warning("STUB: Nim::startMove()");
}
void Nim::showChanges() {
warning("STUB: Nim::showChanges()");
}
void Nim::blip() {
warning("STUB: Nim::blip()");
}
void Nim::checkMouse() {
warning("STUB: Nim::checkMouse()");
}
void Nim::less() {
warning("STUB: Nim::less()");
}
void Nim::takeSome() {
warning("STUB: Nim::takeSome()");
}
void Nim::endOfGame() {
warning("STUB: Nim::endOfGame()");
}
void Nim::dogFood() {
warning("STUB: Nim::dogFood()");
}
bool Nim::find(byte x) {
warning("STUB: Nim::find()");
return true;
}
void Nim::findAp(byte start,byte stepsize) {
warning("STUB: Nim::findAp()");
}
} // End of namespace Avalanche
|