~ubuntu-branches/ubuntu/vivid/manaplus/vivid

« back to all changes in this revision

Viewing changes to src/net/ea/skillhandler.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi
  • Date: 2014-09-30 18:10:18 UTC
  • mfrom: (1.1.35)
  • Revision ID: package-import@ubuntu.com-20140930181018-pb73a0ogw29tjv8k
Tags: 1.4.9.27-1
* New upstream release.
* Bump Standards-Version to 3.9.6 (no changes required).

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "net/ea/skillhandler.h"
24
24
 
25
 
#include "logger.h"
26
 
#include "notifymanager.h"
27
 
 
28
 
#include "being/localplayer.h"
29
25
#include "being/playerinfo.h"
30
26
 
31
27
#include "gui/windows/skilldialog.h"
32
28
 
33
 
#include "utils/gettext.h"
34
 
#include "utils/stringutils.h"
35
 
 
36
29
#include "net/messagein.h"
37
30
 
38
 
#include "resources/notifytypes.h"
39
 
 
40
31
#include "debug.h"
41
32
 
42
 
/** job dependend identifiers (?)  */
43
 
static const unsigned int SKILL_BASIC =       0x0001;
44
 
static const unsigned int SKILL_WARP =        0x001b;
45
 
static const unsigned int SKILL_STEAL =       0x0032;
46
 
static const unsigned int SKILL_ENVENOM =     0x0034;
47
 
 
48
 
/** basic skills identifiers       */
49
 
static const unsigned int BSKILL_TRADE =      0x0000;
50
 
static const unsigned int BSKILL_EMOTE =      0x0001;
51
 
static const unsigned int BSKILL_SIT =        0x0002;
52
 
static const unsigned int BSKILL_CREATECHAT = 0x0003;
53
 
static const unsigned int BSKILL_JOINPARTY =  0x0004;
54
 
static const unsigned int BSKILL_SHOUT =      0x0005;
55
 
 
56
 
/** reasons why action failed      */
57
 
static const unsigned int RFAIL_SKILLDEP =    0x00;
58
 
static const unsigned int RFAIL_INSUFSP =     0x01;
59
 
static const unsigned int RFAIL_INSUFHP =     0x02;
60
 
static const unsigned int RFAIL_NOMEMO =      0x03;
61
 
static const unsigned int RFAIL_SKILLDELAY =  0x04;
62
 
static const unsigned int RFAIL_ZENY =        0x05;
63
 
static const unsigned int RFAIL_WEAPON =      0x06;
64
 
static const unsigned int RFAIL_REDGEM =      0x07;
65
 
static const unsigned int RFAIL_BLUEGEM =     0x08;
66
 
static const unsigned int RFAIL_OVERWEIGHT =  0x09;
67
 
 
68
 
/** should always be zero if failed */
69
 
static const unsigned int SKILL_FAILED =      0x00;
70
 
 
71
33
namespace Ea
72
34
{
73
35
 
91
53
        if (!skillDialog->updateSkill(skillId, range,
92
54
            up, SkillType::Unknown, sp))
93
55
        {
94
 
            skillDialog->addSkill(skillId, "", level,
 
56
            skillDialog->addSkill(SkillOwner::Player,
 
57
                skillId, "", level,
95
58
                range, up, SkillType::Unknown, sp);
96
59
        }
97
60
    }
98
61
}
99
62
 
100
 
void SkillHandler::processSkillFailed(Net::MessageIn &msg)
101
 
