-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPacker.cpp
More file actions
213 lines (183 loc) · 4.37 KB
/
Copy pathPacker.cpp
File metadata and controls
213 lines (183 loc) · 4.37 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
// ********************************************************************************
/// <summary>
///
/// </summary>
/// <created>ʆϒʅ,29.09.2018</created>
/// <changed>ʆϒʅ,13.10.2019</changed>
// ********************************************************************************
#include "Packers.h"
#include "Packer.h"
#include "Console.h"
Actions::Actions () { action = "NULL"; delay = 2000; };
Actions::Actions ( const std::string& prmOne, const unsigned short& prmTwo )
{
action = prmOne;
delay = prmTwo;
};
Packer::Packer ()
{
// the count of active packers
count++;
// rand seed provider + quick reseeding
std::time_t currentTime { std::chrono::system_clock::to_time_t ( std::chrono::system_clock::now () ) };
std::time_t* currentTime_ptr { ¤tTime };
srand ( static_cast<unsigned int>( time ( currentTime_ptr ) + count * 1.123456789 ) );
int rnd { 0 };
id = count;
address = this;
faces [0] = u8"☻";
faces [1] = u8"☺";
//TODO different packer types can be added
// random face + actions
rnd = ( rand () % 2 + 1 );
switch ( rnd )
{
case 1:
currentFace = &faces [0];
process [1] = { faces [0],DELAY_TWO };
break;
case 2:
currentFace = &faces [1];
process [1] = { faces [1],DELAY_TWO };
break;
}
process [0] = { u8" ",DELAY_ONE };
process [2] = { u8".",DELAY_THREE };
process [3] = { u8" ",DELAY_FOUR };
// random start position
do
{
position.X = rand () % ( ( SCREEN_W - 18 ) - 3 ) + 3;
position.Y = rand () % ( ( SCREEN_H - 12 ) - 3 ) + 3;
} while ( position.X % 2 == 0 || position.Y % 2 == 0 );
// random direction
rnd = ( rand () % 1000 + 1 );
if ( rnd % 2 == 0 )
{
direction = true;
} else
{
direction = false;
}
// random motivation
rnd = ( rand () % 6 + 1 );
switch ( rnd )
{
case 1:
motivation = F_bCYAN; // independent-chewer
break;
case 2:
motivation = F_bGREEN; // green-national-chewer
break;
case 3:
motivation = F_bRED; // red-national-chewer
break;
case 4:
motivation = F_bPURPLE; // not-know-chewer
break;
case 5:
motivation = F_bYELLOW; // free-chewer
break;
case 6:
motivation = F_bWHITE; // neutral-chewer
break;
}
// making packer's aspirations ready... :)
// Todo add: current position consideration
rnd = rand () % 4 + 1;
switch ( rnd )
{
case 1:
aspiration = 10;
break;
case 2:
aspiration = 20;
break;
case 3:
aspiration = 30;
break;
case 4:
aspiration = 40;
break;
}
// random state
//TODO changed (part of smart pants of packers :) )
rnd = ( rand () % 3 + 1 );
switch ( rnd )
{
case 1:
mood = 10; // normal
break;
case 2:
mood = 20; // not in the mood
break;
case 3:
mood = 30; // tired
break;
}
colourInserter ( *currentFace, motivation, position );
};
unsigned char Packer::count { 0 };
//unsigned char Packer::aspirationsSeeds [32] { 0 };
//unsigned char Packer::aspirations [32] { 10 };
const unsigned char& Packer::getId ( void )
{
return id;
};
const Actions& Packer::getProcess ( const unsigned char& index )
{
return process [index];
};
COORD& Packer::getPosition ( void )
{
return position;
}
bool& Packer::getDirection ( void )
{
return direction;
};
const WORD& Packer::getMotivation ( void )
{
return motivation;
};
const unsigned char& Packer::getAspiration ( void )
{
// Todo aspiration re-newer
return aspiration;
};
void Packer::involve ( const unsigned short& instance )
{
unsigned char temp { 0 };
temp = ( instance / 10 ) + 1;
switch ( temp )
{
case 1:
process [1] = { u8"☻", DELAY_TWO };
break;
case 2:
process [1] = { u8"☺", DELAY_TWO };
break;
}
temp = ( instance % 10 ) + 1;
switch ( temp )
{
case 1:
motivation = F_bCYAN;
break;
case 2:
motivation = F_bGREEN;
break;
case 3:
motivation = F_bRED;
break;
case 4:
motivation = F_bPURPLE;
break;
case 5:
motivation = F_bYELLOW;
break;
case 6:
motivation = F_bWHITE;
break;
}
};