Advertisement
TanGeng

TLopterBP.pl

Apr 16th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 14.06 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # file: optdota2.pl
  3.  
  4. use FileHandle;
  5.  
  6. ### big hero map
  7. my %bans = (
  8.     Abaddon=>"[url=http://wiki.teamliquid.net/dota2/Abaddon][img]http://i.imgur.com/ktBKtNJ.png[/img][/url]",
  9.     Alchemist=>"[url=http://wiki.teamliquid.net/dota2/Alchemist][h]alchemist[/h][/url]",
  10.     AncientApparition=>"[url=http://wiki.teamliquid.net/dota2/Ancient_Apparition][h]ancient[/h][/url]",
  11.     Antimage=>"[url=http://wiki.teamliquid.net/dota2/Antimage][h]antimage[/h][/url]",
  12.     Axe=>"[url=http://wiki.teamliquid.net/dota2/Axe][h]axe[/h][/url]",
  13.     Bane=>"[url=http://wiki.teamliquid.net/dota2/Bane][h]bane[/h][/url]",
  14.     Batrider=>"[url=http://wiki.teamliquid.net/dota2/Batrider][h]batrider[/h][/url]",
  15.     Beastmaster=>"[url=http://wiki.teamliquid.net/dota2/Beastmaster][h]beastmaster[/h][/url]",
  16.     Bloodseeker=>"[url=http://wiki.teamliquid.net/dota2/Bloodseeker][h]bloodseeker[/h][/url]",
  17.     BountyHunter=>"[url=http://wiki.teamliquid.net/dota2/Bounty_Hunter][h]bounty[/h][/url]",
  18.     Brewmaster=>"[url=http://wiki.teamliquid.net/dota2/Brewmaster][h]brewmaster[/h][/url]",
  19.     Bristleback=>"[url=http://wiki.teamliquid.net/dota2/Bristleback][h]bristleback[/h][/url]",
  20.     Broodmother=>"[url=http://wiki.teamliquid.net/dota2/Broodmother][img]http://i.imgur.com/bVzNEjn.png[/img][/url]",
  21.     Centaur=>"[url=http://wiki.teamliquid.net/dota2/Centaur_Warrunner][h]centaur[/h][/url]",
  22.     ChaosKnight=>"[url=http://wiki.teamliquid.net/dota2/Chaos_Knight][h]chaos[/h][/url]",
  23.     Chen=>"[url=http://wiki.teamliquid.net/dota2/Chen][h]chen[/h][/url]",
  24.     Clinkz=>"[url=http://wiki.teamliquid.net/dota2/Clinkz][h]clinkz[/h][/url]",
  25.     Clockwerk=>"[url=http://wiki.teamliquid.net/dota2/Clockwerk][h]clockwerk[/h][/url]",
  26.     CrystalMaiden=>"[url=http://wiki.teamliquid.net/dota2/Crystal_Maiden][h]crystal[/h][/url]",
  27.     DarkSeer=>"[url=http://wiki.teamliquid.net/dota2/Dark_Seer][h]darkseer[/h][/url]",
  28.     Dazzle=>"[url=http://wiki.teamliquid.net/dota2/Dazzle][h]dazzle[/h][/url]",
  29.     DeathProphet=>"[url=http://wiki.teamliquid.net/dota2/Death_Prophet][h]death[/h][/url]",
  30.     Disruptor=>"[url=http://wiki.teamliquid.net/dota2/Disruptor][h]disruptor[/h][/url]",
  31.     Doom=>"[url=http://wiki.teamliquid.net/dota2/Doom][h]doom[/h][/url]",
  32.     DragonKnight=>"[url=http://wiki.teamliquid.net/dota2/Dragon_Knight][h]dragon[/h][/url]",
  33.     Drow=>"[url=http://wiki.teamliquid.net/dota2/Drow_Ranger][h]drow[/h][/url]",
  34.     Earth=>"[url=http://wiki.teamliquid.net/dota2/Earth_Spirit][img]http://i.imgur.com/oXFNyJS.png[/img][/url]",
  35.     Earthshaker=>"[url=http://wiki.teamliquid.net/dota2/Earthshaker][h]earthshaker[/h][/url]",
  36.     ElderTitan=>"[url=http://wiki.teamliquid.net/dota2/Elder_Titan][img]http://i.imgur.com/MkLSGDo.png[/img][/url]",
  37.     Ember=>"[url=http://wiki.teamliquid.net/dota2/Ember_Spirit][img]http://i.imgur.com/ILnRXSb.png[/img][/url]",
  38.     Enchantress=>"[url=http://wiki.teamliquid.net/dota2/Enchantress][h]enchantress[/h][/url]",
  39.     Enigma=>"[url=http://wiki.teamliquid.net/dota2/Enigma][h]enigma[/h][/url]",
  40.     Faceless=>"[url=http://wiki.teamliquid.net/dota2/Faceless_Void][h]faceless[/h][/url]",
  41.     Gyrocopter=>"[url=http://wiki.teamliquid.net/dota2/Gyrocopter][h]gyrocopter[/h][/url]",
  42.     Huskar=>"[url=http://wiki.teamliquid.net/dota2/Huskar][h]huskar[/h][/url]",
  43.     Invoker=>"[url=http://wiki.teamliquid.net/dota2/Invoker][h]invoker[/h][/url]",
  44.     Io=>"[url=http://wiki.teamliquid.net/dota2/Io][h]io[/h][/url]",
  45.     Jakiro=>"[url=http://wiki.teamliquid.net/dota2/Jakiro][h]jakiro[/h][/url]",
  46.     Juggernaut=>"[url=http://wiki.teamliquid.net/dota2/Juggernaut][h]juggernaut[/h][/url]",
  47.     Keeper=>"[url=http://wiki.teamliquid.net/dota2/Keeper_of_the_Light][h]keeper[/h][/url]",
  48.     Kunkka=>"[url=http://wiki.teamliquid.net/dota2/Kunkka][h]kunkka[/h][/url]",
  49.     Legion=>"[url=http://wiki.teamliquid.net/dota2/Legion_Commander][img]http://i.imgur.com/Jfdfzde.png[/img][/url]",
  50.     Leshrac=>"[url=http://wiki.teamliquid.net/dota2/Leshrac][h]leshrac[/h][/url]",
  51.     Lich=>"[url=http://wiki.teamliquid.net/dota2/Lich][h]lich[/h][/url]",
  52.     Lifestealer=>"[url=http://wiki.teamliquid.net/dota2/Lifestealer][h]lifestealer[/h][/url]",
  53.     Lina=>"[url=http://wiki.teamliquid.net/dota2/Lina][h]lina[/h][/url]",
  54.     Lion=>"[url=http://wiki.teamliquid.net/dota2/Lion][img]http://i.imgur.com/UIBEKN7.png[/img][/url]",
  55.     LoneDruid=>"[url=http://wiki.teamliquid.net/dota2/Lone_Druid][h]lone[/h][/url]",
  56.     Luna=>"[url=http://wiki.teamliquid.net/dota2/Luna][h]luna[/h][/url]",
  57.     Lycan=>"[url=http://wiki.teamliquid.net/dota2/Lycanthrope][h]lycanthrope[/h][/url]",
  58.     Magnus=>"[url=http://wiki.teamliquid.net/dota2/Magnus][h]magnus[/h][/url]",
  59.     Medusa=>"[url=http://wiki.teamliquid.net/dota2/Medusa][h]medusa[/h][/url]",
  60.     Meepo=>"[url=http://wiki.teamliquid.net/dota2/Meepo][h]meepo[/h][/url]",
  61.     Mirana=>"[url=http://wiki.teamliquid.net/dota2/Mirana][h]mirana[/h][/url]",
  62.     Morphling=>"[url=http://wiki.teamliquid.net/dota2/Morphling][h]morphling[/h][/url]",
  63.     Naga=>"[url=http://wiki.teamliquid.net/dota2/Naga_Siren][h]naga[/h][/url]",
  64.     Natures=>"[url=http://wiki.teamliquid.net/dota2/Natures_Prophet][h]natures[/h][/url]",
  65.     Necro=>"[url=http://wiki.teamliquid.net/dota2/Necrolyte][h]necrolyte[/h][/url]",
  66.     Night=>"[url=http://wiki.teamliquid.net/dota2/Night_Stalker][h]night[/h][/url]",
  67.     Nyx=>"[url=http://wiki.teamliquid.net/dota2/Nyx_Assassin][h]nyx[/h][/url]",
  68.     OgreMagi=>"[url=http://wiki.teamliquid.net/dota2/Ogre_Magi][h]ogre[/h][/url]",
  69.     Omni=>"[url=http://wiki.teamliquid.net/dota2/Omniknight][h]omniknight[/h][/url]",
  70.     Outworld=>"[url=http://wiki.teamliquid.net/dota2/Outworld_Devourer][h]outworld[/h][/url]",
  71.     PhantomAssassin=>"[url=http://wiki.teamliquid.net/dota2/Phantom_Assassin][h]phantomassassin[/h][/url]",
  72.     PhantomLancer=>"[url=http://wiki.teamliquid.net/dota2/Phantom_Lancer][h]phantomlancer[/h][/url]",
  73.     Phoenix=>"[url=http://wiki.teamliquid.net/dota2/Phoenix][img]http://i.imgur.com/4n7fnMh.png[/img][/url]",
  74.     Puck=>"[url=http://wiki.teamliquid.net/dota2/Puck][h]puck[/h][/url]",
  75.     Pudge=>"[url=http://wiki.teamliquid.net/dota2/Pudge][h]pudge[/h][/url]",
  76.     Pugna=>"[url=http://wiki.teamliquid.net/dota2/Pugna][h]pugna[/h][/url]",
  77.     Queen=>"[url=http://wiki.teamliquid.net/dota2/Queen_of_Pain][h]queen[/h][/url]",
  78.     Razor=>"[url=http://wiki.teamliquid.net/dota2/Razor][h]razor[/h][/url]",
  79.     Riki=>"[url=http://wiki.teamliquid.net/dota2/Riki][h]riki[/h][/url]",
  80.     Rubick=>"[url=http://wiki.teamliquid.net/dota2/Rubick][h]rubick[/h][/url]",
  81.     SandKing=>"[url=http://wiki.teamliquid.net/dota2/Sand_King][h]sand[/h][/url]",
  82.     ShadowDemon=>"[url=http://wiki.teamliquid.net/dota2/Shadow_Demon][h]shadowdemon[/h][/url]",
  83.     ShadowFiend=>"[url=http://wiki.teamliquid.net/dota2/Shadow_Fiend][h]shadowfiend[/h][/url]",
  84.     ShadowShaman=>"[url=http://wiki.teamliquid.net/dota2/Shadow_Shaman][h]shadowshaman[/h][/url]",
  85.     Silencer=>"[url=http://wiki.teamliquid.net/dota2/Silencer][img]http://i.imgur.com/VJUI4S9.png[/img][/url]",
  86.     Skywrath=>"[url=http://wiki.teamliquid.net/dota2/Skywrath_Mage][img]http://i.imgur.com/I6HXI9F.png[/img][/url]",
  87.     Slardar=>"[url=http://wiki.teamliquid.net/dota2/Slardar][h]slardar[/h][/url]",
  88.     Slark=>"[url=http://wiki.teamliquid.net/dota2/Slark][h]slark[/h][/url]",
  89.     Sniper=>"[url=http://wiki.teamliquid.net/dota2/Sniper][h]sniper[/h][/url]",
  90.     Spectre=>"[url=http://wiki.teamliquid.net/dota2/Spectre][h]spectre[/h][/url]",
  91.     SpiritBreaker=>"[url=http://wiki.teamliquid.net/dota2/Spirit_Breaker][h]spirit[/h][/url]",
  92.     Storm=>"[url=http://wiki.teamliquid.net/dota2/Storm_Spirit][img]http://i.imgur.com/cyTlhAk.png[/img][/url]",
  93.     Sven=>"[url=http://wiki.teamliquid.net/dota2/Sven][h]sven[/h][/url]",
  94.     Templar=>"[url=http://wiki.teamliquid.net/dota2/Templar_Assassin][h]templar[/h][/url]",
  95.     Terrorblade=>"[url=http://wiki.teamliquid.net/dota2/Terrorblade][img]http://i.imgur.com/8OT6Tyx.png[/img][/url]",
  96.     Tidehunter=>"[url=http://wiki.teamliquid.net/dota2/Tidehunter][h]tidehunter[/h][/url]",
  97.     Timbersaw=>"[url=http://wiki.teamliquid.net/dota2/Timbersaw][h]timbersaw[/h][/url]",
  98.     Tinker=>"[url=http://wiki.teamliquid.net/dota2/Tinker][h]tinker[/h][/url]",
  99.     Tiny=>"[url=http://wiki.teamliquid.net/dota2/Tiny][h]tiny[/h][/url]",
  100.     Treant=>"[url=http://wiki.teamliquid.net/dota2/Treant_Protector][h]treant[/h][/url]",
  101.     Troll=>"[url=http://wiki.teamliquid.net/dota2/Troll_Warlord][h]troll[/h][/url]",
  102.     Tusk=>"[url=http://wiki.teamliquid.net/dota2/Tusk][h]tusk[/h][/url]",
  103.     Undying=>"[url=http://wiki.teamliquid.net/dota2/Undying][h]undying[/h][/url]",
  104.     Ursa=>"[url=http://wiki.teamliquid.net/dota2/Ursa][h]ursa[/h][/url]",
  105.     Vengeful=>"[url=http://wiki.teamliquid.net/dota2/Vengeful_Spirit][h]vengeful[/h][/url]",
  106.     Venomancer=>"[url=http://wiki.teamliquid.net/dota2/Venomancer][img]http://i.imgur.com/5mI8G4v.png[/img][/url]",
  107.     Viper=>"[url=http://wiki.teamliquid.net/dota2/Viper][img]http://i.imgur.com/2PJPJv0.png[/img][/url]",
  108.     Visage=>"[url=http://wiki.teamliquid.net/dota2/Visage][h]visage[/h][/url]",
  109.     Warlock=>"[url=http://wiki.teamliquid.net/dota2/Warlock][h]warlock[/h][/url]",
  110.     Weaver=>"[url=http://wiki.teamliquid.net/dota2/Weaver][h]weaver[/h][/url]",
  111.     Windranger=>"[url=http://wiki.teamliquid.net/dota2/Windrunner][h]windrunner[/h][/url]",
  112.     WitchDoctor=>"[url=http://wiki.teamliquid.net/dota2/Witch_Doctor][h]witchdoctor[/h][/url]",
  113.     WraithKing=>"[url=http://wiki.teamliquid.net/dota2/Wraith_King][img]http://i.imgur.com/JOwHsVC.png[/img][/url]",
  114.     Zeus=>"[url=http://wiki.teamliquid.net/dota2/Zeus][h]zeus[/h][/url]",
  115. );
  116.  
  117. ########################################################################
  118. ### side and first pick
  119. ###   this is from arguments
  120. $pick1st=$ARGV[0];
  121. printf("$pick1st First Pick\n");
  122. $pick2nd="Dire";
  123.  
  124. $side1st=$ARGV[1];
  125. printf("$side1st on Left\n");
  126.  
  127. $filename=$ARGV[2];
  128.  
  129. if ($pick1st eq "Dire")
  130. {
  131.     $pick2nd="Radi";
  132. }
  133. elsif ($pick1st eq "Radi")
  134. {
  135.     $pick2nd="Dire";
  136. }
  137. else
  138. {
  139.     printf("HALP!!! Tell me which side has first pick. \"Radi\"|\"Dire\" \n");
  140.     exit 0;
  141. }
  142.  
  143. if ($side1st eq "Dire")
  144. {
  145. }
  146. elsif ($side1st eq "Radi")
  147. {
  148. }
  149. else
  150. {
  151.     printf("HALP!!! Tell me which side should be on left. \"Radi\"|\"Dire\" \n");
  152.     exit 0;
  153. }
  154.  
  155. my $outfile;
  156. if ($filename eq "")
  157. {
  158.     printf("Writing output to stdout.\n");
  159.     $outfile=\*STDOUT;
  160. }
  161. else
  162. {
  163.     printf("Opening file $filename for writing.\n");
  164.     $outfile=FileHandle->new("$filename", "a+");
  165.     if (!defined $outfile)
  166.     {
  167.         printf("HALP!!! Could not open $filename for writing\n");
  168.         exit 0;
  169.     }
  170. }
  171.  
  172.  
  173. ### end side and first pick
  174. ########################################################################
  175.  
  176. ########################################################################
  177. ### hero acquisition
  178. ###   ban pick process in order appearance
  179. @bpProcess=(
  180.     ["1","Ban"],
  181.     ["2","Ban"],
  182.     ["1","Ban"],
  183.     ["2","Ban"],
  184.     ["1","Pick"],
  185.     ["2","Pick"],
  186.     ["2","Pick"],
  187.     ["1","Pick"],
  188.     ["1","Ban"],
  189.     ["2","Ban"],
  190.     ["1","Ban"],
  191.     ["2","Ban"],
  192.     ["2","Pick"],
  193.     ["1","Pick"],
  194.     ["2","Pick"],
  195.     ["1","Pick"],
  196.     ["2","Ban"],
  197.     ["1","Ban"],
  198.     ["2","Pick"],
  199.     ["1","Pick"],
  200. );
  201.  
  202. sub initSideAssign {
  203.     $picknum=0;
  204.     while ($picknum < 20) {
  205.         if ($bpProcess[$picknum][0] eq "1") {
  206.             $bpProcess[$picknum][0] = $_[0];
  207.         }
  208.         if ($bpProcess[$picknum][0] eq "2") {
  209.             $bpProcess[$picknum][0] = $_[1];
  210.         }
  211.         $picknum++;
  212.     }
  213. }
  214.  
  215. ###   prompt for heroes
  216. sub getAHeroName {
  217.     my $newname;
  218.     do {
  219.         print "$_[0]: $bpProcess[$_[0]][0] $bpProcess[$_[0]][1]: ";
  220.         $newname = <STDIN>;
  221.         chomp $newname;
  222.     } while (!exists $bans{$newname} );
  223.     #verify hero
  224.     return $newname;
  225. }
  226.  
  227. ### initialize the picking sides
  228. initSideAssign($pick1st,$pick2nd);
  229.  
  230. @heronames;
  231. $pick=0;
  232. while ($pick < 20) {
  233.     $heronames[$pick]=getAHeroName($pick);
  234.     $pick++;
  235. }
  236.  
  237. printf("\npicks/bans entry completed\n");
  238. ### end hero acquisition
  239. ########################################################################
  240.  
  241.  
  242. ########################################################################
  243. ### pick sorting
  244. @radipicks;
  245. @direpicks;
  246. @radibans;
  247. @direbans;
  248. $radipick=0;
  249. $direpick=0;
  250. $radiban=0;
  251. $direban=0;
  252. $pick=0;
  253. while ($pick < 20) {
  254.     $side=$bpProcess[$pick][0];
  255.     $type=$bpProcess[$pick][1];
  256.     $link=$bans{$heronames[$pick]};
  257.  
  258.     if ($type eq "Ban")
  259.     {
  260.         if ($side eq "Dire")
  261.         {
  262.             $direbans[$direban]=$link;
  263.             $direban++;
  264.         }
  265.         else
  266.         {
  267.             $radibans[$radiban]=$link;
  268.             $radiban++;
  269.         }
  270.     }
  271.     else
  272.     {
  273.         if ($side eq "Dire")
  274.         {
  275.             $direpicks[$direpick]=$link;
  276.             $direpick++;
  277.         }
  278.         else
  279.         {
  280.             $radipicks[$radipick]=$link;
  281.             $radipick++;
  282.         }  
  283.     }
  284.     $pick++;
  285. }
  286. ### end pick sorting
  287. ########################################################################
  288.  
  289.  
  290. ########################################################################
  291. ### output formatting
  292. sub makeRadiPickLine {
  293.     return $radipicks[0]." ".$radipicks[1]." ".$radipicks[2]." ".$radipicks[3]." ".$radipicks[4]."[img]http://i.imgur.com/H1j7SBU.png[/img]".$direpicks[0]." ".$direpicks[1]." ".$direpicks[2]." ".$direpicks[3]." ".$direpicks[4];
  294. }
  295.  
  296. sub makeRadiBanLine {
  297.     return $radibans[0]." ".$radibans[1]." ".$radibans[2]." ".$radibans[3]." ".$radibans[4]."[img]http://i.imgur.com/4HTXS8I.png[/img]".$direbans[0]." ".$direbans[1]." ".$direbans[2]." ".$direbans[3]." ".$direbans[4];
  298. }
  299.  
  300. sub makeDirePickLine {
  301.     return $direpicks[0]." ".$direpicks[1]." ".$direpicks[2]." ".$direpicks[3]." ".$direpicks[4]."[img]http://i.imgur.com/H1j7SBU.png[/img]".$radipicks[0]." ".$radipicks[1]." ".$radipicks[2]." ".$radipicks[3]." ".$radipicks[4];
  302. }
  303.  
  304. sub makeDireBanLine {
  305.     return $direbans[0]." ".$direbans[1]." ".$direbans[2]." ".$direbans[3]." ".$direbans[4]."[img]http://i.imgur.com/4HTXS8I.png[/img]".$radibans[0]." ".$radibans[1]." ".$radibans[2]." ".$radibans[3]." ".$radibans[4];
  306. }
  307.  
  308. if ($side1st eq "Radi")
  309. {
  310.     print $outfile "[center]\n";
  311.     $pickline=makeRadiPickLine();
  312.     print $outfile "$pickline\n";
  313.     $divider="[img]http://i.imgur.com/vvshEHz.png[/img]";
  314.     print $outfile "$divider\n";
  315.     $banline=makeRadiBanLine();
  316.     print $outfile "$banline\n";
  317.     print $outfile "[/center]\n";
  318. }
  319. else
  320. {
  321.     print $outfile "[center]\n";
  322.     $pickline=makeDirePickLine();
  323.     print $outfile "$pickline\n";
  324.     $divider="[img]http://i.imgur.com/M0IcDHl.png[/img]";
  325.     print $outfile "$divider\n";
  326.     $banline=makeDireBanLine();
  327.     print $outfile "$banline\n";
  328.     print $outfile "[/center]\n";
  329. }
  330.  
  331. undef $outfile;
  332. ### end output formatting
  333. ########################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement