int [item] list;
void setup_display() {
file_to_map("DC Data.txt", list);
foreach key in $items[]
if(display_amount(key)>0 && !(list contains key))
list [key] = -1;
map_to_file(list, "DC Data.txt");
}
void display_stuff() {
print("Putting...");
foreach key in list
if(item_amount(key)>0)
print(" "+key, "blue");
print("... into display case");
foreach key in list
switch {
case list[key] == 0:
put_display(item_amount(key), key);
break;
case list[key] > 0:
int dis_amount = max(list[key] - display_amount(key), 0);
if(dis_amount >0 && item_amount(key) > 0)
put_display(min(item_amount(key), dis_amount), key);
break;
case list[key] < 0:
if(item_amount(key) + list[key] > 0)
put_display(item_amount(key) + list[key], key);
break;
}
print("DC updated", "green");
}
void main() {
setup_display();
display_stuff();
}