#include "game.h" #include "card.h" #include "hand.h" #include #include #include #include #include #include #include #include #include "ui.h" #include "global.h" #include "net/comm.h" #include "net/client.h" #include "net/server.h" static void init_mainstack(card *stack, const uint32_t size) { assert(stack != NULL); // assign card values to main stack for(uint32_t i=0, val=MIN_CARD; itable_stacks = { { _cs1, _cs2, _cs3, _cs4 } }; data->table_stacks.stacks[0] = _cs1; data->table_stacks.stacks[1] = _cs2; data->table_stacks.stacks[2] = _cs3; data->table_stacks.stacks[3] = _cs4; //const table_stacks_t ts = { { _cs1, _cs2, _cs3, _cs4 } }; // The stack points window uses ts, too, so there is no separate data set // Example data set for current state window pnoc_t pnoc[10] = { {0, "$you", 10}, {1, "1234567890", 23}, {2, "baz", 38}, {3, "foo_bar", 14}, {4, "lolcat", 60}, {5, "blablub123", 15}, {6, "abcdefg", 103}, {7, "hello", 98}, {8, "hornoxe", 33}, {9, "1337nick", 74} }; pnoc_sort(pnoc, 10); const uint8_t num_players = 10; const uint32_t score = 10; // Example data set for hand cards window const hand_t h = { {22, 0, 12, 85, 27, 69, 78, 0, 77, 0} }; data->hand = h; hand_sort(&data->hand); if(servermode) { pid_t child = fork(); server_process = (child > 0); } if(server_process) // Start server and connect to localhost { int server_sock; socket_list_t client_socks; uint8_t num_players = 1; server_sock = server_start(port); server_get_players(server_sock, &client_socks, num_players); data->players.count = num_players; for(int i=0; iplayers.players[i].player_name); } for(int i=0; inickname, "nickname", 10); net_send(sock, msg_type_hello, NULL); net_recv(sock, msg_type_start_game); net_recv(sock, msg_type_deal_hand); net_recv(sock, msg_type_initial_stacks); ui_init(); // Display all windows ui_display_wnd_table_cards(&data->table_stacks, false, 0); ui_display_wnd_stack_points(&data->table_stacks, false, 0); ui_display_wnd_current_state(pnoc, num_players, 2, score); ui_display_wnd_hand_cards(&data->hand, false, 0); main_loop_client(sock); ui_fini(); } }