[ create a new paste ] login | about

Link: http://codepad.org/0DE7ZRY5    [ raw code | fork ]

C++, pasted on Apr 11:
#pragma once

#include <string>
#include <vector>
#include "Player.h"
class Ability;
class Item;
class Order;



class Unit
{
public:
	enum ATTRIBUTE
	{
		ACTIONS_PER_ROUND	= 0,
		STRENGTH			= 1,
		INTELLIGENCE		= 2,
		SPEED				= 3,
		LIFE				= 4,
		MANA				= 5,
		DAMAGE				= 6,
		SPELL_POWER			= 7,
		ARMOR				= 8,
		PHYSICAL_RESISTANCE	= 9,
		MAGICAL_RESISTANCE	= 10,
		ATTRIBUTE_COUNT		= 11
	};
	enum UNIT_TYPE
	{
		UNIT_TYPE_FLYING	= 0,
		UNIT_TYPE_UNDEAD	= 1,
		UNIT_TYPE_DEAD		= 2,
		UNIT_TYPE_COUNT		= 3
	};

	Unit( const Player& owner, const int unitID );
	virtual ~Unit();
	void setName( const std::string& newname );
	const std::string& getName() const;
	void setLevel( int newLevel );
	int getLevel() const;
	void setAttribute( ATTRIBUTE whichAttribute, float value );
	float getAttribute( ATTRIBUTE whichAttribute ) const;
	void setOwner( const Player& newOwner );
	const Player& getOwner() const;
	void addAbility( Ability& ability );
	void removeAbility( const std::string& abilityName );
	bool hasAbility( const std::string& abilityName ) const;
	void addItem( Item& item );
	void removeItem( const std::string& itemName );
	bool hasItem( const std::string& itemName ) const;
	void order( Order& order );
	Order* const getCurrentOrder() const;
	bool hasUnitType( UNIT_TYPE type ) const;
	void addUnitType( UNIT_TYPE type );
	void removeUnitType( UNIT_TYPE type );
	const int getID() const;
	virtual std::string toString() const;
	bool operator==( const Unit& rhs ) const;

protected:
	const int _unitID;
	std::string _name;
	int _level;
	float _attributes[ATTRIBUTE_COUNT];
	bool _unittypes[UNIT_TYPE_COUNT];
	const Player* _owner;
	std::vector<Ability*> _abilities;
	std::vector<Item*> _items;
	Order* _currentOrder;

private:
	Unit( const Unit& param );
};


Create a new paste based on this one


Comments: