summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client_game_states.c15
-rw-r--r--src/ui.c21
-rw-r--r--src/ui.h1
3 files changed, 26 insertions, 11 deletions
diff --git a/src/client_game_states.c b/src/client_game_states.c
index 3fe262f..6d39ed7 100644
--- a/src/client_game_states.c
+++ b/src/client_game_states.c
@@ -9,6 +9,7 @@ game_state_t state_client_wait_for_hand_cards(const int sock, const uint8_t roun
data_store_t *d = data_store();
ui_display_wnd_messages("Waiting for hand cards from server", false);
+ ui_update();
if(round == 1)
{
@@ -16,11 +17,11 @@ game_state_t state_client_wait_for_hand_cards(const int sock, const uint8_t roun
net_recv(sock, msg_type_initial_stacks);
ui_display_wnd_table_cards(&d->table_stacks, false, 0);
ui_display_wnd_stack_points(&d->table_stacks, false, 0);
+ ui_update();
}
- // Wait for hand cards from server and display them
+ // Wait for hand cards from server
net_recv(sock, msg_type_deal_hand);
- ui_display_wnd_hand_cards(&d->hand, false, 0);
return STATE_CLIENT_SELECT_OPEN_CARD;
}
@@ -30,8 +31,6 @@ game_state_t state_client_select_open_card(const int sock)
data_store_t *d = data_store();
uint8_t open_card_idx;
- ui_display_wnd_messages("Please choose the card you want to play", true);
-
// Select open card
open_card_idx = ui_choose_card(&d->hand);
d->selected_card = d->hand.cards[open_card_idx];
@@ -42,6 +41,7 @@ game_state_t state_client_select_open_card(const int sock)
// Remove picked open card from hand
hand_remove_card(&d->hand, open_card_idx);
ui_display_wnd_hand_cards(&d->hand, false, 0);
+ ui_update();
return STATE_CLIENT_WAIT_FOR_OPEN_CARDS;
}
@@ -51,13 +51,13 @@ game_state_t state_client_wait_for_open_cards(const int sock)
data_store_t *d = data_store();
ui_display_wnd_messages("Waiting for the other players to pick their cards", false); // The two spaces between 'pick' and 'their' are intentionally and used for poor man's word wrap
+ ui_update();
net_recv(sock, msg_type_selected_card_all);
player_list_sort_by_open_card(&d->player_list, d->player_list.count); // sort in ascending order
player_list_entry_t *ple = get_player_list_entry_by_player_id(&d->player_list, d->own_player_id);
assert(ple != NULL);
- ui_display_wnd_current_state(&d->player_list, d->player_list.count, false, 0, ple->score);
return STATE_CLIENT_PLAY_CARDS;
}
@@ -74,13 +74,14 @@ game_state_t state_client_play_cards(const int sock)
uint8_t stack_idx = get_stack_idx_for_card(&ds->table_stacks, c);
bool our_turn = (ds->player_list.players[i].player_id == ds->own_player_id);
+ ui_display_wnd_messages("Placing cards...", false);
ui_display_wnd_current_state(&ds->player_list, ds->player_list.count, true, i, ple->score);
+ ui_update();
if(stack_idx >= NUM_TABLE_STACKS) // card does not fit on any stack
{
if(our_turn) // our turn to select stack
{
- ui_display_wnd_messages("Please choose a stack", true);
ds->stack_index = ui_choose_stack(&ds->table_stacks);
net_send(sock, msg_type_selected_stack_c, NULL);
}
@@ -120,6 +121,8 @@ game_state_t state_client_play_cards(const int sock)
ui_display_wnd_stack_points(&ds->table_stacks, false, 0);
}
+ ui_update();
+
// Wait between player turns, but not after the last one
if (i != ds->player_list.count - 1)
sleep(2);
diff --git a/src/ui.c b/src/ui.c
index b878f61..990e235 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -173,7 +173,7 @@ void ui_display_wnd_table_cards(const table_stacks_t *ts, const bool highlight,
draw_card_stack(w_table_cards, 1 + i*5, 0, false, &ts->stacks[i]);
}
- wrefresh(w_table_cards);
+ wnoutrefresh(w_table_cards);
}
/**
@@ -203,7 +203,7 @@ void ui_display_wnd_stack_points(const table_stacks_t *ts, const bool highlight,
mvwprintw(w_stack_points, 3 + i*5, 1, "%2d", card_stack_get_points(&ts->stacks[i]));
}
- wrefresh(w_stack_points);
+ wnoutrefresh(w_stack_points);
}
/**
@@ -259,7 +259,7 @@ void ui_display_wnd_current_state(const player_list_t *pl, const uint8_t num_pla
pos++;
}
- wrefresh(w_current_state);
+ wnoutrefresh(w_current_state);
}
/**
@@ -279,7 +279,7 @@ void ui_display_wnd_messages(const char *message, const bool highlight)
if (highlight)
wattroff(w_messages, COLOR_PAIR(CP_YELLOW_ON_BLACK));
- wrefresh(w_messages);
+ wnoutrefresh(w_messages);
}
/**
@@ -331,7 +331,7 @@ void ui_display_wnd_hand_cards(const hand_t *h, const bool highlight, const uint
draw_card(w_hand_cards, 6, (i - num_zero_cards - 5) * 8, false, h->cards[i]);
}
- wrefresh(w_hand_cards);
+ wnoutrefresh(w_hand_cards);
}
uint8_t ui_choose_card(hand_t *h)
@@ -353,7 +353,9 @@ uint8_t ui_choose_card(hand_t *h)
chosen_card_idx = i;
}
+ ui_display_wnd_messages("Please choose the card you want to play", true);
ui_display_wnd_hand_cards(h, true, chosen_card_idx);
+ ui_update();
while (KEY_RETURN != (key = wgetch(w_hand_cards)))
{
@@ -384,6 +386,7 @@ uint8_t ui_choose_card(hand_t *h)
}
ui_display_wnd_hand_cards(h, true, chosen_card_idx);
+ ui_update();
}
return chosen_card_idx;
@@ -396,8 +399,10 @@ uint8_t ui_choose_stack(const table_stacks_t *ts)
int key;
uint8_t chosen_stack_idx = 0;
+ ui_display_wnd_messages("Please choose a stack", true);
ui_display_wnd_table_cards(ts, true, chosen_stack_idx);
ui_display_wnd_stack_points(ts, true, chosen_stack_idx);
+ ui_update();
while (KEY_RETURN != (key = wgetch(w_table_cards)))
{
@@ -432,11 +437,17 @@ uint8_t ui_choose_stack(const table_stacks_t *ts)
ui_display_wnd_table_cards(ts, true, chosen_stack_idx);
ui_display_wnd_stack_points(ts, true, chosen_stack_idx);
+ ui_update();
}
return chosen_stack_idx;
}
+void ui_update(void)
+{
+ doupdate();
+}
+
/**
* Initializes ncurses.
*/
diff --git a/src/ui.h b/src/ui.h
index cfe88d1..189b818 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -14,6 +14,7 @@ void ui_display_wnd_messages(const char *message, const bool highlight);
void ui_display_wnd_hand_cards(const hand_t *h, const bool highlight, const uint8_t highlighted_card);
uint8_t ui_choose_card(hand_t *h);
uint8_t ui_choose_stack(const table_stacks_t *ts);
+void ui_update(void);
void ui_init(void);
void ui_fini(void);