-
Notifications
You must be signed in to change notification settings - Fork 0
/
HpRule.h
38 lines (32 loc) · 1.06 KB
/
HpRule.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
#pragma once
#include "Field.h"
#include "Player.h"
#include "EventCreator.h"
#include "Enums.h"
#include "random"
template<DIFFICULTY T>
class HpRule
{
public:
void operator()(EventCreator& ev_cr) {
//EventCreator ev_creator(field, player);
Field* field = ev_cr.Get_Field();
//Player* player = ev_cr.Get_Player();
std::vector<std::vector<Cell>>* cells = field->GetField();
int height = field->GetHeight();
int width = field->GetWidth();
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dist(1, width + height - (width + height) % (T * 5));
for (int i{}; i < height; i++) {
for (int j{}; j < width; j++) {
if (dist(rd) == 1) {
if ((*cells)[i][j].GetObject() == Cell::COMMON && !(*cells)[i][j].GetActive()) {
(*cells)[i][j].SetPlayersEvents(ev_cr.CreateHpEvent());
(*cells)[i][j].SetObject(Cell::HP);
}
}
}
}
}
};