aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/card.cpp
diff options
context:
space:
mode:
authorCharlie Blake2018-01-30 19:51:38 +0000
committerGitHub2018-01-30 19:51:38 +0000
commit2fc005bdbb4707810ad0ae36a6863e70f0ff91b5 (patch)
tree59ca3063ffe6a876d27c96ea95d6a3683273675a /src/main/game/card.cpp
parentMerge pull request #31 from thecharlesblake/profiling-fix (diff)
parentAdd ORDER_ON_CACHE to benchmark script (diff)
downloadmetasol-2fc005bdbb4707810ad0ae36a6863e70f0ff91b5.tar.gz
metasol-2fc005bdbb4707810ad0ae36a6863e70f0ff91b5.zip

Merge pull request #32 from thecharlesblake/piles-always-sorted

Piles always sorted

Diffstat (limited to 'src/main/game/card.cpp')
-rw-r--r--src/main/game/card.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/main/game/card.cpp b/src/main/game/card.cpp
index 5189171..25a981f 100644
--- a/src/main/game/card.cpp
+++ b/src/main/game/card.cpp
@@ -82,3 +82,31 @@ bool operator==(const card& l, const card& r) {
bool operator!=(const card& l, const card& r) {
return !(l == r);
}
+
+bool operator<(const card& l, const card& r) {
+ if (l.get_rank() == r.get_rank())
+ return l.get_suit() < r.get_suit();
+ else
+ return l.get_rank() < r.get_rank();
+}
+
+bool operator>(const card& l, const card& r) {
+ if (l.get_rank() == r.get_rank())
+ return l.get_suit() > r.get_suit();
+ else
+ return l.get_rank() > r.get_rank();
+}
+
+bool operator<=(const card& l, const card& r) {
+ if (l.get_rank() == r.get_rank())
+ return l.get_suit() <= r.get_suit();
+ else
+ return l.get_rank() <= r.get_rank();
+}
+
+bool operator>=(const card& l, const card& r) {
+ if (l.get_rank() == r.get_rank())
+ return l.get_suit() >= r.get_suit();
+ else
+ return l.get_rank() >= r.get_rank();
+}