hoa_global::GlobalParty Class Reference

Represents a party of actors. More...

#include <global_actors.h>

Inheritance diagram for hoa_global::GlobalParty:

Inheritance graph
[legend]
Collaboration diagram for hoa_global::GlobalParty:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void AddActor (GlobalActor *actor, int32 index=-1)
 Adds an actor to the party.
float AverageExperienceLevel () const
 Computes the average experience level of all actors in the party.
GlobalActorGetActorAtIndex (uint32 index) const
 Retrieves a poitner to the actor in the party at a specified index.
GlobalActorGetActorByID (uint32 id) const
 Retrieves a poitner to the actor in the party with the spefified id.
std::vector< GlobalActor * > * GetAllActors ()
uint32 GetPartySize () const
GLOBAL_TARGET GetTargetType ()
 A pure virtual function that returns the type of target.
 GlobalParty (bool allow_duplicates=false)
bool IsAllowDuplicates () const
bool IsPartyEmpty () const
GlobalActorRemoveActorAtIndex (uint32 index)
 Removes an actor from the party.
GlobalActorRemoveActorByID (uint32 id)
 Removes an actor from the party.
void RemoveAllActors ()
 Clears the internally stored actor pointers.
GlobalActorReplaceActorByID (uint32 id, GlobalActor *new_actor)
 Replaces an actor in the party with the specified id with a new actor.
GlobalActorReplaceActorByIndex (uint32 index, GlobalActor *new_actor)
 Replaces an actor in the party at a specified index with a new actor.
void SwapActorsByID (uint32 first_id, uint32 second_id)
 Swaps the location of two actors in the party by looking up their IDs.
void SwapActorsByIndex (uint32 first_index, uint32 second_index)
 Swaps the location of two actors in the party by their indeces.
 ~GlobalParty ()

Private Attributes

std::vector< GlobalActor * > _actors
 The vector of actors that are in this party The class will not create nor destroy GlobalActor pointers stored in this data structure.
bool _allow_duplicates
 If true, actors are allowed to be inserted into the party multiple times.

Detailed Description

Represents a party of actors.

****************************************************************************

This class is a container for a group or "party" of actors. A party is a type of target for items and skills. The GameGlobal class also organizes characters into parties for convienence. Note that an actor may be either an enemy or a character, but you should avoid creating parties that contain both characters and enemies, as it can lead to conflicts (for example, a character and enemy which have the same ID value).

Parties may or may not allow duplicate actors (a duplicate actor is defined as an actor that has the same _id member as another actor in the party). This property is determined in the GlobalParty constructor

Note:
When this class is destroyed, the actors contained within the class are not destroyed.

All methods which perform an operation by using an actor ID are only valid to use if the party does not allow duplicates.

Definition at line 1094 of file global_actors.h.


Constructor & Destructor Documentation

hoa_global::GlobalParty::GlobalParty ( bool  allow_duplicates = false  )  [inline]

Parameters:
allow_duplicates Determines whether or not the party allows duplicate actors to be added (default value == false)

Definition at line 1099 of file global_actors.h.

hoa_global::GlobalParty::~GlobalParty (  )  [inline]

Definition at line 1102 of file global_actors.h.


Member Function Documentation

void hoa_global::GlobalParty::AddActor ( GlobalActor actor,
int32  index = -1 
)

Adds an actor to the party.

Parameters:
actor A pointer to the actor to add to the party
index The index where the actor should be inserted. If negative, actor is added to the end
Note:
The actor will not be added if it is already in the party

Definition at line 1074 of file global_actors.cpp.

References _actors, _allow_duplicates, hoa_global::GlobalActor::GetID(), and hoa_global::GLOBAL_DEBUG.

Referenced by hoa_global::GameGlobal::AddCharacter(), and hoa_global::GameGlobal::RemoveCharacter().

Here is the call graph for this function:

float hoa_global::GlobalParty::AverageExperienceLevel (  )  const

Computes the average experience level of all actors in the party.

Returns:
A float representing the average experience level (0.0f if party is empty)

Definition at line 1287 of file global_actors.cpp.

References _actors.

Referenced by hoa_global::GameGlobal::AverageActivePartyExperienceLevel().

GlobalActor* hoa_global::GlobalParty::GetActorAtIndex ( uint32  index  )  const [inline]

Retrieves a poitner to the actor in the party at a specified index.

Parameters:
index The index where the actor may be found in the party
Returns:
A pointer to the actor at the specified index, or NULL if the index argument was invalid

Definition at line 1166 of file global_actors.h.

References _actors.

Referenced by hoa_menu::MenuMode::_DrawBottomMenu(), hoa_battle::BattleMode::_Initialize(), hoa_menu::private_menu::EquipWindow::_UpdateEquipList(), hoa_menu::private_menu::SkillsWindow::_UpdateSkillList(), hoa_menu::private_menu::SkillsWindow::Draw(), hoa_menu::private_menu::EquipWindow::EquipWindow(), hoa_menu::private_menu::StatusWindow::StatusWindow(), hoa_menu::private_menu::SkillsWindow::Update(), hoa_menu::private_menu::StatusWindow::Update(), and hoa_menu::private_menu::InventoryWindow::Update().

GlobalActor * hoa_global::GlobalParty::GetActorByID ( uint32  id  )  const

Retrieves a poitner to the actor in the party with the spefified id.

Parameters:
id The id of the actor to return
Returns:
A pointer to the actor with the requested ID, or NULL if the actor was not found

Definition at line 1299 of file global_actors.cpp.

References _actors, _allow_duplicates, and hoa_global::GLOBAL_DEBUG.

