summaryrefslogtreecommitdiff
path: root/src/ring.c
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2023-10-12 16:07:05 -0400
committerLouie S <louie@example.com>2023-10-12 16:07:05 -0400
commit3c6cf0ed9980990ca07f6d76817814979691d65e (patch)
treebf11a53332f67b87ba6c05384eaa11cca486deb1 /src/ring.c
parent91da624fe1665f3ddb3216ebb8a56a982074228d (diff)
Pickup displaying
Diffstat (limited to 'src/ring.c')
-rw-r--r--src/ring.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/ring.c b/src/ring.c
new file mode 100644
index 0000000..633648b
--- /dev/null
+++ b/src/ring.c
@@ -0,0 +1,26 @@
+#include <assert.h>
+#include <stdlib.h>
+
+#include "ring.h"
+#include "tower.h"
+
+void pickup_ring() {
+ int i;
+ int pickup = -1;
+
+ // should not be called if we are already holding a ring
+ assert(held == NULL);
+
+ // find the smallest ring on the currently hovered tower (if there is one)
+ for(i = 2; i >= 0; --i) {
+ if(rings[i].location == hover) {
+ pickup = i;
+ break;
+ }
+ }
+
+ if(pickup > 0) {
+ held = &rings[pickup];
+ held->held = true;
+ }
+}