1
/*
2
 *  The Mana World
3
 *  Copyright (C) 2004  The Mana World Development Team
4
 *
5
 *  This file is part of The Mana World.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program; if not, write to the Free Software
19
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
 */
21
22
#ifndef PLAYER_H
23
#define PLAYER_H
24
25
#include "being.h"
26
27
class Graphics;
28
class Map;
29
#ifdef TMWSERV_SUPPORT
30
class Guild;
31
#endif
32
33
enum Gender
34
{
35
    GENDER_MALE = 0,
36
    GENDER_FEMALE = 1,
37
    GENDER_UNSPECIFIED = 2
38
};
39
40
/**
41
 * A player being. Players have their name drawn beneath them. This class also
42
 * implements player-specific loading of base sprite, hair sprite and equipment
43
 * sprites.
44
 */
45
class Player : public Being
46
{
47
    public:
48
        enum Sprite
49
        {
50
            BASE_SPRITE = 0,
51
            SHOE_SPRITE,
52
            BOTTOMCLOTHES_SPRITE,
53
            TOPCLOTHES_SPRITE,
54
#ifdef EATHENA_SUPPORT
55
            MISC1_SPRITE,
56
            MISC2_SPRITE,
57
#endif
58
            HAIR_SPRITE,
59
            HAT_SPRITE,
60
#ifdef EATHENA_SUPPORT
61
            CAPE_SPRITE,
62
            GLOVES_SPRITE,
63
#endif
64
            WEAPON_SPRITE,
65
#ifdef EATHENA_SUPPORT
66
            SHIELD_SPRITE,
67
#endif
68
            VECTOREND_SPRITE
69
        };
70
71
        /**
72
         * Constructor.
73
         */
74
        Player(int id, int job, Map *map, bool isNPC = false);
75
76
        ~Player();
77
78
#ifdef EATHENA_SUPPORT
79
        virtual void logic();
80
#endif
81
82
        virtual Type getType() const { return PLAYER; }
83
84
        /**
85
         * Sets the gender of this being.
86
         */
87
        virtual void setGender(Gender gender);
88
89
        Gender getGender() const { return mGender; }
90
91
        /**
92
         * Whether or not this player is a GM.
93
         */
94
        bool isGM() const { return mIsGM; }
95
96
        /**
97
         * Triggers whether or not to show the name as a GM name.
98
         */
99
        virtual void setGM(bool gm);
100
101
        /**
102
         * Sets visible equipments for this player.
103
         */
104
        virtual void setSprite(unsigned int slot, int id,
105
                               const std::string &color = "");
106
107
        virtual void setSpriteID(unsigned int slot, int id);
108
109
        virtual void setSpriteColor(unsigned int slot,
110
                                    const std::string &color = "");
111
112
#ifdef TMWSERV_SUPPORT
113
        /**
114
         * Adds a guild to the player.
115
         */
116
        Guild *addGuild(short guildId, short rights);
117
118
        /**
119
         * Removers a guild from the player.
120
         */
121
        void removeGuild(int id);
122
123
        /**
124
         * Returns a pointer to the specified guild.
125
         */
126
        Guild *getGuild(const std::string &guildName) const;
127
128
        /**
129
         * Returns a pointer to the guild with matching id.
130
         */
131
        Guild *getGuild(int id) const;
132
133
        /**
134
         * Get number of guilds the player belongs to.
135
         */
136
        short getNumberOfGuilds();
137
138
#endif
139
140
        /**
141
         * Set whether the player in the LocalPlayer's party. Players that are
142
         * in the same party as the local player get their name displayed in
143
         * a different color.
144
         */
145
        void setInParty(bool inParty);
146
147
        bool isInParty() const { return mInParty; }
148
149
        /**
150
         * Gets the way the character is blocked by other objects.
151
         */
152
        virtual unsigned char getWalkMask() const
153
        { return Map::BLOCKMASK_WALL | Map::BLOCKMASK_MONSTER; }
154
155
        /**
156
         * Called when a option (set with config.addListener()) is changed
157
         */
158
        virtual void optionChanged(const std::string &value);
159
160
    protected:
161
        /**
162
         * Gets the way the monster blocks pathfinding for other objects.
163
         */
164
        virtual Map::BlockType getBlockType() const
165
        { return Map::BLOCKTYPE_CHARACTER; }
166
167
        virtual void updateColors();
168
169
        Gender mGender;
170
        std::vector<int> mSpriteIDs;
171
        std::vector<std::string> mSpriteColors;
172
173
#ifdef TMWSERV_SUPPORT
174
        // Character guild information
175
        std::map<int, Guild*> mGuilds;
176
#endif
177
178
        bool mIsGM;
179
180
    private:
181
        bool mInParty;
182
};
183
184
#endif