Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields

battle.h

00001 /***************************************************************************
00002                           battle.h  -  description
00003                              -------------------
00004     begin                : Sat May 3 2003
00005     copyright            : (C) 2003 by Gabor Torok
00006     email                : cctorok@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef BATTLE_H
00019 #define BATTLE_H
00020 
00021 #include <iostream>
00022 #include <string>
00023 #include <vector>
00024 #include "constants.h"
00025 #include "session.h"
00026 #include "map.h"
00027 #include "creature.h"
00028 #include "item.h"
00029 #include "rpg/character.h"
00030 #include "rpg/monster.h"
00031 #include "rpg/spell.h"
00032 #include "effect.h"
00033 #include "projectile.h"
00034 #include "spellcaster.h"
00035 
00036 using namespace std;
00037 
00042 class Session;
00043 class Creature;
00044 class Item;
00045 class Projectile;
00046 class Spell;
00047 
00051 class Battle {
00052  private:
00053   Session *session;
00054   Creature *creature;
00055   Item* item;
00056   char message[200];
00057   int creatureInitiative;
00058   bool initiativeCheck;
00059   int speed;
00060   float dist;
00061   bool empty;
00062   bool projectileHit;
00063   Spell *spell;
00064   int weaponWait;
00065   float range;
00066 
00067   int ap, startingAp;
00068   bool paused;
00069   int steps;
00070   bool needsReset;
00071   int nextTurn;
00072 
00073   // sounds
00074   static int handheldSwishSoundStart, handheldSwishSoundCount;
00075   static int bowSwishSoundStart, bowSwishSoundCount;
00076   static int potionSoundStart, potionSoundCount;
00077   static char *sound[];
00078 
00079  public:
00080 
00081    static bool debugBattle;
00082 
00083    inline int getAP() { return ap; }
00084    inline int decrAP() { return --ap; }
00085    inline int getStartingAP() { return startingAp; }
00086   
00087    void endTurn();
00088 
00092   static void setupBattles(Session *session, Battle *battle[], int count, vector<Battle *> *turns);
00093 
00098   static void projectileHitTurn(Session *session, Projectile *proj, Creature *target);
00099   static void projectileHitTurn(Session *session, Projectile *proj, int x, int y);
00100 
00104   Battle();
00105 
00109   Battle(Session *session, Creature *creature);
00110   ~Battle();
00111 
00112   void reset();
00113   Creature *getAvailableTarget();
00114   Creature *getAvailablePartyTarget();
00115 
00116   inline bool isEmpty() { return empty; }
00117   bool fightTurn();
00118 
00119   void dealDamage(int damage, int maxDamage, int effect=Constants::EFFECT_GLOW, bool magical=false, GLuint delay=0 );
00120 
00121   inline Creature *getCreature() { return creature; }
00122   inline Session *getSession() { return session; }
00123 
00124   void invalidate();
00125 
00126   static inline int getSoundCount() { return handheldSwishSoundCount + bowSwishSoundCount + potionSoundCount; }
00127   static inline char *getSound(int index) { return sound[index]; }
00128 
00129  protected:
00130   void launchProjectile();
00131   //void initTurn();
00132   void hitWithItem();
00133   void initItem(Item *item);
00134   void castSpell();
00135   void executeEatDrinkAction();
00136   // return true if game paused
00137   bool pauseBeforePlayerTurn();
00138   void initTurnStep();
00139   void executeAction();
00140   void stepCloserToTarget();
00141   bool selectNewTarget();
00142   bool moveCreature();
00143 
00144   static char *getRandomSound(int start, int count);
00145 };
00146 
00147 #endif

Generated on Thu Jun 16 21:50:42 2005 for scourge by  doxygen 1.4.0