#include "tank_control.h"

unsigned int level = 0;
unsigned int cap = 1000000;
unsigned int bottle_size = 750;

unsigned int waste = 0;

void clear() {
	waste = 0;
	level = 0;
}

void change_bottle_capacity(unsigned int c) {
	bottle_size = c;
}

void change_tank(unsigned int c) {
	cap = c;
	if (level > cap) {
		waste += level - cap;
		level = cap;
	}
}

void add(unsigned int c) {
	level += c;
	if (level > cap) {
		waste += level - cap;
		level = cap;
	}
}

unsigned int ship_out_bottles() {
	unsigned int bottles = level / bottle_size;
	level = level % bottle_size;
	return bottles;
}

unsigned int get_tank_level() {
	return level;
}

unsigned int get_wastes() {
	return waste;
}
