-
Notifications
You must be signed in to change notification settings - Fork 0
/
PassMove.cpp
25 lines (24 loc) · 1.01 KB
/
PassMove.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
//
// Created by Derek Lin on 12/12/19.
//
#include "PassMove.h"
Uno::PassMove::PassMove(Uno::Player &maker, Uno::GameOfUno &gameState, Uno::MoveType moveType) :
Move(maker, gameState), moveType(moveType) {
}
Uno::Move *Uno::Move::CreatePass(Player &maker, GameOfUno &gameState) {
return new PassMove(maker, gameState, MoveType::PASS);
}
void Uno::PassMove::make() {
if (!(maker.isHoldingPlayableCard() || maker.canDrawMoreCardsThisTurn())) {
//player has no plays they can make
_endsTurn = true;
} else if (gameState.getRules().mustPlayCardEachTurn()) {
std::cout << "You cannot pass. You must play a card this turn." << std::endl;
} else if (maker.canDrawMoreCardsThisTurn()) {
int cardsLeftToDraw = gameState.getRules().getMaxDrawsPerTurn() - maker.getNumCardsDrawnThisTurn();
std::cout << "You cannot pass until you either play a card or draw at least "
<< cardsLeftToDraw << " more cards." << std::endl;
} else {
_endsTurn = true;
}
}