summaryrefslogtreecommitdiff
path: root/src/model/MedalWinner.cpp
diff options
context:
space:
mode:
authorSteru <jerrydream111@gmail.com>2024-08-16 22:19:42 +0200
committerSteru <jerrydream111@gmail.com>2024-08-16 23:58:46 +0200
commit88b1b119dfa35f36b64d81dbe6c84f46d86455c5 (patch)
tree864ba9c747ef86d61b6aeb01e8985676f906bd3e /src/model/MedalWinner.cpp
parentf24b4dcbd11336dabfd146c656e2437e4393b225 (diff)
Compacted competitors into one object, deleted API class (now in sportmodel).
Diffstat (limited to 'src/model/MedalWinner.cpp')
-rw-r--r--src/model/MedalWinner.cpp57
1 files changed, 0 insertions, 57 deletions
diff --git a/src/model/MedalWinner.cpp b/src/model/MedalWinner.cpp
deleted file mode 100644
index 56cfb22..0000000
--- a/src/model/MedalWinner.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-
-#include "MedalWinner.h"
-
-/**
- * Replaces/sets the won medals of a competitor.
- *
- * @param medals The won medals with their amount.
- * @return True, if successful.
- */
-bool MedalWinner::setMedals(const QJsonObject &medals) {
- if (!medals.contains("ME_GOLD")
- || !medals.contains("ME_SILVER")
- || !medals.contains("ME_BRONZE")) {
- return false;
- }
-
- setGold(medals["ME_GOLD"].toInt());
- setSilver(medals["ME_SILVER"].toInt());
- setBronze(medals["ME_BRONZE"].toInt());
-
- return true;
-}
-
-/**
- * Static compare method, which can compare the amount of medals of two MedalWinners.
- * Gold has the highest priority, then m_silver and finally m_bronze.
- *
- * @param lComp First competitor to compare.
- * @param rComp Second competitor to compare.
- * @return True, if the second competitor got more or higher medals.
- */
-bool MedalWinner::compare(MedalWinner lComp, MedalWinner rComp) {
- // create difference between medal amounts
- int gold = lComp.getGold() - rComp.getGold();
- int silver = lComp.getSilver() - rComp.getSilver();
- int bronze = lComp.getBronze() - rComp.getBronze();
-
- // compare medal differences
- return gold < 0 || (gold == 0 && (silver < 0 || (silver == 0 && bronze < 0)));
-}
-
-bool MedalWinner::setMedalWinner(const QJsonObject &competitor) {
- setCompetitor(competitor);
-
- if (!competitor.contains("medals")) return false;
- QJsonObject medals = competitor["medals"].toObject();
- setMedals(medals);
- return true;
-}
-
-void MedalWinner::setMedalWinner(const MedalWinner &competitor) {
- setCompetitor(competitor);
-
- setGold(competitor.m_gold);
- setSilver(competitor.m_silver);
- setBronze(competitor.m_bronze);
-}