From 66109101f8c57a927c3ec9a2b8982a0f5309e25d Mon Sep 17 00:00:00 2001 From: urukgit Date: Fri, 22 Nov 2013 18:03:01 +0100 Subject: AVALANCHE: Add skeleton code for the minigame called Nim. --- engines/avalanche/nim.cpp | 98 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 engines/avalanche/nim.cpp (limited to 'engines/avalanche/nim.cpp') diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp new file mode 100644 index 0000000000..e7a73b5a62 --- /dev/null +++ b/engines/avalanche/nim.cpp @@ -0,0 +1,98 @@ +/* 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 { + + Nim::Nim(AvalancheEngine *vm) { + _vm = vm; + } + + void Nim::playNim() { + warning("STUB: Nim::playNim()"); + } + + 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 -- cgit v1.2.3 From be41405969c6aa6a7472562eafda0092b9b97e52 Mon Sep 17 00:00:00 2001 From: urukgit Date: Fri, 22 Nov 2013 18:39:51 +0100 Subject: AVALANCHE: Fix Nim. --- engines/avalanche/nim.cpp | 130 +++++++++++++++++++++++----------------------- 1 file changed, 66 insertions(+), 64 deletions(-) (limited to 'engines/avalanche/nim.cpp') diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp index e7a73b5a62..cc4681bf3b 100644 --- a/engines/avalanche/nim.cpp +++ b/engines/avalanche/nim.cpp @@ -30,69 +30,71 @@ namespace Avalanche { - Nim::Nim(AvalancheEngine *vm) { - _vm = vm; - } - - void Nim::playNim() { - warning("STUB: Nim::playNim()"); - } - - 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()"); - } +const char * const Nim::names[2] = {"Avalot", "Dogfood"}; + +Nim::Nim(AvalancheEngine *vm) { + _vm = vm; +} + +void Nim::playNim() { + warning("STUB: Nim::playNim()"); +} + +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 -- cgit v1.2.3 From 13449472f2b2930cb09bcb685bf1d9a49c0d8ed1 Mon Sep 17 00:00:00 2001 From: urukgit Date: Sat, 23 Nov 2013 07:50:24 +0100 Subject: AVALANCHE: Implement Nim::playNim(). Repair naming of variables in Nim and add some helper functions. --- engines/avalanche/nim.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) (limited to 'engines/avalanche/nim.cpp') diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp index cc4681bf3b..faca3e491d 100644 --- a/engines/avalanche/nim.cpp +++ b/engines/avalanche/nim.cpp @@ -30,14 +30,83 @@ namespace Avalanche { -const char * const Nim::names[2] = {"Avalot", "Dogfood"}; +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) { + sz.syncAsByte(_playedNim); } void Nim::playNim() { - warning("STUB: 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. + _vm->incScore(7); // 7 points for winning! + } + + if (_playedNim == 1) + _vm->incScore(3); // 3 points for playing your 1st game. } void Nim::chalk(int x,int y, Common::String z) { -- cgit v1.2.3 From 84e99ae652662dfb32294cd9034666af9cf47e76 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Nov 2013 10:18:04 +0100 Subject: AVALANCHE: Fix savegames compatibility before/after Nim implementation --- engines/avalanche/nim.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/avalanche/nim.cpp') diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp index faca3e491d..d066ffc3e8 100644 --- a/engines/avalanche/nim.cpp +++ b/engines/avalanche/nim.cpp @@ -43,6 +43,9 @@ void Nim::resetVariables() { } void Nim::synchronize(Common::Serializer &sz) { + if (sz.isLoading() && sz.getVersion() < 2) + return; + sz.syncAsByte(_playedNim); } -- cgit v1.2.3 From 4fe5c64c3fa8c173c5c23d5dac4abc1dfd717910 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Nov 2013 10:31:51 +0100 Subject: AVALANCHE: Fix formatting in Nim --- engines/avalanche/nim.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'engines/avalanche/nim.cpp') diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp index d066ffc3e8..44a7975bae 100644 --- a/engines/avalanche/nim.cpp +++ b/engines/avalanche/nim.cpp @@ -51,16 +51,16 @@ void Nim::synchronize(Common::Serializer &sz) { void Nim::playNim() { if (_vm->_wonNim) { // Already won the game. - _vm->_dialogs->displayScrollChain('Q',6); + _vm->_dialogs->displayScrollChain('Q', 6); return; } if (!_vm->_askedDogfoodAboutNim) { - _vm->_dialogs->displayScrollChain('q',84); + _vm->_dialogs->displayScrollChain('q', 84); return; } - _vm->_dialogs->displayScrollChain('Q',3); + _vm->_dialogs->displayScrollChain('Q', 3); _playedNim++; _vm->fadeOut(); @@ -92,24 +92,29 @@ void Nim::playNim() { 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? + 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->_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! + } 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. - _vm->incScore(7); // 7 points for winning! + + // 7 points for winning! + _vm->incScore(7); } - if (_playedNim == 1) - _vm->incScore(3); // 3 points for playing your 1st game. + if (_playedNim == 1) { + // 3 points for playing your 1st game. + _vm->incScore(3); + } } void Nim::chalk(int x,int y, Common::String z) { -- cgit v1.2.3 From 1a7bcd72cfd0857c9e0e97be9b4daed5490427fe Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sat, 23 Nov 2013 10:42:15 +0100 Subject: AVALANCHE: Make the call of displayScrollChain() a bit more consistent --- engines/avalanche/nim.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/avalanche/nim.cpp') diff --git a/engines/avalanche/nim.cpp b/engines/avalanche/nim.cpp index 44a7975bae..a2572f1fa5 100644 --- a/engines/avalanche/nim.cpp +++ b/engines/avalanche/nim.cpp @@ -56,7 +56,7 @@ void Nim::playNim() { } if (!_vm->_askedDogfoodAboutNim) { - _vm->_dialogs->displayScrollChain('q', 84); + _vm->_dialogs->displayScrollChain('Q', 84); return; } -- cgit v1.2.3