summaryrefslogtreecommitdiff
path: root/src/ring.c
blob: 633648b5e0ad0c127c2a5a5d0dc4ef0589c52e22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
	}
}