-
Notifications
You must be signed in to change notification settings - Fork 2
/
HeartsGameData.cpp
60 lines (53 loc) · 1.06 KB
/
HeartsGameData.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
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
/*
* HeartsGameData.cpp
* Hearts
*
* Created by Nathan Sturtevant on 11/27/08.
* Copyright 2008 __MyCompanyName__. All rights reserved.
*
*/
#include "HeartsGameData.h"
namespace hearts {
card GetCardPlay(int which, HeartsGameState *g)
{
for (int x = 0; x < 64; x++)
{
if (g->cards[3].has(x))
{
if (which == 0)
return x;
which--;
}
}
return -1;
}
int HeartsGameData::GetScore(int who)
{
if (scores[who].size() <= 0)
return 0;
int sum = 0;
for (unsigned int x = 0; x < scores[who].size(); x++)
sum+=scores[who][x];
return sum;
}
int HeartsGameData::GetLastScore(int who)
{
if (scores[who].size() <= 0)
return 0;
// if (scores[who].size() == 1)
return scores[who].back();
// return scores[who][scores[who].size()-2];
}
//void prepareToTransmit(std::string &str)
//{
//// std::iterator<std::string> i;
// while (str.find(std::string(" ")) != str.end())
// {
//// i = str.find(' ');
//// *i = '0';
//
// str.insert(str.insert(str.find(' '), '%'), '2');
// //iterator insert(iterator pos, const T& x);
// }
//}
} // namespace hearts