ReactOS 0.4.16-dev-306-g647d351
cardcount.cpp
Go to the documentation of this file.
1//
2// CardCount is a helper library for CardStacks.
3//
4// When you initialize a CardCount object with a
5// cardstack, it keeps track of the number of cards
6// the stack contains.
7//
8// e.g. CardCount count(cardstack);
9//
10// Then you can do:
11//
12// int num_fives = count[5]
13//
14// count.Add(cardstack2); - combine with another stack
15//
16// int num_aces = count[1] - aces low
17// int num_aces = count[14] - aces high
18//
19// count.Clear();
20//
21
22#include "cardlib.h"
23#include "cardcount.h"
24
26{
27 Clear();
28}
29
31{
32 Init(cs);
33}
34
36{
37 for(int i = 0; i < 13; i++)
38 count[i] = 0;
39}
40
42{
43 for(int i = 0; i < cs.NumCards(); i++)
44 {
45 Card card = cs[i];
46
47 int val = card.LoVal();
48 count[val - 1]++;
49 }
50}
51
53{
54 for(int i = 0; i < cs.NumCards(); i++)
55 {
56 Card card = cs[i];
57 int val = card.LoVal();
58
59 if(count[val - 1] > 0)
60 count[val - 1]--;
61 }
62}
63
65{
66 Clear();
67 Add(cs);
68}
69
71{
72 if(index < 1) return 0;
73 else if(index > 14) return 0; //if out of range
74 else if(index == 14) index = 1; //if a "ace-high"
75
76 return count[index - 1];
77}
78
79//
80// Decrement specified item by one
81//
83{
84 if(index < 1) return;
85 else if(index > 14) return; //if out of range
86 else if(index == 14) index = 1; //if a "ace-high"
87
88 index -= 1;
89
90 if(count[index] > 0)
91 count[index]--;
92}
#define index(s, c)
Definition: various.h:29
void Dec(size_t index)
Definition: cardcount.cpp:82
void Sub(const CardStack &cs)
Definition: cardcount.cpp:52
void Clear()
Definition: cardcount.cpp:35
int operator[](size_t index) const
Definition: cardcount.cpp:70
void Add(const CardStack &cs)
Definition: cardcount.cpp:41
void Init(const CardStack &cs)
Definition: cardcount.cpp:64
Definition: card.h:28
int LoVal() const
Definition: card.h:59
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
GLuint GLfloat * val
Definition: glext.h:7180
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define cs
Definition: i386-dis.c:442