int x = 1000; // Add 1000 to advertising budget.
visit_url("managestore.php?howmuch="+x+"&advertising=Add+to+Budget&action=addad&pwd");
int current_budget;
string store = visit_url("managestore.php");
matcher budget = create_matcher("Current Budget: (\\d+) Meat" , store);
if(budget.find()) current_budget = budget.group(1);
else abort("Advertising Budget Unknown!");
print("Current Advertising Budget: "+current_budget);
int x = 1000 - current_budget;
if(x > 0)
visit_url("managestore.php?howmuch="+x+"&advertising=Add+to+Budget&action=addad&pwd");
void handle_store_budget(int target) {
string bp = excise(visit_url("managestore.php"),"Current Budget: ","<br");
if (bp == "") {
print("Error detecting store advertising budget.","red");
return;
}
int currbudg = to_int(bp);
print("Store advertising budget: "+currbudg);
boolean increase_ad_budget(int amt) {
print("Adding "+amt+" meat to ad budget...");
return contains_text(visit_url("managestore.php?howmuch="+amt+"&action=addad&pwd"),"Advertising budget increased.");
}
if (currbudg < target && increase_ad_budget(target - currbudg))
print("Budget increased to "+target+".");
}