Hi guys.
I am using Ians framework witch uses objects instead of object numbers. I am working on my item system right now and ran into a little problem. does antone know if there is a way to loop though all the objects to see if one of the varibles are greater then 0. i could check one at a time to see but that seams like alot of code for a simple thing.
this is how my item class works
#pragma once
#include "NumberResource.h"
#include <boost/shared_ptr.hpp>
class BasicItem
{
public:
BasicItem();
// Destructor - virtual, because I expect this class to be inherited from
virtual ~BasicItem();
u_int Cost(){ return Price; } // How much the Item cost.
std::string GetName(){ return Name; } // The Name of the Item
protected:
class ItemRef
{
public:
ItemRef() : ObjectNumber(FreeList.NewItem()) { }
~ItemRef()
{
FreeList.ReleaseItem(ObjectNumber);
}
int Ref() const { return ObjectNumber; }
private:
int ObjectNumber;
static NumberResource FreeList;
};
u_int Price; // Price for the item.
std::string Name;
u_int Quantity; // amount of that item.
int Heal_Amt;
int Bonus;
int Attack;
int Defence;
int Agility;
int Strength;
float Weight; // used for how the object affects the speed of the player.
std::string Type; // type of item heal, attack, defend, ect.
boost::shared_ptr<ItemRef> IT;
friend class LoadPlayer;
friend class Menu_Sprite;
};
#include "stdafx.h"
#include "Items.h"
#include "Invertory.h"
Item::Item( std::string name, u_int cost, std::string type)
{
Name = name;
Price = cost;
Type = type;
}
void Item::SetAttributes(int amount)
{
if (Type == "Heal")
{
Heal_Amt = amount;
}
}
void Item::SetAttributes(int amount, int bonus)
{
if (Type == "Attack")
{
Attack = amount;
Bonus = bonus;
}
if (Type == "Defence")
{
Defence = amount;
Bonus = bonus;
}
}
void Item::SetAttributes(int atk, int def, int agi, int str)
{
Attack = atk;
Defence = def;
Agility = agi;
Strength = str;
}
void Item::SetQuantity(int amount)
{
Quantity = amount;
}
int Item::GetQuantity()
{
return Quantity;
}
thats pretty mucg the basics of it.
any ideas