Horizon Official Technical Documentation
ExpDB.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 *
11 * Copyright (c) 2019 Sagun K. (sagunxp@gmail.com).
12 * Copyright (c) 2019 Horizon Dev Team.
13 *
14 * Base Author - Sagun K. (sagunxp@gmail.com)
15 *
16 * This library is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 **************************************************/
29
30#ifndef HORIZON_ZONE_STATICDB_EXPDB_HPP
31#define HORIZON_ZONE_STATICDB_EXPDB_HPP
32
35#include <vector>
36#include <sol/sol.hpp>
37
38namespace Horizon
39{
40namespace Zone
41{
42
44{
45 uint32_t max_level;
46 std::vector<uint64_t> exp;
47};
48
50{
53};
54
56{
57public:
60
62 {
63 static ExpDatabase instance;
64 return &instance;
65 }
66
67 bool load();
68
69 std::shared_ptr<const exp_group_data> get_exp_group(std::string const &name, exp_group_type type)
70 {
71 return type == EXP_GROUP_TYPE_BASE ? _base_exp_group_db.at(name) : _job_exp_group_db.at(name);
72 }
73
74 uint32_t get_status_point(uint32_t level)
75 {
76 if (level <= 0 || level > _stat_point_db.size() || level > MAX_LEVEL)
77 return 0;
78 return _stat_point_db.at(level);
79 }
80
82
83protected:
84 int load_group(sol::table &tbl, exp_group_type type);
88};
89
90}
91}
92
93#define ExpDB Horizon::Zone::ExpDatabase::get_instance()
94
95#endif /* HORIZON_ZONE_STATICDB_EXPDB_HPP */
#define MAX_LEVEL
Definition: Horizon.hpp:48
Definition: ExpDB.hpp:56
bool load_status_point_table()
Definition: ExpDB.cpp:104
LockedLookupTable< std::string, std::shared_ptr< const exp_group_data > > _base_exp_group_db
Definition: ExpDB.hpp:85
int load_group(sol::table &tbl, exp_group_type type)
Definition: ExpDB.cpp:60
~ExpDatabase()
Definition: ExpDB.hpp:59
ExpDatabase()
Definition: ExpDB.hpp:58
uint32_t get_status_point(uint32_t level)
Definition: ExpDB.hpp:74
bool load()
Definition: ExpDB.cpp:36
LockedLookupTable< std::string, std::shared_ptr< const exp_group_data > > _job_exp_group_db
Definition: ExpDB.hpp:86
LockedLookupTable< uint32_t, uint32_t > _stat_point_db
Definition: ExpDB.hpp:87
static ExpDatabase * get_instance()
Definition: ExpDB.hpp:61
std::shared_ptr< const exp_group_data > get_exp_group(std::string const &name, exp_group_type type)
Definition: ExpDB.hpp:69
Definition: LockedLookupTable.hpp:44
Value at(Key const &key, Value const &default_value=Value()) const
Definition: LockedLookupTable.hpp:63
std::size_t size()
Definition: LockedLookupTable.hpp:96
exp_group_type
Definition: ExpDB.hpp:50
@ EXP_GROUP_TYPE_JOB
Definition: ExpDB.hpp:52
@ EXP_GROUP_TYPE_BASE
Definition: ExpDB.hpp:51
Definition: Element.hpp:7
Definition: ExpDB.hpp:44
std::vector< uint64_t > exp
Definition: ExpDB.hpp:46
uint32_t max_level
Definition: ExpDB.hpp:45