⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 item.h

📁 MUD游戏编程光盘代码
💻 H
字号:
// MUD Programming
// Ron Penton
// (C)2003
// Item.h - The class defining Items in the SimpleMUD
// 
// 


#ifndef SIMPLEMUDITEM_H
#define SIMPLEMUDITEM_H

#include <string>
#include <iostream>
#include "BasicLib/BasicLib.h"
#include "Entity.h"
#include "Attributes.h"

using std::ostream;
using std::istream;

namespace SimpleMUD
{

typedef unsigned long int money;

// --------------------------------------------------------------------
//  Class that stores information about items
// --------------------------------------------------------------------
class Item : public Entity
{
public:
    Item()
    {
        m_type = WEAPON;
        m_min = 0;
        m_max = 0;
        m_speed = 0;
    }

    inline ItemType& Type()         { return m_type; }

    inline int& GetAttr( int p_att )
    {
        return m_attributes[p_att];
    }

    inline int& Min()               { return m_min; }
    inline int& Max()               { return m_max; }
    inline int& Speed()             { return m_speed; }
    inline money& Price()           { return m_price; }


    friend istream& operator>>( istream& p_stream, Item& i );

protected:
    // -----------------------------------------
    //  Item Information
    // -----------------------------------------
    ItemType m_type;

    // item attributes
    int m_min;
    int m_max;
    int m_speed;
    money m_price;

    // player modification attributes
    AttributeSet m_attributes;


};  // end class Item


// --------------------------------------------------------------------
//  Extracts an item in text form from a stream
// --------------------------------------------------------------------
inline istream& operator>>( istream& p_stream, Item& i )
{
    std::string temp;

    p_stream >> temp >> std::ws;     std::getline( p_stream, i.m_name );
    p_stream >> temp >> temp;         i.m_type = GetItemType( temp );
    p_stream >> temp >> i.m_min;
    p_stream >> temp >> i.m_max;
    p_stream >> temp >> i.m_speed;
    p_stream >> temp >> i.m_price;
    p_stream >> i.m_attributes;

    return p_stream;
}


}   // end namespace SimpleMUD


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -