I want my script to run a semi-rare automatically whenever the counter expires. Strangely enough, it works fine for the purple light district, but when it tries to run the castle top floor, it stops the world "Fortune Cookie counter expired." so the user can decide where to spend the adventure.
I want to be warned when I'm playing and the semi-rare counter comes up. But I expect my script to be able to take care of it for me while it's running, without manual intervention.
Here's some minimal reproducible code to demonstrate the issue:
I want to be warned when I'm playing and the semi-rare counter comes up. But I expect my script to be able to take care of it for me while it's running, without manual intervention.
Here's some minimal reproducible code to demonstrate the issue:
Code:
boolean IsPurpleLightAvailable()
{
matcher imgNum = create_matcher("purplelightdistrict(\\d+)\\.gif", visit_url("clan_hobopolis.php?place=8"));
return imgNum.find() && imgNum.group(1).to_int() < 10;
}
string runaway(int round, monster mon, string page)
{
return "run away";
}
void RunSemiRare()
{
string lastLocation = get_property("semirareLocation");
if (lastLocation != "The Castle in the Clouds in the Sky (Top Floor)")
{
visit_url("adventure.php?snarfblat=324"); // castle top floor
run_combat("runaway");
}
else if (IsPurpleLightAvailable() && "hobo nickel".to_item().item_amount() >= 5)
{
string page = visit_url("adventure.php?snarfblat=172"); // purple light district
if (page.contains_text("choice.php"))
run_choice(1);
else
run_combat("runaway");
}
else
{
// do something else, irrelevant to this question
}
}
void main()
{
string countersString = get_property("relayCounters");
string[int] counters = countersString.split_string(":");
int fortuneCookieCounter = 0;
for (int i = 2; i < counters.count(); i += 3)
{
int turns = counters[i - 2].to_int();
string type = counters[i - 1];
if (type.index_of("Fortune Cookie") >= 0)
{
if (fortuneCookieCounter == 0 || turns < fortuneCookieCounter)
fortuneCookieCounter = turns;
}
}
print("turns until semi-rare " + (fortuneCookieCounter - my_turnCount()));
for (int i = my_turnCount(); i < fortuneCookieCounter; i++) // burn turns until semi-rare is up
{
visit_url("adventure.php?snarfblat=83"); // visit the hole in the sky, because it doesn't have any choice adventures to interfere
run_combat();
}
RunSemiRare();
}