forked from Whales/Cataclysm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
computer.h
114 lines (100 loc) · 2.8 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
#ifndef _COMPUTER_H_
#define _COMPUTER_H_
//#include "texthash.h"
#include "output.h"
#include <vector>
#include <string>
#define DEFAULT_COMPUTER_NAME ""
class game;
class player;
enum computer_action
{
COMPACT_NULL = 0,
COMPACT_OPEN,
COMPACT_SAMPLE,
COMPACT_RELEASE,
COMPACT_TERMINATE,
COMPACT_PORTAL,
COMPACT_CASCADE,
COMPACT_RESEARCH,
COMPACT_MAPS,
COMPACT_MAP_SEWER,
COMPACT_MISS_LAUNCH,
COMPACT_MISS_DISARM,
COMPACT_LIST_BIONICS,
COMPACT_ELEVATOR_ON,
COMPACT_AMIGARA_LOG,
COMPACT_AMIGARA_START,
COMPACT_DOWNLOAD_SOFTWARE,
COMPACT_BLOOD_ANAL,
NUM_COMPUTER_ACTIONS
};
enum computer_failure
{
COMPFAIL_NULL = 0,
COMPFAIL_SHUTDOWN,
COMPFAIL_ALARM,
COMPFAIL_MANHACKS,
COMPFAIL_SECUBOTS,
COMPFAIL_DAMAGE,
COMPFAIL_PUMP_EXPLODE,
COMPFAIL_PUMP_LEAK,
COMPFAIL_AMIGARA,
COMPFAIL_DESTROY_BLOOD,
NUM_COMPUTER_FAILURES
};
struct computer_option
{
std::string name;
computer_action action;
int security;
computer_option() { name = "Unknown", action = COMPACT_NULL, security = 0; };
computer_option(std::string N, computer_action A, int S) :
name (N), action (A), security (S) {};
};
class computer
{
public:
computer();
computer(std::string Name, int Security);
~computer();
computer & operator=(const computer &rhs);
// Initialization
void set_security(int Security);
void add_option(std::string opt_name, computer_action action, int Security);
void add_failure(computer_failure failure);
// Basic usage
void shutdown_terminal(); // Shutdown (free w_terminal, etc)
void use(game *g);
bool hack_attempt(player *p, int Security = -1);// -1 defaults to main security
// Save/load
std::string save_data();
void load_data(std::string data);
std::string name; // "Jon's Computer", "Lab 6E77-B Terminal Omega"
int mission_id; // Linked to a mission?
private:
int security; // Difficulty of simply logging in
std::vector<computer_option> options; // Things we can do
std::vector<computer_failure> failures; // Things that happen if we fail a hack
WINDOW *w_terminal; // Output window
// Called by use()
void activate_function (game *g, computer_action action);
// Generally called when we fail a hack attempt
void activate_random_failure(game *g);
// ...but we can also choose a specific failure.
void activate_failure (game *g, computer_failure fail);
// OUTPUT/INPUT
// Reset to a blank terminal (e.g. at start of usage loop)
void reset_terminal();
// Prints a line to the terminal (with printf flags)
void print_line(const char *text, ...);
// For now, the same as print_line but in red (TODO: change this?)
void print_error(const char *text, ...);
// Prints code-looking gibberish
void print_gibberish_line();
// Prints a line and waits for Y/N/Q
char query_ynq(const char *text, ...);
// Same as query_ynq, but returns true for y or Y
bool query_bool(const char *text, ...);
};
#endif