aboutsummaryrefslogtreecommitdiff
path: root/src/main/game/card.cpp
diff options
context:
space:
mode:
authorthecharlesblake2018-01-30 15:49:28 +0000
committerthecharlesblake2018-01-30 15:49:28 +0000
commit583b9a005ebd447d39c0515e2692178cc1dfe7b9 (patch)
tree0f134d7b22f78543c73d0524db6bd5d64f8fa20b /src/main/game/card.cpp
parentUpdate global cache to insert ordered vec (diff)
downloadmetasol-583b9a005ebd447d39c0515e2692178cc1dfe7b9.tar.gz
metasol-583b9a005ebd447d39c0515e2692178cc1dfe7b9.zip

Update card & pile with comp operators for sorting

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();
+}