summaryrefslogtreecommitdiff
path: root/src/being
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-11 19:28:57 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-11 19:28:57 +0300
commit87c59212f8590a8dd72fac3e320fcb2ada781355 (patch)
tree198d627c44f1164140659827a5c782d30bec375b /src/being
parent02e91411eb9961e95f856bd717d6ca0d8ec0e435 (diff)
downloadplus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.gz
plus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.bz2
plus-87c59212f8590a8dd72fac3e320fcb2ada781355.tar.xz
plus-87c59212f8590a8dd72fac3e320fcb2ada781355.zip
Move player attributes into separate file.
Diffstat (limited to 'src/being')
-rw-r--r--src/being/attributes.h52
-rw-r--r--src/being/being.cpp5
-rw-r--r--src/being/localplayer.cpp13
-rw-r--r--src/being/playerinfo.cpp13
-rw-r--r--src/being/playerinfo.h24
5 files changed, 70 insertions, 37 deletions
diff --git a/src/being/attributes.h b/src/being/attributes.h
new file mode 100644
index 000000000..612ef886c
--- /dev/null
+++ b/src/being/attributes.h
@@ -0,0 +1,52 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef BEING_ATTRIBUTES_H
+#define BEING_ATTRIBUTES_H
+
+namespace Attributes
+{
+ /**
+ * Standard attributes for players.
+ */
+ enum Attributes
+ {
+ LEVEL = 0,
+ HP,
+ MAX_HP,
+ MP,
+ MAX_MP,
+ EXP,
+ EXP_NEEDED,
+ MONEY,
+ TOTAL_WEIGHT,
+ MAX_WEIGHT,
+ SKILL_POINTS,
+ CHAR_POINTS,
+ CORR_POINTS,
+ ATTACK_DELAY = 100,
+ ATTACK_RANGE = 101,
+ WALK_SPEED = 102,
+ ATTACK_SPEED = 103
+ };
+} // namespace Attributes
+
+#endif // BEING_ATTRIBUTES_H
diff --git a/src/being/being.cpp b/src/being/being.cpp
index c9af368b2..4cd30f35f 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -33,6 +33,7 @@
#include "soundmanager.h"
#include "text.h"
+#include "being/attributes.h"
#include "being/beingcacheentry.h"
#include "being/playerrelations.h"
@@ -2392,8 +2393,8 @@ void Being::drawSpriteAt(Graphics *const graphics,
}
if (mShowOwnHP && mInfo && player_node == this && mAction != DEAD)
{
- drawHpBar(graphics, PlayerInfo::getAttribute(PlayerInfo::MAX_HP),
- PlayerInfo::getAttribute(PlayerInfo::HP), 0,
+ drawHpBar(graphics, PlayerInfo::getAttribute(Attributes::MAX_HP),
+ PlayerInfo::getAttribute(Attributes::HP), 0,
UserPalette::PLAYER_HP, UserPalette::PLAYER_HP2,
x - 50 + mapTileSize / 2 + mInfo->getHpBarOffsetX(),
y + mapTileSize - 6 + mInfo->getHpBarOffsetY(),
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 7efaaa907..ca6514ace 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -35,6 +35,7 @@
#include "statuseffect.h"
#include "resources/map/walklayer.h"
+#include "being/attributes.h"
#include "being/playerinfo.h"
#include "being/playerrelations.h"
@@ -191,9 +192,9 @@ LocalPlayer::LocalPlayer(const int id, const int subtype) :
else
mNameColor = nullptr;
- PlayerInfo::setStatBase(PlayerInfo::WALK_SPEED,
+ PlayerInfo::setStatBase(Attributes::WALK_SPEED,
static_cast<int>(getWalkSpeed().x));
- PlayerInfo::setStatMod(PlayerInfo::WALK_SPEED, 0);
+ PlayerInfo::setStatMod(Attributes::WALK_SPEED, 0);
loadHomes();
@@ -1075,7 +1076,7 @@ void LocalPlayer::attributeChanged(const int id,
{
switch (id)
{
- case PlayerInfo::EXP:
+ case Attributes::EXP:
{
if (oldVal > newVal)
break;
@@ -1088,7 +1089,7 @@ void LocalPlayer::attributeChanged(const int id,
}
break;
}
- case PlayerInfo::LEVEL:
+ case Attributes::LEVEL:
mLevel = newVal;
break;
default:
@@ -2693,7 +2694,7 @@ void LocalPlayer::tryMagic(const std::string &spell, const int baseMagic,
if (PlayerInfo::getSkillLevel(340) >= baseMagic
&& PlayerInfo::getSkillLevel(342) >= schoolMagic)
{
- if (PlayerInfo::getAttribute(PlayerInfo::MP) >= mana)
+ if (PlayerInfo::getAttribute(Attributes::MP) >= mana)
{
if (!client->limitPackets(PACKET_CHAT))
return;
@@ -3594,7 +3595,7 @@ void LocalPlayer::respawn()
int LocalPlayer::getLevel() const
{
- return PlayerInfo::getAttribute(PlayerInfo::LEVEL);
+ return PlayerInfo::getAttribute(Attributes::LEVEL);
}
void LocalPlayer::updateNavigateList()
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index fdbad89a5..b4824599b 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -24,6 +24,9 @@
#include "client.h"
#include "configuration.h"
#include "inventory.h"
+
+#include "being/attributes.h"
+
#include "itemsoundmanager.h"
#include "gui/windows/inventorywindow.h"
@@ -363,18 +366,18 @@ void updateAttrs()
if (!handler)
return;
const int attr = handler->getAttackLocation();
- const int attackDelay = getStatBase(ATTACK_DELAY);
+ const int attackDelay = getStatBase(Attributes::ATTACK_DELAY);
if (attr != -1 && attackDelay)
{
- setStatBase(ATTACK_SPEED, getStatBase(attr) * 1000
+ setStatBase(Attributes::ATTACK_SPEED, getStatBase(attr) * 1000
/ attackDelay, false);
- setStatMod(ATTACK_SPEED, getStatMod(attr) * 1000
+ setStatMod(Attributes::ATTACK_SPEED, getStatMod(attr) * 1000
/ attackDelay, true);
}
else
{
- setStatBase(ATTACK_SPEED, 0, false);
- setStatMod(ATTACK_SPEED, 0, true);
+ setStatBase(Attributes::ATTACK_SPEED, 0, false);
+ setStatMod(Attributes::ATTACK_SPEED, 0, true);
}
}
diff --git a/src/being/playerinfo.h b/src/being/playerinfo.h
index 5139493e1..262db1a7d 100644
--- a/src/being/playerinfo.h
+++ b/src/being/playerinfo.h
@@ -69,30 +69,6 @@ class Item;
*/
namespace PlayerInfo
{
- /**
- * Standard attributes for players.
- */
- enum Attribute
- {
- LEVEL = 0,
- HP,
- MAX_HP,
- MP,
- MAX_MP,
- EXP,
- EXP_NEEDED,
- MONEY,
- TOTAL_WEIGHT,
- MAX_WEIGHT,
- SKILL_POINTS,
- CHAR_POINTS,
- CORR_POINTS,
- ATTACK_DELAY = 100,
- ATTACK_RANGE = 101,
- WALK_SPEED = 102,
- ATTACK_SPEED = 103
- };
-
// --- Attributes -------------------------------------------------------------
/**