record mon_data
{
string image;
string name;
};
static mon_data [int] monsters;
void parseManuel(string URL)
{
string page = visit_url(URL);
matcher entry_matcher = create_matcher( "<a name='mon(.*?)'></a><table width=95%>(.*?)</table>", page );
while ( entry_matcher.find() ) {
int id = entry_matcher.group( 1 ).to_int();
string entry = entry_matcher.group( 2 );
matcher image_matcher = create_matcher( "/.*images/(.*?.gif) width=([(100)(60)])", entry );
string image = image_matcher.find() ? image_matcher.group( 1 ) : "";
matcher data_matcher = create_matcher( "<font size=.2>(.*?)</font>", entry );
if ( data_matcher.find() && data_matcher.find() ) {
string name = data_matcher.group( 1 );
monsters[ id ] = new mon_data( image, name );
}
}
}
void parseall()
{
monsters.clear();
parseManuel("questlog.php?which=6&vl=a");
parseManuel("questlog.php?which=6&vl=b");
parseManuel("questlog.php?which=6&vl=c");
parseManuel("questlog.php?which=6&vl=d");
parseManuel("questlog.php?which=6&vl=e");
parseManuel("questlog.php?which=6&vl=f");
parseManuel("questlog.php?which=6&vl=g");
parseManuel("questlog.php?which=6&vl=h");
parseManuel("questlog.php?which=6&vl=i");
parseManuel("questlog.php?which=6&vl=j");
parseManuel("questlog.php?which=6&vl=k");
parseManuel("questlog.php?which=6&vl=l");
parseManuel("questlog.php?which=6&vl=m");
parseManuel("questlog.php?which=6&vl=n");
parseManuel("questlog.php?which=6&vl=o");
parseManuel("questlog.php?which=6&vl=p");
parseManuel("questlog.php?which=6&vl=q");
parseManuel("questlog.php?which=6&vl=r");
parseManuel("questlog.php?which=6&vl=s");
parseManuel("questlog.php?which=6&vl=t");
parseManuel("questlog.php?which=6&vl=u");
parseManuel("questlog.php?which=6&vl=v");
parseManuel("questlog.php?which=6&vl=w");
parseManuel("questlog.php?which=6&vl=x");
parseManuel("questlog.php?which=6&vl=y");
parseManuel("questlog.php?which=6&vl=z");
parseManuel("questlog.php?which=6&vl=-");
}
void main()
{
print("Checking Monster Manuel...", "blue");
parseall();
print("Done checking Monster Manuel!", "blue");
print( "Monster Manuel has told you about " + monsters.count() + " different monsters" );
map_to_file( monsters, "monster_map.txt" );
print( "Raw data saved to monster_map.txt in your 'data' directory." );
foreach id, data in monsters {
string name = data.name;
string image = data.image;
monster mon = name.to_monster();
if ( mon.to_string() == "none" ){
mon = image_to_monster( image );
}
if ( mon.to_string() == "none" ){
print( "Discrepancy: KoLmafia could not find monster '" + name + "' with id " + id );
}
else if ( mon.id != id ) {
print( "Discrepancy: Manuel says monster '" + name + "' has id " + id + " but KolMafia thinks it is id " + mon.id );
}
}
}