how to detect Clancy status in ash?

morgad

Member
I have the following code snippet trying to detect if Clancy wants attention, but as Mafia apparently tracks clancy status, how would I access this directly, and avoid this crude code?

Code:
/// got to be a better way than this
	string charpane = visit_url("charpane.php");
	if (contains_text(charpane, "_att.gif")) abort("stopping so you can visit Clancy.");

best regards
Dave
 

nworbetan

Member
AfaIk, checking the charpane for _att.gif is currently the only way to tell if _att.gif is present in the charpane. :p I wouldn't call that crude, unless maybe you're checking it after every adventure or something?
 

roippi

Developer
If you wanted to avoid all the extra server hits, you could do a set_property() in a charpane override, and then your script could look at the value of that property.
 

Veracity

Developer
Staff member
KoLmafia pulls it out of the charpane:

Code:
			String level = clancyMatcher.group( CharPaneRequest.compactCharacterPane ? 3 : 1 );
			String image = clancyMatcher.group( CharPaneRequest.compactCharacterPane ? 1 : 2 );
			boolean att = clancyMatcher.group( CharPaneRequest.compactCharacterPane ? 2 : 3 ) != null;
			AdventureResult instrument =
				image.equals( "1" ) ? CharPaneRequest.SACKBUT :
				image.equals( "2" ) ? CharPaneRequest.CRUMHORN :
				image.equals( "3" ) ? CharPaneRequest.LUTE :
				null;
			KoLCharacter.setClancy( StringUtilities.parseInt( level ), instrument, att );
and out of api.php:

Code:
			int level = JSON.getInt( "clancy_level" );
			int itype = JSON.getInt( "clancy_instrument" );
			boolean att = JSON.getBoolean( "clancy_wantsattention" );
			AdventureResult instrument =
				itype == 1 ? CharPaneRequest.SACKBUT :
				itype == 2 ? CharPaneRequest.CRUMHORN :
				itype == 3 ? CharPaneRequest.LUTE :
				null;
			KoLCharacter.setClancy( level, instrument, att );
but we don't currently save the "attention" flag - or provide any easy way in ASH of getting any of the three Clancy attributes (current level, current instrument, wants attention).

It wouldn't be too hard.
 

Bale

Minion
but we don't currently save the "attention" flag - or provide any easy way in ASH of getting any of the three Clancy attributes (current level, current instrument, wants attention).

Not entirely true.


  • Current Level: not hard, but I wouldn't mind a simple function.
    Code:
    int clancy = minstrel_level() 
       - (have_effect($effect[Song of Accompaniment]) > 0? 3: 0) 
       - (have_skill($skill[More to Love])? 3: 0);
  • Current Instrument: There is an easy way in Ash! You already added a minstrel_instrument() function.

  • Wants attention: This one is tough...
    Perhaps a new function would be useful.
 
Top