本文整理汇总了C++中Match::getCategory方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::getCategory方法的具体用法?C++ Match::getCategory怎么用?C++ Match::getCategory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::getCategory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: linkToMatch
bool BracketVisElement::linkToMatch(const Match& ma) const
{
Category myCat = getLinkedCategory();
if (ma.getCategory() != myCat) return false;
// lock the database before writing
DbLockHolder lh{db, DatabaseAccessRoles::MainThread};
row.update(BV_MATCH_REF, ma.getId());
return true;
}
示例2: updateRankingsAfterMatchResultChange
ERR RankingMngr::updateRankingsAfterMatchResultChange(const Match& ma, const MatchScore& oldScore, bool skipSorting) const
{
if (ma.getState() != STAT_MA_FINISHED) return WRONG_STATE;
Category cat = ma.getCategory();
int catId = cat.getId();
int firstRoundToModify = ma.getMatchGroup().getRound();
// determine the score differences (delta) for each affected player pair
MatchScore newScore = *(ma.getScore()); // is guaranteed to be != nullptr
tuple<int, int, int> deltaMatches_P1{0,0,0}; // to be added to PlayerPair1
tuple<int, int, int> deltaMatches_P2{0,0,0}; // to be added to PlayerPair2
int oldWinner = oldScore.getWinner();
int newWinner = newScore.getWinner();
if ((oldWinner == 0) && (newWinner == 1))
{
deltaMatches_P1 = tuple<int, int, int>{1, 0, -1};
deltaMatches_P2 = tuple<int, int, int>{0, 1, -1};
}
if ((oldWinner == 0) && (newWinner == 2))
{
deltaMatches_P1 = tuple<int, int, int>{0, 1, -1};
deltaMatches_P2 = tuple<int, int, int>{1, 0, -1};
}
if ((oldWinner == 1) && (newWinner == 0))
{
deltaMatches_P1 = tuple<int, int, int>{-1, 0, 1};
deltaMatches_P2 = tuple<int, int, int>{0, -1, 1};
}
if ((oldWinner == 2) && (newWinner == 0))
{
deltaMatches_P1 = tuple<int, int, int>{0, -1, 1};
deltaMatches_P2 = tuple<int, int, int>{-1, 0, 1};
}
if ((oldWinner == 1) && (newWinner == 2))
{
deltaMatches_P1 = tuple<int, int, int>{-1, 1, 0};
deltaMatches_P2 = tuple<int, int, int>{1, -1, 0};
}
if ((oldWinner == 2) && (newWinner == 1))
{
deltaMatches_P1 = tuple<int, int, int>{1, -1, 0};
deltaMatches_P2 = tuple<int, int, int>{-1, 1, 0};
}
tuple<int, int> gameSumOld = oldScore.getGameSum();
tuple<int, int> gameSumNew = newScore.getGameSum();
int gamesTotalOld = get<0>(gameSumOld) + get<1>(gameSumOld);
int gamesTotalNew = get<0>(gameSumNew) + get<1>(gameSumNew);
int deltaWonGamesP1 = -get<0>(gameSumOld) + get<0>(gameSumNew);
int deltaLostGamesP1 = -(gamesTotalOld - get<0>(gameSumOld)) + (gamesTotalNew - get<0>(gameSumNew));
int deltaWonGamesP2 = -get<1>(gameSumOld) + get<1>(gameSumNew);
int deltaLostGamesP2 = -(gamesTotalOld - get<1>(gameSumOld)) + (gamesTotalNew - get<1>(gameSumNew));
tuple<int, int> deltaGames_P1{deltaWonGamesP1, deltaLostGamesP1}; // to be added to PlayerPair1
tuple<int, int> deltaGames_P2{deltaWonGamesP2, deltaLostGamesP2}; // to be added to PlayerPair2
tuple<int, int> scoreSumOld = oldScore.getScoreSum();
tuple<int, int> scoreSumNew = newScore.getScoreSum();
int oldWonPoints_P1 = get<0>(scoreSumOld);
int newWonPoints_P1 = get<0>(scoreSumNew);
int deltaWonPoints_P1 = newWonPoints_P1 - oldWonPoints_P1;
int oldLostPoints_P1 = oldScore.getPointsSum() - oldWonPoints_P1;
int newLostPoints_P1 = newScore.getPointsSum() - newWonPoints_P1;
int deltaLostPoints_P1 = newLostPoints_P1 - oldLostPoints_P1;
tuple<int, int> deltaPoints_P1{deltaWonPoints_P1, deltaLostPoints_P1};
tuple<int, int> deltaPoints_P2{deltaLostPoints_P1, deltaWonPoints_P1};
// determine who actually is P1 and P2
int pp1Id = ma.getPlayerPair1().getPairId();
int pp2Id = ma.getPlayerPair2().getPairId();
// find the first entry to modify
// derive the group number of the affected ranking entries
//
// we may only modify subsequent entries with the same
// group number as the initial number. Thus, we prevent
// a modification of e.g. the ranking entries in a KO-phase
// after we started modifications in the round robin phase.
//
// we get the group number from the first entry of the
// first player pair to be modified
WhereClause w;
w.addIntCol(RA_CAT_REF, catId);
w.addIntCol(RA_PAIR_REF, pp1Id);
w.addIntCol(RA_ROUND, firstRoundToModify);
auto re = getSingleObjectByWhereClause<RankingEntry>(w);
if (re == nullptr) return OK; // no ranking entries yet
int grpNum = re->getGroupNumber();
//
// a helper function that does the actual modification
//
auto doMod = [&](int pairId, const tuple<int, int, int>& matchDelta,
const tuple<int, int>& gamesDelta, const tuple<int, int>& pointsDelta)
{
// let's build a where clause that captures all entries
// to modified
//.........这里部分代码省略.........