Advanced Strategic Command
campaignactionrecorder.h
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 #ifndef campaignactionrecorderH
22 #define campaignactionrecorderH
23 
24 #include <sigc++/sigc++.h>
25 #include "luacommandwriter.h"
26 #include "gamemap.h"
27 
28 template <class C>
30  int counter;
31  public:
32  LuaCommandListRecorder ( C& container ) : LuaCommandListWriter<C>( container), counter(0) {};
33  void printCommand( const ASCString& command ){
34  if ( command.find('\n') != ASCString::npos ) {
36  } else {
37  ++counter;
38  LuaCommandListWriter<C>::outputLine("r = asc." + command + "\n" );
39  LuaCommandListWriter<C>::outputLine("if r:successful()==false then asc.displayActionError(r) \n asc.errorMessage('Failure at command " + ASCString::toString(counter) + "') \n return\nend \n" );
40  }
41  }
42 };
43 
44 
45 class CampaignActionLogger : public sigc::trackable, public ActionRecorder {
46 
47  void endTurn( Player& player );
48 
49  GameMap* gamemap;
50 
51  typedef list<ASCString> CommandList;
52  CommandList commands;
53 
54  void mapWon( Player& player );
55  void commitCommand( GameMap* map, Command& command );
57 
58  public:
60 
61  void readData ( tnstream& stream );
62 
63  void writeData ( tnstream& stream ) ;
64 };
65 
66 #endif
virtual void outputLine(const ASCString &line)
void readData(tnstream &stream)
The interface for all kinds of IO stream.
A Command is an action that the player initiates.
Definition: command.h:114
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
void splitString(const ASCString &string)
static ASCString toString(int i)
converts the parameter to a String
Definition: ascstring.cpp:193
void printCommand(const ASCString &command)
Definition of THE central asc class: GameMap.
void writeData(tnstream &stream)
the different players in ASC. There may be 8 players (0..7) and neutral units (8) ...
Definition: player.h:99
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182