Bug - Fixed Dungeon Fist! visit_url() issue

Rinn

Developer
So I scripted optimal Dungeon Fist! playing, and while my script worked mafia created a debug log every time a visit_url was called. If I remove the first two urls (and remove the call to buy) and run the script after manually starting Dungeon Fist! the script works fine, doesn't trigger any errors and will increment my ticket count after the game is finished. I don't have arcade hints turned on if that matters.

The script:
Code:
string [int] raw_url;
raw_url[raw_url.count()] = "arcade.php";
raw_url[raw_url.count()] = "arcade.php?action=game&whichgame=3&pwd";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=3&choiceform3=Go+West";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Fight%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Fight%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+East";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+West";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+East";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Fight%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Fight%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+East";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+East";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Fight%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+West";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+West";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+East";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Fight%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+East";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Fight%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Attack%21";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=2&choiceform2=Use+Potion";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+West";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=3&choiceform3=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=3&choiceform3=Go+South";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+West";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=1&choiceform1=Go+North";
raw_url[raw_url.count()] = "choice.php?pwd&whichchoice=486&option=3&choiceform3=Go+West";

void DungeonFist()
{    
    if (my_adventures() < 5)
    {
        abort("You need 5 adventures remaining to play Dungeon Fist!");
        return;
    }
    
    if (item_amount($item[game grid token]) == 0)
    {
        buy(1, $item[game grid token]);
    }
    
    foreach i in raw_url
    {
        visit_url(raw_url[i]);
    }
}

void main()
{
    DungeonFist();
}
Debug log (repeated after practically every visit_url()):
Code:
class java.lang.NullPointerException: null
java.lang.NullPointerException
    at net.sourceforge.kolmafia.request.ArcadeRequest.postChoiceDungeonFist(ArcadeRequest.java:327)
    at net.sourceforge.kolmafia.session.ChoiceManager.postChoice1(ChoiceManager.java:2823)
    at net.sourceforge.kolmafia.request.GenericRequest.processResponse(GenericRequest.java:1779)
    at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1728)
    at net.sourceforge.kolmafia.request.GenericRequest.retrieveServerReply(GenericRequest.java:1423)
    at net.sourceforge.kolmafia.request.GenericRequest.execute(GenericRequest.java:1161)
    at net.sourceforge.kolmafia.request.GenericRequest.run(GenericRequest.java:1052)
    at net.sourceforge.kolmafia.RequestThread.postRequest(RequestThread.java:73)
    at net.sourceforge.kolmafia.textui.RuntimeLibrary.visit_url(RuntimeLibrary.java:1546)
    at net.sourceforge.kolmafia.textui.RuntimeLibrary.visit_url(RuntimeLibrary.java:1522)
    at net.sourceforge.kolmafia.textui.RuntimeLibrary.visit_url(RuntimeLibrary.java:1512)
    at sun.reflect.GeneratedMethodAccessor52.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.sourceforge.kolmafia.textui.parsetree.LibraryFunction.execute(LibraryFunction.java:119)
    at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:166)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
    at net.sourceforge.kolmafia.textui.parsetree.Loop.execute(Loop.java:57)
    at net.sourceforge.kolmafia.textui.parsetree.ForEachLoop.executeSlice(ForEachLoop.java:170)
    at net.sourceforge.kolmafia.textui.parsetree.ForEachLoop.execute(ForEachLoop.java:109)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
    at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:127)
    at net.sourceforge.kolmafia.textui.parsetree.FunctionCall.execute(FunctionCall.java:166)
    at net.sourceforge.kolmafia.textui.parsetree.BasicScope.execute(BasicScope.java:451)
    at net.sourceforge.kolmafia.textui.parsetree.UserDefinedFunction.execute(UserDefinedFunction.java:127)
    at net.sourceforge.kolmafia.textui.Interpreter.executeScope(Interpreter.java:265)
    at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:198)
    at net.sourceforge.kolmafia.textui.Interpreter.execute(Interpreter.java:191)
    at net.sourceforge.kolmafia.textui.command.CallScriptCommand.call(CallScriptCommand.java:194)
    at net.sourceforge.kolmafia.textui.command.CallScriptCommand.run(CallScriptCommand.java:63)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeCommand(KoLmafiaCLI.java:527)
    at net.sourceforge.kolmafia.KoLmafiaCLI.executeLine(KoLmafiaCLI.java:401)
    at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.handleQueue(CommandDisplayFrame.java:191)
    at net.sourceforge.kolmafia.swingui.CommandDisplayFrame$CommandQueueHandler.run(CommandDisplayFrame.java:172)
 

Veracity

Developer
Staff member
Revision 8506 will eliminate the NPE.
You do not need the "choiceform1" fields, by the way.
 

Rinn

Developer
I didn't think so, someone else provided me with a list of urls and I really didn't feel like editing any of them.
 

Veracity

Developer
Staff member
By the way, you are missing a key URL, which was the cause of the original bug. When you call "arcade.php?action=game&whichgame=3&pwd", KoL redirects you to choice.php. That allows KoLmafia to log the visit in your session log and pick out the names of the options. Your log will look like:

[10364] Dungeon Fist!
Action: Go West
Encounter: Demons
Action: Fight!
...

rather than missing the first two lines. Add:

raw_url[raw_url.count()] = "choice.php";

after

raw_url[raw_url.count()] = "arcade.php?action=game&whichgame=3&pwd";

Well, what the heck. Here is your script modified to remove extraneous stuff and to add the call to choice.php. I tested it and it worked nicely.
 

Attachments

  • DungeonFist.ash
    8.9 KB · Views: 219

Bale

Minion
Am I the only one that thought it was a teeny bit silly to do this?

Code:
    if (my_adventures() < 5)
    {
        abort("You need 5 adventures remaining to play Dungeon Fist!");
[COLOR="#ff0000"][B]        return;[/B][/COLOR]
    }

Lol! If you abort, then then why do you need a return?
 
Top