-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintro.h
More file actions
37 lines (30 loc) · 1003 Bytes
/
intro.h
File metadata and controls
37 lines (30 loc) · 1003 Bytes
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
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include "game.h"
using std::cin;
using std::cout;
using std::endl;
using std::flush;
void showIntroText() {
cout << endl
<< "...What’s this? A mystery car has just entered the race" << endl
<< " and he’s coming from behind, like a bullet!" << endl;
}
PieceRange getStartingParticipant() {
while (true) {
cout << endl << "Who goes first? Type cpu or human: " << flush;
char inputBuffer[1024] = {0};
cin >> inputBuffer;
std::string first(inputBuffer);
std::transform(first.begin(), first.end(), first.begin(), ::tolower);
if (first == "c" || first == "cpu" || first == "computer") {
cout << "The computer goes first." << endl;
return PieceRange::Black;
} else if (first == "h" || first == "human") {
cout << "The player goes first." << endl;
return PieceRange::White;
}
}
}