Advertisement
wlm2048

Botania Rune Calculator

Apr 14th, 2015
1,033
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.14 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use 5.012;
  4.  
  5. use warnings;
  6. use strict;
  7.  
  8. use Data::Dumper;
  9.  
  10. my $target = $ARGV[0];
  11. $target = qq|rune of $target|;
  12.  
  13. say "Creating $target";
  14.  
  15. my $indent = "    ";
  16.  
  17. my $runes = {
  18.     'rune of lust' => {
  19.         'mana diamond' => 2,
  20.         'rune of summer' => 1,
  21.         'rune of air' => 1,
  22.     },
  23.     'rune of gluttony' => {
  24.         'mana diamond' => 2,
  25.         'rune of winter' => 1,
  26.         'rune of fire' => 1,
  27.     },
  28.     'rune of greed' => {
  29.         'mana diamond' => 2,
  30.         'rune of spring' => 1,
  31.         'rune of water' => 1,
  32.     },
  33.     'rune of sloth' => {
  34.         'mana diamond' => 2,
  35.         'rune of autumn' => 1,
  36.         'rune of air' => 1,
  37.     },
  38.     'rune of wrath' => {
  39.         'mana diamond' => 2,
  40.         'rune of winter' => 1,
  41.         'rune of earth' => 1,
  42.     },
  43.     'rune of envy' => {
  44.         'mana diamond' => 2,
  45.         'rune of winter' => 1,
  46.         'rune of water' => 1,
  47.     },
  48.     'rune of pride' => {
  49.         'mana diamond' => 2,
  50.         'rune of summer' => 1,
  51.         'rune of fire' => 1,
  52.     },
  53.     'rune of spring' => {
  54.         'sapling' => 3,
  55.         'wheat' => 1,
  56.         'rune of fire' => 1,
  57.         'rune of water' => 1,
  58.     },
  59.     'rune of summer' => {
  60.         'sand' => 2,
  61.         'slimeball' => 1,
  62.         'melon' => 1,
  63.         'rune of air' => 1,
  64.         'rune of earth' => 1,
  65.     },
  66.     'rune of autumn' => {
  67.         'leaves' => 3,
  68.         'spider eye' => 1,
  69.         'rune of air' => 1,
  70.         'rune of fire' => 1,
  71.     },
  72.     'rune of winter' => {
  73.         'snow' => 2,
  74.         'wool' => 1,
  75.         'cake' => 1,
  76.         'rune of earth' => 1,
  77.         'rune of water' => 1,
  78.     },
  79.     'rune of mana' => {
  80.         'manasteel ingot' => 5,
  81.         'mana pearl' => 1,
  82.     },
  83.     'rune of earth' => {
  84.         'manasteel ingot' => 3,
  85.         'stone' => 1,
  86.         'block of coal' => 1,
  87.         'mushroom' => 1,
  88.     },
  89.     'rune of air' => {
  90.         'manasteel ingot' => 3,
  91.         'carpet' => 1,
  92.         'feather' => 1,
  93.         'string' => 1,
  94.     },
  95.     'rune of fire' => {
  96.         'manasteel ingot' => 3,
  97.         'nether brick' => 1,
  98.         'gunpowder' => 1,
  99.         'nether wart' => 1,
  100.     },
  101.     'rune of water' => {
  102.         'manasteel ingot' => 3,
  103.         'bonemeal' => 1,
  104.         'sugar canes' => 1,
  105.         'vanilla fishing rod' => 1,
  106.     },
  107. };
  108.  
  109. my $rune = $runes->{ $target };
  110.  
  111. my $depth = 0;
  112. my $mundane = {};
  113. parse( $rune );
  114.  
  115. print "\n\n";
  116.  
  117. for my $item (sort keys %$mundane) {
  118.     say "$item: $mundane->{ $item }";
  119. }
  120.  
  121. exit;
  122.  
  123. sub runes_last {
  124.     return  1 if $a =~ /^rune of/ and $b !~ /^rune of/;
  125.     return -1 if $b =~ /^rune of/ and $a !~ /^rune of/;
  126.     return $a cmp $b;
  127. }
  128.  
  129. sub parse {
  130.     my $rune = shift;
  131.     for my $bit (sort runes_last keys $rune) {
  132.         print $indent x $depth;
  133.         if ($bit =~ /^rune of/) {
  134.             say "+ $bit";
  135.         }
  136.         else {
  137.             say "- $bit: $rune->{ $bit }";
  138.             $mundane->{ $bit } += $rune->{ $bit };
  139.         }
  140.         if ($bit =~ /^rune of/) {
  141.             $depth++;
  142.             parse( $runes->{ $bit } );
  143.             $depth--;
  144.         }
  145.     }
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement