00001 /* 00002 This file is part of Advanced Strategic Command; http://www.asc-hq.de 00003 Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; see the file COPYING. If not, write to the 00017 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00018 Boston, MA 02111-1307 USA 00019 */ 00020 00021 00022 #ifndef CommandH 00023 #define CommandH 00024 00025 #include "action.h" 00026 00114 class Command : public GameAction { 00115 public: 00116 enum State { Planned, 00117 Evaluated, 00118 SetUp, 00119 Run, 00120 Finished, 00121 Failed }; 00122 private: 00123 State state; 00124 public: 00125 State getState() const { return state; }; 00126 00127 virtual ASCString getCommandString() const = 0; 00128 00129 ActionResult redo( const Context& context ); 00130 00132 virtual vector<MapCoordinate> getCoordinates() const; 00133 00134 protected: 00135 Command( GameMap* gamemap ); 00136 00137 void setState( State state ); 00138 00139 virtual ActionResult go ( const Context& context ) = 0; 00140 00141 virtual ActionResult runAction( const Context& context ) ; 00142 virtual ActionResult undoAction( const Context& context ); 00143 00144 virtual void readData ( tnstream& stream ); 00145 virtual void writeData ( tnstream& stream ) const; 00146 00147 virtual ActionResult checkExecutionPrecondition() const; 00148 00149 }; 00150 00151 #endif 00152
1.5.1