Feature - Implemented Expose ChoiceManager.lastDecision

Currently, ChoiceManager.lastChoice is exposed to the user (via last_choice) so we can tell what choice adventure we are at (and available_choice_options lets us see those lovely choices).

Unless I'm completely blind, we have no way in ASH to tell which choice was made last although Mafia is aware of it. So, I was hoping to propose a last_decision function which is pretty straight-forward and I've included the diff here:

Code:
Index: src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java
===================================================================
--- src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java (revision 18733)
+++ src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java (working copy)
@@ -1153,6 +1158,9 @@
        functions.add( new LibraryFunction( "last_choice", DataTypes.INT_TYPE, params ) );

        params = new Type[] {};
+       functions.add( new LibraryFunction( "last_decision", DataTypes.INT_TYPE, params ) );
+
+       params = new Type[] {};
        functions.add( new LibraryFunction( "available_choice_options", DataTypes.INT_TO_STRING_TYPE, par$

        params = new Type[] { DataTypes.BOOLEAN_TYPE };
@@ -5381,6 +5404,11 @@
        return DataTypes.makeIntValue( ChoiceManager.lastChoice );
    }

+   public static Value last_decision( Interpreter interpreter )
+   {
+       return DataTypes.makeIntValue( ChoiceManager.lastDecision );
+   }
+
    public static Value available_choice_options( Interpreter interpreter )
    {
        return RuntimeLibrary.available_choice_options( false );

I am using this currently so I can have a script check what choice a user made and track the results of it for spadings (specifically in this case, to keep track of the needle changes in the Bastille).
 

Darzil

Developer
Added as r18736. Note you can post diff files here, and we tend to use leading tabs rather than spaces.

Thanks
 
Top