00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <sstream>
00023 #include "../include/app.h"
00024 #include "../include/constant.h"
00025 #include "results.h"
00026 #include "../character/character.h"
00027 #include "team.h"
00028 #include "macro.h"
00029 #include "../tool/i18n.h"
00030
00031 TeamResults::TeamResults(const std::string& name,
00032 const Surface* logo,
00033 const Character* MV,
00034 const Character* MUl,
00035 const Character* MUs,
00036 const Character* BT)
00037 : teamName(name),
00038 team_logo(logo),
00039 mostViolent(MV),
00040 mostUsefull(MUl),
00041 mostUseless(MUs),
00042 biggestTraitor(BT)
00043 {
00044 }
00045
00046 TeamResults* TeamResults::createTeamResults(Team* team)
00047 {
00048 int most_violent = 0;
00049 int most_useless = 0x0FFFFFFF;
00050 int most_usefull = 0;
00051 int most_traitor = 0;
00052 const Character* MostViolent = NULL;
00053 const Character* MostUsefull = NULL;
00054 const Character* MostUseless = NULL;
00055 const Character* BiggestTraitor = NULL;
00056
00057
00058 for (Team::const_iterator player = team->begin(),
00059 last_player = team->end();
00060 player != last_player;
00061 ++player)
00062
00063 {
00064
00065 if (player->GetMostDamage() > most_violent)
00066 {
00067 most_violent = player->GetMostDamage();
00068 MostViolent = &(*(player));
00069 }
00070
00071 if (player->GetOtherDamage() > most_usefull)
00072 {
00073 most_usefull = player->GetOtherDamage();
00074 MostUsefull = &(*(player));
00075 }
00076
00077 if (player->GetOtherDamage() < most_useless)
00078 {
00079 most_useless = player->GetOtherDamage();
00080 MostUseless = &(*(player));
00081 }
00082
00083 if (player->GetOwnDamage() > most_traitor)
00084 {
00085 most_traitor = player->GetOwnDamage();
00086 BiggestTraitor = &(*(player));
00087 }
00088 }
00089
00090 return new TeamResults(team->GetName()+" - "+team->GetPlayerName(),
00091 &team->flag,
00092 MostViolent,
00093 MostUsefull,
00094 MostUseless,
00095 BiggestTraitor);
00096 }
00097
00098 TeamResults* TeamResults::createGlobalResults(std::vector<TeamResults*>* list)
00099 {
00100 int most_violent = 0;
00101 int most_useless = 0x0FFFFFFF;
00102 int most_usefull = 0;
00103 int most_traitor = 0;
00104 const Character* MostViolent = NULL;
00105 const Character* MostUsefull = NULL;
00106 const Character* MostUseless = NULL;
00107 const Character* BiggestTraitor = NULL;
00108
00109 for (res_iterator result=list->begin(), last_result=list->end();
00110 result != last_result;
00111 ++result)
00112 {
00113 const Character* player;
00114
00115 player = (*(result))->getMostViolent();
00116 if(player == NULL) continue;
00117 if (player->GetMostDamage() > most_violent)
00118 {
00119 most_violent = player->GetMostDamage();
00120 MostViolent = player;
00121 }
00122
00123 if (player->GetOtherDamage() > most_usefull)
00124 {
00125 most_usefull = player->GetOtherDamage();
00126 MostUsefull = player;
00127 }
00128
00129 if (player->GetOtherDamage() < most_useless)
00130 {
00131 most_useless = player->GetOtherDamage();
00132 MostUseless = player;
00133 }
00134
00135 if (player->GetOwnDamage() > most_traitor)
00136 {
00137 most_traitor = player->GetOwnDamage();
00138 BiggestTraitor = player;
00139 }
00140 }
00141
00142
00143 return new TeamResults(_("All teams"),
00144 NULL,
00145 MostViolent,
00146 MostUsefull,
00147 MostUseless,
00148 BiggestTraitor);
00149 }
00150
00151 std::vector<TeamResults*>* TeamResults::createAllResults(void)
00152 {
00153 TeamResults* results;
00154 std::vector<TeamResults*>* results_list = new std::vector<TeamResults*>;
00155
00156
00157 FOR_EACH_TEAM(team)
00158 {
00159 results = TeamResults::createTeamResults(*team);
00160
00161 results_list->push_back(results);
00162 }
00163
00164
00165 results = TeamResults::createGlobalResults(results_list);
00166 results_list->push_back(results);
00167
00168 return results_list;
00169 }
00170
00171 void TeamResults::deleteAllResults(std::vector<TeamResults*>* results_list)
00172 {
00173
00174 for (int i=results_list->size()-1; i==0; i--)
00175 delete ((*results_list)[i]);
00176
00177
00178 delete results_list;
00179 }