Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use 5.012;
- use warnings;
- use strict;
- use Data::Dumper;
- my $target = $ARGV[0];
- $target = qq|rune of $target|;
- say "Creating $target";
- my $indent = " ";
- my $runes = {
- 'rune of lust' => {
- 'mana diamond' => 2,
- 'rune of summer' => 1,
- 'rune of air' => 1,
- },
- 'rune of gluttony' => {
- 'mana diamond' => 2,
- 'rune of winter' => 1,
- 'rune of fire' => 1,
- },
- 'rune of greed' => {
- 'mana diamond' => 2,
- 'rune of spring' => 1,
- 'rune of water' => 1,
- },
- 'rune of sloth' => {
- 'mana diamond' => 2,
- 'rune of autumn' => 1,
- 'rune of air' => 1,
- },
- 'rune of wrath' => {
- 'mana diamond' => 2,
- 'rune of winter' => 1,
- 'rune of earth' => 1,
- },
- 'rune of envy' => {
- 'mana diamond' => 2,
- 'rune of winter' => 1,
- 'rune of water' => 1,
- },
- 'rune of pride' => {
- 'mana diamond' => 2,
- 'rune of summer' => 1,
- 'rune of fire' => 1,
- },
- 'rune of spring' => {
- 'sapling' => 3,
- 'wheat' => 1,
- 'rune of fire' => 1,
- 'rune of water' => 1,
- },
- 'rune of summer' => {
- 'sand' => 2,
- 'slimeball' => 1,
- 'melon' => 1,
- 'rune of air' => 1,
- 'rune of earth' => 1,
- },
- 'rune of autumn' => {
- 'leaves' => 3,
- 'spider eye' => 1,
- 'rune of air' => 1,
- 'rune of fire' => 1,
- },
- 'rune of winter' => {
- 'snow' => 2,
- 'wool' => 1,
- 'cake' => 1,
- 'rune of earth' => 1,
- 'rune of water' => 1,
- },
- 'rune of mana' => {
- 'manasteel ingot' => 5,
- 'mana pearl' => 1,
- },
- 'rune of earth' => {
- 'manasteel ingot' => 3,
- 'stone' => 1,
- 'block of coal' => 1,
- 'mushroom' => 1,
- },
- 'rune of air' => {
- 'manasteel ingot' => 3,
- 'carpet' => 1,
- 'feather' => 1,
- 'string' => 1,
- },
- 'rune of fire' => {
- 'manasteel ingot' => 3,
- 'nether brick' => 1,
- 'gunpowder' => 1,
- 'nether wart' => 1,
- },
- 'rune of water' => {
- 'manasteel ingot' => 3,
- 'bonemeal' => 1,
- 'sugar canes' => 1,
- 'vanilla fishing rod' => 1,
- },
- };
- my $rune = $runes->{ $target };
- my $depth = 0;
- my $mundane = {};
- parse( $rune );
- print "\n\n";
- for my $item (sort keys %$mundane) {
- say "$item: $mundane->{ $item }";
- }
- exit;
- sub runes_last {
- return 1 if $a =~ /^rune of/ and $b !~ /^rune of/;
- return -1 if $b =~ /^rune of/ and $a !~ /^rune of/;
- return $a cmp $b;
- }
- sub parse {
- my $rune = shift;
- for my $bit (sort runes_last keys $rune) {
- print $indent x $depth;
- if ($bit =~ /^rune of/) {
- say "+ $bit";
- }
- else {
- say "- $bit: $rune->{ $bit }";
- $mundane->{ $bit } += $rune->{ $bit };
- }
- if ($bit =~ /^rune of/) {
- $depth++;
- parse( $runes->{ $bit } );
- $depth--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement