summaryrefslogtreecommitdiff
path: root/src/being/localplayer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-04-27 14:50:47 +0300
committerAndrei Karas <akaras@inbox.ru>2014-04-27 14:50:47 +0300
commit744b6e62e1252ca50445b21f671ad8d81dd28ea1 (patch)
tree79adc9663a740ed471e33c97932ce6b28de11377 /src/being/localplayer.cpp
parent2ee2f8b060e4fe88feeeba5508189c916e55a70d (diff)
downloadmv-744b6e62e1252ca50445b21f671ad8d81dd28ea1.tar.gz
mv-744b6e62e1252ca50445b21f671ad8d81dd28ea1.tar.bz2
mv-744b6e62e1252ca50445b21f671ad8d81dd28ea1.tar.xz
mv-744b6e62e1252ca50445b21f671ad8d81dd28ea1.zip
Add AttributeListener.
Diffstat (limited to 'src/being/localplayer.cpp')
-rw-r--r--src/being/localplayer.cpp56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index b75ee0ebd..ad26a15c2 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -96,6 +96,7 @@ extern SkillDialog *skillDialog;
LocalPlayer::LocalPlayer(const int id, const int subtype) :
Being(id, PLAYER, subtype, nullptr),
+ AttributeListener(),
mGMLevel(0),
mInvertDirection(0),
mCrazyMoveType(config.getIntValue("crazyMoveType")),
@@ -1029,33 +1030,7 @@ void LocalPlayer::processEvent(const Channels channel,
{
if (channel == CHANNEL_ATTRIBUTES)
{
- if (event.getName() == EVENT_UPDATEATTRIBUTE)
- {
- switch (event.getInt("id"))
- {
- case PlayerInfo::EXP:
- {
- if (event.getInt("oldValue") > event.getInt("newValue"))
- break;
-
- const int change = event.getInt("newValue")
- - event.getInt("oldValue");
-
- if (change != 0)
- {
- // TRANSLATORS: get xp message
- addMessageToQueue(strprintf("%d %s", change, _("xp")));
- }
- break;
- }
- case PlayerInfo::LEVEL:
- mLevel = event.getInt("newValue");
- break;
- default:
- break;
- };
- }
- else if (event.getName() == EVENT_UPDATESTAT)
+ if (event.getName() == EVENT_UPDATESTAT)
{
if (!mShowJobExp)
return;
@@ -1107,6 +1082,33 @@ void LocalPlayer::processEvent(const Channels channel,
}
}
+void LocalPlayer::attributeChanged(const int id,
+ const int oldVal,
+ const int newVal)
+{
+ switch (id)
+ {
+ case PlayerInfo::EXP:
+ {
+ if (oldVal > newVal)
+ break;
+
+ const int change = newVal - oldVal;
+ if (change != 0)
+ {
+ // TRANSLATORS: get xp message
+ addMessageToQueue(strprintf("%d %s", change, _("xp")));
+ }
+ break;
+ }
+ case PlayerInfo::LEVEL:
+ mLevel = newVal;
+ break;
+ default:
+ break;
+ }
+}
+
void LocalPlayer::moveTo(const int x, const int y)
{
setDestination(x, y);