forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
computer.h
151 lines (137 loc) · 4.26 KB
/
computer.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once
#ifndef CATA_SRC_COMPUTER_H
#define CATA_SRC_COMPUTER_H
#include <string>
#include <vector>
#include "calendar.h"
class JsonIn;
class JsonOut;
class JsonObject;
enum computer_action {
COMPACT_NULL = 0,
COMPACT_AMIGARA_LOG,
COMPACT_AMIGARA_START,
COMPACT_BLOOD_ANAL,
COMPACT_CASCADE,
COMPACT_COMPLETE_DISABLE_EXTERNAL_POWER, // Completes "Disable External Power" mission
COMPACT_CONVEYOR,
COMPACT_DATA_ANAL,
COMPACT_DEACTIVATE_SHOCK_VENT,
COMPACT_DISCONNECT,
COMPACT_DOWNLOAD_SOFTWARE,
COMPACT_ELEVATOR_ON,
COMPACT_EMERG_MESS,
COMPACT_EMERG_REF_CENTER, //Points to the refugee center
COMPACT_EXTRACT_RAD_SOURCE,
COMPACT_GEIGER,
COMPACT_IRRADIATOR,
COMPACT_LIST_BIONICS,
COMPACT_LOCK,
COMPACT_MAP_SEWER,
COMPACT_MAP_SUBWAY,
COMPACT_MAPS,
COMPACT_MISS_DISARM,
COMPACT_OPEN,
COMPACT_OPEN_DISARM,
COMPACT_PORTAL,
COMPACT_RADIO_ARCHIVE,
COMPACT_RELEASE,
COMPACT_RELEASE_BIONICS,
COMPACT_RELEASE_DISARM,
COMPACT_REPEATER_MOD, //Converts a terminal in a radio station into a 'repeater', locks terminal and completes mission
COMPACT_RESEARCH,
COMPACT_SAMPLE,
COMPACT_SHUTTERS,
COMPACT_SR1_MESS, //Security Reminders for Hazardous Waste Sarcophagus (SRCF)
COMPACT_SR2_MESS,
COMPACT_SR3_MESS,
COMPACT_SR4_MESS,
COMPACT_SRCF_1_MESS,
COMPACT_SRCF_2_MESS,
COMPACT_SRCF_3_MESS,
COMPACT_SRCF_ELEVATOR,
COMPACT_SRCF_SEAL,
COMPACT_SRCF_SEAL_ORDER,
COMPACT_TERMINATE,
COMPACT_TOLL,
COMPACT_TOWER_UNRESPONSIVE,
COMPACT_UNLOCK,
COMPACT_UNLOCK_DISARM,
NUM_COMPUTER_ACTIONS
};
enum computer_failure_type {
COMPFAIL_NULL = 0,
COMPFAIL_ALARM,
COMPFAIL_AMIGARA,
COMPFAIL_DAMAGE,
COMPFAIL_DESTROY_BLOOD,
COMPFAIL_DESTROY_DATA,
COMPFAIL_MANHACKS,
COMPFAIL_PUMP_EXPLODE,
COMPFAIL_PUMP_LEAK,
COMPFAIL_SECUBOTS,
COMPFAIL_SHUTDOWN,
NUM_COMPUTER_FAILURES
};
struct computer_option {
std::string name;
computer_action action;
int security;
computer_option();
computer_option( const std::string &N, computer_action A, int S );
// Save to/load from saves
void serialize( JsonOut &jout ) const;
void deserialize( JsonIn &jin );
// Load from data files
static computer_option from_json( const JsonObject &jo );
};
struct computer_failure {
computer_failure_type type;
computer_failure();
computer_failure( computer_failure_type t ) : type( t ) {
}
// Save to/load from saves
void serialize( JsonOut &jout ) const;
void deserialize( JsonIn &jin );
// Load from data files
static computer_failure from_json( const JsonObject &jo );
};
class computer
{
public:
computer( const std::string &new_name, int new_security );
// Initialization
void set_security( int Security );
void add_option( const computer_option &opt );
void add_option( const std::string &opt_name, computer_action action, int security );
void add_failure( const computer_failure &failure );
void add_failure( computer_failure_type failure );
void set_access_denied_msg( const std::string &new_msg );
void set_mission( int id );
// Save/load
void load_legacy_data( const std::string &data );
void serialize( JsonOut &jout ) const;
void deserialize( JsonIn &jin );
friend class computer_session;
private:
// "Jon's Computer", "Lab 6E77-B Terminal Omega"
std::string name;
// Linked to a mission?
int mission_id;
// Difficulty of simply logging in
int security;
// Number of times security is tripped
int alerts;
// Date of next attempt
time_point next_attempt;
// Things we can do
std::vector<computer_option> options;
// Things that happen if we fail a hack
std::vector<computer_failure> failures;
// Message displayed when the computer is secured and initial login fails.
// Can be customized to for example warn the player of potentially lethal
// consequences like secubots spawning.
std::string access_denied;
void remove_option( computer_action action );
};
#endif // CATA_SRC_COMPUTER_H