1 #pragma once 2 #ifndef CATA_SRC_COMPUTER_H 3 #define CATA_SRC_COMPUTER_H 4 5 #include <iosfwd> 6 #include <string> 7 #include <vector> 8 9 #include "calendar.h" 10 11 class JsonIn; 12 class JsonObject; 13 class JsonOut; 14 15 enum computer_action { 16 COMPACT_NULL = 0, 17 COMPACT_AMIGARA_LOG, 18 COMPACT_AMIGARA_START, 19 COMPACT_BLOOD_ANAL, 20 COMPACT_CASCADE, 21 COMPACT_COMPLETE_DISABLE_EXTERNAL_POWER, // Completes "Disable External Power" mission 22 COMPACT_CONVEYOR, 23 COMPACT_DATA_ANAL, 24 COMPACT_DEACTIVATE_SHOCK_VENT, 25 COMPACT_DISCONNECT, 26 COMPACT_DOWNLOAD_SOFTWARE, 27 COMPACT_ELEVATOR_ON, 28 COMPACT_EMERG_MESS, 29 COMPACT_EMERG_REF_CENTER, //Points to the refugee center 30 COMPACT_EXTRACT_RAD_SOURCE, 31 COMPACT_GEIGER, 32 COMPACT_IRRADIATOR, 33 COMPACT_LIST_BIONICS, 34 COMPACT_LOCK, 35 COMPACT_MAP_SEWER, 36 COMPACT_MAP_SUBWAY, 37 COMPACT_MAPS, 38 COMPACT_MISS_DISARM, 39 COMPACT_OPEN, 40 COMPACT_OPEN_DISARM, 41 COMPACT_PORTAL, 42 COMPACT_RADIO_ARCHIVE, 43 COMPACT_RELEASE, 44 COMPACT_RELEASE_BIONICS, 45 COMPACT_RELEASE_DISARM, 46 COMPACT_REPEATER_MOD, //Converts a terminal in a radio station into a 'repeater', locks terminal and completes mission 47 COMPACT_RESEARCH, 48 COMPACT_SAMPLE, 49 COMPACT_SHUTTERS, 50 COMPACT_SR1_MESS, //Security Reminders for Hazardous Waste Sarcophagus (SRCF) 51 COMPACT_SR2_MESS, 52 COMPACT_SR3_MESS, 53 COMPACT_SR4_MESS, 54 COMPACT_SRCF_1_MESS, 55 COMPACT_SRCF_2_MESS, 56 COMPACT_SRCF_3_MESS, 57 COMPACT_SRCF_ELEVATOR, 58 COMPACT_SRCF_SEAL, 59 COMPACT_SRCF_SEAL_ORDER, 60 COMPACT_TERMINATE, 61 COMPACT_TOLL, 62 COMPACT_TOWER_UNRESPONSIVE, 63 COMPACT_UNLOCK, 64 COMPACT_UNLOCK_DISARM, 65 NUM_COMPUTER_ACTIONS 66 }; 67 68 enum computer_failure_type { 69 COMPFAIL_NULL = 0, 70 COMPFAIL_ALARM, 71 COMPFAIL_AMIGARA, 72 COMPFAIL_DAMAGE, 73 COMPFAIL_DESTROY_BLOOD, 74 COMPFAIL_DESTROY_DATA, 75 COMPFAIL_MANHACKS, 76 COMPFAIL_PUMP_EXPLODE, 77 COMPFAIL_PUMP_LEAK, 78 COMPFAIL_SECUBOTS, 79 COMPFAIL_SHUTDOWN, 80 NUM_COMPUTER_FAILURES 81 }; 82 83 struct computer_option { 84 std::string name; 85 computer_action action; 86 int security; 87 88 computer_option(); 89 computer_option( const std::string &N, computer_action A, int S ); 90 // Save to/load from saves 91 void serialize( JsonOut &jout ) const; 92 void deserialize( JsonIn &jin ); 93 // Load from data files 94 static computer_option from_json( const JsonObject &jo ); 95 }; 96 97 struct computer_failure { 98 computer_failure_type type; 99 100 computer_failure(); computer_failurecomputer_failure101 explicit computer_failure( computer_failure_type t ) : type( t ) { 102 } 103 // Save to/load from saves 104 void serialize( JsonOut &jout ) const; 105 void deserialize( JsonIn &jin ); 106 // Load from data files 107 static computer_failure from_json( const JsonObject &jo ); 108 }; 109 110 class computer 111 { 112 public: 113 computer( const std::string &new_name, int new_security ); 114 115 // Initialization 116 void set_security( int Security ); 117 void add_option( const computer_option &opt ); 118 void add_option( const std::string &opt_name, computer_action action, int security ); 119 void add_failure( const computer_failure &failure ); 120 void add_failure( computer_failure_type failure ); 121 void set_access_denied_msg( const std::string &new_msg ); 122 void set_mission( int id ); 123 // Save/load 124 void load_legacy_data( const std::string &data ); 125 void serialize( JsonOut &jout ) const; 126 void deserialize( JsonIn &jin ); 127 128 friend class computer_session; 129 private: 130 // "Jon's Computer", "Lab 6E77-B Terminal Omega" 131 std::string name; 132 // Linked to a mission? 133 int mission_id; 134 // Difficulty of simply logging in 135 int security; 136 // Number of times security is tripped 137 int alerts; 138 // Date of next attempt 139 time_point next_attempt; 140 // Things we can do 141 std::vector<computer_option> options; 142 // Things that happen if we fail a hack 143 std::vector<computer_failure> failures; 144 // Message displayed when the computer is secured and initial login fails. 145 // Can be customized to for example warn the player of potentially lethal 146 // consequences like secubots spawning. 147 std::string access_denied; 148 149 void remove_option( computer_action action ); 150 }; 151 152 #endif // CATA_SRC_COMPUTER_H 153