//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
record RaidEntry
{
    int ID; //ID
    string A;//action
    string EA;//extended action
    int TS;//turns spent
};
RaidEntry [int][int] RaidLog;//logger
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
void ParseGroup(int Z, string PageData, )
{
    matcher RaidMatch; //Raid Matcher
    int E=1; //Entry Counter
    
    if(Z==9 || Z==11)
        RaidMatch= create_matcher( "(.+?) \\(#(\\d+)\\) distributed <b>(.+?)</b> to (.+?) \\(#(\\d+)\\)" , PageData );
    else
        RaidMatch= create_matcher( "(.+?) \\(#(\\d+)\\) (.+?) (.+?) \\((\\d+) (turns|turn)\\)" , PageData );
        
    while( RaidMatch.find() )
    {
        RaidLog[Z][E].ID=RaidMatch.group( 2 ).to_int();
        RaidLog[Z][E].A=RaidMatch.group( 3 );
        RaidLog[Z][E].EA=RaidMatch.group( 4 );
        RaidLog[Z][E].TS=RaidMatch.group( 5 ).to_int();
        E=E+1;
    }
}
void ParseRaidLogs ()
{    
    matcher Zone; //Zone Matcher
    string PageData; //PageData
    string Hobopolis;//PageData
    string SlimeTube;//PageData
    int Z=1; //Zone Counter    
        
    //capture and split pagedata
    PageData= visit_url( "clan_raidlogs.php" ); //Capture Page
    Zone= create_matcher("<b>Hobopolis:</b>(.+?)<b>The Slime Tube:</b>",PageData);
    if(Zone.find())    Hobopolis=Zone.group(1);
    Zone= create_matcher("<b>The Slime Tube:</b>(.+?)<b>Previous Clan Dungeon Runs:</b>",PageData);
    if(Zone.find())    SlimeTube=Zone.group(1);
        
    while (Z<=11)
    {
        switch (Z)
        {
            case 1:
            Zone= create_matcher( "<b>Exposure Esplanade:</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 2:
            Zone= create_matcher( "<b>The Heap:</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 3:
            Zone= create_matcher( "<b>Sewers:</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 4:
            Zone= create_matcher( "<b>The Ancient Hobo Burial Ground:</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 5:
            Zone= create_matcher( "<b>Miscellaneous</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 6:
            Zone= create_matcher( "<b>Town Square:</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 7:
            Zone= create_matcher( "<b>Burnbarrel Blvd.:</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 8:
            Zone= create_matcher( "<b>The Purple Light District:</b><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 9:
            Zone= create_matcher( "<p><b>Loot Distribution:</b><p><blockquote>(.+?)</blockquote>" , Hobopolis ); break;
            case 10:
            Zone= create_matcher( "<b>Miscellaneous</b><blockquote>(.+?)</blockquote>" ,  SlimeTube ); break;
            case 11:
            Zone= create_matcher( "<p><b>Loot Distribution:</b><p><blockquote>(.+?)</blockquote>" ,  SlimeTube ); break;
        }
        if(Zone.find())    ParseGroup(Z, Zone.group(1));
        Z=Z+1;
    }
    map_to_file(RaidLog, "mredge73_RAID.txt");
    //print("LogCaptured");
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
/*
Zones by Number
1=EE
2=Heap
3=Sewer
4=Burial
5=Misc
6=Town
7=BB
8=Purple
9=Hobo Loot
10=Slime
11=Slime Loot
*/
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int TurnCount(int Z)
{
    ParseRaidLogs ();
    int Total=0;
    int C = Count (RaidLog[Z]);
    if(Z==9 || Z==11) return C;
    int E =    1;        
    while (E<=C)
    {
        if(Z==10 && contains_text(RaidLog[Z][E].EA, "Mother")) RaidLog[Z][E].TS=0;        
        Total=Total+RaidLog[Z][E].TS;
        E=E+1;
    }
    return Total;
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int HoboTotal()
{
    ParseRaidLogs ();
    int Z=1;
    int Total=0;
    while (Z<=8)
    {
        int E =    1;    
        while (E<=Count (RaidLog[Z]))
        {
            Total=Total+RaidLog[Z][E].TS;
            E=E+1;
        }    
    Z=Z+1;
    }
    return Total;    
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int SlimeTotal()
{ return TurnCount(10);}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
void main()
{
    print("Hobopolis Turn Count: "+HoboTotal());
    print("SlimeTube Turn Count: "+SlimeTotal());
    print("Done");
}