-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.h
More file actions
125 lines (104 loc) · 3.64 KB
/
Game.h
File metadata and controls
125 lines (104 loc) · 3.64 KB
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
#include <iostream>
#include <iterator>
#include <list>
#include "helpers.h"
#include "MapNode.h"
#include "Route.h"
#include "Message.h"
#include "Connectable.h"
#pragma once
using namespace std;
// Game class responsible for keeping track of game state and rendering scenes in the console
class Game
{
private:
// Basic stats
int* day;
int gold = 0;
// Sum of resources in respective buildings
vector<pair<string, int>> resources_tracker = {
{"Wood", 0},
{"Stone", 0},
{"Clay", 0},
{"Sand", 0},
{"Food", 0},
};
vector<pair<string, int>> means = {
{"Carriages", 1},
{"Workers", 10}
};
vector<pair<string, int>> means_in_use = {
{"Carriages", 0},
{"Workers", 0}
};
vector<pair<string, vector<pair<string, int>>*>> basic_data = {
{"RESOURCES", &resources_tracker},
{"AVAILABLE", &means},
{"IN USE", &means_in_use}
};
const vector<string> available_buildings = {
"Woodcutter's Lodge",
"Quarry",
"Clay Pit",
"Sand Quarry",
"Farm"
};
vector<Settlement*> settlements;
vector<Building*> buildings;
list<Route*> routes;
MailBox* mailbox;
// Map and Environment
int map_width, map_height;
MapNode **game_map;
public:
Game(MailBox* mailbox, int* day);
~Game();
void start(const int map_width, const int map_height);
void step();
void save();
void load();
void map_seed();
// Rendering functions
void intro();
void render_blank_rows(int number_of_rows);
void render_standard();
int render_messages();
void render_map();
void render_map_tile(int x, int y);
int render_buildings();
void render_building(Building *b);
void render_building_info(int building_index);
int render_settlements();
void render_settlement(Settlement *s);
void render_stock(Connectable *c, bool indexes = false);
void render_settlement_market_sell(Settlement *s);
void render_settlement_market_buy(Settlement *s);
int render_routes();
void render_route(Route *r);
// Resource functions
void add_tracker_resource(string resource_name, int amount);
bool use_means(string means_name, int amount);
bool release_means(string means_name, int amount);
bool add_means(string mean_name, int amount);
bool build(int x, int y, string building_name);
vector<string> get_available_buildings();
void clear_resources_tracker();
void update_resources_tracker();
int sell_resources(Settlement *s, string resource_name, int amount);
int buy_means(Settlement *s, string mean_name, int amount);
// Gameplay functions
void buildings_step();
void settlements_step();
bool reserve_carriage();
bool release_carriage();
bool assign_workers(Building *b, int amount, int *assigned_workers);
bool free_workers(Building *b, int amount, int *freed_workers);
bool create_route(Connectable *sender, Connectable *receiver, std::string resource_name, int amount, bool repeating);
void update_routes();
void cancel_route(Route *r);
// Helper functions
MapNode* get_map_tile(int x, int y);
Building* get_building_by_id(int id);
Settlement* get_settlement_by_id(int id);
Route* get_route_by_id(int id);
};