Out of ideas

I need to create a win condition in connect four, but I have no knowledge of how to.

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
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

void timer(unsigned short i){
clock_t delay = i*CLOCKS_PER_SEC;
clock_t start = clock();
    while(clock() - start < delay);
}

class ConnectFour{
public:
    ConnectFour(){markerX = 'X', markerY = 'Y';}
    void assignBoard(char multiArray[][7]){
        for(int r=0; r<6; r++){
            for(int c=0; c<7; c++){
                multiArray[r][c] = 'O';
            }
        }
    }
    void displayBoard(char multiArray[][7]){
        for(int r=0; r<6; r++){
            cout << "           ";
            for(int c=0; c<7; c++){
                cout << multiArray[r][c] << "|";
            }
            cout << endl;
        }
        cout << "           " << "1 2 3 4 5 6 7" << endl;
    }
    void turn(unsigned short& loop){
        cout << endl;
            if(loop%2 == 0)
                cout << "            " << "Player X: ";
            else
                cout << "            " << "Player Y: ";
    }
    bool errHandle(int& value){
        if(!cin){
            cout.put('\a');
            system("cls");
            system("color 1A");
            cout << "ERROR: Non-integer value has been registered!\n\nTERMINATING\n";
            exit(EXIT_FAILURE);
        }
        else if(value <= 0 || value > 7){
            system("cls");
            cout << "Please only enter values between 1 and 7\n";
            timer(2);
            system("cls");
            return true;
        }

    }
    void pos(char multiArray[][7], int& value, unsigned short& loop){
        char currentPlayerMarker;
            if(loop%2 == 0)
                currentPlayerMarker = markerX;
            else
                currentPlayerMarker = markerY;
            for(int row = 5; row >=0; row--){
                if(multiArray[row][value-1] == 'O'){
                    multiArray[row][value-1] = currentPlayerMarker;
                break;
            }
        }
    }
    bool boardLimit(char multiArray[][7], int& value){
        short counter = 1;
            for(int c=0; c<6; c++){
                if(markerX == multiArray[0][c] && value == counter || markerY == multiArray[0][c] && value == counter){
                    system("cls");
                    cout << "Row " << value << " is filled, pick another.\n";
                    timer(3);
                    system("cls");
                    return true;
            }
            counter++;
        }
    }
    // CREATE WIN CONDITION FUNC HERE

private:
    char markerX, markerY;
};

main(){
char board[6][7];
unsigned short loop = 0;
int value;
ConnectFour game;
game.assignBoard(board);
    while(loop < 42){
        game.displayBoard(board);
        game.turn(loop);
        (cin >> value).get();
            if(game.errHandle(value) == true)
                continue;
            else if(game.boardLimit(board, value) == true)
                continue;
        game.pos(board, value, loop);
        // IMPLEMENT WIN CONDITION FUNC HERE
        loop++;
        system("cls");
    }
system("cls");
game.displayBoard(board);
cout << "\n            IT'S A DRAW\n";
}


Any ideas?
Topic archived. No new replies allowed.