Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19

Thread: int my_path_ID()

  1. #1
    Senior Member
    Join Date
    Apr 2019
    Posts
    193

    Default int my_path_ID()

    Could it be possible to get some kind of "my_path_ID()" function that returns your path number instead of name? I'm trying to make something that'd require that (predicting a pseudo-random buff that uses the path ID in the seeding). Since mafia gets this information from api.php, having access to it would save some extra steps.

  2. #2
    Senior Member
    Join Date
    Apr 2019
    Posts
    193

    Default

    ...also is it possible to get int path_to_int(string path_name) ?

  3. #3
    Senior Member
    Join Date
    Apr 2019
    Posts
    193

    Default

    ...bump?

    If it's not possible, at least right now (something else having priority?), could I get to know where mafia stores the path information, to try and make that conversion myself?

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    Having spent a buttload of time supporting new content and ASH improvements recently, I've stepped back for now, and am mostly looking only at Bugs.
    I did consider this and examined AfterLifeRequest, which looks at KoL's "path id" numbers:

    Code:
    			switch ( path )
    			{
    			case 0:
    				builder.append( "no" );
    				break;
    			case 1:
    				builder.append( "a Boozetafarians" );
    				break;
    			case 2:
    				builder.append( "a Teetotaler" );
    				break;
    			case 3:
    				builder.append( "an Oxygenarian" );
    				break;
    			case 4:
    				builder.append( "a Bees Hate You" );
    				break;
    			case 6:
    				builder.append( "a Way of the Surprising Fist" );
    				break;
    			case 7:
    				builder.append( "a Trendy" );
    				break;
    			case 8:
    				builder.append( "an Avatar of Boris" );
    				break;
    			case 9:
    				builder.append( "a Bugbear Invasion" );
    				break;
    			case 10:
    				builder.append( "a Zombie Slayer" );
    				break;
    			case 11:
    				builder.append( "a Class Act" );
    				break;
    			case 12:
    				builder.append( "an Avatar of Jarlsberg" );
    				break;
    			case 14:
    				builder.append( "a BIG!" );
    				break;
    			case 15:
    				builder.append( "a KOLHS" );
    				break;
    			case 16:
    				builder.append( "a Class Act II: A Class For Pigs" );
    				break;
    			case 17:
    				builder.append( "an Avatar of Sneaky Pete" );
    				break;
    			case 18:
    				builder.append( "a Slow and Steady" );
    				break;
    			case 19:
    				builder.append( "a Heavy Rains" );
    				break;
    			case 21:
    				builder.append( "a Picky" );
    				break;
    			case 22:
    				builder.append( "the Standard" );
    				break;
    			case 23:
    				builder.append( "an Actually Ed the Undying" );
    				break;
    			case 24:
    				builder.append( "the One Crazy Random Summer" );
    				break;
    			case 25:
    				builder.append( "a Community Service" );
    				break;
    			case 26:
    				builder.append( "an Avatar of West of Loathing" );
    				break;
    			case 27:
    				builder.append( "a The Source" );
    				break;
    			case 28:
    				builder.append( "a Nuclear Autumn" );
    				break;
    			case 29:
    				builder.append( "a Gelatinous Noob" );
    				break;
    			case 30:
    				builder.append( "a License to Adventure" );
    				break;
    			case 31:
    				builder.append( "a Live. Ascend. Repeat." );
    				break;
    			case 32:
    				builder.append( "a Pocket Familiars" );
    				break;
    			case 33:
    				builder.append( "a G-Lover" );
    				break;
    			case 34:
    				builder.append( "a Disguises Delimit" );
    				break;
    			case 35:
    				builder.append( "a Dark Gyffte" );
    				break;
    			case 36:
    				builder.append( "a Two Crazy Random Summer" );
    				break;
    			case 37:
    				builder.append( "a Kingdom of Exploathing" );
    				break;
    			case 38:
    				builder.append( "a Path of the Plumber" );
    				break;
    			case 39:
    				builder.append( "a Low Key Summer" );
    				break;
    			default:
    				builder.append( "(Path " );
    				builder.append( String.valueOf( path ) );
    				builder.append( ")" );
    				break;
    			}
    
    			builder.append( " path," );
    So, yeah, there are paths even for the consumption restrictions.

    But it made me think that maybe, internally, we should have an Enum, with path descriptor and ID and (other stuff).
    And then, rather than storing your current path as a String, store it as an enum value?
    And would it be worth it to have a $path datatype in ASH?
    (We used to have (and removed) a "zodiac" type. Although KoL has changed its own terminology: even though they are named after constellations, they are "moon" signs. Huh?)

    Which is to say, this looked more and more like a code refactoring than a simple "function to map a string to an integer".

    I'm not rejecting your idea, but I think it takes actual thought and design.

    If we made "path" a data type, you're asking for

    path my_path()
    int to_int( path )

    Which is all a little "project". Assuming we wanted to go that route.

  5. #5
    Senior Member
    Join Date
    Apr 2019
    Posts
    193

    Default

    Would there be a way to help? I don't know a lot of java, but if there's a part that would require a lot of copy-pasting the almost-same part many times with little differences (like building a map), maybe..?

  6. #6
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    Here is another place: where we parse the result from api.php?what=status into a string:

    Code:
    		String path = JSON.getString( "path" );
    		if ( path.equals( "0" ) )
    		{
    			path = "None";
    		}
    		else if ( path.equals( "1" ) )
    		{
    			path = "Boozetafarian";
    		}
    		else if ( path.equals( "2" ) )
    		{
    			path = "Teetotaler";
    		}
    		else if ( path.equals( "3" ) )
    		{
    			path = "Oxygenarian";
    		}
    		else if ( path.equals( "4" ) )
    		{
    			path = "Bees Hate You";
    		}
    		else if ( path.equals( "6" ) )
    		{
    			path = "Way of the Surprising Fist";
    		}
    		else if ( path.equals( "7" ) )
    		{
    			path = "Trendy";
    		}
    		else if ( path.equals( "8" ) )
    		{
    			path = "Avatar of Boris";
    		}
    		else if ( path.equals( "9" ) )
    		{
    			path = "Bugbear Invasion";
    		}
    		else if ( path.equals( "10" ) )
    		{
    			path = "Zombie Slayer";
    		}
    		else if ( path.equals( "11" ) )
    		{
    			path = "Class Act";
    		}
    		else if ( path.equals( "12" ) )
    		{
    			path = "Avatar of Jarlsberg";
    		}
    		else if ( path.equals( "14" ) )
    		{
    			path = "BIG!";
    		}
    		else if ( path.equals( "15" ) )
    		{
    			path = "KOLHS";
    		}
    		else if ( path.equals( "16" ) )
    		{
    			path = "Class Act II: A Class For Pigs";
    		}
    		else if ( path.equals( "17" ) )
    		{
    			path = "Avatar of Sneaky Pete";
    		}
    		else if ( path.equals( "18" ) )
    		{
    			path = "Slow and Steady";
    		}
    		else if ( path.equals( "19" ) )
    		{
    			path = "Heavy Rains";
    		}
    		else if ( path.equals( "21" ) )
    		{
    			path = "Picky";
    		}
    		else if ( path.equals( "22" ) )
    		{
    			path = "Standard";
    		}
    		else if ( path.equals( "23" ) )
    		{
    			path = "Actually Ed the Undying";
    		}
    		else if ( path.equals( "24" ) )
    		{
    			path = "One Crazy Random Summer";
    		}
    		else if ( path.equals( "25" ) )
    		{
    			path = "Community Service";
    		}
    		else if ( path.equals( "26" ) )
    		{
    			path = "Avatar of West of Loathing";
    		}
    		else if ( path.equals( "27" ) )
    		{
    			path = "The Source";
    		}
    		else if ( path.equals( "28" ) )
    		{
    			path = "Nuclear Autumn";
    		}
    		else if ( path.equals( "29" ) )
    		{
    			path = "Gelatinous Noob";
    		}
    		else if ( path.equals( "30" ) )
    		{
    			path = "License to Adventure";
    		}
    		else if ( path.equals( "31" ) )
    		{
    			path = "Live. Ascend. Repeat.";
    		}
    		else if ( path.equals( "32" ) )
    		{
    			path = "Pocket Familiars";
    		}
    		else if ( path.equals( "33" ) )
    		{
    			path = "G-Lover";
    		}
    		else if ( path.equals( "34" ) )
    		{
    			path = "Disguises Delimit";
    		}
    		else if ( path.equals( "35" ) )
    		{
    			path = "Dark Gyffte";
    		}
    		else if ( path.equals( "36" ) )
    		{
    			path = "Two Crazy Random Summer";
    		}
    		else if ( path.equals( "37" ) )
    		{
    			path = "Kingdom of Exploathing";
    		}
    		else if ( path.equals( "38" ) )
    		{
    			path = "Path of the Plumber";
    		}
    		else if ( path.equals( "39" ) )
    		{
    			path = "Low Key Summer";
    		}
    		KoLCharacter.setPath( path );
    That could be a map lookup for int => enum path.
    The question is, what do we return in the hours after KoL releases a new path ID before we have code to support it - or before you have downloaded the version to support it?
    It's not a hard project - but it is a project .

  7. #7
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    Here is code in KoLCharacter:

    Code:
    	// Paths
    	public static final String BEES_HATE_YOU = "Bees Hate You";
    	public static final String SURPRISING_FIST = "Way of the Surprising Fist";
    	public static final String TRENDY = "Trendy";
    	public static final String BUGBEAR_INVASION = "Bugbear Invasion";
    	public static final String ZOMBIE_SLAYER = "Zombie Slayer";
    	public static final String CLASS_ACT = "Class Act";
    	public static final String BIG = "BIG!";
    	public static final String KOLHS = "KOLHS";
    	public static final String CLASS_ACT_II = "Class Act II: A Class For Pigs";
    	public static final String SLOW_AND_STEADY = "Slow and Steady";
    	public static final String HEAVY_RAINS = "Heavy Rains";
    	public static final String PICKY = "Picky";
    	public static final String ACTUALLY_ED_THE_UNDYING = "Actually Ed the Undying";
    	public static final String CRAZY_RANDOM = "One Crazy Random Summer";
    	public static final String COMMUNITY_SERVICE = "Community Service";
    	public static final String WEST_OF_LOATHING = "Avatar of West of Loathing";
    	public static final String THE_SOURCE = "The Source";
    	public static final String NUCLEAR_AUTUMN = "Nuclear Autumn";
    	public static final String GELATINOUS_NOOB = "Gelatinous Noob";
    	public static final String LICENSE = "License to Adventure";
    	public static final String LIVE_ASCEND_REPEAT = "Live. Ascend. Repeat.";
    	public static final String POKEFAM = "Pocket Familiars";
    	public static final String GLOVER = "G-Lover";
    	public static final String DISGUISES_DELIMIT = "Disguises Delimit";
    	public static final String DARK_GYFFTE = "Dark Gyffte";
    	public static final String CRAZY_RANDOM_TWO = "Two Crazy Random Summer";
    	public static final String KINGDOM_OF_EXPLOATHING = "Kingdom of Exploathing";
    	public static final String PATH_OF_THE_PLUMBER = "Path of the Plumber";
    	public static final String LOWKEY = "Low Key Summer";
    Yeah, we are long-since due to make this an enum. I have (so far) pointed to three places where particular paths are recognized via specific strings - the path name.

  8. #8
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    We should have AscensionPath.java, which containes enum Path and various maps and utility functions to map from (string or int) to Path to (string or int).
    If we make Path an ASH object, that is code in DataTypes and Parser and Type and other places.
    Whether or not we make Path an ASH object, we can add two functions to RuntimeLibrary, as you propose.

    The tricky part is, as I mentioned, what about "path 40" - the next (not yet released) challenge path, before we add the Enum object for it?

  9. #9
    Senior Member
    Join Date
    Apr 2019
    Posts
    193

    Default

    We could have an array with 46 entries (0-indexed) (40 paths + 6), with the last 6 reading "unknown"

    Then, whenever a path is changed from "unknown" to "<new path name>", the array gets bigger by 1 entry (so once path 40 is out, we increase the array so that it now has 47 entries).

    Having 6 "unknown"s would mean that someone has 2 years (3 new paths per year) to update mafia without getting errors?

  10. #10
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    13,311

    Default

    I'd say have them be named "path 40" through "path 45", say. It would otherwise work as you suggest.

    OK, fine. I'll look into refactoring the base data structure for a Path to be what I proposed. Then, we can decide if we want a (not-backwards-compatible) datatype named "path" or simply two functions like you proposed which use the new internal representation of a path.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •