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/avalanche.cpp | 3 ++ engines/avalanche/avalanche.h | 2 + engines/avalanche/module.mk | 3 +- engines/avalanche/nim.cpp | 98 +++++++++++++++++++++++++++++++++++++++++ engines/avalanche/nim.h | 72 ++++++++++++++++++++++++++++++ engines/avalanche/parser.cpp | 8 ++-- 6 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 engines/avalanche/nim.cpp create mode 100644 engines/avalanche/nim.h (limited to 'engines/avalanche') diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index 8b3efe4081..b608ed1f11 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -55,6 +55,7 @@ AvalancheEngine::AvalancheEngine(OSystem *syst, const AvalancheGameDescription * _menu = nullptr; _closing = nullptr; _sound = nullptr; + _nim = nullptr; _platform = gd->desc.platform; initVariables(); @@ -77,6 +78,7 @@ AvalancheEngine::~AvalancheEngine() { delete _menu; delete _closing; delete _sound; + delete _nim; for (int i = 0; i < 31; i++) { for (int j = 0; j < 2; j++) { @@ -182,6 +184,7 @@ Common::ErrorCode AvalancheEngine::initialize() { _menu = new Menu(this); _closing = new Closing(this); _sound = new SoundHandler(this); + _nim = new Nim(this); _graphics->init(); _dialogs->init(); diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index fdbc4c7a15..b2a4269249 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -41,6 +41,7 @@ #include "avalanche/menu.h" #include "avalanche/closing.h" #include "avalanche/sound.h" +#include "avalanche/nim.h" #include "common/serializer.h" @@ -84,6 +85,7 @@ public: Menu *_menu; Closing *_closing; SoundHandler *_sound; + Nim *_nim; OSystem *_system; diff --git a/engines/avalanche/module.mk b/engines/avalanche/module.mk index 9c1205df02..0f66bb8213 100644 --- a/engines/avalanche/module.mk +++ b/engines/avalanche/module.mk @@ -15,7 +15,8 @@ MODULE_OBJS = \ dialogs.o \ sequence.o \ sound.o \ - timer.o + timer.o \ + nim.o # This module can be built as a plugin ifeq ($(ENABLE_AVALANCHE), DYNAMIC_PLUGIN) 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 diff --git a/engines/avalanche/nim.h b/engines/avalanche/nim.h new file mode 100644 index 0000000000..9d421c401c --- /dev/null +++ b/engines/avalanche/nim.h @@ -0,0 +1,72 @@ +/* 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. + */ + +#ifndef AVALANCHE_NIM_H +#define AVALANCHE_NIM_H + +namespace Avalanche { + +class Nim { +public: + Nim(AvalancheEngine *vm); + void playNim(); + +private: + AvalancheEngine *_vm; + + const Common::String names[2] = {"Avalot", "Dogfood"}; + byte old[3]; + byte stones[3]; + byte stonePic[4][23][7]; // Picture of Nimstone. + byte turns; + bool dogfoodsTurn; + byte stonesLeft; + bool clicked; + byte row; + byte number; + bool squeak; + int8 mNum, mRow; + + void chalk(int x,int y, Common::String z); + void setup(); + void plotStone(byte x,byte y); + void board(); + void startMove(); + void showChanges(); + void blip(); + void checkMouse(); + void less(); + void takeSome(); + void endOfGame(); + void dogFood(); + bool find(byte x); + void findAp(byte start,byte stepsize); +}; + +} // End of namespace Avalanche + +#endif // AVALANCHE_NIM_H diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index 6090dc967a..eef325fa63 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -27,6 +27,7 @@ #include "avalanche/avalanche.h" #include "avalanche/parser.h" +#include "avalanche/nim.h" #include "gui/saveload.h" @@ -1965,11 +1966,10 @@ void Parser::doThat() { switch (_vm->_room) { case kRoomArgentPub: // ...in the pub, => play Nim. - warning("STUB: Parser::doThat() - case kVerbCodeplay - play_nim()"); - // play_nim(); + _vm->_nim->playNim(); - // The following parts are copied from play_nim(). - // The player automatically wins the game everytime he wins, until I implement the mini-game. + // The following parts are copied from the original play_nim() and a little plus. + // The player automatically wins the game everytime he plays, until I implement the mini-game. if (_vm->_wonNim) { // Already won the game. _vm->_dialogs->displayScrollChain('Q', 6); return; -- cgit v1.2.3