summaryrefslogtreecommitdiff
path: root/src/resources/abilitydb.h
blob: 6b3de5a6c4cb28ee55f33aa5c0d7505b75b9d627 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
 *  The Mana Client
 *  Copyright (C) 2010-2013  The Mana Developers
 *
 *  This file is part of The Mana 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/>.
 */

#pragma once

#include <string>
#include "utils/xml.h"

struct AbilityInfo
{
    enum TargetMode
    {
        TARGET_BEING,       // target any being
        TARGET_POINT,       // target map location
        TARGET_DIRECTION    // target a direction
    };
    int id;
    std::string name; // displayed name of ability
    std::string icon; // filename of graphical icon
    std::string useAction; // action when using the ability

    TargetMode targetMode;

    bool rechargeable; // true when the ability has a recharge bar
    int rechargeNeeded; // maximum recharge when applicable
    int rechargeCurrent; // current recharge when applicable
};

/**
 * Ability information database.
 */
namespace AbilityDB
{
    void init();

    void readAbilityNode(XML::Node node, const std::string &filename);

    void checkStatus();

    void unload();

    /** Gets the ability info for ID. Will return nullptr when it is
     *  a server-specific ability.
     */
    AbilityInfo *get(int id);

    /**
     * Finds an ability by name. Returns nullptr when the ability could not be
     * found.
     */
    AbilityInfo *find(std::string_view name);
}