forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenario.h
132 lines (104 loc) · 4.48 KB
/
scenario.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#pragma once
#ifndef CATA_SRC_SCENARIO_H
#define CATA_SRC_SCENARIO_H
#include <set>
#include <string>
#include <vector>
#include "string_id.h"
#include "translations.h"
#include "type_id.h"
class JsonObject;
class profession;
template<typename T>
class generic_factory;
class scenario
{
private:
friend class string_id<scenario>;
friend class generic_factory<scenario>;
string_id<scenario> id;
bool was_loaded = false;
translation _name_male;
translation _name_female;
translation _description_male;
translation _description_female;
translation _start_name;
bool blacklist = false; // If true, professions is a blacklist.
bool extra_professions = false; // If true, professions add to default professions.
std::vector<profession_id> professions; // as specified in JSON, verbatim
/**
* @ref permitted_professions populates this vector on the first call, which takes
* a bit of work. On subsequent calls, this vector is returned.
*/
mutable std::vector<profession_id> cached_permitted_professions;
std::set<trait_id> _allowed_traits;
std::set<trait_id> _forced_traits;
std::set<trait_id> _forbidden_traits;
std::vector<start_location_id> _allowed_locs;
int _point_cost = 0;
std::set<std::string> flags; // flags for some special properties of the scenario
std::string _map_extra;
std::vector<mission_type_id> _missions;
vproto_id _starting_vehicle = vproto_id::NULL_ID();
void load( const JsonObject &jo, const std::string &src );
bool scenario_traits_conflict_with_profession_traits( const profession &p ) const;
public:
//these three aren't meant for external use, but had to be made public regardless
scenario();
static void load_scenario( const JsonObject &jo, const std::string &src );
// these should be the only ways used to get at scenario
static const scenario *generic(); // points to the generic, default profession
// return a random scenario, weighted for use w/ random character creation
static const scenario *weighted_random();
static const std::vector<scenario> &get_all();
// clear scenario map, every scenario pointer becomes invalid!
static void reset();
/** calls @ref check_definition for each scenario */
static void check_definitions();
/** Check that item definitions are valid */
void check_definition() const;
const string_id<scenario> &ident() const;
std::string gender_appropriate_name( bool male ) const;
std::string description( bool male ) const;
start_location_id start_location() const;
start_location_id random_start_location() const;
std::string start_name() const;
int start_location_count() const;
int start_location_targets_count() const;
vproto_id vehicle() const;
const profession_id &weighted_random_profession() const;
std::vector<profession_id> permitted_professions() const;
bool traitquery( const trait_id &trait ) const;
std::set<trait_id> get_locked_traits() const;
bool is_locked_trait( const trait_id &trait ) const;
bool is_forbidden_trait( const trait_id &trait ) const;
bool allowed_start( const start_location_id &loc ) const;
signed int point_cost() const;
bool has_map_extra() const;
const std::string &get_map_extra() const;
/**
* Returns "All", "Limited", or "Almost all" (translated)
* This is used by newcharacter.cpp
*/
std::string prof_count_str() const;
// Is this scenario blacklisted?
bool scen_is_blacklisted() const;
/** Such as a seasonal start, fiery start, surrounded start, etc. */
bool has_flag( const std::string &flag ) const;
/**
*
*/
bool can_pick( const scenario ¤t_scenario, int points ) const;
const std::vector<mission_type_id> &missions() const;
};
struct scen_blacklist {
std::set<string_id<scenario>> scenarios;
bool whitelist = false;
static void load_scen_blacklist( const JsonObject &jo, const std::string &src );
void load( const JsonObject &jo, const std::string & );
void finalize();
};
void reset_scenarios_blacklist();
const scenario *get_scenario();
void set_scenario( const scenario *new_scenario );
#endif // CATA_SRC_SCENARIO_H