-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArea.cpp
More file actions
156 lines (140 loc) · 4.44 KB
/
Copy pathArea.cpp
File metadata and controls
156 lines (140 loc) · 4.44 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
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
152
153
154
155
156
// ********************************************************************************
/// <summary>
///
/// </summary>
/// <created>ʆϒʅ,29.09.2018</created>
/// <changed>ʆϒʅ,13.10.2019</changed>
// ********************************************************************************
#include "Packers.h"
#include "Area.h"
#include "Console.h"
Area::Area ( unsigned char mode ) :age ( mode )
{
wallH = u8"═"; // Unicode: "━"
wallV = u8"║"; // Unicode: "┃"
edges [0] = u8"╔"; // Unicode: "┏"
edges [1] = u8"╚"; // Unicode: "┗"
edges [2] = u8"╝"; // Unicode: "┛"
edges [3] = u8"╗"; // Unicode: "┓"
colourW = F_CYAN;
rows = SCREEN_H - 12;
columns = SCREEN_W - 18;
resources [0] = u8"♠";
resources [1] = u8"♣";
resources [2] = u8"♦";
colourH = F_GREEN;
colourR = F_YELLOW;
colourV = F_bRED;
// area
COORD position;
for ( int y = 1; y <= rows; y++ )
{
for ( int x = 1; x <= columns; x++ )
{
position.X = x;
position.Y = y;
colourInserter ( position );
// first horizontal wall
if ( y == 1 && x != columns )
{
// left top edge
if ( y == 1 && x == 1 )
colourInserter ( edges [0], colourW );
colourInserter ( wallH, colourW );
}
// right top edge
if ( y == 1 && x == columns )
colourInserter ( edges [3], colourW );
// left bottom edge
if ( y == rows && x == 1 )
colourInserter ( edges [1], colourW );
// second horizontal wall
if ( y == rows && x != columns )
colourInserter ( wallH, colourW );
else
// right bottom edge
if ( y == rows && x == columns )
colourInserter ( edges [2], colourW );
else
// vertical walls
if ( x == 1 || x == columns )
if ( y != 1 )
colourInserter ( wallV, colourW );
// packs
if ( y != 1 && y != rows && y % 2 == 0 )
if ( x != 1 && x != columns && x % 2 == 0 )
colourInserter ( resources [1], colourH );
std::cout << '\n';
}
}
};
void Area::setter ( const unsigned short& state, const COORD& position )
{
//TODO to be added: other resource colours + reconstruction
int wish { state };
wish /= 10;
switch ( wish )
{
case 1:
if ( position.X - 1 > 2 )
{
colourInserter ( { position.X - 1, position.Y - 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y - 1][position.X - 1] = currentState;
} else
if ( position.X + 1 < columns )
{
colourInserter ( { position.X + 1, position.Y - 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y - 1][position.X + 1] = currentState;
}
break;
case 2:
if ( position.Y - 1 > 2 )
{
colourInserter ( { position.X - 1, position.Y - 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y - 1][position.X - 1] = currentState;
} else
if ( position.Y + 1 < rows )
{
colourInserter ( { position.X - 1, position.Y + 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y + 1][position.X - 1] = currentState;
}
break;
case 3:
if ( position.X - 1 > 2 )
{
colourInserter ( { position.X - 1, position.Y + 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y + 1][position.X - 1] = currentState;
} else
if ( position.X + 1 < columns )
{
colourInserter ( { position.X + 1, position.Y + 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y + 1][position.X + 1] = currentState;
}
break;
case 4:
if ( position.Y - 1 > 2 )
{
colourInserter ( { position.X + 1, position.Y - 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y - 1][position.X + 1] = currentState;
} else
if ( position.Y + 1 < rows )
{
colourInserter ( { position.X + 1, position.Y + 1 } );
colourInserter ( u8"♣", F_YELLOW );
//stateArray [position.Y + 1][position.X + 1] = currentState;
}
break;
}
};
const COORD Area::get ()
{
COORD frame { columns, rows };
return frame;
};