Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implementation of CKamikazeAward
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //------------------------------------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "KamikazeAward.h"
  14. //------------------------------------------------------------------------------------------------------
  15. // Function: CKamikazeAward::getWinner
  16. // Purpose: determines the winner of the award
  17. //------------------------------------------------------------------------------------------------------
  18. void CKamikazeAward::getWinner()
  19. {
  20. CEventListIterator it;
  21. for (it=g_pMatchInfo->eventList()->begin(); it != g_pMatchInfo->eventList()->end(); ++it)
  22. {
  23. if ((*it)->getType()==CLogEvent::SUICIDE || (*it)->getType()==CLogEvent::KILLED_BY_WORLD)
  24. {
  25. PID kami=(*it)->getArgument(0)->asPlayerGetPID();
  26. numdeaths[kami]++;
  27. winnerID=kami;
  28. fNoWinner=false;
  29. }
  30. }
  31. map<PID,int>::iterator kamiter;
  32. for (kamiter=numdeaths.begin();kamiter!=numdeaths.end();++kamiter)
  33. {
  34. int currID=(*kamiter).first;
  35. if (numdeaths[currID]>numdeaths[winnerID])
  36. winnerID=currID;
  37. }
  38. }
  39. //------------------------------------------------------------------------------------------------------
  40. // Function: CKamikazeAward::noWinner
  41. // Purpose: writes html indicating that no one won this award
  42. // Input: html - the html file to write to
  43. //------------------------------------------------------------------------------------------------------
  44. void CKamikazeAward::noWinner(CHTMLFile& html)
  45. {
  46. html.write("No one killed themselves during this match! Good work!");
  47. }
  48. //------------------------------------------------------------------------------------------------------
  49. // Function: CKamikazeAward::extendedinfo
  50. // Purpose: reports how many times the winner killed him/herself
  51. // Input: html - the html file to write to
  52. //------------------------------------------------------------------------------------------------------
  53. void CKamikazeAward::extendedinfo(CHTMLFile& html)
  54. {
  55. if (numdeaths[winnerID]==1)
  56. html.write("%s suicided once.",winnerName.c_str());
  57. else
  58. html.write("%s was self-victimized %li times.",winnerName.c_str(),numdeaths[winnerID]);
  59. }