Debugging an abandoned script (CS/Planner)

Lxndr

Member
In the abandoned relay script CS/Planner (http://kolmafia.us/showthread.php?5657-Skill-CS-planner) it's having trouble detecting Tome skills or Grimoire skills if they've already been cast.

Here's the code that checks for skills:

Code:
void getskills(){
 print("Collecting skill information");
 remove opts["SKILL"];
 string b=visit_url("charsheet.php");
 b=substring(b,b.index_of("height=1"));
 if(index_of(b,"Current Familiar")>0)b=substring(b,0,index_of(b,"Current Familiar"));
 string m=visit_url("campground.php?action=bookshelf");
 matcher am;
 piece this;
 foreach sort in allInfo["SKILL","MR"]{
  this=allInfo["SKILL","MR",sort];
  if((m.index_of(this.name)>0)||(m.index_of(this.link)>0))this.r=2;
  opts["SKILL","MR",sort]=this;
 }
 foreach sub,sort in allInfo["SKILL"]{
  if(sub=="MR")
  continue;
  this=allInfo["SKILL",sub,sort];
  if(this.name=="")this.name=sort;
  am=create_matcher(">"+this.name+"</a> \\((.)",b);
  if(find(am)){
   if(group(am,1)=="<")this.r=2;
   else this.r=1;
  }
  if((this.r==0)&&(index_of(b,">"+this.name+"</a>")>0))this.r=3;
  opts["SKILL",sub,sort]=this;
 }
}

It pulls some of this from a map file. Here's the relevant text from the map file:

Code:
 #Type	Cat	Sort	Name(if!=)	Link(if!=)	Image	R
SKILL	MR	T1	Summon Snowcones		dsnowcone.gif	0
SKILL	MR	T2	Summon Stickers		papersword.gif	0
SKILL	MR	T3	Summon Sugar Sheets		sugsheet.gif	0
SKILL	MR	T4	Summon Clip Art		book3.gif	0
SKILL	MR	T5	Summon Rad Libs		radlibtome.gif	0
SKILL	MR	T6	Summon Smithsness		smithereens.gif	0
SKILL	MR	L1	Summon Candy Heart		candyheart.gif	0
SKILL	MR	L2	Summon Party Favor		divpopper.gif	0
SKILL	MR	L3	Summon Love Song		music.gif	0
SKILL	MR	L4	Summon BRICKOs		brickobrick.gif	0
SKILL	MR	L5	Summon Dice		d20.gif	0
SKILL	MR	L6	Summon Resolutions		resolution.gif	0
SKILL	MR	L7	Summon Taffy		taffy7.gif	0
SKILL	MR	G1	Summon Hilarious Objects		groucho.gif	0
SKILL	MR	G2	Summon Tasteful Items	Summon "Tasteful" Gifts	lamprey.gif	0
SKILL	MR	G3	Summon Alice's Army Cards		aapack.gif	0
SKILL	MR	G4	Summon Geeky Gifts		nerdgrimoire.gif	0
SKILL	MR	G5	Summon Confiscated Things		book4.gif	0

Now, this isn't my code, I've just sort of adopted maintaining the map file. And I'm interested in learning how to fix the code.

Can anyone give me any insights into why this isn't able to see already-cast Tome skills and/or Grimoire skills?

(I hypothesize that it's because they're grayed out in the bookshelf because this works on any Libram skill).
 

lostcalpolydude

Developer
Staff member
You have a Tome of Snowcone Summoning.
You have a Tome of Sticker Summoning.
You have a Tome of Sugar Shummoning.
The actual skill names aren't on the page because you can't actually use them any more today.
 

Lxndr

Member
Right. That makes sense to me. That fits with my hypothesis.

So... any ideas on how to tweak that monster bit of code? Or do I update the map file to "Tome of Snowcone Summoning" vs. "Snowcone Summoning"?

It looks like it checks both charsheet.php and bookshelf.php, is the second check necessary, or is that causing all the problems?
 
Top