cmpsc330hw4/main.cpp

43 lines
1.3 KiB
C++
Raw Normal View History

2024-11-19 23:54:26 +00:00
#include "gameplay.h"
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
2024-11-20 00:11:06 +00:00
int main() {
2024-11-19 23:54:26 +00:00
int rows, cols;
char player1Name, player2Name;
string player1Type, player2Type;
// Read board dimensions
cin >> rows >> cols;
// Read player 1 details
cin >> player1Name >> player1Type;
// Read player 2 details
cin >> player2Name >> player2Type;
// Determine player types and initialize gameplay
Player* randomPlayerName, *strategicPlayerName;
if (tolower(player1Type[0]) == 'r' && tolower(player2Type[0]) == 's') {
randomPlayerName = new RandomPlayer(player1Name);
strategicPlayerName = new StrategicPlayer(player2Name);
} else if (tolower(player1Type[0]) == 's' && tolower(player2Type[0]) == 'r') {
randomPlayerName = new RandomPlayer(player2Name);
strategicPlayerName = new StrategicPlayer(player1Name);
}else if (tolower(player1Type[0]) == 'r' && tolower(player2Type[0]) == 'r') {
randomPlayerName = new RandomPlayer(player2Name);
strategicPlayerName = new RandomPlayer(player1Name);
} else {
randomPlayerName = new StrategicPlayer(player2Name);
strategicPlayerName = new StrategicPlayer(player1Name);
}
Gameplay game(rows, cols, randomPlayerName, strategicPlayerName);
game.playGame();
return 0;
}