Horizon Official Technical Documentation
JobDB.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_JOBDB_HPP
31#define HORIZON_ZONE_STATICDB_JOBDB_HPP
32
36#include <array>
37#include <sol/sol.hpp>
38#include <map>
39
40namespace Horizon
41{
42namespace Zone
43{
45{
46 int id{0};
47 std::string name{""};
48 int max_weight{20000};
49 std::string base_exp_group{""}, job_exp_group{""};
50 std::array<int, IT_WT_SINGLE_MAX> weapon_base_aspd { 0 };
51 std::vector<int> hp_table, sp_table;
52};
54{
55public:
58
60 {
61 static JobDatabase instance;
62 return &instance;
63 }
64
65 job_class_type get_job_class_by_name(std::string name) const;
67
68 bool load();
69 int load_job(sol::table &job_tbl, std::string name = "");
70 bool load_job_internal(sol::table &job_tbl, job_config_data &data, std::string job_name = "");
71 bool load_hp_sp_table(sol::table &job_tbl, job_config_data &data, std::string &job_name, std::string table_name);
72
73 std::shared_ptr<const job_config_data> get_job_by_id(uint16_t job_id) { return _job_db.at((job_class_type) job_id); }
74 std::string get_job_name_by_id(int32_t id) {
75 for (auto j = _name2id_list.begin(); j != _name2id_list.end(); j++)
76 if (j->second == id)
77 return j->first;
78 return "";
79 }
80private:
82 std::map<std::string, int> _name2id_list;
83};
84}
85}
86
87#define JobDB Horizon::Zone::JobDatabase::get_instance()
88
89#endif /* HORIZON_ZONE_STATICDB_JOBDB_HPP */
job_class_mask
Definition: UnitDefinitions.hpp:650
job_class_type
Definition: UnitDefinitions.hpp:474
Definition: JobDB.hpp:54
bool load_job_internal(sol::table &job_tbl, job_config_data &data, std::string job_name="")
Definition: JobDB.cpp:220
std::shared_ptr< const job_config_data > get_job_by_id(uint16_t job_id)
Definition: JobDB.hpp:73
LockedLookupTable< uint32_t, std::shared_ptr< const job_config_data > > _job_db
Definition: JobDB.hpp:81
job_class_type get_job_class_by_name(std::string name) const
Definition: JobDB.cpp:154
bool load_hp_sp_table(sol::table &job_tbl, job_config_data &data, std::string &job_name, std::string table_name)
Definition: JobDB.cpp:333
static JobDatabase * get_instance()
Definition: JobDB.hpp:59
~JobDatabase()
Definition: JobDB.hpp:57
bool load()
Definition: JobDB.cpp:164
JobDatabase()
Definition: JobDB.cpp:35
int load_job(sol::table &job_tbl, std::string name="")
Definition: JobDB.cpp:186
job_class_mask job_id_to_mask(job_class_type job_id) const
Definition: JobDB.cpp:381
std::map< std::string, int > _name2id_list
Definition: JobDB.hpp:82
std::string get_job_name_by_id(int32_t id)
Definition: JobDB.hpp:74
Definition: LockedLookupTable.hpp:44
Definition: Element.hpp:7
Definition: JobDB.hpp:45
std::string base_exp_group
Definition: JobDB.hpp:49
int max_weight
Definition: JobDB.hpp:48
std::string name
Definition: JobDB.hpp:47
std::vector< int > sp_table
Definition: JobDB.hpp:51
std::array< int, IT_WT_SINGLE_MAX > weapon_base_aspd
Definition: JobDB.hpp:50
std::string job_exp_group
Definition: JobDB.hpp:49
std::vector< int > hp_table
Definition: JobDB.hpp:51