1 ////////////////////////////////////////////////////////////////////////////////
2 //            Copyright (C) 2017 by Bertram (Valyria Tear)
3 //                         All Rights Reserved
4 //
5 // This code is licensed under the GNU GPL version 2. It is free software
6 // and you may modify it and/or redistribute it under the terms of this license.
7 // See http://www.gnu.org/copyleft/gpl.html for details.
8 ////////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef __SKILL_NODE_HEADER__
11 #define __SKILL_NODE_HEADER__
12 
13 #include "engine/video/image.h"
14 #include "common/position_2d.h"
15 
16 namespace vt_global {
17 
18 /** *****************************************************************************
19 *** \brief Skill node data
20 *** Handles related data management to a given skill node.
21 *** *****************************************************************************/
22 class SkillNode
23 {
24 friend class SkillGraph;
25 
26 public:
27     SkillNode(uint32_t id,
28               float x_location,
29               float y_location,
30               const std::string& icon_path,
31               uint32_t experience_points_needed,
32               int32_t skill_id_learned);
33 
34     //! \brief Gets skill node id
GetId()35     uint32_t GetId() const {
36         return _id;
37     }
38 
GetPosition()39     const vt_common::Position2D& GetPosition() const {
40         return _position;
41     }
42 
GetXPosition()43     float GetXPosition() const {
44         return _position.x;
45     }
46 
GetYPosition()47     float GetYPosition() const {
48         return _position.y;
49     }
50 
GetIconImage()51     vt_video::AnimatedImage& GetIconImage() {
52         return _icon_image;
53     }
54 
55     //! \brief Gets skill id learned, or -1 if none.
GetSkillIdLearned()56     int32_t GetSkillIdLearned() const {
57         return _skill_id_learned;
58     }
59 
GetExperiencePointsNeeded()60     uint32_t GetExperiencePointsNeeded() const {
61         return _experience_points_needed;
62     }
63 
GetItemsNeeded()64     const std::vector<std::pair<uint32_t, uint32_t> >& GetItemsNeeded() const {
65         return _items_needed;
66     }
67 
GetStatsUpgrades()68     const std::vector<std::pair<uint32_t, uint32_t> >& GetStatsUpgrades() const {
69         return _stats_upgrades;
70     }
71 
GetChildrenNodeLinks()72     const std::vector<uint32_t>& GetChildrenNodeLinks() const {
73         return _children_nodes_links;
74     }
75 
GetParentNodeLinks()76     const std::vector<uint32_t>& GetParentNodeLinks() const {
77         return _parent_nodes_links;
78     }
79 
80     void AddNeededItem(uint32_t item_id, uint32_t item_number);
81 
82     //! \brief Add the linked stat upgrade.
83     //! Note that for evade stat, the upgrade value is later divided by 10.
84     void AddStatUpgrade(uint32_t stat, uint32_t upgrade);
85 
86     //! \brief Adds a child link to the skill node
87     void AddChildNodeLink(uint32_t node_id);
88 
89     //! \brief Adds a parent link to the skill node
90     void AddParentNodeLink(uint32_t node_id);
91 
92 private:
93     //! \brief The Skill Node Id
94     uint32_t _id;
95 
96     //! \brief Location in the skill graph
97     vt_common::Position2D _position;
98 
99     //! \brief Icon used to represent this node.
100     vt_video::AnimatedImage _icon_image;
101 
102     //! \brief Experience points needed to reach this node
103     uint32_t _experience_points_needed;
104 
105     //! \brief Skill learned, or -1 if none
106     int32_t _skill_id_learned;
107 
108     //! \brief The list of items needs to reach the node
109     std::vector<std::pair<uint32_t, uint32_t> > _items_needed;
110 
111     //! \brief The list of stats upgrade the character gets when reaching the node
112     std::vector<std::pair<uint32_t, uint32_t> > _stats_upgrades;
113 
114     //! \brief Permited children links to other nodes
115     std::vector<uint32_t> _children_nodes_links;
116 
117     //! \brief Permited parent links to other nodes
118     std::vector<uint32_t> _parent_nodes_links;
119 };
120 
121 } // namespace vt_global
122 
123 #endif // __SKILL_NODE_HEADER__
124