PageRenderTime 18ms CodeModel.GetById 9ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/BJEngine/src/Card.h

https://bitbucket.org/mild1/bj
C Header | 79 lines | 69 code | 10 blank | 0 comment | 1 complexity | 2fa92d9b39a6144815145b28e28b5bfa MD5 | raw file
 1#ifndef _CARD_H_
 2#define _CARD_H_
 3
 4#include <ostream>
 5
 6enum Card
 7{
 8    CardFirst = 1,
 9    Card2,
10    Card3,
11    Card4,
12    Card5,
13    Card6,
14    Card7,
15    Card8,
16    Card9,
17    Card10,
18    CardJ,
19    CardQ,
20    CardK,
21    CardA,
22    CardLast
23};
24
25struct Score
26{
27    inline static unsigned int CardsScores(Card card)
28    {
29        static const unsigned int cardsScores[] =
30        {
31            0, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11
32        };
33        return cardsScores[card];
34    };
35
36    inline static Card Score2Card(unsigned int scr)
37    {
38        static const Card int2Card[] =
39        {
40            CardLast,
41            CardA,
42            Card2,
43            Card3,
44            Card4,
45            Card5,
46            Card6,
47            Card7,
48            Card8,
49            Card9,
50            Card10,
51            CardA
52        };
53        return int2Card[scr];
54    }
55
56    Score()
57    {
58        Reset();
59    }
60
61    unsigned int score;
62    bool         isSoft;
63
64    void AddCard(Card card);
65    void Reset();
66
67    friend std::ostream& operator <<(std::ostream& os, const Score& score)
68    {
69        if(score.isSoft)
70            os << "soft ";
71        else
72            os << "hard ";
73        os << score.score;
74        return os;
75    };
76};
77
78
79#endif