blob: 89841c42138f720ecb236d4cf26796a15dfb967e (
plain)
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
|
#include "common.h"
#include <assert.h>
uint32_t cardpoints(const card c)
{
assert(c > 0 && c <= 105);
if (55 == c) return 7; // Card 55 is worth of 7 points
if (c % 11 == 0) return 5; // Cards that are multiples of 11 are worth 5 points
if (c % 10 == 0) return 3; // ... 10 are worth 3 points
if (c % 5 == 0) return 2; // ... 5 are worth 2 points
return 1; // All other cards are worth 1 point
}
uint32_t stackpoints(const cardstack s)
{
uint32_t points = 0;
for(uint32_t i = 0; i < MAX_CARDSTACK_SIZE; i++)
{
if(s[i] > 0)
points += cardpoints(s[i]);
}
return points;
}
|