std::vector<GlobalActor*>* hoa_global::GlobalParty::GetAllActors (  )  [inline]

Definition at line 1187 of file global_actors.h.

References _actors.

uint32 hoa_global::GlobalParty::GetPartySize (  )  const [inline]

Definition at line 1184 of file global_actors.h.

References _actors.

Referenced by hoa_menu::private_menu::EquipWindow::_InitCharSelect(), hoa_menu::private_menu::SkillsWindow::_InitCharSelect(), hoa_menu::private_menu::StatusWindow::_InitCharSelect(), hoa_menu::private_menu::InventoryWindow::_InitCharSelect(), hoa_battle::BattleMode::_Initialize(), hoa_battle::BattleMode::_UpdateTargetSelection(), hoa_menu::private_menu::StatusWindow::StatusWindow(), and hoa_menu::private_menu::StatusWindow::~StatusWindow().

GLOBAL_TARGET hoa_global::GlobalParty::GetTargetType (  )  [inline, virtual]

A pure virtual function that returns the type of target.

Returns:
The appropriate GLOBAL_TARGET enum for the target type in question
This method is necessary so that GlobalTarget can be an abstract class. Inheriting classes simply need to return a valid target type.

Implements hoa_global::GlobalTarget.

Definition at line 1175 of file global_actors.h.

References hoa_global::GLOBAL_TARGET_PARTY.

bool hoa_global::GlobalParty::IsAllowDuplicates (  )  const [inline]

Definition at line 1181 of file global_actors.h.

References _allow_duplicates.

bool hoa_global::GlobalParty::IsPartyEmpty (  )  const [inline]

Definition at line 1178 of file global_actors.h.

References _actors.

GlobalActor * hoa_global::GlobalParty::RemoveActorAtIndex ( uint32  index  ) 

Removes an actor from the party.

Parameters:
index The index of the actor in the party to remove
Returns:
A pointer to the actor that was removed, or NULL if the index provided was invalid

Definition at line 1111 of file global_actors.cpp.

References _actors, and hoa_global::GLOBAL_DEBUG.

GlobalActor * hoa_global::GlobalParty::RemoveActorByID ( uint32  id  ) 

Removes an actor from the party.

Parameters:
id The id value of the actor to remove
Returns:
A pointer to the actor that was removed, or NULL if the actor was not found in the party

Definition at line 1129 of file global_actors.cpp.

References _actors, _allow_duplicates, and hoa_global::GLOBAL_DEBUG.

void hoa_global::GlobalParty::RemoveAllActors (  )  [inline]

Clears the internally stored actor pointers.

Note:
This function does not return the actor pointers, so if you wish to get the GlobalActors make sure you do so prior to invoking this call.

Definition at line 1128 of file global_actors.h.

References _actors.

Referenced by hoa_global::GameGlobal::ClearAllData(), and hoa_global::GameGlobal::RemoveCharacter().

GlobalActor * hoa_global::GlobalParty::ReplaceActorByID ( uint32  id,
GlobalActor new_actor 
)

Replaces an actor in the party with the specified id with a new actor.

Parameters:
id The id of the actor to be replaced
new_actor A pointer to the actor that will replace the existing actor
Returns:
A pointer to the replaced actor, or NULL if the operation did not take place

Definition at line 1253 of file global_actors.cpp.

References _actors, _allow_duplicates, and hoa_global::GLOBAL_DEBUG.

GlobalActor * hoa_global::GlobalParty::ReplaceActorByIndex ( uint32  index,
GlobalActor new_actor 
)

Replaces an actor in the party at a specified index with a new actor.

Parameters:
index The index of the actor to be replaced
new_actor A pointer to the actor that will replace the existing actor
Returns:
A pointer to the replaced actor, or NULL if the operation did not take place

Definition at line 1232 of file global_actors.cpp.

References _actors, and hoa_global::GLOBAL_DEBUG.

void hoa_global::GlobalParty::SwapActorsByID ( uint32  first_id,
uint32  second_id 
)

Swaps the location of two actors in the party by looking up their IDs.

Parameters:
first_id The id of the first actor to swap
second_id The id of the second actor to swap

Definition at line 1186 of file global_actors.cpp.

References _actors, _allow_duplicates, and hoa_global::GLOBAL_DEBUG.

void hoa_global::GlobalParty::SwapActorsByIndex ( uint32  first_index,
uint32  second_index 
)

Swaps the location of two actors in the party by their indeces.

Parameters:
first_index The index of the first actor to swap
second_index The index of the second actor to swap

Definition at line 1157 of file global_actors.cpp.

References _actors, and hoa_global::GLOBAL_DEBUG.


Member Data Documentation

std::vector<GlobalActor*> hoa_global::GlobalParty::_actors [private]

The vector of actors that are in this party The class will not create nor destroy GlobalActor pointers stored in this data structure.

Definition at line 1194 of file global_actors.h.

Referenced by AddActor(), AverageExperienceLevel(), GetActorAtIndex(), GetActorByID(), GetAllActors(), GetPartySize(), IsPartyEmpty(), RemoveActorAtIndex(), RemoveActorByID(), RemoveAllActors(), ReplaceActorByID(), ReplaceActorByIndex(), SwapActorsByID(), and SwapActorsByIndex().

bool hoa_global::GlobalParty::_allow_duplicates [private]

If true, actors are allowed to be inserted into the party multiple times.

Definition at line 1197 of file global_actors.h.

Referenced by AddActor(), GetActorByID(), IsAllowDuplicates(), RemoveActorByID(), ReplaceActorByID(), and SwapActorsByID().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:14:23 2007 for Hero of Allacrost by  doxygen 1.5.1