Add some options
This commit is contained in:
parent
e8a1389cda
commit
1e8b280271
8
card.c
8
card.c
@ -104,7 +104,7 @@ int first_open_spot(Hand *h) {
|
||||
return fos;
|
||||
}
|
||||
|
||||
void add_to_hand(Hand *h, Card *c) {
|
||||
void add_to_hand(Hand *h, Card *c, float deal_speed) {
|
||||
c->order = first_open_spot(h);
|
||||
h->cards[h->count] = c;
|
||||
|
||||
@ -131,7 +131,7 @@ void add_to_hand(Hand *h, Card *c) {
|
||||
}
|
||||
c->move.curve = CURVE_EASE_IN_OUT;
|
||||
c->move.current_time = 0.;
|
||||
c->move.end_time = 0.2;
|
||||
c->move.end_time = deal_speed;
|
||||
|
||||
h->count++;
|
||||
}
|
||||
@ -140,11 +140,11 @@ bool card_done_moving(Card *c) {
|
||||
return c->move.current_time > c->move.end_time;
|
||||
}
|
||||
|
||||
void deal(Hand *from, Hand *to, int count, bool up) {
|
||||
void deal(Hand *from, Hand *to, int count, bool up, float deal_speed) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
Card *c = from->cards[from->count - 1];
|
||||
c->visible = up;
|
||||
add_to_hand(to, c);
|
||||
add_to_hand(to, c, deal_speed);
|
||||
from->count--;
|
||||
}
|
||||
}
|
||||
|
4
card.h
4
card.h
@ -76,9 +76,9 @@ struct Hand {
|
||||
void draw_card(Card *c, Texture2D *cards_texture);
|
||||
bool point_within_card(Card *c, Vector2 v);
|
||||
void shuffle_hand(Hand *h);
|
||||
void deal(Hand *from, Hand *to, int count, bool up);
|
||||
void deal(Hand *from, Hand *to, int count, bool up, float deal_speed);
|
||||
void remove_from_hand(Hand *h, Card *c);
|
||||
void add_to_hand(Hand *h, Card *c);
|
||||
void add_to_hand(Hand *h, Card *c, float deal_speed);
|
||||
bool card_done_moving(Card *c);
|
||||
Rectangle next_card_position(Hand *h);
|
||||
|
||||
|
25
game.c
25
game.c
@ -26,6 +26,7 @@ void initialize_game(Game *g) {
|
||||
g->field_multiplier = NULL;
|
||||
g->kan_value = 12;
|
||||
g->dialog = NULL;
|
||||
g->deal_speed = 0.2;
|
||||
|
||||
init_dialogs(g);
|
||||
|
||||
@ -265,16 +266,16 @@ void capture_card_from_field(Game *g, Card *played, Card *target, Hand *hand, Ha
|
||||
}
|
||||
|
||||
remove_from_hand(hand, played);
|
||||
add_to_hand(scored, played);
|
||||
add_to_hand(scored, played, g->deal_speed);
|
||||
|
||||
if (same_month_card_count == 3) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
remove_from_hand(&g->field, same_month_card[i]);
|
||||
add_to_hand(scored, same_month_card[i]);
|
||||
add_to_hand(scored, same_month_card[i], g->deal_speed);
|
||||
}
|
||||
} else {
|
||||
remove_from_hand(&g->field, target);
|
||||
add_to_hand(scored, target);
|
||||
add_to_hand(scored, target, g->deal_speed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -289,7 +290,7 @@ void run_frame_ai_playing(Game *g) {
|
||||
capture_card_from_field(g, play.played, play.target, hand, scored);
|
||||
} else {
|
||||
remove_from_hand(hand, play.played);
|
||||
add_to_hand(&g->field, play.played);
|
||||
add_to_hand(&g->field, play.played, g->deal_speed);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +323,7 @@ void run_frame_initializing(Game *g) {
|
||||
for (int i = 0; i < 48; i++) {
|
||||
Card *c = &g->cards[i];
|
||||
c->visible = false;
|
||||
add_to_hand(&g->deck, c);
|
||||
add_to_hand(&g->deck, c, g->deal_speed);
|
||||
}
|
||||
|
||||
shuffle_hand(&g->deck);
|
||||
@ -349,15 +350,15 @@ bool misdeal(Game *g) {
|
||||
|
||||
void run_frame_dealing(Game *g) {
|
||||
if (current_player(g)->hand.count < 4) {
|
||||
deal(&g->deck, ¤t_player(g)->hand, 4, is_player_turn(g));
|
||||
deal(&g->deck, ¤t_player(g)->hand, 4, is_player_turn(g), g->deal_speed);
|
||||
g->turn_number++;
|
||||
} else if (g->field.count < 3) {
|
||||
deal(&g->deck, &g->field, 3, true);
|
||||
deal(&g->deck, &g->field, 3, true, g->deal_speed);
|
||||
} else if (current_player(g)->hand.count < 7) {
|
||||
deal(&g->deck, ¤t_player(g)->hand, 3, is_player_turn(g));
|
||||
deal(&g->deck, ¤t_player(g)->hand, 3, is_player_turn(g), g->deal_speed);
|
||||
g->turn_number++;
|
||||
} else if (g->field.count < 6) {
|
||||
deal(&g->deck, &g->field, 3, true);
|
||||
deal(&g->deck, &g->field, 3, true, g->deal_speed);
|
||||
} else {
|
||||
if (misdeal(g)) {
|
||||
printf("misdeal\n");
|
||||
@ -468,7 +469,7 @@ void run_frame_choosing_target(Game *g) {
|
||||
} else {
|
||||
g->current_play_from_hand->selected = false;
|
||||
remove_from_hand(&g->player.hand, g->current_play_from_hand);
|
||||
add_to_hand(&g->field, g->current_play_from_hand);
|
||||
add_to_hand(&g->field, g->current_play_from_hand, g->deal_speed);
|
||||
g->current_play_from_hand = NULL;
|
||||
}
|
||||
g->state = GAME_STATE_SHOWING_CARD_FROM_DECK;
|
||||
@ -478,7 +479,7 @@ void run_frame_choosing_target(Game *g) {
|
||||
void run_frame_showing_card_from_deck(Game *g) {
|
||||
Card *top_card = g->deck.cards[g->deck.count - 1];
|
||||
remove_from_hand(&g->deck, top_card);
|
||||
add_to_hand(&g->deck, top_card);
|
||||
add_to_hand(&g->deck, top_card, g->deal_speed);
|
||||
top_card->visible = true;
|
||||
top_card->move.end_time = 0.3;
|
||||
top_card->move.destination.y = top_card->move.destination.y + 150;
|
||||
@ -498,7 +499,7 @@ void run_frame_playing_from_deck(Game *g) {
|
||||
g->state = GAME_STATE_CHECKING_FOR_NEW_DEKIYAKU;
|
||||
} else if(target_count == 0) {
|
||||
remove_from_hand(&g->deck, top_card);
|
||||
add_to_hand(&g->field, top_card);
|
||||
add_to_hand(&g->field, top_card, g->deal_speed);
|
||||
g->state = GAME_STATE_CHECKING_FOR_NEW_DEKIYAKU;
|
||||
} else {
|
||||
g->state = GAME_STATE_CHOOSING_TARGET_FROM_DECK;
|
||||
|
2
game.h
2
game.h
@ -50,6 +50,8 @@ struct Game {
|
||||
Dialog *dialog;
|
||||
Player *dealer;
|
||||
int number_of_rounds;
|
||||
Color card_backs;
|
||||
float deal_speed;
|
||||
int current_round;
|
||||
};
|
||||
|
||||
|
15
options.c
Normal file
15
options.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "options.h"
|
||||
|
||||
void load_options_from_game(Game *g, Options *o) {
|
||||
o->kan_value = g->kan_value;
|
||||
o->number_of_rounds = g->number_of_rounds;
|
||||
o->card_backs = g->card_backs;
|
||||
o->deal_speed = g->deal_speed;
|
||||
}
|
||||
|
||||
void save_options_to_game(Game *g, Options *o) {
|
||||
g->kan_value = o->kan_value;
|
||||
g->number_of_rounds = o->number_of_rounds;
|
||||
g->card_backs = o->card_backs;
|
||||
g->deal_speed = o->deal_speed;
|
||||
}
|
18
options.h
Normal file
18
options.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _HF_OPTIONS_
|
||||
#define _HF_OPTIONS_
|
||||
|
||||
typedef struct Options Options;
|
||||
|
||||
#include "game.h"
|
||||
|
||||
struct Options {
|
||||
int kan_value;
|
||||
int number_of_rounds;
|
||||
Color card_backs;
|
||||
float deal_speed;
|
||||
};
|
||||
|
||||
void load_options_from_game(Game *g, Options *o);
|
||||
void save_options_to_game(Game *g, Options *o);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user