-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameFactory.cpp
More file actions
20 lines (17 loc) · 816 Bytes
/
Copy pathgameFactory.cpp
File metadata and controls
20 lines (17 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "gameFactory.h"
// Function to create the appropriate game mode based on the command line arguments
std::unique_ptr<baseGame> gameFactory::createGame(int argc, char* argv[]){
if (argc > 1) {
std::string mode = argv[1];
if (mode == "-save") {
bool save = true;
return std::make_unique<defaultGame>(save); // Create a default game with save mode
}
else if (mode == "-load") {
bool silentMode = (argc > 2 && std::string(argv[2]) == "-silent");
return std::make_unique<loadGame>(silentMode); // Create a load game (with or without silent mode)
}
}
// Default mode if no arguments are provided
return std::make_unique<defaultGame>(false); // Create a default game without save mode
}