diff options
Diffstat (limited to 'src/client_game_states.c')
| -rw-r--r-- | src/client_game_states.c | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/src/client_game_states.c b/src/client_game_states.c index 2659673..a913863 100644 --- a/src/client_game_states.c +++ b/src/client_game_states.c @@ -62,38 +62,49 @@ game_state_t state_client_wait_for_open_cards(const int sock) game_state_t state_client_play_cards(const int sock, const uint8_t round) { -#if 0 - data_store_t *d = data_store(); - uint8_t stack_idx; + data_store_t *ds = data_store(); - foreach(open_card) + for(int i=0; i<ds->player_list.count; i++) { - play_lowest_open_card + card c = ds->player_list.players[i].open_card; + uint8_t stack_idx = get_stack_idx_for_card(&ds->table_stacks, c); + + if(stack_idx >= NUM_TABLE_STACKS) // card does not fit on any stack { - determine_stack_for_open_card + uint32_t stack_points; + + if(ds->player_list.players[i].player_id == ds->own_player_id) // our turn to select stack { - if (stack_has_to_be_picked) - { - if (we_have_to_pick) - { - pick_stack(); - send_stack_to_server(); - } - else // another client has to pick - { - receive_stack(); - } - - clear_stack(stack_id); - } + ds->stack_index = ui_choose_stack(&ds->table_stacks); + net_send(sock, msg_type_selected_stack_c, NULL); } - place_card() + + net_recv(sock, msg_type_selected_stack_s); + stack_points = card_stack_get_points(&ds->table_stacks.stacks[ds->stack_index]); + card_stack_clear(&ds->table_stacks.stacks[ds->stack_index], c); + } + else // card fits on a stack -> place it + { + card_stack_t* cs = &ds->table_stacks.stacks[stack_idx]; + if(cs->cards[MAX_CARD_STACK_SIZE-1] != 0) // stack is full { - if(count_stack_cards == 6) - clear_stack(stack_id); + uint32_t stack_points = card_stack_get_points(cs); + card_stack_clear(cs, c); + } + else + { + // put open card on top of stack + for(int j=0; j<MAX_CARD_STACK_SIZE; j++) + { + if(cs->cards[j] != 0) + continue; + cs->cards[j] = c; + break; + } } } } +#if 0 if (we_have_hand_cards) { return STATE_CLIENT_SELECT_OPEN_CARD; @@ -110,5 +121,6 @@ game_state_t state_client_play_cards(const int sock, const uint8_t round) return STATE_CLIENT_GAME_FINISHED; } #endif + return 1337; } |
