Display teyaku
This commit is contained in:
parent
7b4847e165
commit
a40067ff8f
15
main.c
15
main.c
@ -12,7 +12,7 @@
|
|||||||
char *text = "こんにちわ、 世界!";
|
char *text = "こんにちわ、 世界!";
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
InitWindow(800, 450, "Hanafuda Hachi-Hachi");
|
InitWindow(800, 550, "Hanafuda Hachi-Hachi");
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -86,9 +86,22 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
int num_selected = 0;
|
||||||
for (int i = 0; i < 48; i++) {
|
for (int i = 0; i < 48; i++) {
|
||||||
|
num_selected += cards[i].selected;
|
||||||
draw_card(&cards[i]);
|
draw_card(&cards[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (num_selected == 7) {
|
||||||
|
Hand h;
|
||||||
|
h.count = 0;
|
||||||
|
for (int i = 0; i < 48; i++) {
|
||||||
|
if (cards[i].selected) memcpy(&h.cards[h.count++], &cards[i], sizeof(Card));
|
||||||
|
}
|
||||||
|
|
||||||
|
char *s = TextFormat("Set: %s(%d) / Chaff: %s(%d) / Total: %d", set_teyaku_english(h), set_teyaku_points(h), chaff_teyaku_english(h), chaff_teyaku_points(h), calculate_teyaku(h));
|
||||||
|
DrawText(s, 10, 500, 25, BLACK);
|
||||||
|
}
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
teyaku.c
4
teyaku.c
@ -1,3 +1,5 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "teyaku.h"
|
#include "teyaku.h"
|
||||||
#include "card.h"
|
#include "card.h"
|
||||||
|
|
||||||
@ -82,7 +84,5 @@ char *chaff_teyaku_english(Hand h) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int calculate_teyaku(Hand h) {
|
int calculate_teyaku(Hand h) {
|
||||||
if (calculate_chaff_teyaku(h)) printf("%s\n", chaff_teyaku_english(h));
|
|
||||||
if (calculate_set_teyaku(h)) printf("%s\n", set_teyaku_english(h));
|
|
||||||
return chaff_teyaku_points(h) + set_teyaku_points(h);
|
return chaff_teyaku_points(h) + set_teyaku_points(h);
|
||||||
}
|
}
|
||||||
|
10
teyaku.h
10
teyaku.h
@ -4,7 +4,7 @@
|
|||||||
#include "card.h"
|
#include "card.h"
|
||||||
|
|
||||||
typedef enum SetTeyaku {
|
typedef enum SetTeyaku {
|
||||||
SET_TEYAKU_NONE,
|
SET_TEYAKU_NONE = 0,
|
||||||
TRIPLET,
|
TRIPLET,
|
||||||
STANDING_TRIPLET,
|
STANDING_TRIPLET,
|
||||||
TWO_TRIPLETS,
|
TWO_TRIPLETS,
|
||||||
@ -18,7 +18,7 @@ typedef enum SetTeyaku {
|
|||||||
} SetTeyaku;
|
} SetTeyaku;
|
||||||
|
|
||||||
typedef enum ChaffTeyaku {
|
typedef enum ChaffTeyaku {
|
||||||
CHAFF_TEYAKU_NONE,
|
CHAFF_TEYAKU_NONE = 0,
|
||||||
CHAFF_TEYAKU_RED,
|
CHAFF_TEYAKU_RED,
|
||||||
ONE_RIBBON,
|
ONE_RIBBON,
|
||||||
ONE_ANIMAL,
|
ONE_ANIMAL,
|
||||||
@ -27,5 +27,11 @@ typedef enum ChaffTeyaku {
|
|||||||
} ChaffTeyaku;
|
} ChaffTeyaku;
|
||||||
|
|
||||||
int calculate_teyaku(Hand h);
|
int calculate_teyaku(Hand h);
|
||||||
|
SetTeyaku calculate_set_teyaku(Hand h);
|
||||||
|
ChaffTeyaku calculate_chaff_teyaku(Hand h);
|
||||||
|
char *set_teyaku_english(Hand h);
|
||||||
|
char *chaff_teyaku_english(Hand h);
|
||||||
|
int set_teyaku_points(Hand h);
|
||||||
|
int chaff_teyaku_points(Hand h);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user