{
102
 
    // Action failed (ex. sit because you have not reached the
103
 
    // right level)
104
 
    const int skillId   = msg.readInt16();
105
 
    const int16_t bskill  = msg.readInt16();
106
 
    msg.readInt16();  // btype
107
 
    const signed char success = msg.readUInt8();
108
 
    const signed char reason  = msg.readUInt8();
109
 
    if (success != static_cast<int>(SKILL_FAILED)
110
 
        && bskill == static_cast<int>(BSKILL_EMOTE))
111
 
    {
112
 
        logger->log("Action: %d/%d", bskill, success);
113
 
    }
114
 
 
115
 
    std::string txt;
116
 
    if (success == static_cast<int>(SKILL_FAILED)
117
 
        && skillId == static_cast<int>(SKILL_BASIC))
118
 
    {
119
 
        if (localPlayer && bskill == static_cast<int>(BSKILL_EMOTE)
120
 
            && reason == static_cast<int>(RFAIL_SKILLDEP))
121
 
        {
122
 
            localPlayer->stopAdvert();
123
 
        }
124
 
 
125
 
        switch (bskill)
126
 
        {
127
 
            case BSKILL_TRADE:
128
 
                // TRANSLATORS: error message
129
 
                txt = _("Trade failed!");
130
 
                break;
131
 
            case BSKILL_EMOTE:
132
 
                // TRANSLATORS: error message
133
 
                txt = _("Emote failed!");
134
 
                break;
135
 
            case BSKILL_SIT:
136
 
                // TRANSLATORS: error message
137
 
                txt = _("Sit failed!");
138
 
                break;
139
 
            case BSKILL_CREATECHAT:
140
 
                // TRANSLATORS: error message
141
 
                txt = _("Chat creating failed!");
142
 
                break;
143
 
            case BSKILL_JOINPARTY:
144
 
                // TRANSLATORS: error message
145
 
                txt = _("Could not join party!");
146
 
                break;
147
 
            case BSKILL_SHOUT:
148
 
                // TRANSLATORS: error message
149
 
                txt = _("Cannot shout!");
150
 
                break;
151
 
            default:
152
 
                logger->log("QQQ SMSG_SKILL_FAILED: bskill "
153
 
                            + toString(bskill));
154
 
                break;
155
 
        }
156
 
 
157
 
        txt.append(" ");
158
 
 
159
 
        switch (reason)
160
 
        {
161
 
            case RFAIL_SKILLDEP:
162
 
                // TRANSLATORS: error message
163
 
                txt.append(_("You have not yet reached a high enough lvl!"));
164
 
                break;
165
 
            case RFAIL_INSUFHP:
166
 
                // TRANSLATORS: error message
167
 
                txt.append(_("Insufficient HP!"));
168
 
                break;
169
 
            case RFAIL_INSUFSP:
170
 
                // TRANSLATORS: error message
171
 
                txt.append(_("Insufficient SP!"));
172
 
                break;
173
 
            case RFAIL_NOMEMO:
174
 
                // TRANSLATORS: error message
175
 
                txt.append(_("You have no memos!"));
176
 
                break;
177
 
            case RFAIL_SKILLDELAY:
178
 
                // TRANSLATORS: error message
179
 
                txt.append(_("You cannot do that right now!"));
180
 
                break;
181
 
            case RFAIL_ZENY:
182
 
                // TRANSLATORS: error message
183
 
                txt.append(_("Seems you need more money... ;-)"));
184
 
                break;
185
 
            case RFAIL_WEAPON:
186
 
                // TRANSLATORS: error message
187
 
                txt.append(_("You cannot use this skill with that "
188
 
                    "kind of weapon!"));
189
 
                break;
190
 
            case RFAIL_REDGEM:
191
 
                // TRANSLATORS: error message
192
 
                txt.append(_("You need another red gem!"));
193
 
                break;
194
 
            case RFAIL_BLUEGEM:
195
 
                // TRANSLATORS: error message
196
 
                txt.append(_("You need another blue gem!"));
197
 
                break;
198
 
            case RFAIL_OVERWEIGHT:
199
 
                // TRANSLATORS: error message
200
 
                txt.append(_("You're carrying to much to do this!"));
201
 
                break;
202
 
            default:
203
 
                // TRANSLATORS: error message
204
 
                txt.append(_("Huh? What's that?"));
205
 
                logger->log("QQQ SMSG_SKILL_FAILED: reason "
206
 
                            + toString(reason));
207
 
                break;
208
 
        }
209
 
    }
210
 
    else
211
 
    {
212
 
        switch (skillId)
213
 
        {
214
 
            case SKILL_WARP :
215
 
                // TRANSLATORS: error message
216
 
                txt = _("Warp failed...");
217
 
                break;
218
 
            case SKILL_STEAL :
219
 
                // TRANSLATORS: error message
220
 
                txt = _("Could not steal anything...");
221
 
                break;
222
 
            case SKILL_ENVENOM :
223
 
                // TRANSLATORS: error message
224
 
                txt = _("Poison had no effect...");
225
 
                break;
226
 
            default:
227
 
                logger->log("QQQ SMSG_SKILL_FAILED: skillId "
228
 
                            + toString(skillId));
229
 
                break;
230
 
        }
231
 
    }
232
 
 
233
 
    NotifyManager::notify(NotifyTypes::SKILL_FAIL_MESSAGE, txt);
234
 
}
235
63
}  // namespace Ea