src/team/team.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
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; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * A team.
00020  *****************************************************************************/
00021 
00022 #ifndef TEAM_H
00023 #define TEAM_H
00024 
00025 #include <list>
00026 #include <map>
00027 #include <string>
00028 #include "team_energy.h"
00029 #include "../character/character.h"
00030 #include "../graphic/surface.h"
00031 #include "../include/base.h"
00032 #include "../weapon/crosshair.h"
00033 #include "../weapon/weapon.h"
00034 #include "../tool/point.h"
00035 #include "../tool/resource_manager.h"
00036 
00037 class Character;
00038 class Weapon;
00039 
00040 typedef enum {
00041   TEAM_human_local,
00042   TEAM_ai_local,
00043   TEAM_remote
00044 } team_player_type_t;
00045 
00046 class Team
00047 {
00048   public:
00049     typedef std::list<Character>::iterator iterator;
00050     typedef std::list<Character>::const_iterator const_iterator;
00051 
00052     std::map<std::string, int> m_nb_ammos;
00053     std::map<std::string, int> m_nb_units;
00054 
00055   // Autres
00056     CrossHair crosshair;
00057     Surface flag;
00058     Point2i sauve_camera;
00059     TeamEnergy energy;
00060 
00061   private:
00062     bool is_camera_saved;
00063     std::string m_teams_dir; // parent directory hosting the data
00064     std::string m_id;
00065     std::string m_name;
00066     std::string m_player_name;
00067     std::string m_sound_profile;
00068     std::list<Character> characters;
00069     iterator active_character;
00070     Weapon *active_weapon;
00071     uint nb_characters;
00072 
00073     team_player_type_t type_of_player;
00074 
00075     Team (const std::string& _teams_dir,
00076           const std::string& _id,
00077           const std::string& _name,
00078           const Surface &_flag,
00079           const std::string& _sound_profile);
00080 
00081     bool LoadCharacters(uint howmany);
00082   public:
00083     static Team* CreateTeam (const std::string &teams_dir, const std::string &id);
00084 
00085     void LoadGamingData(uint howmany);
00086     void UnloadGamingData();
00087 
00088     bool IsSameAs(const Team& other) const;
00089 
00090   // Manage number of characters
00091     void SetNbCharacters(uint howmany);
00092     uint GetNbCharacters() const { return nb_characters; }
00093 
00094   // Switch to next worm.
00095     void NextCharacter();
00096     void SelectCharacter(uint index);
00097 
00098   // Prepare turn.
00099     void PrepareTurn();
00100 
00101   // Access to the character.
00102     Character& ActiveCharacter();
00103 
00104     void DrawEnergy(const Point2i& pos);
00105     void Refresh();
00106 
00107   // Change the weapon.
00108     void SetWeapon (Weapon::Weapon_type nv_arme);
00109     int NbAliveCharacter() const;
00110 
00111   // Access to the active weapon.
00112     Weapon& AccessWeapon() const;
00113     const Weapon& GetWeapon() const;
00114     Weapon::Weapon_type GetWeaponType() const;
00115 
00116   // Init the energy bar of the team.
00117     void InitEnergy (uint max);
00118 
00119   // Update the energy bar values of the team.
00120     void UpdateEnergyBar();
00121     TeamEnergy & GetEnergyBar();
00122 
00123   // Read the total energy of the team.
00124     uint ReadEnergy();
00125 
00126   // Access to data.
00127     const std::string& GetName() const { return m_name; }
00128     const std::string& GetId() const { return m_id; }
00129     const std::string& GetPlayerName() const { return m_player_name; }
00130     const std::string& GetSoundProfile() const { return m_sound_profile; }
00131     iterator begin();
00132     iterator end();
00133     Character* FindByIndex(uint index);
00134 
00135     void SetPlayerName(const std::string& player_name);
00136 
00137   // Number of ammo for the current selected weapon.
00138   // (return INFINITE_AMMO is ammo are unlimited !)
00139     int ReadNbAmmos() const;
00140     int ReadNbAmmos(const std::string &weapon_name) const;
00141     int& AccessNbAmmos();
00142 
00143 
00144   // Number of current unit per ammo for the selected weapon.
00145     int ReadNbUnits() const;
00146     int ReadNbUnits(const std::string &weapon_name) const;
00147     int& AccessNbUnits();
00148     void ResetNbUnits();
00149 
00150   // Only for network:
00151   // true if the team belong to a local player
00152   // false if the team belong to a player on the network or on the AI
00153     bool IsLocal() const;
00154 
00155   // true if the team belong to a local AI
00156     bool IsLocalAI() const;
00157 
00158     bool IsActiveTeam() const;
00159 
00160     void SetLocal();
00161     void SetLocalAI();
00162     void SetRemote();
00163 
00164 };
00165 
00166 #endif /* TEAM_H */
00167 

Generated on Mon Jan 1 13:10:59 2007 for Wormux by  doxygen 1.4.7