void god_turn(Labyrinth &map) { if (map.bombs_in_game == 0) { global_message("Everybody gets one more bomb!"); for (int i = 0; i < (int) map.player.size(); ++i) { if (!map.player[i].in_game) continue; map.player[i].bombs++; } map.bombs_in_game = map.players_in_game; } if (map.bullets_in_game == 0) { global_message("Everybody gets one more bullet!"); for (int i = 0; i < (int) map.player.size(); ++i) { if (!map.player[i].in_game) continue; map.player[i].bullets++; } map.bullets_in_game = map.players_in_game; } }
void finish_game(Labyrinth &map) { int winner = map.current_player; global_message("Player " + map.player[winner].name + " has won the game!"); for (int i = 0; i < (int) map.player.size(); ++i) { global_message(map.player[i].name + " has been killed " + to_string(map.player[i].deaths) + " times"); global_message(map.player[i].name + " has failed " + to_string(map.player[i].fails) + " times"); global_message(map.player[i].name + " has made " + to_string(map.player[i].good_turns) + " good turns"); } int worst = __INT_MAX__; for (int i = 0; i < (int) map.player.size(); ++i) { if (i == winner || is_developer(map.player[i])) continue; worst = min(worst, 5 * map.player[i].good_turns - map.player[i].fails); } vector <int> losers(0); for (int i = 0; i < (int) map.player.size(); ++i) { if (i == winner || is_developer(map.player[i])) continue; if (5 * map.player[i].good_turns - map.player[i].fails > worst) continue; losers.push_back(i); } if (!SERVER) { global_message("The current labyrinth state is:"); print_labyrinth(map); } if (!losers.empty()) { int loser = losers[rand() % int(losers.size())]; global_message(map.player[loser].name + " must give a big chocolate to " + map.player[winner].name); } this_thread::sleep_for(chrono::seconds(60)); exit(0); }
static int global_process_user(struct userNode *user, UNUSED_ARG(void *extra)) { if(IsLocal(user) || self->uplink->burst || user->uplink->burst) return 0; send_messages(user, MESSAGE_RECIPIENT_LUSERS, 1); /* only alert on new usercount if the record was broken in the last * 30 seconds, and no alert had been sent in that time. */ if((now - max_clients_time) <= 30 && (now - last_max_alert) > 30) { char *message; message = alloca(36); sprintf(message, "New user count record: %d", max_clients); global_message(MESSAGE_RECIPIENT_OPERS, message); last_max_alert = now; } return 0; }