[advice] daily deeds polish

roippi

Developer
I.. think.. I understand, yes, but won't that be order-independent? I have to keep track of that, too.
 

Bale

Minion
Oh right. I was thinking only about turning them on and off, not changing their order. It really felt like that when I was looking at this sentence...

Since there's just one comma-delimited preference string that contains all of the enabled deeds.

I'm not sure how you are formatting that. Can you also have an item that tells how many daily deeds are possible and then add on the new ones if the number is too low? I'm sure you can work out some system for auto-enabling new daily deeds even if it requires a second new preference.
 

Theraze

Active member
Yeah... if you have that, could just start by either having a version number as your first item, or some other such mark...
 

roippi

Developer
I'm not sure how you are formatting that.

This is what my preference looks like at the moment:
Code:
> get dailyDeedsOptions

Library Card,Friars,VIP Pool,Telescope,Demon Summoning,Crimbo Tree,April Shower,Daily Dungeon,Ball Pit,Breakfast,Bag o' Tricks,Legendary Beat,Outrageous Sombrero,Skate Park,Concert,Oscus' Soda,Rage Gland,Stills,Free Rests,Hot Tub,Photocopy,Camera,Bonus Adventures,Nuns,Express Card,Flush Mojo,Melange,Tea Party,Putty,Familiar Drops,Free Fights,Free Runaways,$CUSTOM:Blah blah Display|Boolean|pyramidBombUsed|cast madrigal

Basically, a comma-delimited list that tells daily deeds what built-in methods to call, and in which order. Also, at the end, you can see that I've added a custom button. It says "Blah blah Display" on it, is enabled/disabled by the pyramidBombUsed preference, and does cast madrigal when clicked. Totally useful.

Planned and more-or-less-already-implemented custom elements:
*Boolean - button that is enabled/disabled by a boolean user preference
*BooleanItem - same as boolean, but is additionally shown/hidden depending if you have an item
*Skill - button for either one-a-day or finite use skills tracked by a preference. Specify a maximum, at which point it will be disabled. Puts a text tracker (i.e. 0/3) next to the button if maximum > 1.
*Also considering a "Text" type, but that's sketchy.

What's cool is that this is basically an API for daily deeds. Some enterprising script writer could, for example, customize their deeds for each level 1-13. Or have a pre- and post-farming checklist. Don't even need ash, you can just alias it.

Can you also have an item that tells how many daily deeds are possible and then add on the new ones if the number is too low? I'm sure you can work out some system for auto-enabling new daily deeds even if it requires a second new preference.

Yeah, I'm pretty sure a second preference is required here. The simplest way is to make one preference that determines order, and a second that disables items. However I think I'm fundamentally against that approach, as it makes the code significantly harder to follow (and write). Still thinkin' bout it.
 

roippi

Developer
Decided to implement a Text type. I like what you can do with it.

Code:
> get dailyDeedsOptions

$CUSTOM|Text|Demonstration of customized Daily Deeds,$CUSTOM|Text|//\\//\\//\\ by Roippi //\\//\\//\\,$CUSTOM|Text| ,$CUSTOM|Text|This is a built-in deed:,VIP Pool,$CUSTOM|Text|So is this:,April Shower,$CUSTOM|Text| ,$CUSTOM|Text|This is a custom "Boolean" button that tracks a preference (hermitHax0red),$CUSTOM|Text|When clicked it gets clovers.,$CUSTOM|Boolean|Is the hermit hax0red?|hermitHax0red|hermit * clover,$CUSTOM|Text| ,$CUSTOM|Text|This is a custom line of text that also tracks some preferences:,$CUSTOM|Text|I've ascended |knownAscensions| times. My last adventure was in zone: |lastAdventure

yields:

ddprefs2.JPG

What's nifty about the text is that you don't need any special syntax to separate preferences from text chunks. You can specify as many strings as you want, but any that uniquely match a preference get automagically turned into said preference.

I'm nearing the end of working on adding API functionality. I've added a LOT of sanitizing so that users can't break things, but I'm sure I'll be proved wrong. I'll start work on the GUI soon; I want to be able to do most, if not all, of this stuff in there.
 

roippi

Developer
Kay, gotta stop adding API functionality. I'll write up a functional specification once I'm done with everything; the syntax ends up being fairly simple, but there's a lot of different methods.

I'm pretty stoked to see what people end up doing with this. I'm still wrapping my brain around all the stuff you can do with it. Since you can specify your own preferences and have the buttons call ash scripts, you can do almost whatever you want. Hell, you can code up multiple panels and have buttons that will shift you between them. Sky's the limit.

Last API teaser:

Code:
> get dailyDeedsOptions

$CUSTOM|Text|Demonstration of customized Daily Deeds,$CUSTOM|Text|//\\//\\//\\ by Roippi //\\//\\//\\,$CUSTOM|Text| ,$CUSTOM|Text|This is a built-in deed:,VIP Pool,$CUSTOM|Text|So is this:,April Shower,$CUSTOM|Text| ,$CUSTOM|Text|This is a custom "BooleanPref" button that tracks a preference (hermitHax0red),$CUSTOM|Text|If/when hermitHax0red is true,| this deed is greyed out.,$CUSTOM|Text|When clicked|,| it gets clovers.,$CUSTOM|BooleanPref|Is the hermit hax0red?|hermitHax0red|hermit * clover,$CUSTOM|Text| ,$CUSTOM|Text|This is a custom line of text that also tracks some preferences:,$CUSTOM|Text|I've ascended |knownAscensions| times. My last adventure was in zone: |lastAdventure,$CUSTOM|Text| ,$CUSTOM|Text|This is a "Skill" type button. It has a few uses,| but usually tracks a multi-use skill with an arbitrary limit:,$CUSTOM|Skill|get me some BRICKOs|libramSummons|summon brickos|7,$CUSTOM|Text| ,$CUSTOM|Text|Lastly,| here is a 'MultiPref' deed.,$CUSTOM|Text|You define the displayText,| an int preference,| the button command,| and the preference disabling threshold.,$CUSTOM|Text|It is up to you to make the preference track whatever your button is doing.,$CUSTOM|MultiPref|Run my custom ASH script up to 5 times|_farmingLoops|call farm.ash|5,$CUSTOM|Text| ,$CUSTOM|Text|You can define your own preferences and call ash scripts with your button commands.,$CUSTOM|Text|I haven't demonstrated all of the different types and overloaded variants here,| but this should be a good starting place.,$CUSTOM|Text|Have fun.

ddprefs3.JPG
 

roippi

Developer
So if anyone wants an advance copy to check out, here it is.

Designing the GUI for handling custom deeds is going to take me quite a while. The GUI right now is fully functional for adding built-in deeds and moving things around, but there's no graphical way of adding custom deeds. You have to construct those manually and add them to your dailyDeedsOptions preference. After that, you can shuffle them around in the GUI.

I suppose now would be a good time to provide the spec for making custom deeds. I'll plop it in its own post.
 
Last edited:

roippi

Developer
All deeds are specified by one comma-delimited preference "dailyDeedsOptions". Order matters. Built-in deeds are simply called by referring to their built-in name; these are viewable by pulling up the Daily Deeds tab and looking in the "Built-in Deeds" list. In the source code these can be found in DailyDeedsPanel.BUILTIN_DEEDS.

Custom Deeds

Custom deeds provide the user with a way of adding buttons or text to their daily deeds panel that is not natively provided for. All deeds start with the keyword $CUSTOM followed by a pipe (|) symbol. As you are constructing a custom deed, you separate the different arguments with pipes.

All deed types except for Text require a preference to track. If you want to add a button that is always enabled, you will have to create a dummy preference that is always false.

There are currently 5 different types of custom deeds. Remember that all of these "acceptable forms" are prefaced by $CUSTOM|.

BooleanPref - one-a-day deed
acceptable forms:
BooleanPref|displayText|preference
BooleanPref|displayText|preference|command

displayText - the text that will be displayed on the button
preference - the boolean preference to track. The button will be enabled when the preference is false, and disabled when the preference is true.
command (optional) - the command to execute. If not specified, will default to displayText.

MultiPref - n-times-a-day deed
acceptable forms:
BooleanPref|displayText|preference|command|maxUses

preference - the integer preference to track. The button will be enabled when preference < maxUses.
maxUses - an arbitrary integer. Specifies a threshold to disable the button at. A counter in the form of <preference>/<maxUses> will be displayed to the right of the button.

