#include <game/server/gamecontext.hpp>

extern "C" {

void start_vote(
  int cid, const char* chatmsg, const char* desc, void* command
) {
 game.start_vote(cid, chatmsg, desc, command);
}
int vote_active() {

 return game.vote_closetime;
}

void vote_enforce(int result) {
 game.vote_enforce 
  = result ? GAMECONTEXT::VOTE_ENFORCE_YES : GAMECONTEXT::VOTE_ENFORCE_NO;
}

void do_send_chat(int chatter_cid, int target, const char* text) {
 if (target < 0) 
  game.do_send_chat(chatter_cid, target+2, text);
 else
  game.do_send_chat_target(target, text, chatter_cid);
}

void send_broadcast(const char* text, int cid) {
 game.send_broadcast(text, cid);
}

void restart(int warmup) {
 if (warmup) game.controller->do_warmup(warmup);
 else game.controller->startround();
};

void game_pause(int state) {
 game.controller->pause(state);
};

void endround() {
 game.controller->endround();
};

void set_team(int cid, int team) {
 game.players[cid]->last_setteam = time_get();
 game.players[cid]->set_team(team);
 game.controller->check_team_balance();
};

void client_statistics(
  int cid, int* shots, int* hits, int* kills, int* deaths
) {
 PLAYER* p = game.players[cid];
 *shots  = p->s_shots;
 *hits   = p->s_hits;
 *kills  = p->s_kills;
 *deaths = p->s_deaths;
};

int client_team(int cid) {
 return game.players[cid]->team;
};

}
