Feature - Implemented Adding Instant Karma to the ascension check list

Bors

New member
Can Instant Karma be added to the ascension check list? Possible under common stuff you haven't done yet. Thanks
 

lostcalpolydude

Developer
Staff member
I added some code to my copy for this, and once I'm finished testing I plan on attaching a diff here for it (unless it just isn't getting added). Basically I added a variable to track how many karma have been discarded, the variable is incremented when you discard a karma (this is done in GenericRequest.java, maybe it should go somewhere else, but karma is in the ItemPool and the variable is in defaults.txt). Before you jump through the gash, if you have any karma and you've discarded less than 3 you get a reminder message. When you ascend, the variable is reduced by 3 or set to 0 as appropriate, but I can't test that part until I ascend in 6+ days (grrr carboloading).

I wanted the reminder list to have a link to discard a karma (with the confirmation popup of course), but I couldn't figure out how to add the password hash to the link, so for now it just links back to the right inventory section.
 

Veracity

Developer
Staff member
By all means - attach your diff when you are ready.

Here is an example, from ValhallaDecorator, which you are presumably modifying, of inserting the password hash into the buffer.

Code:
		buffer.append( "<input type=hidden name=action value=\"resurrect\"><input type=hidden name=pwd value=\"" );
		buffer.append( GenericRequest.passwordHash );
		buffer.append( "\"><center><table>" );
 

lostcalpolydude

Developer
Staff member
I haven't tested the ascending part, but I'm confident the block of code is right even if I put it in the wrong place (onAscension() in ValhallaManager.java). The changes in ItemPool.java and defaults.txt are trivial.

GenericRequest.java stuff does everything it needs to do for tracking when you discard karma (including not incrementing if you cancel the discard when the dialog pops up).

The block of code in ValhallaDecorator.java looks a bit sloppy, but in-line javascript seemed simpler than any other approach. The only "problem" with this code is that if the user has discard-confirm turned off, this will pop up a confirm window anyway, because it doesn't seem worthwhile to hit the server to find out what the setting is (plus the fact that I'm pretty sure I would fail at an elegant solution to that lookup). I expect the HTML layout might need some changing to fit the format that you would prefer.
 

Attachments

  • karma.diff
    3.8 KB · Views: 48

jasonharper

Developer
Well, the discard handling really belongs in ResultProcessor.java, which is already parsing discards to maintain inventory counts (this also avoids a problem a few years down the line, when your code would start falsely triggering on items in the 44480-44489 range). And I put the -3 part in a slightly different place, so it would be triggered even if mafia didn't witness the actual ascension. And I modified the discard link to get the results to load inline. But other than that, your patch was accepted as-is for r8307.
 
Top