-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.cpp
41 lines (33 loc) · 773 Bytes
/
user.cpp
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
38
39
40
41
/**
* @file user.cpp
* @author DSN
* @brief Defines the member functions of \c User
* @version 0.1
* @date 2023-08-19
*
*/
#include "user.h"
#include "io.h"
#include <iostream>
void User::chance(Deck& deck)
{
char option{};
std::cout << "\nHIT or STAND? (h/s): ";
std::cin >> option;
inputCleanup();
if (option == 's')
m_stand = true;
else
hit(deck);
if (m_score > m_limit)
m_busted = true;
}
void User::hit(Deck& deck)
{
const Card card{ deck.dealCard() };
std::cout << "Card: " << card;
m_score += card.getCardValue();
if (card.getRank() == rank_ace and m_score > m_limit)
m_score -= 10;
std::cout << "\nCurrent score: " << m_score << '\n';
}