win counter has stopped working.

Why is it when you try and fix one issue another issue seems to appear?
my win counter has been working fine for the last two days and now has suddenly decided to stop playing ball.

any help is appriciated

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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
	#include <iostream>
	#include <conio.h>
	#include <algorithm>
	#include <ctime>
	#include <string>
	#include <climits>
	#include <iomanip>

	using namespace std;

	const int b = 24; //used to pass parramaters for beginner minefield
	


class gameBoardE
{
    public:

    void init_gameGrid(char gameGridE[24][24]) ///Expert
    {
        for (int j = 0; j < 24; j++)
        {
            for (int i = 0; i < 24; i++)
                {
                    gameGridE[j][i]=0;
                }
        }
    }
	
	
	
    void draw_gameGrid(char gameGridE[24][24]) ///
    {
        int line = 1;
		
        cout <<setw(4) <<"   1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24\n";
        for (int j = 0; j < 24; j++)
        {
            cout << setw(2)<<line++;
            for (int i = 0; i < 24; i++)   ///redefined this loop
            {
                if(gameGridE[j][i] > 0)
                  cout << "[" << gameGridE[j][i] << "]";
                else
                  cout<<"[ ]";
            }
            cout<<endl;
        }
    }

    void drawExpertBoard(int expertMField[][b])
    {
        int line = 1;
        cout <<"   1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24\n";
        for (int j = 0; j < 24; j++)
        {
            cout <<setw(2)<<line++;
            for (int i = 0; i < 24; i++)
            {
                cout << "[" << expertMField[j][i] << "]";
            }
            cout<<endl;
        }

   }


    void shuffleBoard(int expertMField[][b]) // randomises 99 mines (9) into an array 24 x 24 (expert board)
    {
        srand ((unsigned int)(time(0)));

        for(int x=0; x<24; x++)
        {

            for(int j=0;j<24; j++)
            {

                int xCoord = rand()%24;
                int yCoord = rand()%24;
                int temp    = expertMField[x][j];
                expertMField[x][j] = expertMField[xCoord][yCoord];
                expertMField[xCoord][yCoord] = temp;
            }
        }
    }
};


//------Class for Move functions-------------------------

class MoveE
{
    public:
    	char ansr;
    	int counter;
		
    int getPos() ///new function
	    {
	        int value = 0;
	        cin>>value;
	        
	        
	        while(value<1 || value>24)
	        {
	            cout<<"Enter a number between 1-24 \n";
	            cin>>value; 
	            
	            if (cin.fail())
					{
						cin.clear();
						cin.ignore(INT_MAX, '\n');
						cin >> value;
					}
		
	        }
	        return value;
    	}

    bool validCoords(int _row,int _col)///checks if [_row,_col] are within the grid 
    {
        if((_row < 0 || _row > 23) || (_col < 0 || _col > 23))
            return false;

        return true;
    }

    bool gotMine(int board[][b],int _row, int _col) /// return true if the coords have a mine //new func
    {
        return (board[_row][_col] == 9);
    }

