GigaPasjans
Loading...
Searching...
No Matches
CardHelper.h
1// Wykonane przez Piotra ChudziƄskiego w dniu 27.04.2025
2#pragma once
3
4#include "CardConstants.h"
5#include "Deck.h"
6
7namespace Game::CardHelper
8{
13 static bool IsStackInTableau(const CardStack *stack)
14 {
15 return stack->GetBaseSize() > 0 && stack->GetBaseSize() < CardConstants::TableauSize;
16 }
17
22 static bool IsStackStock(const CardStack *stack) { return stack->GetBaseSize() == CardConstants::StockSize; }
23
28 static bool IsStackFoundation(const CardStack *stack) { return stack->GetBaseSize() == 0; }
29
34 static constexpr bool IsRed(CardColor color) { return color == CardColor::Hearts || color == CardColor::Diamonds; }
35
40 static constexpr int8 GetCardValue(const CardType type)
41 {
42 switch (type)
43 {
44 case CardType::Ace: return 1;
45 case CardType::N2: return 2;
46 case CardType::N3: return 3;
47 case CardType::N4: return 4;
48 case CardType::N5: return 5;
49 case CardType::N6: return 6;
50 case CardType::N7: return 7;
51 case CardType::N8: return 8;
52 case CardType::N9: return 9;
53 case CardType::N10: return 10;
54 case CardType::Jack: return 11;
55 case CardType::Queen: return 12;
56 case CardType::King: return 13;
57 }
58 return -1;
59 }
60
65 static bool IsOppositeColor(Card *left, Card *right)
66 {
67 return IsRed(left->Color.GetEnum()) != IsRed(right->Color.GetEnum());
68 }
69} // namespace Game::CardHelper