Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Geeft true als kleur schaak staat
- //Kleur (color) is the parameter to decide for what color to check
- //if the king of that color is checked
- bool game::schaak(zw kleur) {
- //Getting the opposite color
- //If kleur = white (wit), oppositeColor
- //is black (zwart)
- zw oppositeColor = zwart;
- //Setting the king (white or black)
- //in variable schaakStuk* king;
- schaakStuk* king = witKoning;
- string color = "Wit staat schaak!!"; //String to display in message
- if (kleur == zwart) {
- //If the color-parameter is black, oppositeColor
- //and king should be changed related to color
- oppositeColor = wit;
- king = zwartKoning;
- color = "Zwart staat schaak!!!";
- }
- //Vector holding valid moves (read more below)
- vector<string> v;
- //Iterating over all chess pieces on the board
- for (auto i : schaakStukken) {
- //If chess-piece is of opposite color
- if (i.second->getKleur() == oppositeColor) {
- //Setting all valid moves of chess-piece
- //in current iteration
- v = i.second->geldige_zetten(*this, i.first);
- //Iterating over all valid positions of chess-piece
- //in current iteration
- for (auto j : v) {
- //if one of the valid possible positions equals to
- //the enemy's king position
- if (j == king->getCurrentPositie().str()) {
- //Show message and return
- QMessageBox joehoe;
- joehoe.setText(QString::fromStdString(color));
- joehoe.exec();
- //Outputting all valid positions
- cout << "j " << j << endl;
- //Temporarily commented out
- //return true;
- }
- }
- }
- }
- return false;
- }
- MainWindow::setPiece()
- void MainWindow::update()
- MainWindow::clicked()
Add Comment
Please, Sign In to add comment