-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcField.cpp
More file actions
72 lines (58 loc) · 1.4 KB
/
cField.cpp
File metadata and controls
72 lines (58 loc) · 1.4 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
//
// Created by jerem on 17.05.2022.
//
#include "cField.h"
#include <iostream>
void cField::deleteFlag() {
mFlagStatus = false;
}
void cField::setFlag() {
mFlagStatus = true;
}
bool cField::isFlagged(){
return mFlagStatus;
}
bool cField::isVisible(){
return mVisibilityStatus;
}
int cField::giveBombValue(){
return mBombValue;
}
int cField::serialReveal(cField ** board, int dimVertical, int dimHorizontal) {
if(mVisibilityStatus) return 0;
if(!mBombStatus) mVisibilityStatus = true;
else{
return 1;
}
if(mBombValue == 0) {
for (int s = -1; s < 2; s++) {
for (int g = -1; g < 2; g++) {
if ((g != 0 || s != 0) && ((mX + s < dimVertical && mX + s >= 0) && (mY + g < dimHorizontal && mY + g >= 0)) ) {
board[mX + s][mY + g].serialReveal(board, dimVertical, dimHorizontal);
}
}
}
}
return 0;
}
void cField::bombSetup() {
mBombStatus = true;
}
bool cField::giveBombStatus() {
return mBombStatus;
}
void cField::addValue() {
mBombValue++;
}
std::ostream & operator << (std::ostream &wyjscie, cField &i) {
wyjscie << " " << i.giveBombValue() << " ";
return wyjscie;
}
cField & operator+= (cField & val, int a){
val.mBombValue = val.mBombValue + a;
return val;
}
cField & cField::operator= (bool a){
this->mBombStatus = true;
return * this;
}