//------------------------------------------------------------------------------------------------------
// Function:	CPlayerSpecifics::writeHTML
// Purpose:	writes out html based on the intermediate data generated by generate()
// Input:	html - the html file to output to
//------------------------------------------------------------------------------------------------------
void CPlayerSpecifics::writeHTML(CHTMLFile& html)
{
	int numteams=0;
	for (int t=0;t<MAX_TEAMS;t++)
		if (g_pMatchInfo->teamExists(t)) numteams++;

	html.write("<table cols=%li cellspacing=0 border=0 cellpadding=10 bordercolor=black>\n",numteams);
	
	CPlayerListIterator i;
	//multimap<double,CPlayer,greater<double> > ranksort;
	
	//split playerlist into teams;
	multimap<double,CPlayer,greater<double> > rankedteams[MAX_TEAMS];

	for (i=g_pMatchInfo->playerBegin();i!=g_pMatchInfo->playerEnd();++i)
	{
		PID pid=(*i).first;
		CPlayer p=(*i).second;
		for (int t=0;t<MAX_TEAMS;t++)
		{
			if (p.teams.contains(t))
			{
				double rank=p.perteam[t].rank();
				pair<double,CPlayer> insertme(rank,p);
				rankedteams[t].insert(insertme);
			}
		}
	}

	while(!rankedteams[0].empty() || !rankedteams[1].empty() || !rankedteams[2].empty() || !rankedteams[3].empty())
	{
		html.write("<tr>\n");
		int t;
		
		for (t=0;t<MAX_TEAMS;t++)
		{
			if (!g_pMatchInfo->teamExists(t))
				continue;
			
			html.write("<td width=250 valign=top>");	
			
			
			if (rankedteams[t].begin()==rankedteams[t].end())
				continue;
			else
			{
				CPlayer& plr=(*(rankedteams[t].begin())).second;
				CPlayerReport cpr(&plr,t);
				cpr.writeHTML(html);
				rankedteams[t].erase(rankedteams[t].begin());
				//break;
			}
			html.write("</td>\n");
		}
		html.write("</tr>\n");
	}
	html.write("</table>");
	
}
Example #2
0
//------------------------------------------------------------------------------------------------------
// Function:	CScoreboard::writeHTML
// Purpose:	generates html from the intermediate data generated by generate()
// Input:	html - the html file to write the html code into
//------------------------------------------------------------------------------------------------------
void CScoreboard::writeHTML(CHTMLFile& html)
{
    CPlayerListIterator i;
    int t;

    bool teamFound=false;

    for (t=0; t<MAX_TEAMS; t++)
    {
        if (!g_pMatchInfo->teamExists(t))
            continue;

        if (!teamFound)
        {
            html.write("<p>");
            html.write("<img src=\"%s/scores.gif\">",g_pApp->supportHTTPPath.c_str());
            teamFound=true;
        }

        int totalkills=0;
        int totaldeaths=0;
        double teamrank=0;
        int numplrs=0;

        html.write("<table cellpadding=3 cellspacing=0 border=0 class=scores>");
        html.write("<tr class=header>");
        html.write("<td ><font class=boardtext>%s</font></td>",g_pMatchInfo->teamName(t).c_str());
        html.write("<td><font class=boardtext>Kills</font></td>");
        html.write("<td><font class=boardtext>Deaths</font></td>");
        html.write("<td><font class=boardtext>Rank</font></td>");
        html.write("</tr>");

        multimap<double,CPlayer> ranksort;
        for (i=g_pMatchInfo->playerBegin(); i!=g_pMatchInfo->playerEnd(); ++i)
        {
            pair<PID,CPlayer> plr=(*i);
            PID pid=plr.first;
            CPlayer& p=plr.second;

            if (p.teams.contains(t))
            {
                double rank=p.perteam[t].rank();
                pair<double,CPlayer> insertme(rank,p);
                ranksort.insert(insertme);
                //ranksort[rank]=p;
            }
        }

        multimap<double,CPlayer>::reverse_iterator i2;
        for (i2=ranksort.rbegin(); i2!=ranksort.rend(); ++i2)
        {
            double rank=(*i2).first;
            CPlayer p=(*i2).second;

            if (!p.teams.contains(t))
            {
                continue;
            }

            html.write("<tr>\n");
            html.write("\n");
            html.write("<td width=140><font class=player%s>%s</font></td>\n",Util::teamcolormap[t],p.name.c_str());
            html.write("<td width=100><font class=boardtext>%li</font></td>\n",p.perteam[t].kills);
            html.write("<td width=100><font class=boardtext>%li</font></td>\n",p.perteam[t].deaths);
            html.write("<td width=100><font class=boardtext>%.2lf</font></td>\n",rank);

            html.write("</tr>\n");
            totalkills+=p.perteam[t].kills;
            totaldeaths+=p.perteam[t].deaths;
            teamrank+=rank;
            numplrs++;
        }

        html.write("<tr>");
        html.write("<td colspan=4><hr></td>");
        html.write("</tr>");
        html.write("<tr>");
        html.write("<td><font class=boardtext>totals</font></td>");
        html.write("<td><font class=boardtext>%li</font></td>",totalkills);
        html.write("<td><font class=boardtext>%li</font></td>",totaldeaths);
        html.write("<td><font class=boardtext>%.2lf (avg)</font></td>",teamrank/numplrs);
        html.write("</tr>");
        html.write("</table>\n<p>\n");


    }

}