#include #include #include "ui.h" #include "game.h" #include "net.h" #include "player.h" #include "hand.h" int main(int argc, char **argv) { char* port = 0; char *addr; bool servermode = false; if (argc < 2) { printf("usage: '%s address port' for client mode, or '%s port' for server mode\n", argv[0], argv[0]); return EXIT_SUCCESS; } else if (argc == 2) // Server mode { int ssock; int* csocks; struct player_list players; int opponents = 3; const char* nickname = "deki"; const hand testhand = { 12, 23, 35, 42, 55, 57, 70, 81, 103, 0 }; servermode = true; port = argv[1]; // start listening ssock = server_start(port); // accept client connections csocks = server_get_players(ssock, opponents); players.count = opponents + 1; players.names[0] = malloc(strlen(nickname)); strcpy(players.names[0], nickname); for(int i=0; icount; i++) printf("Player %d: %s\n", i, players->names[i]); // receive test hand testhand = client_recv(sock, msg_type_deal_cards); printf("received cards: "); for(int i=0; icount; i++) free(players->names[i]); free(players); free(testhand); close(sock); } //ui_init(); //start_game(servermode, addr, port); //ui_fini(); return EXIT_SUCCESS; }