OpenClonk
C4RoundResultsPlayer Class Reference

#include <C4RoundResults.h>

Public Member Functions

 C4RoundResultsPlayer ()
 
 C4RoundResultsPlayer (const C4RoundResultsPlayer &cpy)
 
void CompileFunc (StdCompiler *pComp)
 
int32_t GetID () const
 
C4FacetGetBigIcon ()
 
uint32_t GetTotalPlayingTime () const
 
bool IsScoreOldValid () const
 
int32_t GetScoreOld () const
 
bool IsScoreNewValid () const
 
int32_t GetScoreNew () const
 
const char * GetCustomEvaluationStrings ()
 
int32_t GetLeagueScoreNew () const
 
bool IsLeagueScoreNewValid () const
 
int32_t GetLeagueScoreGain () const
 
int32_t GetLeagueRankNew () const
 
int32_t GetLeagueRankSymbolNew () const
 
int32_t GetLeaguePerformance () const
 
void EvaluateLeague (C4RoundResultsPlayer *pLeaguePlayer)
 
void EvaluatePlayer (C4Player *pPlr)
 
void SetID (int32_t idNew)
 
void AddCustomEvaluationString (const char *szCustomString)
 
void SetLeaguePerformance (int32_t iNewPerf)
 
bool operator== (const C4RoundResultsPlayer &cmp)
 
C4RoundResultsPlayeroperator= (const C4RoundResultsPlayer &cpy)
 

Detailed Description

Definition at line 32 of file C4RoundResults.h.

Constructor & Destructor Documentation

◆ C4RoundResultsPlayer() [1/2]

C4RoundResultsPlayer::C4RoundResultsPlayer ( )
inline

Definition at line 61 of file C4RoundResults.h.

61 : sLeagueProgressData() {}

◆ C4RoundResultsPlayer() [2/2]

C4RoundResultsPlayer::C4RoundResultsPlayer ( const C4RoundResultsPlayer cpy)
inline

Definition at line 62 of file C4RoundResults.h.

62 { *this=cpy; }

Member Function Documentation

◆ AddCustomEvaluationString()

void C4RoundResultsPlayer::AddCustomEvaluationString ( const char *  szCustomString)

Definition at line 94 of file C4RoundResults.cpp.

95 {
96  if (sCustomEvaluationStrings.getLength()) sCustomEvaluationStrings.Append(" ");
97  sCustomEvaluationStrings.Append(szCustomString);
98 }
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
size_t getLength() const
Definition: StdBuf.h:445

References StdStrBuf::Append(), and StdStrBuf::getLength().

Referenced by C4RoundResults::AddCustomEvaluationString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompileFunc()

void C4RoundResultsPlayer::CompileFunc ( StdCompiler pComp)

Definition at line 30 of file C4RoundResults.cpp.

