GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/statuseffect.cpp Lines: 1 23 4.3 %
Date: 2017-11-29 Branches: 2 32 6.3 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2008-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "statuseffect.h"
24
25
#include "configuration.h"
26
#include "soundmanager.h"
27
28
#include "const/resources/spriteaction.h"
29
30
#include "gui/widgets/tabs/chat/chattab.h"
31
32
#include "particle/particleengine.h"
33
34
#include "resources/sprite/animatedsprite.h"
35
36
#include "debug.h"
37
38
StatusEffect::StatusEffect() :
39
    mMessage(),
40
    mSFXEffect(),
41
    mStartParticleEffect(),
42
    mParticleEffect(),
43
    mIcon(),
44
    mAction(),
45
    mName(),
46
    mIsPersistent(false),
47
    mIsPoison(false),
48
    mIsCart(false),
49
    mIsRiding(false),
50
    mIsTrickDead(false),
51
    mIsPostDelay(false)
52
{
53
}
54
55
StatusEffect::~StatusEffect()
56
{
57
}
58
59
void StatusEffect::playSFX() const
60
{
61
    if (!mSFXEffect.empty())
62
        soundManager.playSfx(mSFXEffect);
63
}
64
65
void StatusEffect::deliverMessage() const
66
{
67
    if (!mMessage.empty() && (localChatTab != nullptr))
68
        localChatTab->chatLog(mMessage, ChatMsgType::BY_SERVER);
69
}
70
71
Particle *StatusEffect::getStartParticle() const
72
{
73
    if (particleEngine == nullptr || mStartParticleEffect.empty())
74
        return nullptr;
75
    return particleEngine->addEffect(mStartParticleEffect, 0, 0);
76
}
77
78
Particle *StatusEffect::getParticle() const
79
{
80
    if (particleEngine == nullptr || mParticleEffect.empty())
81
        return nullptr;
82
    return particleEngine->addEffect(mParticleEffect, 0, 0);
83
}
84
85
AnimatedSprite *StatusEffect::getIcon() const
86
{
87
    if (mIcon.empty())
88
    {
89
        return nullptr;
90
    }
91
    return AnimatedSprite::load(pathJoin(paths.getStringValue("sprites"),
92
        mIcon));
93
}
94
95
std::string StatusEffect::getAction() const
96
{
97
    if (mAction.empty())
98
        return SpriteAction::INVALID;
99
    return mAction;
100

6
}