New Content - Implemented Olympic-Sized Swimming Pool

fronobulax

Developer
Staff member
I'll try a manual refresh but past experience suggests that changes inventory and not necessarily the Recent Items which is where I would hope to see it. (The presence/absence of items there remind me to do things that do not fit well into Breakfast or a Daily Deed or a Login script).
 

lostcalpolydude

Developer
Staff member
Parsing that item "drop" is very different from everything else. It shows up the same as any other speech bubble in the pool, except it's only possible while you are upside down (when you can't send a message identical to a normal item-containing message on your own). Being unable to track getting the item (or really anything happening in the pool) is a large part of why I didn't bother adding a way to get treasure, since mafia wouldn't recognize obvious failure if I did it.
 

slyz

Developer
I doesn't look like I won't have time to add this to native Mafia, life is hectic these days.

For those who want to add a "dive for treasure" button in their Daily Deeds, here is a how-to:
  • Download Donavin69's DiveForTreasure.ash (put it in Mafia's /scripts folder).
  • In Mafia, open up the Preferences and go to Login and Logout -> Daily Deeds.
  • We are going to add a custom command deed, so hit the "add custom" button and enter the following:
Code:
displayText: dive in the pool
preference: _treasureDive
command: call DiveForTreasure.ash; set _treasureDive = 1
 

Uli

Member
There are already two buttons added to the daily deeds for people to choose to either swim laps or do submarine sprints. Can you add another button that allows people to cannonball into the pool, do a handstand, dive for treasure, and get out?


Thanks!
 

Uli

Member
Wow, many apologies. I hate being 'that guy' who didn't use the search function. Sorry about that!
 
I'm taking a stab at finishing this feature off. I'm posting in the hopes of getting others to sanity check my logic before I get too far down a coding dead-end.

The core of the remaining issue, I believe, is the ability for kolmafia to detect the item drop - making the calls to do the dive in/handstand/get out, as shown by the ash script, are easy. So, that's where I'm focusing my effort - to get kolmafia to properly recognize the item drop in the pool, then after that I'll go work on adding a built-in "get stuff from pool" command. After playing with how the pool works, I think I've found a reliable way to get back if you got an item or not - to be looking for posts to choice.php w/ whichchoice=585 and action=treasure, and parsing for the following javascript:

var state ={"2259118":[1,0,3,[1,"I found a lost key!",1340774168],"pastamancer","IronTetsubo"]};//foo

where the "I found a [a-zA-Z]!" can then be used to match the actual item found.

As always with these, there's not a clean place to put this. It didn't feel like ChoiceManager.java was the right fit, and yet it felt like overkill to create a request/ClanLoungePoolRequest.java, so I figured I'd extend all the various functions in request/ClanLoungeRequest.java to also look for choice.php w/ whichchoice=585 to handle all the pool bits. Good call? Bad Call? Am I missing something here?
 

Catch-22

Active member
where the "I found a [a-zA-Z]!" can then be used to match the actual item found.

