home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Inne / Gry / Atomic_Tanks / Atomic-Tanks-5.1.exe / src / team.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2010-06-07  |  910 b   |  36 lines

  1. #include "tank.h"
  2. #include "team.h"
  3. #include "player.h"
  4.  
  5. // check to see if a team has won.
  6. int Team_Won(GLOBALDATA *global)
  7. {
  8.   bool all_jedi = true;
  9.   bool all_sith = true;
  10.   int current_player = 0;
  11.   int my_team = 1;
  12.   int player_count = 0;
  13.  
  14.   while ((all_jedi || all_sith) && ( current_player < global->numPlayers) )
  15.     {
  16.       if ( (global->players[current_player]->tank) &&
  17.            (global->players[current_player]->tank->l) )
  18.         {
  19.           my_team = (int)global->players[current_player]->team;
  20.           if ( (my_team == TEAM_JEDI) || (my_team == TEAM_NEUTRAL) )
  21.             all_sith = false;
  22.  
  23.           if ( (my_team == TEAM_SITH) || (my_team == TEAM_NEUTRAL) )
  24.             all_jedi = false;
  25.           player_count++;
  26.         }
  27.       current_player++;
  28.     }
  29.  
  30.   if (! player_count) return NO_WIN;
  31.   if (all_jedi) return JEDI_WIN;
  32.   else if (all_sith) return SITH_WIN;
  33.   else return NO_WIN;
  34. }
  35.  
  36.