Feature - Implemented Update charpane in Ed when using /servant chat command

Ensiferum

Member
Would it be possible to update the charpane when switching servants through chat, the same way it is updated when switching familiars?

The /servant command is processed much faster (and with possibly less server hits) than mafia's series of visiting URLs. However, I've stuck with the mafia version because it updates the charpane.
 

lostcalpolydude

Developer
Staff member
The charpane does refresh. I guess you (like me) use ChIT, and didn't notice the servant image change. What you're actually reporting is that mafia doesn't recognize that you have a different servant out after the chat command.
 

Veracity

Developer
Staff member
I suspect we just need to recognise servant from charpane, will look at that.
I don't see why.

All chat commands turn into a page request - foo.php?arguments - the result of which is shown to you, and which can cause a charpane refresh if something changed in the charpane. The correct way for us to handle that is to recognize (and log, as usual) when we see the page request being submitted, and to recognize (and process) the response to the request.

We wait for the charpane (or api) to tell us about adventures used and such, but for just about everything else, we should keep our model up-to-date by looking at the request/response that changed it, not a second-order effect like a charpane refresh.

So, can you supply a DEBUG log that shows you submitting the /servant command and getting the response, please?
 

Darzil

Developer
Well, we currently check charpane for Clancy, Jarlsberg and Familiars, so I'm just doing exactly the same thing.

There is a chat message we could recognise :
Code:
<font color=green>"Hey, Lazy Servant, get to work" you bark at your Priest.<!--js(parent.charpane.location.href="charpane.php";)--></font><br>

Trying a servant you don't have gives :
Code:
<font color=green>No servants matched</font><br>

Doing /familiar X as Ed gives in chat pane :
Code:
<font color=green>You get more familiar with Carrie, your Black Cat.<!--js(dojax('familiar.php?action=newfam&newfam=93&ajax=1');)--></font><br>

And in the main pane :
Ed already has more than enough servants.
 

Attachments

  • DEBUG_20150330.txt
    228.3 KB · Views: 34
Last edited by a moderator:

Ensiferum

Member
What you're actually reporting is that mafia doesn't recognize that you have a different servant out after the chat command.
The game charpane probably does, but I rarely look there. KoLmafia's charpane doesn't:
Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
         KoLmafia v16.8 r15660, Windows XP, Java 1.6.0_26
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Please note: do not post this log in the KoLmafia thread of KoL's
 Gameplay-Discussion forum. If you would like the KoLmafia dev team
 to look at it, please write a bug report at kolmafia.us. Include
 specific information about what you were doing when you made this
 and include this log as an attachment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Timestamp: Mon Mar 30 18:47:23 EEST 2015
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


<font color=green>"Hey, Lazy Servant, get to work" you bark at your Scribe.<!--js(parent.charpane.location.href="charpane.php";)--></font><br>
<font color=green>"Hey, Lazy Servant, get to work" you bark at your Priest.<!--js(parent.charpane.location.href="charpane.php";)--></font><br>

My request is that Mafia updates its own charpane the same way it does for familiars and other companions when they are switched via chat commands.
 

Veracity

Developer
Staff member
That is fascinating. That was really the entire DEBUG log from when you typed the "/servant" command into chat? Hard to understand how that could be; I see no request being submitted to KoL, even though you show me what looks like (part of) a response to a request.

That is, literally, the first example of a chat command that is, apparently, completely executed in KoL itself, rather than having the browser submit a request which then causes the processing.

Well, I'm done with Ed for now, otherwise I'd look forward into seeing it with my own eyes.
 

Darzil

Developer
r15667.

Also submitted a /bug, as currently the chat command works during combat.

Also now recalculates adjustments and changes compact side pane when servant changes.
 

Veracity

Developer
Staff member
My request is that Mafia updates its own charpane the same way it does for familiars and other companions when they are switched via chat commands.
Perhaps you did not understand what I said earlier, when I explained how "switching familiars via chat" works. Let me try to be clearer.

I turned on DEBUG logging and checked the "log chat requests" option.
I typed into chat: "/familiar jumpsuited hound dog"

The following transactions occurred:

Code:
Requesting: http://www.kingdomofloathing.com/submitnewchat.php?j=1&pwd&playerid=115875&graf=%2Ftalkie+%2Ffamiliar+jumpsuited+hound+dog
Retrieved: http://www.kingdomofloathing.com/submitnewchat.php?j=1&pwd&playerid=115875&graf=%2Ftalkie+%2Ffamiliar+jumpsuited+hound+dog
{"output":"<font color=green>You get more familiar with Tort, your Jumpsuited Hound Dog.<!--js(dojax('familiar.php?action=newfam&newfam=69&ajax=1');)--><\/font>","msgs":[]}
Requesting: http://www.kingdomofloathing.com/familiar.php?action=newfam&newfam=69&ajax=1&_=1427737320096
Retrieved: http://www.kingdomofloathing.com/familiar.php?action=newfam&newfam=69&ajax=1&_=1427737320096
<script type="text/javascript">top.charpane.location.href="charpane.php";</script><table  width=95%  cellspacing=0 cellpadding=0><tr><td style="color: white;" align=center bgcolor=blue><b>Results:</b></td></tr><tr><td style="padding: 5px; border: 1px solid blue;"><center><table><tr><td><center><center>You put Gronald back in the Terrarium.<p>You take Tort with you.</center></td></tr></table></center></td></tr><tr><td height=4></td></tr></table>
The browser submitted the chat message
KoL responded with a message to display in chat and an embedded Javascript command to change the familiar.
The browser submitted the request to familiar.php
KoL responded with a message saying it had changed the familiar
That message incorporated a request to refresh the charpane.

So, yes - we all completely understood your request. We did NOT understand that KoL was using a brand-new mechanism for changing servants via chat than it uses for changing familiars.
 

Darzil

Developer
That is fascinating. That was really the entire DEBUG log from when you typed the "/servant" command into chat? Hard to understand how that could be; I see no request being submitted to KoL, even though you show me what looks like (part of) a response to a request.
You can see more in the log I attached, with the to and from browser/kol included. It does seem to be literally a chat post followed by a request to refresh the charpane.

I just did what we currently do for Familiars, Clancy, Jarlsberg companions and Thralls when reading Characterpane, and it seems to make everything work.
 

Veracity

Developer
Staff member
I just did what we currently do for Familiars, Clancy, Jarlsberg companions and Thralls when reading Characterpane, and it seems to make everything work.
Yeah. The difference with those is that every way you can change them within KoL, we can watch it happen and if you can do it via chat - /familiar, /cast, whatever - KoL responds to the chat command with a request that the browser submit the url that does it.

Servants are different, it seems, in that you have to go through choice.php to access them; there is no one-request &ajax command to let you change them, unfortunately. Therefore, I would wager that the /servant command prints something in the chat pane and refreshes the charpane, but unlike every other similar companion change, there will not be a little frame inserted at the top via ajax telling you about it.

A pity; we'd really prefer to use a single request ajax command to change servants ourself - from the green sidepane, from the ervant command, etc.
 

Veracity

Developer
Staff member
I'm guessing KoL did it that way because it requires two requests normally.
Agreed.

Unfortunately, it is a precedent, and we might need to handle it a bit more directly. For example, when we process chat messages, we could recognize what just happened and do the right thing without waiting for a charpane refresh. The log Ensiferum showed had the message in green. Do we treat it as an Event?

Damn. I'll have to do Ed again, it seems, so I can play with this...
 

Ensiferum

Member
Hrm. I think something is a bit off in r15667.

The status pane is not updating after /servant chat commands, and on top of that it's randomly adding extra 5 levels for servants when they are switched via said chat commands. Mafia's status pane only updates after a "refresh" from the relay browser charpane.

Right now it's thinking that I have a level 30 cat and is showing the bonus item drops for a level 30 fairy.
 

Ensiferum

Member
I think I figured why isn't the status pane being updated. The only case in which an update happens is when the /servant command is used in the relay chat. Using it in Mafia's GUI chat or directly from the gCLI doesn't force an update.

If it has any relevance, here is the syntax difference of the requests in these cases:
Code:
[B]Relay Chat:[/B]
Requesting: http://www.kingdomofloathing.com/submitnewchat.php?j=1&pwd&playerid=2270792&graf=%2Fclan+%2Fservant+scribe
[B]
gCLI and GUI Chat[/B]
Requesting: http://www.kingdomofloathing.com/submitnewchat.php?pwd&playerid=2270792&graf=%2Fservant+priest
 

lostcalpolydude

Developer
Staff member
Using it in relay chat generates javascript telling the charpane to refresh. That can't work with mafia's chat. Since mafia currently only knows about the servant changing from the charpane refreshing, that would explain it, and also covers why Veracity's discussion matters for completely practical reasons.
 
Top