Make it possible to score points ha haaaaa
This commit is contained in:
parent
e4e917ac48
commit
dd9c9fc2d3
38
game.c
38
game.c
@ -22,6 +22,10 @@ void initialize_game(Game *g) {
|
|||||||
g->player_teyaku.calculated = false;
|
g->player_teyaku.calculated = false;
|
||||||
g->left_teyaku.calculated = false;
|
g->left_teyaku.calculated = false;
|
||||||
g->right_teyaku.calculated = false;
|
g->right_teyaku.calculated = false;
|
||||||
|
g->player_points = 0;
|
||||||
|
g->right_points = 0;
|
||||||
|
g->left_points = 0;
|
||||||
|
g->kan_value = 12;
|
||||||
for (int i = 0; i < 48; i++) {
|
for (int i = 0; i < 48; i++) {
|
||||||
CardType t = CHAFF;
|
CardType t = CHAFF;
|
||||||
RibbonType rt = RIBBON_NONE;
|
RibbonType rt = RIBBON_NONE;
|
||||||
@ -322,10 +326,27 @@ void run_frame_calculating_scores(Game *g) {
|
|||||||
printf("All eights! Dealer gets %d kan\n", special_case.score);
|
printf("All eights! Dealer gets %d kan\n", special_case.score);
|
||||||
break;
|
break;
|
||||||
case SPECIAL_CASE_DOUBLE_EIGHTS:
|
case SPECIAL_CASE_DOUBLE_EIGHTS:
|
||||||
printf("Double eights! Player %d gets %d kan\n", special_case.target, special_case.score);
|
|
||||||
break;
|
|
||||||
case SPECIAL_CASE_SIXTEEN_CHAFF:
|
case SPECIAL_CASE_SIXTEEN_CHAFF:
|
||||||
printf("Sixteen chaff! Player %d gets %d kan\n", special_case.target, special_case.score);
|
printf("Double eights or 16 chaff! Player %d gets %d kan\n", special_case.target, special_case.score);
|
||||||
|
switch (special_case.target) {
|
||||||
|
case SPECIAL_CASE_TARGET_PLAYER:
|
||||||
|
transfer_kan(g, &g->player_points, &g->right_points, special_case.score);
|
||||||
|
transfer_kan(g, &g->player_points, &g->left_points, special_case.score);
|
||||||
|
break;
|
||||||
|
case SPECIAL_CASE_TARGET_RIGHT:
|
||||||
|
transfer_kan(g, &g->right_points, &g->player_points, special_case.score);
|
||||||
|
transfer_kan(g, &g->right_points, &g->left_points, special_case.score);
|
||||||
|
break;
|
||||||
|
case SPECIAL_CASE_TARGET_LEFT:
|
||||||
|
transfer_kan(g, &g->left_points, &g->right_points, special_case.score);
|
||||||
|
transfer_kan(g, &g->left_points, &g->player_points, special_case.score);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
transfer_points(g, &g->player_points, &g->temp_points, hand_points(&g->player_scored));
|
||||||
|
transfer_points(g, &g->right_points, &g->temp_points, hand_points(&g->right_scored));
|
||||||
|
transfer_points(g, &g->left_points, &g->temp_points, hand_points(&g->left_scored));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
g->state = GAME_STATE_INITIALIZING;
|
g->state = GAME_STATE_INITIALIZING;
|
||||||
@ -416,3 +437,14 @@ void run_until_closing(Game *g) {
|
|||||||
draw_frame(g);
|
draw_frame(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void transfer_points(Game *g, int *to, int *from, int amount) {
|
||||||
|
amount *= g->field_multiplier->value;
|
||||||
|
*to += amount;
|
||||||
|
*from -= amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void transfer_kan(Game *g, int *to, int *from, int amount) {
|
||||||
|
amount *= g->kan_value;
|
||||||
|
transfer_points(g, to, from, amount);
|
||||||
|
}
|
||||||
|
4
game.h
4
game.h
@ -36,9 +36,13 @@ struct Game {
|
|||||||
FieldMultiplier *field_multiplier;
|
FieldMultiplier *field_multiplier;
|
||||||
Teyaku player_teyaku, left_teyaku, right_teyaku;
|
Teyaku player_teyaku, left_teyaku, right_teyaku;
|
||||||
Card *current_play_from_hand, *current_play_target;
|
Card *current_play_from_hand, *current_play_target;
|
||||||
|
int player_points, right_points, left_points, temp_points;
|
||||||
|
int kan_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
void initialize_game(Game *g);
|
void initialize_game(Game *g);
|
||||||
void run_until_closing(Game *g);
|
void run_until_closing(Game *g);
|
||||||
|
void transfer_points(Game *g, int *to, int *from, int amount);
|
||||||
|
void transfer_kan(Game *g, int *to, int *from, int amount);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user