I don't think that matcher will work for everything, try:
Code:
(?<=found a )[\w-™&; ]*(?=!)
I don't know if KoL says "I found a Ze™ Goggles!" though, nor do I know if the TM symbol is a HTML entity or if it's directly encoded (the matcher will work for both, but won't work if KoL says "I found Ze™ Goggles!").
 

fronobulax

Developer
Staff member
It didn't feel like ChoiceManager.java was the right fit, and yet it felt like overkill to create a request/ClanLoungePoolRequest.java, so I figured I'd extend all the various functions in request/ClanLoungeRequest.java to also look for choice.php w/ whichchoice=585 to handle all the pool bits. Good call? Bad Call? Am I missing something here?
Why don't you revist that? My naive impression is that a new request type makes for cleaner and more readable code. Extending seems to me like one of those things where you someone else looks at the code in six months and wonders what and why?
 
Why don't you revist that? My naive impression is that a new request type makes for cleaner and more readable code. Extending seems to me like one of those things where you someone else looks at the code in six months and wonders what and why?

Fair enough, revisit I will - I'll go with the request/ClanLoungePoolRequest.java approach, then.
 

Catch-22

Active member
I don't know if KoL says "I found a Ze™ Goggles!"

Code:
<span>  I found a Ze™ goggles!  </span>

Just confirmed that the TM sign is not a HTML entity, and the "found a" text, so the matcher should be:

Code:
(?<=found a )[\w-™ ]*(?=!)
 
Yup - but I'm not matching on the span because it's rendered by the client via javascript - I'm matching on the javascript function, which is ™ - I got one of these the day before or so. I'll finish up my patch, hopefully I'll be clearer then.

dave
 

Catch-22

Active member
Yup - but I'm not matching on the span because it's rendered by the client via javascript - I'm matching on the javascript function, which is ™

Wow, that's weird. I never knew when Javascript modified the DOM it expanded HTML entities. That seems like an odd behaviour, maybe it's just a Firefox thing...
 
Wow, that's weird. I never knew when Javascript modified the DOM it expanded HTML entities. That seems like an odd behaviour, maybe it's just a Firefox thing...

Shrug. No idea about firefox's behavior, but if you're using firebug (or the developer tools in chrome, what I'm using), you can see the page returned by the post to choice.php when diving for treasure embeds the following javascript:


var state ={"2259118":[6,3,1,[1,"I found a Ze™ goggles!",1341028895],"pastamancer","IronTetsubo"]};//foo

which then gets used by the rest of the javascript functions to get included as a span dynamically. But that's transient, and rendered by the javascript that kolmafia's not running anyways, so it doesn't exist for me to search on. it is interesting, though, that somehow through the javascript transformation it gets turned into the actual "TM" symbol instead of the ™
 
Thanks for the poke - should have a patch later tonight. I went back and forth on a bunch of approaches, but think I've got one, and I'm waiting for rollover to test. sorry for the delay...
 
Okay, here's my first cut. this is almost assuredly not committable, but figured I'd at least get it out there for feedback. I went with the "create a new ClanLoungeSwimmingPoolRequest.java" approach per the feedback. I still need to clean up the breakfast work, and registerRequest? Not as sure about that, so need to do more investigation to see if it's relevant or not. And I likely have other cruft I've forgotten as I changed approaches/was debugging. However:

- items found via diving are properly registered - it also correctly ignores people saying "I found ...", and only registers on actual dive responses.
- "swim cannonball | item" now properly works, in that you get into the pool, handstand, dive, and get out.

Although I'm less certain about the second one since I used up my one dive for the day testing the first one. :)

Anyways, todo:

- Make breakfast work, by having the clanlounge breakfast also call the clanloungeswimmingpool breakfast.
- get a preference set when you find an item to be consistent with the rest of the limited per day things we've got.
- figure out registerRequest, and if it's needed or not.
- Cleanup whatever other cruft I missed when copying ClanLoungeRequest.java -> ClanLoungeSwimmingPoolRequest.java

builds off of latest (11276). Broadly I made it generic for being able to call the other pool functions (handstand, opening/closing eyes, etc), but didn't bother to expose them via the cli since I figured no one cares - if it is interesting to folk, let me know and I'll adjust accordingly.
 

Attachments

  • vip_pool_fix2.patch
    12.5 KB · Views: 18
- Make breakfast work, by having the clanlounge breakfast also call the clanloungeswimmingpool breakfast.
- get a preference set when you find an item to be consistent with the rest of the limited per day things we've got.
- figure out registerRequest, and if it's needed or not.
- Cleanup whatever other cruft I missed when copying ClanLoungeRequest.java -> ClanLoungeSwimmingPoolRequest.java

Okay, latest version takes care of all the todos. To recap:

- items found via diving are properly registered - it also correctly ignores people saying "I found ...", and only registers on actual dive responses.
- "swim cannonball | item" now properly works, in that you get into the pool, handstand, dive, and get out.
- breakfast properly works - if you've flagged breakfast to go get clan vip stuff, it will also go into the pool, get the item, and get out (and set a new daily pref to indicate you've done so).

And I fixed registerRequest and cleaned up all the leftover cruft from clanloungerequest.java. I think this one's commitable! :) Or at least, I hope so - as always, feedback on my approach is welcome, happy to redo whatever's necessary to do it right.
 

Attachments

  • vip_pool_fix3.patch
    13.1 KB · Views: 24

roippi

Developer
Committed mostly as-is, r11287

The pref you added needed an entry in defaults.txt, that's the only thing that was really an issue. Other than that, I threw some try/finally blocks around the diving requests just to make things robust, and changed the RequestLogger lines a bit to fit personal taste ("Getting out in clan VIP..." => "Getting out of clan VIP...". Good stuff!
 
Top