00001 /* -*- Mode: C++; c-basic-offset: 5 -*- */ 00002 00003 /* 00004 * Combination of a first person action and a real time strategy battle game. 00005 */ 00006 00007 /* 00008 * Conditions.h 00009 * MetalWarriors 00010 * $Revision: 1.5 $ 00011 * 00012 * Created by bishop on Sun Sep 04 2005. 00013 * Copyright (c) 2003 - 2005 Daniel Aarno and Erik Ytterberg. 00014 * All rights reserved. 00015 * 00016 * This program is free software; you can redistribute it and/or modify 00017 * it under the terms of the GNU General Public License as published by 00018 * the Free Software Foundation; either version 2 of the License, or 00019 * (at your option) any later version. 00020 * 00021 * This program is distributed in the hope that it will be useful, 00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00024 * GNU General Public License for more details. 00025 * 00026 * You should have received a copy of the GNU General Public License 00027 * along with this program; if not, write to the Free Software 00028 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00029 */ 00030 00031 #ifndef _CONDITIONS_ 00032 #define _CONDITIONS_ 00033 00034 #include "WinCond.h" 00035 #include <vector> 00036 00037 class NumOp; 00038 00039 //====================================================================== 00040 // Condition on the number of tanks remaining 00041 //====================================================================== 00064 class TankCountCond : public Cond::Bool { 00065 public: 00066 //pointer to memberfunction that takes a string argument 00067 typedef bool (TankCountCond::* set_func_t)(const std::string &arg); 00068 00069 TankCountCond() : op(0) {} 00070 virtual ~TankCountCond(); 00071 00072 virtual void evaluate(); 00073 00074 bool setTankCount(const std::string &countStr); 00075 bool setOperator(const std::string &oper); 00076 bool setTeamNumber(const std::string &teamNo); 00077 00078 virtual set_func_t funcForType(const std::string &type); 00079 00080 private: 00081 int team; 00082 int count; 00083 NumOp* op; 00084 }; 00085 00086 //====================================================================== 00087 // Condition on the teams power 00088 //====================================================================== 00089 00113 class TeamPowerCond : public Cond::Bool { 00114 public: 00115 //pointer to memberfunction that takes a string argument 00116 typedef bool (TeamPowerCond::* set_func_t)(const std::string &arg); 00117 00118 TeamPowerCond() : op(0) {} 00119 virtual ~TeamPowerCond(); 00120 00121 virtual void evaluate(); 00122 00123 bool setPower(const std::string &countStr); 00124 bool setOperator(const std::string &oper); 00125 bool setTeamNumber(const std::string &teamNo); 00126 00127 virtual set_func_t funcForType(const std::string &type); 00128 00129 private: 00130 int team; 00131 double power; 00132 NumOp* op; 00133 }; 00134 00135 //====================================================================== 00136 // Condition on holding an area 00137 //====================================================================== 00138 00166 class HoldAreaCond : public Cond::Bool { 00167 public: 00168 //pointer to memberfunction that takes a string argument 00169 typedef bool (HoldAreaCond::* set_func_t)(const std::string &arg); 00170 00171 HoldAreaCond() : curTime(-1) {} 00172 00173 virtual void evaluate(); 00174 00175 bool setArea(const std::string &areaCoords); 00176 bool setTime(const std::string &time); 00177 bool setTeamNumber(const std::string &teamNo); 00178 00179 virtual set_func_t funcForType(const std::string &type); 00180 00181 private: 00182 int team; 00183 double time; 00184 double curTime; 00185 std::vector<float> x_coords; 00186 std::vector<float> y_coords; 00187 }; 00188 00189 00190 class TankHealthCond : public Cond::Bool { 00191 public: 00192 //pointer to memberfunction that takes a string argument 00193 typedef bool (TankHealthCond::* set_func_t)(const std::string &arg); 00194 00195 TankHealthCond() : op(0) {} 00196 00197 virtual void evaluate(); 00198 00199 bool setHealth(const std::string &countStr); 00200 bool setOperator(const std::string &oper); 00201 bool setTeamNumber(const std::string &teamNo); 00202 bool setName(const std::string &teamNo); 00203 00204 virtual set_func_t funcForType(const std::string &type); 00205 00206 private: 00207 std::string name; 00208 int team; 00209 double health; 00210 NumOp* op; 00211 }; 00212 00213 #endif
1.4.7