31 {
32  // remember to adjust operator = and == when adding values here!
33  pComp->Value(mkNamingAdapt(id, "ID", 0));
34  // pComp->Value(mkNamingAdapt(fctBigIcon, "Icon", C4TargetFacet())); - not possible
35  pComp->Value(mkNamingAdapt(iTotalPlayingTime, "TotalPlayingTime", 0u));
36  pComp->Value(mkNamingAdapt(iScoreOld, "SettlementScoreOld", -1));
37  pComp->Value(mkNamingAdapt(iScoreNew, "SettlementScoreNew", -1));
38  pComp->Value(mkNamingAdapt(iLeagueScoreNew, "Score", -1)); // name used in league reply!
39  pComp->Value(mkNamingAdapt(iLeagueScoreGain, "GameScore", -1)); // name used in league reply!
40  pComp->Value(mkNamingAdapt(iLeagueRankNew, "Rank", 0)); // name used in league reply!
41  pComp->Value(mkNamingAdapt(iLeagueRankSymbolNew, "RankSymbol", 0)); // name used in league reply!
42  pComp->Value(mkNamingAdapt(sLeagueProgressData, "LeagueProgressData", StdCopyStrBuf()));
43  StdEnumEntry<LeagueStatus> LeagueStatusEntries[] =
44  {
45  { "", RRPLS_Unknown },
46  { "Lost", RRPLS_Lost },
47  { "Won", RRPLS_Won },
48  };
49  pComp->Value(mkNamingAdapt(mkEnumAdaptT<uint8_t>(eLeagueStatus, LeagueStatusEntries), "Status", RRPLS_Unknown)); // name used in league reply!
50 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
Definition: StdAdaptors.h:795
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References mkNamingAdapt(), and StdCompiler::Value().

Here is the call graph for this function:

◆ EvaluateLeague()

void C4RoundResultsPlayer::EvaluateLeague ( C4RoundResultsPlayer pLeaguePlayer)

Definition at line 82 of file C4RoundResults.cpp.

83 {
84  assert(pLeaguePlayerInfo);
85  //
86  // copy league info
87  iLeagueScoreNew = pLeaguePlayerInfo->iLeagueScoreNew;
88  iLeagueScoreGain = pLeaguePlayerInfo->iLeagueScoreGain;
89  iLeagueRankNew = pLeaguePlayerInfo->iLeagueRankNew;
90  iLeagueRankSymbolNew = pLeaguePlayerInfo->iLeagueRankSymbolNew;
91  sLeagueProgressData =pLeaguePlayerInfo->sLeagueProgressData;
92 }

Referenced by C4RoundResults::EvaluateLeague().

Here is the caller graph for this function:

◆ EvaluatePlayer()

void C4RoundResultsPlayer::EvaluatePlayer ( C4Player pPlr)

Definition at line 52 of file C4RoundResults.cpp.

53 {
54  assert(pPlr);
55  // set fields by player
56  iTotalPlayingTime = pPlr->TotalPlayingTime;
57  if (pPlr->Evaluated)
58  {
59  iScoreNew = pPlr->TotalScore;
60  iScoreOld = iScoreNew - pPlr->LastRound.FinalScore;
61  }
62  else
63  {
64  // player not evaluated (e.g., removed by disconnect): Old score known only
65  iScoreOld = pPlr->TotalScore;
66  }
67  // load icon from player
68  fctBigIcon.Clear();
69  if (pPlr->BigIcon.Surface)
70  {
71  fctBigIcon.Create(pPlr->BigIcon.Wdt, pPlr->BigIcon.Hgt);
72  pPlr->BigIcon.Draw(fctBigIcon);
73  }
74  // progress data by player
75  C4PlayerInfo *pInfo = pPlr->GetInfo();
76  if (pInfo)
77  {
78  sLeagueProgressData.Copy(pInfo->GetLeagueProgressData());
79  }
80 }
C4Surface * Surface
Definition: C4Facet.h:117
float Hgt
Definition: C4Facet.h:118
float Wdt
Definition: C4Facet.h:118
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void Clear()
Definition: C4FacetEx.h:44
C4FacetSurface BigIcon
Definition: C4Player.h:138
bool Evaluated
Definition: C4Player.h:85
class C4PlayerInfo * GetInfo()
Definition: C4Player.cpp:1552
int32_t TotalPlayingTime
Definition: C4InfoCore.h:91
C4RoundResult LastRound
Definition: C4InfoCore.h:92
int32_t TotalScore
Definition: C4InfoCore.h:89
const char * GetLeagueProgressData() const
Definition: C4PlayerInfo.h:192
int32_t FinalScore
Definition: C4InfoCore.h:71
void Copy()
Definition: StdBuf.h:467

References C4Player::BigIcon, C4FacetSurface::Clear(), StdStrBuf::Copy(), C4FacetSurface::Create(), C4Facet::Draw(), C4Player::Evaluated, C4RoundResult::FinalScore, C4Player::GetInfo(), C4PlayerInfo::GetLeagueProgressData(), C4Facet::Hgt, C4PlayerInfoCore::LastRound, C4Facet::Surface, C4PlayerInfoCore::TotalPlayingTime, C4PlayerInfoCore::TotalScore, and C4Facet::Wdt.

Referenced by C4RoundResults::EvaluatePlayer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBigIcon()

C4Facet& C4RoundResultsPlayer::GetBigIcon ( )
inline

Definition at line 67 of file C4RoundResults.h.

67 { return fctBigIcon; }

◆ GetCustomEvaluationStrings()

const char* C4RoundResultsPlayer::GetCustomEvaluationStrings ( )
inline

Definition at line 73 of file C4RoundResults.h.

73 { return sCustomEvaluationStrings.getData(); }
const char * getData() const
Definition: StdBuf.h:442

References StdStrBuf::getData().

Here is the call graph for this function:

◆ GetID()

int32_t C4RoundResultsPlayer::GetID ( ) const
inline

Definition at line 66 of file C4RoundResults.h.

66 { return id; }

Referenced by C4RoundResults::EvaluateLeague().

Here is the caller graph for this function:

◆ GetLeaguePerformance()

int32_t C4RoundResultsPlayer::GetLeaguePerformance ( ) const
inline

Definition at line 79 of file C4RoundResults.h.

79 { return iLeaguePerformance; }

◆ GetLeagueRankNew()

int32_t C4RoundResultsPlayer::GetLeagueRankNew ( ) const
inline

Definition at line 77 of file C4RoundResults.h.

77 { return iLeagueRankNew; } // returns rank on league server after round evaluation (0 for not assigned)

◆ GetLeagueRankSymbolNew()

int32_t C4RoundResultsPlayer::GetLeagueRankSymbolNew ( ) const
inline

Definition at line 78 of file C4RoundResults.h.

78 { return iLeagueRankSymbolNew; }

◆ GetLeagueScoreGain()

int32_t C4RoundResultsPlayer::GetLeagueScoreGain ( ) const
inline

Definition at line 76 of file C4RoundResults.h.

76 { return iLeagueScoreGain; }

◆ GetLeagueScoreNew()

int32_t C4RoundResultsPlayer::GetLeagueScoreNew ( ) const
inline

Definition at line 74 of file C4RoundResults.h.

74 { return iLeagueScoreNew; } // returns score number on league server after round evaluation (0 for not assigned)

◆ GetScoreNew()

int32_t C4RoundResultsPlayer::GetScoreNew ( ) const
inline

Definition at line 72 of file C4RoundResults.h.

72 { return iScoreNew; }

◆ GetScoreOld()

int32_t C4RoundResultsPlayer::GetScoreOld ( ) const
inline

Definition at line 70 of file C4RoundResults.h.

70 { return iScoreOld; }

◆ GetTotalPlayingTime()

uint32_t C4RoundResultsPlayer::GetTotalPlayingTime ( ) const
inline

Definition at line 68 of file C4RoundResults.h.

68 { return iTotalPlayingTime; }

◆ IsLeagueScoreNewValid()

bool C4RoundResultsPlayer::IsLeagueScoreNewValid ( ) const
inline

Definition at line 75 of file C4RoundResults.h.

75 { return iLeagueScoreNew>=0; }

◆ IsScoreNewValid()

bool C4RoundResultsPlayer::IsScoreNewValid ( ) const
inline

Definition at line 71 of file C4RoundResults.h.

71 { return iScoreNew>=0; }

◆ IsScoreOldValid()

bool C4RoundResultsPlayer::IsScoreOldValid ( ) const
inline

Definition at line 69 of file C4RoundResults.h.

69 { return iScoreOld>=0; }

◆ operator=()

C4RoundResultsPlayer & C4RoundResultsPlayer::operator= ( const C4RoundResultsPlayer cpy)

Definition at line 117 of file C4RoundResults.cpp.

118 {
119  if (this == &cpy) return *this;
120  // assign all xcept icon
121  id = cpy.id;
122  iTotalPlayingTime = cpy.iTotalPlayingTime;
123  iScoreOld = cpy.iScoreOld;
124  iScoreNew = cpy.iScoreNew;
125  sCustomEvaluationStrings = cpy.sCustomEvaluationStrings;
126  iLeagueScoreNew = cpy.iLeagueScoreNew;
127  iLeagueScoreGain = cpy.iLeagueScoreGain;
128  iLeagueRankNew = cpy.iLeagueRankNew;
129  iLeagueRankSymbolNew = cpy.iLeagueRankSymbolNew;
130  eLeagueStatus = cpy.eLeagueStatus;
131  sLeagueProgressData = cpy.sLeagueProgressData;
132  return *this;
133 }

◆ operator==()

bool C4RoundResultsPlayer::operator== ( const C4RoundResultsPlayer cmp)

Definition at line 100 of file C4RoundResults.cpp.

101 {
102  // cmp all xcept icon
103  if (id != cmp.id) return false;
104  if (iTotalPlayingTime != cmp.iTotalPlayingTime) return false;
105  if (iScoreOld != cmp.iScoreOld) return false;
106  if (iScoreNew != cmp.iScoreNew) return false;
107  if (sCustomEvaluationStrings != cmp.sCustomEvaluationStrings) return false;
108  if (iLeagueScoreNew != cmp.iLeagueScoreNew) return false;
109  if (iLeagueScoreGain != cmp.iLeagueScoreGain) return false;
110  if (iLeagueRankNew != cmp.iLeagueRankNew) return false;
111  if (iLeagueRankSymbolNew != cmp.iLeagueRankSymbolNew) return false;
112  if (eLeagueStatus != cmp.eLeagueStatus) return false;
113  if (sLeagueProgressData != cmp.sLeagueProgressData) return false;
114  return true;
115 }

◆ SetID()

void C4RoundResultsPlayer::SetID ( int32_t  idNew)
inline

Definition at line 84 of file C4RoundResults.h.

84 { this->id=idNew; }

Referenced by C4RoundResultsPlayers::GetCreateByID().

Here is the caller graph for this function:

◆ SetLeaguePerformance()

void C4RoundResultsPlayer::SetLeaguePerformance ( int32_t  iNewPerf)
inline

Definition at line 86 of file C4RoundResults.h.

86 { iLeaguePerformance = iNewPerf; }

Referenced by C4RoundResults::SetLeaguePerformance().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: