blob: 6773f6a96ae48118dbe4b8dbed7fa1d4e78585ef (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/*****************************************************************************
* ___ __ __ ___ _ __ *
* / _ \\ \/ // _ \ '_ \ *
* | (_) |> <| __/ | | | *
* \___//_/\_\\___|_| |_| *
* *
* The card game *
* *
* Copyright (C) 2011, Reiner Herrmann <reiner@reiner-h.de> *
* Mario Kilies <MarioKilies@GMX.net> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
*****************************************************************************/
#include "card.h"
#include <assert.h>
/**
* Calculate the score of a single card
* Cards divisible by 5: 2 points
* Cards divisible by 10: 3 points
* Cards divisible by 11: 5 points
* Card 55 (divisible by 5 and 11): 7 points
* @return Score of the card
*/
uint32_t card_get_points(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
}
|