BooleanItem - this button will use fuzzy matching to find the name of the item specified. Will execute "use <itemName>" when clicked. Will only be visible when you possess one or more of the item.
acceptable forms:
BooleanItem|displayText|preference
BooleanItem|displayText|preference|itemName

itemName - the name of the item that will be used. If not specified, will default to displayText.

Skill - cast a skill that is tracked by a boolean or int preference. Will execute "cast <skillName>" when clicked.
acceptable forms:
Skill|displayText|preference
Skill|displayText|preference|skillName
Skill|displayText|preference|skillName|maxCasts

preference - a boolean preference if the 3- or 4-argument version is used, or an integer preference if the 5-argument version is used.
skillName- the name of the skill that will be cast. If not specified, will default to displayText. Must be specified if maxCasts are specified.
maxCasts - an arbitrary integer. Specifies a threshold to disable the button at. A counter in the form of <preference>/<maxCasts> will be displayed to the right of the button.

Text
acceptable forms:
Text|pretty much anything.

You can supply as many arguments as you want to a Text deed. Any argument that uniquely matches a preference will be replaced by that preference's value. If you want to use a comma in your text, immediately follow the comma with a pipe character so it will not be parsed as the end of the Text deed.

Edit: if anyone missed it and is wondering why I wrote this ginormous post, I posted a preliminary patch of this on the bottom of the previous page.
 
Last edited:

lostcalpolydude

Developer
Staff member
The Preferences frame opens up empty for me with this patch, only showing the General|Tools|People... bar. I get "net.sourceforge.kolmafia.swingui.OptionsFrame could not be loaded". The rest of mafia, including the Daily Deeds panel, works fine.
 

roippi

Developer
Oh, haha. Let's pretend that didn't happen. That will probably also have completely or almost-completely wiped out your default dailyDeedsOptions preference; I really need to add a button that resets the preference to default.

Now I'm having massive issues generating a patch.. let me know if this one is malformed. I'm seriously so annoyed at SVN right now.
 

Attachments

  • ddprefs3.patch
    45.8 KB · Views: 28

Theraze

Active member
Question... would it make sense for the first comma delineated value to be the version number? So you could just check that and if it's less than the latest 'current' version, add whatever official daily deeds are new to the end of their list, wherever that is?
 

roippi

Developer
They'd have to, yeah.

I haven't implemented the automatically-add-new-deeds bit yet, mostly because I haven't thought of a satisfactory way to do it. I think a second preference is needed. The jarring thing is that it adds deeds at the way bottom - even below the lines of text telling you about daily stills and runaways and whatnot.
 

Theraze

Active member
Well, each item wouldn't need to have a version number, just the version it was implemented. Release/final version is 1. Say there's a new 'standard' item. When that was added, it would go to version 2. If 3 things happened to be implemented then, it would still go to version 2. Next item or items, version 3. If someone is running version 1 and version 3 gets installed, it adds everything from old+1 to current, which should be pretty easy to do in a for-loop.
 

roippi

Developer
That'd work, yeah. I'm not terribly concerned about how to implement it technically.

One of the main reasons that I'm dissatisfied with the add-new-stuff-to-the-end approach is that it's ugly. In the default layout, text goes at the bottom of the deeds panel; it's weird to just have a button/combobox suddenly appear down there. It basically forces users to go into preferences and either move it into the proper position or delete it when a new built-in deed is added. Is making work for 100% of users better than not informing some portion of users about new content?

Nor can I just force new additions to load the "correct" order from defaults.txt, as the whole point of this revamp is to let you arbitrarily rearrange your deeds.

ETA:
Now I'm having massive issues generating a patch.. let me know if this one is malformed. I'm seriously so annoyed at SVN right now.

So I just downloaded tortoiseSVN.. MAN this is so much better than dealing with crappy windows CLI nonsense. Let me know if there's any more patching issues.
 
Last edited:

lostcalpolydude

Developer
Staff member
I would rather fix new items to be displayed appropriately when they show up than check Preferences all the time just in case something was added. Those are the only 2 options for someone not reading this forum regularly.
 

roippi

Developer
Kay. I think I've convinced myself as well. I could also automatically add a line of text before it saying "new items added in daily deeds version <version>:"

I'll add it in my next patch, whenever that ends up being. Hand-coding GUI stuff is kicking my butt.
 
Top