    void checkMines(int expertMField[][b],char gameGridE[24][24], int Row, int Column) ///renamed nad redifined function Move
    {
		    do {	cout <<"Do you want to Flag of Reveal the square? F for flag, R for Reveal"<<"\n";
		            cin >> ansr;
		    } while (!(ansr == 'F'||ansr == 'f' || ansr == 'R' || ansr =='r' ));
		            
					if (ansr == 'F' || ansr == 'f')
						{	
							if(gameGridE[Row][Column] == 0 )
						 		{
								 gameGridE[Row][Column] = 70;
						 		}
						}
       	if (ansr == 'R' || ansr == 'r')
						{
							
							int _MinesFound = 48;
			        		int _NeighbrCellsOffset[8][2]  = {{-1,-1},{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0}};
			
			        		for(int i =0; i<8; i++)
			        			{
			            			int _neigx = _NeighbrCellsOffset[i][0];//neighbor cell row
			            			int _neigy = _NeighbrCellsOffset[i][1];//neighbor cell column
			           				if(validCoords((Row+_neigx),(Column+_neigy)) && gotMine(expertMField,(Row+_neigx),(Column+_neigy)))
			            				++_MinesFound;
			        			}
			        		gameGridE[Row][Column] = _MinesFound;
			        		counter++;
					    }
					    
				
				
							system("CLS");
			        		GboardE.draw_gameGrid(gameGridE);
				
			 }
    void playerE(int expertMField[][b],char gameGridE[24][24], int Row, int Column) 
    {
        bool alive = true;
        char answer;

        while(alive)
        {
            cout << "Enter Row number 1-24: "<<endl;
            Row    = getPos()-1;
            cout << "Enter Column number 1-24: "<<endl;
            Column = getPos()-1;

	
            MoveE move1;
            move1.checkMines(expertMField,gameGridE,Row,Column);

            if(gotMine(expertMField,Row,Column)&& gameGridE[Row][Column] != 70)
            {
                char answer= ' ';
        do{
		
                system("CLS");
                cout<<"	  BOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOM"<<endl;
                cout<<"		     		GAME OVER"<<endl;
                cout<<"	            Play again? Type Y or N"<<endl;
                cin>>answer;
			}while (!(answer =='y'||answer =='Y'||answer =='N'||answer =='n'));
			
                if(answer == 'Y' || answer == 'y')
                {
                	counter = 0;
                    GboardE.shuffleBoard(expertMField);
                    GboardE.init_gameGrid(gameGridE);
                    GboardE.draw_gameGrid(gameGridE);
                    GboardE.drawExpertBoard(expertMField);
                }

                if(answer == 'n' || answer == 'N')
			            {
			            	exit(1);
						}
                    
            
            }
            
              if (counter == 5){
            			system("CLS");
		                cout<<"	  Winner Winner, Chicken Dinner"<<endl;
		                
            			system("CLS");
		                cout<<"	            Play again? Type Y or N"<<endl;
		                cin>>answer;
		                if(answer == 'Y' || answer == 'y')
			                {
			                	system("CLS");
			                	counter=0;
			                    GboardE.shuffleBoard(expertMField);
                    			GboardE.init_gameGrid(gameGridE);
                    			GboardE.draw_gameGrid(gameGridE);     
			                }
			            if(answer == 'n' || answer == 'N')
			            {
			            	exit(1);
						}
			}
        }
    }

     
    private:
        gameBoardE GboardE;    
};
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
//-----------------------------------------------------EXPERT ENDS-----------------------------------------------------------------------------------------------------------------------------

	class menu
	{
	public:

	void Menu(int expertMField[][b],char gameGridE[24][24],int Row, int Column){

	int selection;
do{
	system("CLS");
	cout << "********************************MINESWEEPER*************************************\n\n";
	cout << "1. Play Beginner Game\n" << "2. Play Intermediate Game\n" << "3. Play Advanced Game\n" << "4. Show Score Board\n" << "5. Quit Game\n\n\n";
	cout << "Please enter your selection: ";
	cin >> selection;
	cout << endl;

	switch (selection)
	{
	case 1:
		cout << "Play Beginner Game\n";
		cout << "\n";
		system("CLS");

		gameBoardE Gboard; 
		Gboard.shuffleBoard(expertMField);
		Gboard.init_gameGrid(gameGridE);
		Gboard.draw_gameGrid(gameGridE);
		Gboard.drawExpertBoard(expertMField);

		MoveE Move1;
		Move1.playerE(expertMField,gameGridE,Row,Column);
		break;

	case 2:
		cout << "Play Intermediate Game\n";
		cout << "\n";
		system("CLS");

		break;
	case 3:
		cout << "Play Advanced Game\n";
		cout << "\n";
		system("CLS");

		break;

	case 4:
		cout << "Show Score Board\n";
		cout << "\n";
		break;

	case 5:
		cout << "Goodbye.\n";
		break;

	default: cout << selection << "is not a valid menu item.\n";

		cout << endl;
 }	
 
 
 }while(selection !=0);
 	
 	 
} 
};
//---- End menu----


int main(){
	bool alive = true;
	int Row, Column;
	char gameGridE[24][24];
		int expertMField[][b] = {
								{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
								{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
								{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
								{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
								{9,9,9,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
								{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
								};

		menu Menu1;
		Menu1.Menu(expertMField,gameGridE,Row,Column);

}
Topic archived. No new replies allowed.