This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
breakthroughpine64backup/Board.h

63 lines
1.3 KiB
C
Raw Normal View History

2015-10-19 15:36:20 -05:00
#pragma once
2015-10-19 15:56:21 -05:00
#include <iostream>
#include <vector>
2015-10-27 10:40:55 -05:00
#include "Piece.h"
2015-10-19 15:56:21 -05:00
2015-10-19 15:36:20 -05:00
using namespace std;
2015-10-19 15:45:41 -05:00
struct moves {
int row;
int column;
2015-10-19 15:45:41 -05:00
string moveType;
2015-10-29 08:58:32 -05:00
moves() {
row = -1;
column = -1;
moveType = "";
}
2015-10-19 15:45:41 -05:00
moves(int linea, int columna, string m) {
row = linea;
column = columna;
moveType = m;
}
};
2015-10-19 15:36:20 -05:00
class Board {
2015-10-27 10:40:55 -05:00
vector<Piece*> xpieces;
vector<Piece*> opieces;
2015-10-27 11:31:44 -05:00
vector<Piece*> pieces;
2015-11-03 23:00:12 -06:00
vector<Board> record;
bool valid, xtaken, otaken;
2015-11-03 23:00:12 -06:00
char turn = 'O';
2015-10-19 15:36:20 -05:00
public:
Board();
2015-10-27 12:55:23 -05:00
Board(const Board& b);
2015-11-03 23:00:12 -06:00
vector<Board> getRecord() const{ return record; }
2015-10-28 17:12:44 -05:00
void setValidFalse(){ valid = false; }
void setValidTrue(){ valid = true; }
bool isValid(){ return valid; }
2015-10-27 11:31:44 -05:00
bool isPiece(int r, int c);
Piece* getPiece(int r, int c);
2015-10-28 17:12:44 -05:00
void isTaken(int r, int c);
bool checkTaken(char c);
vector<Piece*> getPieces() const { return pieces; }
vector<Piece*> getTypePieces(char type) const;
char getTurn() const { return turn; }
2015-10-19 15:36:20 -05:00
bool isGameOver();
char whoWon();
2015-10-19 15:36:20 -05:00
void changeTurns();
void resetTaken();
2015-10-19 15:36:20 -05:00
void displayBoard();
2015-10-27 11:51:37 -05:00
string boardToString();
2015-10-29 08:58:32 -05:00
Board move(moves m);
2015-10-27 11:31:44 -05:00
bool isThisMovePossible(int r, int c, string moveType);
vector<moves> viewPossibleMoves();
2015-10-19 15:45:41 -05:00
string myToUpper(string input);
2015-11-03 23:00:12 -06:00
Board* undo();
2015-10-19 16:37:20 -05:00
void snapshot(vector<Board>& inputVec, Board inputBoard);
int evaluate(char max, char min);
2015-10-29 08:58:32 -05:00
};