bool victory_condition_resolve(void) { int nbr; bool is_play; t_node *team; t_team *team_info; t_node *team_player; is_play = false; for (team = g_server.team_list->nodes; team; team = team->next) { team_info = ((t_team *)team->data); team_player = team_info->members->nodes; if (team_info->members->size > 0 || team_info->free_slots > 0) is_play = true; nbr = cnt_player_lvl_max(team_player); if (nbr >= 6) return (write_winner(team_info)); } if (!is_play) { print_log("Everyone is dead, Game Over !"); return (true); } return (false); }
int main() { int pile, /* This is how many coins we have */ player, /* Who is playing? */ n_coins; /* Number of coins taken */ srand(time(0)); /* Setup random */ printf("Welcome to NIM ...\n"); pile = MAX_COINS; /* Set start values (= init) */ player = HUMAN; while(play == 1) { printf("Det ligger %d mynt i boeghoegen\n", pile); if (player == HUMAN) { n_coins = human_choice(pile); } else { n_coins = computer_choice(pile); printf("- Jag tog %d\n", n_coins); } pile -= n_coins; player = toggle(player); if(pile<=1){ write_winner(player); play_again(); } } return 0; }