Bug - Fixed Debug log when cheating with Deck of Every Card

Magus_Prime

Well-known member
I noticed this for the first time today with r16806 and just tried again with r16811 and it happened again. Here's the View attachment DEBUG_20160324.txt.

What happens is:

1. Use the relay browser to enter my inventory
2. Select the "cheat" link next to the Deck of Every Card
3. Select the card I want from the drop-down
4. Then the debug log message appears in the gCLI
5. The frame in the relay browser resets
6. If I refresh the page in Firefox I can continue from where things went off the rails

Any thoughts?
 
Last edited:

fronobulax

Developer
Staff member
I have a trivial script that just lists "cli_execute("play random;");" 15 times. I just want to use all the draws and don't care whether the call fails because I am out of draws or not. It consistently gives me a debug log after I fight the hermit. Since WHAM does not beat the Hermit I end up Beaten UP and never bothered to pinpoint the source of the log. On the off chance that these are related, I'll try and post it the next time.
 

Veracity

Developer
Staff member
Unless that just started happening, I am quite sure it is not a result of the change I made yesterday in 16805. Feel free to start a new thread - preferably with a DEBUG log showing the drawing the card and the fight, as well as the stack trace.
 

Veracity

Developer
Staff member
By the way, it sounds like there are many better ways to make your script, even without different logic.

play-random.txt:

Code:
play random
play random
play random
play random
play random
play random
play random
play random
play random
play random
play random
play random
play random
play random
play random
play-random.txt:

Code:
play random
repeat 14
play-random.ash:

Code:
cli-execute {
...either of the above..
}
play-random.ash:

Code:
for i from 1 to 15
    cli_execute( "play random" );
 

Veracity

Developer
Staff member
Yeah. Using my own choice.php - which is similar to Bale's but better ;) - I got this:

Code:
Starting relay script: choice.ash
Requesting: http://www.kingdomofloathing.com/choice.php?whichchoice=1086&option=1&pwd&which=63
Retrieved: http://www.kingdomofloathing.com/choice.php?whichchoice=1086&option=1&pwd&which=63
Field: Location = [choice.php?forceoption=0]

Starting relay script: choice.ash
Requesting: http://www.kingdomofloathing.com/choice.php?forceoption=0
Retrieved: http://www.kingdomofloathing.com/choice.php?forceoption=0
Finished relay script: choice.ash

Unexpected error, debug log printed.
We were inside a choice.php relay script.
It submitted a request for choice.php?whichchoice=1086&option=1&pwd&which=63
That redirected to choice.php?forceoption=0

I didn't think KoL would redirect from xxx.php to xxx.php, but, obviously, it does.

This would presumably not be an issue if we stopped automatically following redirects in visit_url in Relay Scripts, but I'm not ready to work on that yet.

Pondering.
 

Veracity

Developer
Staff member
OK, Revision 16821 prevents the same thread from starting a relay script it is already executing. The method was synchronized, which blocked multiple threads from doing that, but redirecting from choice.php to choice.php leaves you in the same thread, for now.

Still need to consider simply not following redirects in relay scripts any more.
 

fronobulax

Developer
Staff member
Since I muddied the waters...

I got the debug log again and it appears that what is going on is that as I was running through the deck (using the suboptimal 15 line script ;-) ) I got beaten up, my "when beaten up abort line" triggered in my mood and the next invocation triggered the log. So I do not think what I saw is a function of the Deck and it is probably an edge case not worth trying to track down.
 

fronobulax

Developer
Staff member
This is from this morning. Running the 15 line cli_execute noted above. Drew and got beaten up by hermit. Mood had abort on beaten up. I think that's it.

Session log below. The hermit was the second card and the hot tub visit was triggered by me manually.

Code:
use 1 Deck of Every Card

[1011520] Deck of Every Card
Encounter: Mine
You acquire an item: linoleum ore
You acquire an item: asbestos ore
You acquire an item: chrome ore

use 1 Deck of Every Card

[1011520] Deck of Every Card
Encounter: IX - The Hermit
Encounter: The Hermit
Round 0: fronobulax wins initiative!
Round 1: Your opponent seems to want to attack you, but isn't willing to get any closer to SshoDomogonododononononono than he has to.
Round 1: fronobulax executes a macro!
Round 1: fronobulax attacks!
Round 2: The Hermit takes 14553 damage.
Round 2: You feel a sudden shock as PeggyLee feeds an electrical pulse through both of your temples. Whoo! Perks you up better than a hot cup of coffee.
Round 2: You gain 12 Mana Points
Round 2: You lose 3,704 hit points
Round 2: fronobulax casts WEAPON OF THE PASTALORD!
Round 3: The Hermit takes 47783 damage.
Round 3: You feel a sudden shock as PeggyLee feeds an electrical pulse through both of your temples. Whoo! Perks you up better than a hot cup of coffee.
Round 3: You gain 12 Mana Points
Round 3: You lose 5,432 hit points
Round 3: fronobulax casts WEAPON OF THE PASTALORD!
Round 4: The Hermit takes 23880 damage.
Round 4: You feel a sudden shock as PeggyLee feeds an electrical pulse through both of your temples. Whoo! Perks you up better than a hot cup of coffee.
Round 4: You gain 13 Mana Points
Round 4: You lose 5,185 hit points
Round 4: fronobulax casts WEAPON OF THE PASTALORD!
Round 5: The Hermit takes 23878 damage.
Round 5: You lose 4,691 hit points
Round 5: fronobulax casts WEAPON OF THE PASTALORD!
Round 6: The Hermit takes 23876 damage.
Round 6: You lose 3,951 hit points
Round 6: fronobulax casts WEAPON OF THE PASTALORD!
Round 7: The Hermit takes 23901 damage.
Round 7: You lose 5,926 hit points
You acquire an item: hermit factoid

use 1 Deck of Every Card
Unexpected error, debug log printed.

Visiting Relaxing Hot Tub in clan VIP lounge
You lose an effect: Beaten Up (0)
You gain 24,689 hit points
 

Attachments

  • DEBUG_20160411.txt
    2.9 KB · Views: 15

Veracity

Developer
Staff member
How odd.

Code:
		// You're too beaten up. An accidental papercut would kill you at this point.
		if ( responseText.contains( "You're too beaten up" ) )
		{
			KoLmafia.updateDisplay( MafiaState.ERROR, "You are too beaten up to draw a card" );
			return;
		}
Apparently, responseText is null, rather than having the expected message.

I'll try this tomorrow in a debugger once I hit aftercore: I'll force myself to get beaten up and will attempt to cheat a card.
 

Veracity

Developer
Staff member
I experimented a bit. I got the Beaten Up effect - but had > 0 HP - and did "cheat swamp".

Our check for "You're too beaten up" occurs after we "use" the deck but before we submit a choice, and it did not trigger in that case; the inv_use.php just redirected to choice.php and everything worked normally.

I will eventually try this when I am Beaten Up AND have 0 HP.

In the meantime, please run your script with the debug log and let me see KoLmafia actually submitting the request, next time, rather than just the stack trace.

Thanks.
 

fronobulax

Developer
Staff member
I experimented a bit. I got the Beaten Up effect - but had > 0 HP - and did "cheat swamp".

Our check for "You're too beaten up" occurs after we "use" the deck but before we submit a choice, and it did not trigger in that case; the inv_use.php just redirected to choice.php and everything worked normally.

I will eventually try this when I am Beaten Up AND have 0 HP.

In the meantime, please run your script with the debug log and let me see KoLmafia actually submitting the request, next time, rather than just the stack trace.

Thanks.

Will do.

My hypothesis was that

cli_execute("play random;");

resulted in being beaten up.
the mood, which had abort on beaten up, triggered and set an abort state.
the next invocation of cli_execute("play random;"); triggered the error presumably because of the abort state.

To poke holes in my own theory I probably should look at when moods are executed.

Regardless, thank you for looking at this.
 

fronobulax

Developer
Staff member
Attached.

I restored the When Beaten Up Abort to my mood since that had been there previously.
I turned the Debug on, ran the 15 line script, it fought the hermit, gave the error, I manually visited the hot tub and restarted the script.
 

Attachments

  • DEBUG_20160418.txt
    515 KB · Views: 12
Top