Advertisement
NovaYoshi

goldick

Nov 13th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.69 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #include <time.h>
  6.  
  7. //http://gnuwin32.sourceforge.net/packages/wget.htm
  8.  
  9. static int Goldick(const char *Name, char *Link) {
  10.   FILE *HTMLFile = fopen(Name,"rb");
  11.   if(HTMLFile == NULL) {
  12.     fputs("Goldick Couldn't open file",stderr); return 0;
  13.   }
  14.   fseek(HTMLFile, 0, SEEK_END);
  15.   long FileSize = ftell(HTMLFile);
  16.   rewind(HTMLFile);
  17.   char *Buffer = (char*)malloc(sizeof(char)*FileSize);
  18.   if(Buffer == NULL) {
  19.     fclose(HTMLFile);
  20.     fputs("Goldick Memory error",stderr); return 0;
  21.   }
  22.   if(FileSize != fread(Buffer,1,FileSize,HTMLFile)) {
  23.     fclose(HTMLFile);
  24.     fputs("Goldick Reading error",stderr); return 0;
  25.   }
  26.   fclose(HTMLFile);
  27.  
  28.   int PokedexNum = -1, HP = 0, ATK = 0, DEF = 0, SpATK = 0, SpDEF = 0, SPD = 85;
  29.   char PokeName[64]="???";
  30.   char Type[64]="Gay";
  31.   char Kind[64]="Dick"; // dick
  32.   char URL[200] = "http://novasquirrel.com";
  33.  
  34.   char *Ptr;
  35.   Ptr = strstr(Buffer, "line-height:2.28;\"><b><a href=\"/wiki/List_of_Pok%C3%A9mon_by_National_Pok%C3%A9dex_number\" title=\"List of Pokémon by National Pokédex number");
  36.   if(Ptr != NULL) {
  37.     Ptr = strstr(Ptr, "</span>");
  38.     if(Ptr != NULL) {
  39.       while(*Ptr != '#') Ptr--;
  40.       PokedexNum = strtol(Ptr+1, NULL, 10);
  41.     }
  42.   }
  43.  
  44.   int GetStat(char *Base, char *SeekMe) {
  45.     char *Peek;
  46.     if((Peek = strstr(Base, SeekMe)) == NULL) return 0;
  47.     if((Peek = strstr(Peek, "</th>")) == NULL) return 0;
  48.     if((Peek = strstr(Peek+1, "</th>")) == NULL) return 0;
  49.     while(!isdigit(*Peek)) Peek--;
  50.     while(isdigit(*Peek)) Peek--;
  51.     return strtol(Peek+1, NULL, 10);
  52.   }
  53.  
  54.   char *BaseStats = strstr(Buffer, "<h4> <span class=\"mw-headline\" id=\"Base_stats\">Base stats</span></h4>");
  55.   if(BaseStats != NULL) {
  56.     HP = GetStat(BaseStats, "/wiki/Stats#Hit_Points");
  57.     ATK = GetStat(BaseStats, "/wiki/Stats#Attack");
  58.     DEF = GetStat(BaseStats, "/wiki/Stats#Defense");
  59.     SpATK = GetStat(BaseStats, "/wiki/Stats#Special_Attack");
  60.     SpDEF = GetStat(BaseStats, "/wiki/Stats#Special_Defense");
  61.     SPD = GetStat(BaseStats, "/wiki/Stats#Speed");
  62.   }
  63.  
  64.   int NumType = 0;
  65.   void TryType(char *LookFor, char *Name) {
  66.     if(NULL==strstr(Buffer, LookFor)) return;
  67.     if(NumType == 0) {
  68.       strcpy(Type, Name);
  69.       NumType++;
  70.     } else if(NumType == 1) {
  71.       strcat(Type, "/");
  72.       strcat(Type, Name);
  73.     }
  74.   }
  75.  
  76.   TryType("\"Normal-type Pokémon\"","Normal");
  77.   TryType("\"Ghost-type Pokémon\"","Ghost");
  78.   TryType("\"Fighting-type Pokémon\"","Fighting");
  79.   TryType("\"Electric-type Pokémon\"","Electric");
  80.   TryType("\"Grass-type Pokémon\"","Grass");
  81.   TryType("\"Psychic-type Pokémon\"","Psychic");
  82.   TryType("\"Bug-type Pokémon\"","Bug");
  83.   TryType("\"Dragon-type Pokémon\"","Dragon");
  84.   TryType("\"Ice-type Pokémon\"","Ice");
  85.   TryType("\"Dark-type Pokémon\"","Dark");
  86.   TryType("\"Steel-type Pokémon\"","Steel");
  87.   TryType("\"Poison-type Pokémon\"","Poison");
  88.   TryType("\"Fire-type Pokémon\"","Fire");
  89.   TryType("\"Water-type Pokémon\"","Water");
  90.   TryType("\"Rock-type Pokémon\"","Rock");
  91.   TryType("\"Ground-type Pokémon\"","Ground");
  92.   TryType("\"Flying-type Pokémon\"","Flying");
  93.  
  94.   Ptr = strstr(Buffer, "<title>");
  95.   if(Ptr != NULL) {
  96.     Ptr += 7;
  97.     char *Poke = PokeName;
  98.     while(*Ptr != '(')
  99.       *(Poke++) = *(Ptr++);
  100.     while(*Poke != ' ')
  101.       Poke--;
  102.     *Poke = 0;
  103.   }
  104.   sprintf(URL, "http://bulbapedia.bulbagarden.net/wiki/%s", PokeName);
  105.   for(Ptr = URL;*Ptr;Ptr++)
  106.     if(*Ptr == ' ')
  107.       *Ptr = '_';
  108.  
  109.   Ptr = strstr(Buffer, "<td> <b><a href=\"/wiki/Species\" title=\"Species\"><span style=\"color:#000;\">Species</span></a></b>");
  110.   if(Ptr != NULL) {
  111.     Ptr = strstr(Ptr, "</td></tr></table>");
  112.     if(Ptr != NULL) {
  113.       while(*Ptr != '>') Ptr--;
  114.       Ptr+=2;
  115.       char *Poke = Kind;
  116.       while(!(Ptr[1]=='P'&&Ptr[2]=='o'&&Ptr[3]=='k'))
  117.         *(Poke++) = *(Ptr++);
  118.       *Poke = 0;
  119.       if(!strcasecmp(Kind, "Duck"))
  120.         strcpy(Kind, "Dick");
  121.     }
  122.   }
  123.  
  124.   if(HP !=  0)
  125.     printf("#%.3i %s, the %s Pokemon. %s type. Base stats: HP %i, ATK %i, DEF %i, SpATK %i, SpDEF %i, SPD %i, TOTAL %i. %s", PokedexNum, PokeName, Kind, Type, HP, ATK, DEF, SpATK, SpDEF, SPD, HP+ATK+DEF+SpATK+SpDEF+SPD, URL);
  126.   else
  127.     printf("Are you sure that's a Pokemon?");
  128.  
  129.   free(Buffer);
  130.   return 1;
  131. }
  132.  
  133. int main(int argc, char *argv[]) {
  134.   srand((unsigned)time(NULL));
  135.   if(argc < 2){puts(":("); return -1;}
  136.   remove("pokeymans.html");
  137.   char Buff[768];
  138.  
  139.   if(!strcasecmp(argv[1],"NovaSquirrel")) {
  140.     printf("#??? NovaSquirrel, the Dickgirl Pokemon. Electric type. Base stats: HP 100, ATK 100, DEF 100, SpATK 100, SpDEF 100, SPD 100, Total 600.");
  141.   } else if(!strcasecmp(argv[1],"penis")) {
  142.     printf("#??? My Penis, the Phallic Pokemon. Normal type. Base stats: HP 1, ATK 1, DEF 1, SpATK 1, SpDEF 1, SPD 100, Total 105.");
  143.   } else if(!strcasecmp(argv[1],"fisher_price")) {
  144.     printf("#??? Fisher Price, the Go Eat Shit Fuckers Pokemon. Nuclear type. Base stats: HP -1, ATK -1, DEF -1, SpATK -1, SpDEF -1, SPD -1, Total -6.");
  145.   } else if(argv[1][0]=='.') {
  146.     char *TypeNames[] = {"Normal","Ghost","Fighting","Electric","Grass","Psychic","Bug","Dragon","Ice","Dark","Steel","Poison","Fire","Water","Rock","Ground","Flying","Nuclear",NULL};
  147.     char *Kinds[] = {"Fake","Cool","Dick","Illegal","President","Drugs","Epic","Rad"};
  148.     char *StuffNames;
  149.     int HP = 1+(rand()&255);
  150.     int ATK = 1+(rand()&255);
  151.     int DEF = 1+(rand()&255);
  152.     int SpATK = 1+(rand()&255);
  153.     int SpDEF = 1+(rand()&255);
  154.     int SPD = 1+(rand()&255);
  155.     char PokeName[100];
  156.     int i;
  157.  
  158.     for(i=0;i<strlen(argv[1]);i++)
  159.       if(argv[1][1+i]=='_')
  160.         PokeName[i] = ' ';
  161.       else
  162.         PokeName[i] = argv[1][1+i];
  163.     PokeName[i]=0;
  164.  
  165.     if(rand()&1)
  166.       printf("#??? %s, the %s Pokemon. %s type. Base stats: HP %i, ATK %i, DEF %i, SpATK %i, SpDEF %i, SPD %i, TOTAL %i.", PokeName, Kinds[(rand()>>7)&7], TypeNames[rand()%18], HP, ATK, DEF, SpATK, SpDEF, SPD, HP+ATK+DEF+SpATK+SpDEF+SPD);
  167.     else
  168.       printf("#??? %s, the %s Pokemon. %s/%s type. Base stats: HP %i, ATK %i, DEF %i, SpATK %i, SpDEF %i, SPD %i, TOTAL %i.", PokeName, Kinds[(rand()>>7)&7], TypeNames[rand()%18], TypeNames[rand()%18], HP, ATK, DEF, SpATK, SpDEF, SPD, HP+ATK+DEF+SpATK+SpDEF+SPD);
  169.   } else {
  170.     sprintf(Buff, "wget \"http://bulbapedia.bulbagarden.net/wiki/%s_(Pok%%C3%%A9mon)\" -q -O pokeymans.html", argv[1]);
  171.     system(Buff);
  172.  
  173.     char Link[1024]="";
  174.     Goldick("pokeymans.html", Link);
  175.     remove("pokeymans.html");
  176.   }
  177. }
  178. // #055 Golduck, the Dick Pokémon. Water type. Base Stats: HP 80, ATK 82, DEF 78, SpATK 95, SpDEF 80, SPD 85, TOTAL 500. http://bulbapedia.bulbagarden.net/wiki/Golduck
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement