Is there a way to check if the last adventure was a non-combat and what non-combat it was?
Is there a way to check if the last adventure was a non-combat and what non-combat it was?
I think so. This is the best I could do:
I haven't worked through every instance this might present. Are there any combats that might not evaluate to monsters? Are there any non-combats that would?Code:string lastEncounter = get_property("lastEncounter"); if(to_monster(lastEncounter) == last_monster()) { print("True"); # lastEncounter was a combat } else { print("False"); # lastEncounter was a non-combat }
Maybe. Though it seems as though this function ought to work if possible. As far as I can tell the name is taken from the HTML via regex when stored in lastEncounter, but by the time it gets stored in MonsterStatusTracker (where last_monster() gets its info from) the name has been canonicalised to match mafia's internal data.
Honestly, I'm struggling to follow all the parsing and handling between the request coming back and it ending up in MonsterStatusTracker. Is this worth submitting as a bug or is this likely to be unimportant?
I wanted to do a very similar thing discussed in this thread: http://kolmafia.us/showthread.php?18...unter-a-combat
I ended up rejecting the method of matching monster names because of those kind of issues (also problems with Hobopolis hobos, Dread monsters and other stuff where procedural names dont match the canonical monster name).
Instead I ended up parsing the last adventure from the session logs using this code snippet:
But I'm not really sure how you'd go from that to recognising that it was a noncombat.Code:string LastAdvTxt() { string lastlog = session_logs(1)[0]; int nowmark = max(last_index_of(lastlog,"["+my_turncount()+"]"),last_index_of(lastlog,"["+(my_turncount()+1)+"]")); return substring(lastlog,nowmark); }
The thought I has was to check get_property("lastEncounter") and compare that to a lists of know non-combats.
No ideal, but it would be true if you knew what adventures you were looking for.
or maybe this, using that amazing code snippet:
Code:if (!contains_text(LastAdvTxt(),"Round 1")) { //this is not a combat }
Last edited by ckb; 08-17-2017 at 12:29 AM.
Ah, this is all good, thanks. I was having trouble finding this kind of thing on the wiki.