hanafuda/points.c
2025-02-26 20:05:31 -05:00

40 lines
1.3 KiB
C

// Copyright 2025 Bill Rossi
//
// This file is part of Hanafuda Hachi-Hachi.
//
// Hanafuda Hachi-Hachi 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.
//
// Hanafuda Hachi-Hachi 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 Hanafuda Hachi-Hachi. If not, see <https://www.gnu.org/licenses/>.
#include <stdio.h>
#include "points.h"
int hand_points(Hand *hand) {
int points = 0;
for (int i = 0; i < hand->count; i++) {
Card *c = hand->cards[i];
switch (c->type) {
case CHAFF:
points += 1;
break;
case RIBBON:
points += 5;
break;
case ANIMAL:
points += 10;
break;
case BRIGHT:
points += 20;
break;
}
}
return points - 88;
}
void kan_points_string(Game *g, int points, char *string) {
sprintf(string, "%d kan %d", points / g->kan_value, points % g->kan_value);
}