diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-07-06 13:06:12 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-07-06 13:06:12 -0600 |
commit | 851f67cd9975b090b051decb1deab6b0489d14c5 (patch) | |
tree | 05e4256f0ec5128cc0bee41b3992f3c8c0111926 /src | |
parent | e0de8a124bf94b79d9d64e5406b21e8598a05d56 (diff) | |
download | mana-client-851f67cd9975b090b051decb1deab6b0489d14c5.tar.gz mana-client-851f67cd9975b090b051decb1deab6b0489d14c5.tar.bz2 mana-client-851f67cd9975b090b051decb1deab6b0489d14c5.tar.xz mana-client-851f67cd9975b090b051decb1deab6b0489d14c5.zip |
Merge some player stats
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/gui/status.cpp | 37 | ||||
-rw-r--r-- | src/gui/status.h | 4 | ||||
-rw-r--r-- | src/gui/statuswindow.cpp | 57 | ||||
-rw-r--r-- | src/gui/statuswindow.h | 4 | ||||
-rw-r--r-- | src/localplayer.cpp | 16 | ||||
-rw-r--r-- | src/localplayer.h | 24 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/ea/playerhandler.cpp | 6 |
9 files changed, 61 insertions, 91 deletions
diff --git a/src/game.cpp b/src/game.cpp index f1df57cc..5d15c779 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -224,7 +224,7 @@ static void createGuiWindows() npcDialog = new NpcDialog; npcPostDialog = new NpcPostDialog; storageWindow = new StorageWindow; - statusWindow = new StatusWindow(player_node); + statusWindow = new StatusWindow(); miniStatusWindow = new MiniStatusWindow; inventoryWindow = new InventoryWindow; skillDialog = new SkillDialog; diff --git a/src/gui/status.cpp b/src/gui/status.cpp index eca01725..ea5f63d0 100644 --- a/src/gui/status.cpp +++ b/src/gui/status.cpp @@ -38,9 +38,8 @@ #include "utils/mathutils.h" #include "utils/stringutils.h" -StatusWindow::StatusWindow(LocalPlayer *player): - Window(player->getName()), - mPlayer(player), +StatusWindow::StatusWindow(): + Window(player_node->getName()), mCurrency(0) { setWindowName("Status"); @@ -171,14 +170,14 @@ void StatusWindow::update() { // Status Part // ----------- - mLvlLabel->setCaption(strprintf(_("Level: %d"), mPlayer->getLevel())); + mLvlLabel->setCaption(strprintf(_("Level: %d"), player_node->getLevel())); mLvlLabel->adjustSize(); - mJobLvlLabel->setCaption(strprintf(_("Job: %d"), mPlayer->mJobLevel)); + mJobLvlLabel->setCaption(strprintf(_("Job: %d"), player_node->mJobLevel)); mJobLvlLabel->adjustSize(); - if (mCurrency != mPlayer->getMoney()) { - mCurrency = mPlayer->getMoney(); + if (mCurrency != player_node->getMoney()) { + mCurrency = player_node->getMoney(); mGpLabel->setCaption(strprintf(_("Money: %s"), Units::formatCurrency(mCurrency).c_str())); mGpLabel->adjustSize(); @@ -202,20 +201,20 @@ void StatusWindow::update() N_("Dexterity"), N_("Luck") }; - int statusPoints = mPlayer->mStatsPointsToAttribute; + int statusPoints = player_node->getCharacterPoints(); // Update labels for (int i = 0; i < 6; i++) { mStatsLabel[i]->setCaption(gettext(attrNames[i])); - mStatsDisplayLabel[i]->setCaption(toString((int) mPlayer->mAttr[i])); - mPointsLabel[i]->setCaption(toString((int) mPlayer->mAttrUp[i])); + mStatsDisplayLabel[i]->setCaption(toString((int) player_node->mAttr[i])); + mPointsLabel[i]->setCaption(toString((int) player_node->mAttrUp[i])); mStatsLabel[i]->adjustSize(); mStatsDisplayLabel[i]->adjustSize(); mPointsLabel[i]->adjustSize(); - mStatsButton[i]->setEnabled(mPlayer->mAttrUp[i] <= statusPoints); + mStatsButton[i]->setEnabled(player_node->mAttrUp[i] <= statusPoints); } mRemainingStatsPointsLabel->setCaption( strprintf(_("Remaining Status Points: %d"), statusPoints)); @@ -225,34 +224,34 @@ void StatusWindow::update() // Attack TODO: Count equipped Weapons and items attack bonuses mStatsAttackPoints->setCaption( - toString(mPlayer->ATK + mPlayer->ATK_BONUS)); + toString(player_node->ATK + player_node->ATK_BONUS)); mStatsAttackPoints->adjustSize(); // Defense TODO: Count equipped Armors and items defense bonuses mStatsDefensePoints->setCaption( - toString(mPlayer->DEF + mPlayer->DEF_BONUS)); + toString(player_node->DEF + player_node->DEF_BONUS)); mStatsDefensePoints->adjustSize(); // Magic Attack TODO: Count equipped items M.Attack bonuses mStatsMagicAttackPoints->setCaption( - toString(mPlayer->MATK + mPlayer->MATK_BONUS)); + toString(player_node->MATK + player_node->MATK_BONUS)); mStatsMagicAttackPoints->adjustSize(); // Magic Defense TODO: Count equipped items M.Defense bonuses mStatsMagicDefensePoints->setCaption( - toString(mPlayer->MDEF + mPlayer->MDEF_BONUS)); + toString(player_node->MDEF + player_node->MDEF_BONUS)); mStatsMagicDefensePoints->adjustSize(); // Accuracy % - mStatsAccuracyPoints->setCaption(toString(mPlayer->HIT)); + mStatsAccuracyPoints->setCaption(toString(player_node->HIT)); mStatsAccuracyPoints->adjustSize(); // Evasion % - mStatsEvadePoints->setCaption(toString(mPlayer->FLEE)); + mStatsEvadePoints->setCaption(toString(player_node->FLEE)); mStatsEvadePoints->adjustSize(); // Reflex % - mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter + mStatsReflexPoints->setCaption(toString(player_node->DEX / 4)); // + counter mStatsReflexPoints->adjustSize(); } @@ -400,7 +399,7 @@ static void updateProgressBar(ProgressBar *bar, int value, int max, void StatusWindow::updateXPBar(ProgressBar *bar, bool percent) { updateProgressBar(bar, - player_node->getXp(), + player_node->getLevelProgress(), player_node->mXpForNextLevel, percent); } diff --git a/src/gui/status.h b/src/gui/status.h index 403a7d59..3e5df917 100644 --- a/src/gui/status.h +++ b/src/gui/status.h @@ -40,7 +40,7 @@ class StatusWindow : public Window, public gcn::ActionListener /** * Constructor. */ - StatusWindow(LocalPlayer *player); + StatusWindow(); /** * Called when receiving actions from widget. @@ -63,8 +63,6 @@ class StatusWindow : public Window, public gcn::ActionListener static void updateJobBar(ProgressBar *bar, bool percent = true); private: - LocalPlayer *mPlayer; - /** * Status Part */ diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp index edbf387b..5f29e5a5 100644 --- a/src/gui/statuswindow.cpp +++ b/src/gui/statuswindow.cpp @@ -30,9 +30,8 @@ #include "utils/stringutils.h" -StatusWindow::StatusWindow(LocalPlayer *player): - Window(player->getName()), - mPlayer(player) +StatusWindow::StatusWindow(): + Window(player_node->getName()) { setWindowName("Status"); setResizable(true); @@ -198,13 +197,13 @@ void StatusWindow::update() // Status Part // ----------- mLvlLabel->setCaption( "Level: " + - toString(mPlayer->getLevel()) + + toString(player_node->getLevel()) + " (" + - toString(mPlayer->getLevelProgress()) + + toString(player_node->getLevelProgress()) + "%)"); mLvlLabel->adjustSize(); - mMoneyLabel->setCaption("Money: " + toString(mPlayer->getMoney()) + " GP"); + mMoneyLabel->setCaption("Money: " + toString(player_node->getMoney()) + " GP"); mMoneyLabel->adjustSize(); updateHPBar(mHpBar, true); @@ -219,16 +218,16 @@ void StatusWindow::update() "Intelligence", "Willpower" }; - int characterPoints = mPlayer->getCharacterPoints(); - int correctionPoints = mPlayer->getCorrectionPoints(); + int characterPoints = player_node->getCharacterPoints(); + int correctionPoints = player_node->getCorrectionPoints(); // Update labels for (int i = 0; i < 6; i++) { mStatsLabel[i]->setCaption(attrNames[i]); mStatsDisplayLabel[i]->setCaption( strprintf("%d / %d", - mPlayer->getAttributeEffective(CHAR_ATTR_BEGIN + i), - mPlayer->getAttributeBase(CHAR_ATTR_BEGIN + i))); + player_node->getAttributeEffective(CHAR_ATTR_BEGIN + i), + player_node->getAttributeBase(CHAR_ATTR_BEGIN + i))); mStatsLabel[i]->adjustSize(); mStatsDisplayLabel[i]->adjustSize(); @@ -248,34 +247,34 @@ void StatusWindow::update() // Attack TODO: Count equipped Weapons and items attack bonuses mStatsAttackPoints->setCaption( - toString(mPlayer->ATK + mPlayer->ATK_BONUS)); + toString(player_node->ATK + player_node->ATK_BONUS)); mStatsAttackPoints->adjustSize(); // Defense TODO: Count equipped Armors and items defense bonuses mStatsDefensePoints->setCaption( - toString(mPlayer->DEF + mPlayer->DEF_BONUS)); + toString(player_node->DEF + player_node->DEF_BONUS)); mStatsDefensePoints->adjustSize(); // Magic Attack TODO: Count equipped items M.Attack bonuses mStatsMagicAttackPoints->setCaption( - toString(mPlayer->MATK + mPlayer->MATK_BONUS)); + toString(player_node->MATK + player_node->MATK_BONUS)); mStatsMagicAttackPoints->adjustSize(); // Magic Defense TODO: Count equipped items M.Defense bonuses mStatsMagicDefensePoints->setCaption( - toString(mPlayer->MDEF + mPlayer->MDEF_BONUS)); + toString(player_node->MDEF + player_node->MDEF_BONUS)); mStatsMagicDefensePoints->adjustSize(); // Accuracy % - mStatsAccuracyPoints->setCaption(toString(mPlayer->HIT)); + mStatsAccuracyPoints->setCaption(toString(player_node->HIT)); mStatsAccuracyPoints->adjustSize(); // Evasion % - mStatsEvadePoints->setCaption(toString(mPlayer->FLEE)); + mStatsEvadePoints->setCaption(toString(player_node->FLEE)); mStatsEvadePoints->adjustSize(); // Reflex % - mStatsReflexPoints->setCaption(toString(mPlayer->DEX / 4)); // + counter + mStatsReflexPoints->setCaption(toString(player_node->DEX / 4)); // + counter mStatsReflexPoints->adjustSize(); */ // Update Second column widgets position @@ -298,52 +297,52 @@ void StatusWindow::action(const gcn::ActionEvent &event) // Stats Part if (eventId == "STR+") { - mPlayer->raiseAttribute(LocalPlayer::STR); + player_node->raiseAttribute(LocalPlayer::STR); } else if (eventId == "AGI+") { - mPlayer->raiseAttribute(LocalPlayer::AGI); + player_node->raiseAttribute(LocalPlayer::AGI); } else if (eventId == "DEX+") { - mPlayer->raiseAttribute(LocalPlayer::DEX); + player_node->raiseAttribute(LocalPlayer::DEX); } else if (eventId == "VIT+") { - mPlayer->raiseAttribute(LocalPlayer::VIT); + player_node->raiseAttribute(LocalPlayer::VIT); } else if (eventId == "INT+") { - mPlayer->raiseAttribute(LocalPlayer::INT); + player_node->raiseAttribute(LocalPlayer::INT); } else if (eventId == "WIL+") { - mPlayer->raiseAttribute(LocalPlayer::WIL); + player_node->raiseAttribute(LocalPlayer::WIL); } else if (eventId == "STR-") { - mPlayer->lowerAttribute(LocalPlayer::STR); + player_node->lowerAttribute(LocalPlayer::STR); } else if (eventId == "AGI-") { - mPlayer->lowerAttribute(LocalPlayer::AGI); + player_node->lowerAttribute(LocalPlayer::AGI); } else if (eventId == "DEX-") { - mPlayer->lowerAttribute(LocalPlayer::DEX); + player_node->lowerAttribute(LocalPlayer::DEX); } else if (eventId == "VIT-") { - mPlayer->lowerAttribute(LocalPlayer::VIT); + player_node->lowerAttribute(LocalPlayer::VIT); } else if (eventId == "INT-") { - mPlayer->lowerAttribute(LocalPlayer::INT); + player_node->lowerAttribute(LocalPlayer::INT); } else if (eventId == "WIL-") { - mPlayer->lowerAttribute(LocalPlayer::WIL); + player_node->lowerAttribute(LocalPlayer::WIL); } } diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h index 1e2a5097..7b3b8ae0 100644 --- a/src/gui/statuswindow.h +++ b/src/gui/statuswindow.h @@ -42,7 +42,7 @@ class StatusWindow : public Window, public gcn::ActionListener /** * Constructor. */ - StatusWindow(LocalPlayer *player); + StatusWindow(); /** * Called when receiving actions from widget. @@ -62,8 +62,6 @@ class StatusWindow : public Window, public gcn::ActionListener static void updateHPBar(ProgressBar *bar, bool showMax = false); private: - LocalPlayer *mPlayer; - /** * Status Part */ diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 2f8761e7..240f0a65 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -94,13 +94,11 @@ LocalPlayer::LocalPlayer(int id, int job, Map *map): mAttackRange(0), ATK(0), MATK(0), DEF(0), MDEF(0), HIT(0), FLEE(0), ATK_BONUS(0), MATK_BONUS(0), DEF_BONUS(0), MDEF_BONUS(0), FLEE_BONUS(0), - mStatPoint(0), mSkillPoint(0), - mStatsPointsToAttribute(0), + mSkillPoint(0), mEquipment(new Equipment), #endif mInStorage(false), #ifdef EATHENA_SUPPORT - mXp(0), mTargetTime(-1), #endif mLastTarget(-1), @@ -843,13 +841,13 @@ std::pair<int, int> LocalPlayer::getExperience(int skill) return std::pair<int, int> (mExpCurrent.at(skill), mExpNext.at(skill)); } -#else +#endif -void LocalPlayer::setXp(int xp) +void LocalPlayer::setLevelProgress(int percent) { - if (mMap && xp > mXp) + if (mMap && percent > percent) { - const std::string text = toString(xp - mXp) + " xp"; + const std::string text = toString(percent - percent) + " xp"; // Show XP number particleEngine->addTextRiseFadeOutEffect( @@ -859,11 +857,9 @@ void LocalPlayer::setXp(int xp) &guiPalette->getColor(Palette::EXP_INFO), gui->getInfoParticleFont(), true); } - mXp = xp; + mLevelProgress = percent; } -#endif - void LocalPlayer::pickedUp(const std::string &item) { if (mMap) diff --git a/src/localplayer.h b/src/localplayer.h index 85681e03..4053e81e 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -312,17 +312,6 @@ class LocalPlayer : public Player void setInStorage(bool inStorage); #ifdef EATHENA_SUPPORT - /** - * Sets the amount of XP. Shows XP gaining effect if the player is on - * a map. - */ - void setXp(int xp); - - /** - * Returns the amount of experience points. - */ - int getXp() const { return mXp; } - Uint32 mCharId; /**< Used only during character selection. */ Uint32 mJobXp; @@ -338,8 +327,7 @@ class LocalPlayer : public Player int ATK, MATK, DEF, MDEF, HIT, FLEE; int ATK_BONUS, MATK_BONUS, DEF_BONUS, MDEF_BONUS, FLEE_BONUS; - Uint16 mStatPoint, mSkillPoint; - Uint16 mStatsPointsToAttribute; + Uint16 mSkillPoint; #endif int getHp() const @@ -360,13 +348,10 @@ class LocalPlayer : public Player void setLevel(int value) { mLevel = value; } -#ifdef TMWSERV_SUPPORT - void setLevelProgress(int percent) - { mLevelProgress = percent; } + void setLevelProgress(int percent); int getLevelProgress() const { return mLevelProgress; } -#endif int getMoney() const { return mMoney; } @@ -386,7 +371,6 @@ class LocalPlayer : public Player void setMaxWeight(int value) { mMaxWeight = value; } -#ifdef TMWSERV_SUPPORT int getAttributeBase(int num) const { return mAttributeBase[num]; } @@ -421,7 +405,6 @@ class LocalPlayer : public Player static const SkillInfo& getSkillInfo(int skill); std::pair<int, int> getExperience(int skill); -#endif bool mUpdateName; /** Whether or not the name settings have changed */ @@ -436,12 +419,10 @@ class LocalPlayer : public Player bool mInStorage; /**< Whether storage is currently accessible */ #ifdef EATHENA_SUPPORT - int mXp; /**< Experience points. */ int mTargetTime; /** How long the being has been targeted **/ #endif int mLastTarget; /** Time stamp of last targeting action, -1 if none. */ -#ifdef TMWSERV_SUPPORT // Character status: std::vector<int> mAttributeBase; std::vector<int> mAttributeEffective; @@ -450,7 +431,6 @@ class LocalPlayer : public Player int mCharacterPoints; int mCorrectionPoints; int mLevelProgress; -#endif int mLevel; int mMoney; int mTotalWeight; diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 77bfaa50..4ffea0c9 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -173,7 +173,7 @@ LocalPlayer *CharServerHandler::readPlayerData(MessageIn &msg, int &slot) tempPlayer->setGender(mLoginData->sex); tempPlayer->mCharId = msg.readInt32(); - tempPlayer->setXp(msg.readInt32()); + tempPlayer->setLevelProgress(msg.readInt32()); tempPlayer->setMoney(msg.readInt32()); tempPlayer->mJobXp = msg.readInt32(); tempPlayer->mJobLevel = msg.readInt32(); diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 58167339..40cfc71c 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -229,7 +229,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) case 0x0007: player_node->mMp = value; break; case 0x0008: player_node->mMaxMp = value; break; case 0x0009: - player_node->mStatsPointsToAttribute = value; + player_node->setCharacterPoints(value); break; case 0x000b: player_node->setLevel(value); break; case 0x000c: @@ -276,7 +276,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) case SMSG_PLAYER_STAT_UPDATE_2: switch (msg.readInt16()) { case 0x0001: - player_node->setXp(msg.readInt32()); + player_node->setLevelProgress(msg.readInt32()); break; case 0x0002: player_node->mJobXp = msg.readInt32(); @@ -351,7 +351,7 @@ void PlayerHandler::handleMessage(MessageIn &msg) // Updates stats and status points case SMSG_PLAYER_STAT_UPDATE_5: - player_node->mStatsPointsToAttribute = msg.readInt16(); + player_node->setCharacterPoints(msg.readInt16()); player_node->mAttr[LocalPlayer::STR] = msg.readInt8(); player_node->mAttrUp[LocalPlayer::STR] = msg.readInt8(); player_node->mAttr[LocalPlayer::AGI] = msg.readInt8(); |