-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerHand.cpp
More file actions
74 lines (64 loc) · 1.13 KB
/
Copy pathPlayerHand.cpp
File metadata and controls
74 lines (64 loc) · 1.13 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "PlayerHand.h"
PlayerHand::PlayerHand(SDL_Rect rect, Deck* drawDeck, Deck* playDeck)
{
location = rect;
this->drawDeck = drawDeck;
this->playDeck = playDeck;
}
void PlayerHand::PlayCard(Card* card)
{
card->interactable = false;
Hand::PlayCard(card);
}
void PlayerHand::FillHand()
{
for (int i = 0; i <= 7; i++)
{
DrawCard();
}
}
void PlayerHand::DrawCard()
{
Hand::DrawCard();
hand.back()->interactable = true;
}
int PlayerHand::GetHandSize()
{
return hand.size();
}
void PlayerHand::MouseDown(MousePos mouse)
{
if (takingTurn)
{
for (Card* card : hand)
{
if (card->CheckMouseOver(mouse))
{
if (CanCardBePlayed(card))
{
PlayCard(card);
takingTurn = false;
break;
}
else
{
SDL_Log("Card could not be played");
break;
}
}
}
}
}
void PlayerHand::RenderCall(SDL_Renderer* renderer)
{
// set locations
// render all
// x = hand.x+i*(width/number of cards)
for (int i = 0; i < hand.size(); i++)
{
Card* card = hand[i];
card->SetLocation({location.x + i * (location.w/(int)hand.size()), location.y, 100, 150});
card->RenderCall(renderer);
}
return;
}