#!/usr/bin/perl -w use strict; # read catgod output my $godid; my $goddom = 0; my $godfire = 0; my $godwater = 0; my $godair = 0; my $godearth = 0; my $godastral = 0; my $goddeath = 0; my $godnature = 0; my $godblood = 0; my $godawake; my $order = 0; my $prod = 0; my $heat = 0; my $growth = 0; my $luck = 0; my $magic = 0; my $line; $line=<>; # throw out name and titles $line=<>; # throw out nation $line=<>; # this line has the body number if ($line =~ /Body (\d+)/) { $godid = $1; } else { die "Can't read god id!\n"; } $line=<>; # this line has magic if ($line =~ /Magic:/) { if ($line =~ /Earth (\d+)/) { $godearth = $1; } if ($line =~ /Fire (\d+)/) { $godfire = $1; } if ($line =~ /Water (\d+)/) { $godwater = $1; } if ($line =~ /Air (\d+)/) { $godair = $1; } if ($line =~ /Death (\d+)/) { $goddeath = $1; } if ($line =~ /Astral (\d+)/) { $godastral = $1; } if ($line =~ /Nature (\d+)/) { $godnature = $1; } if ($line =~ /Blood (\d+)/) { $godblood = $1; } } else { die "Can't read magic!\n"; } $line=<>; # This line has dominion if ($line =~ /Dominion (\d+)/) { $goddom = $1; } else { die "Can't read dominion!\n"; } $line=<>; # This line has scales if ($line =~ /Scales:/) { if ($line =~ /Turmoil (\d+)/) { $order = -$1; } if ($line =~ /Sloth (\d+)/) { $prod = -$1; } if ($line =~ /Cold (\d+)/) { $heat = -$1; } if ($line =~ /Death (\d+)/) { $growth = -$1; } if ($line =~ /Misfortune (\d+)/) { $luck = -$1; } if ($line =~ /Drain (\d+)/) { $magic = -$1; } if ($line =~ /Order (\d+)/) { $order = $1; } if ($line =~ /Productivity (\d+)/) { $prod = $1; } if ($line =~ /Heat (\d+)/) { $heat = $1; } if ($line =~ /Growth (\d+)/) { $growth = $1; } if ($line =~ /Fortune (\d+)/) { $luck = $1; } if ($line =~ /Magic (\d+)/) { $magic = $1; } } else { die "Can't read scales!\n"; } $line=<>; # This line has awakeness $godawake = $line; # read base information my $id = -1; my $mycost = -1; my $dom = -1; my $pathcost = -1; my $fire = -1; my $water = -1; my $air = -1; my $earth = -1; my $astral = -1; my $death = -1; my $nature = -1; my $blood = -1; open(CSV,"pretenders.csv") or die "Can't open pretenders.csv!"; $_=; # chop off first line my @labels = split(",",); my $i; for ($i=0;$i<@labels;$i++) { if ($labels[$i] eq "\"id#\"") { $id = $i; } elsif ($labels[$i] eq "\"path\"") { $pathcost = $i; } elsif ($labels[$i] eq "\"dom\"") { $dom = $i; } elsif ($labels[$i] eq "\"gold\"") { $mycost = $i; } elsif ($labels[$i] eq "\"F\"") { $fire = $i; } elsif ($labels[$i] eq "\"A\"") { $air = $i; } elsif ($labels[$i] eq "\"W\"") { $water = $i; } elsif ($labels[$i] eq "\"E\"") { $earth = $i; } elsif ($labels[$i] eq "\"S\"") { $astral = $i; } elsif ($labels[$i] eq "\"D\"") { $death = $i; } elsif ($labels[$i] eq "\"N\"") { $nature = $i; } elsif ($labels[$i] eq "\"B\"") { $blood = $i; } } ($id!=-1) or die "Couldn't find id field!\n"; ($mycost!=-1) or die "Couldn't find cost field!\n"; ($pathcost!=-1) or die "Couldn't find pathcost field!\n"; ($dom!=-1) or die "Couldn't find dom field!\n"; ($fire!=-1) or die "Couldn't find fire field!\n"; ($air!=-1) or die "Couldn't find air field!\n"; ($earth!=-1) or die "Couldn't find earth field!\n"; ($water!=-1) or die "Couldn't find water field!\n"; ($death!=-1) or die "Couldn't find death field!\n"; ($astral!=-1) or die "Couldn't find astral field!\n"; ($nature!=-1) or die "Couldn't find nature field!\n"; ($blood!=-1) or die "Couldn't find blood field!\n"; my $basecost = 0; my $basedom = 0; my $basepathcost = 0; my $baseair = 0; my $basefire = 0; my $baseearth = 0; my $basewater = 0; my $baseastral = 0; my $basedeath = 0; my $basenature = 0; my $baseblood = 0; while ($line=) { my @fields=split(",",$line); if ($fields[$id]==$godid) { $basecost=$fields[$mycost]; $basedom=$fields[$dom]; $basepathcost=$fields[$pathcost]; $basefire=$fields[$fire]; $baseair=$fields[$air]; $baseearth=$fields[$earth]; $basewater=$fields[$water]; $baseastral=$fields[$astral]; $basedeath=$fields[$death]; $basenature=$fields[$nature]; $baseblood=$fields[$blood]; if ($basefire eq "\"\"") { $basefire = 0; } if ($baseair eq "\"\"") { $baseair = 0; } if ($baseearth eq "\"\"") { $baseearth = 0; } if ($basewater eq "\"\"") { $basewater = 0; } if ($baseastral eq "\"\"") { $baseastral = 0; } if ($basedeath eq "\"\"") { $basedeath = 0; } if ($basenature eq "\"\"") { $basenature = 0; } if ($baseblood eq "\"\"") { $baseblood = 0; } } } close(CSV); # Finally, it's time for the math my $cost = $basecost; if ($godawake =~ /Dormant/) { $cost-=150; } if ($godawake =~ /Imprisoned/) { $cost-=250; } # Scales $cost += $order*40; $cost += $prod*40; $cost += -abs($heat)*40; $cost += $growth*40; $cost += $luck*40; $cost += $magic*40; # Dominion my $domdiff = $goddom-$basedom; $cost += 7*$domdiff*($domdiff+1)/2; # Magic my $pathdiff = 0; if ($godfire) { if ($basefire>0) { $pathdiff = $godfire-$basefire; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $godfire; $cost += $basepathcost+4*($pathdiff+1)*$pathdiff-8; } } if ($godair) { if ($baseair>0) { $pathdiff = $godair-$baseair; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $godair; $cost += $basepathcost+4*$pathdiff*($pathdiff+1)-8; } } if ($godwater) { if ($basewater>0) { $pathdiff = $godwater-$basewater; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $godwater; $cost += $basepathcost+4*($pathdiff+1)*$pathdiff-8; } } if ($godearth) { if ($baseearth>0) { $pathdiff = $godearth-$baseearth; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $godearth; $cost += $basepathcost+4*($pathdiff+1)*$pathdiff-8; } } if ($godastral) { if ($baseastral>0) { $pathdiff = $godastral-$baseastral; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $godastral; $cost += $basepathcost+4*($pathdiff+1)*$pathdiff-8; } } if ($goddeath) { if ($basedeath>0) { $pathdiff = $goddeath-$basedeath; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $goddeath; $cost += $basepathcost+4*($pathdiff+1)*$pathdiff-8; } } if ($godnature) { if ($basenature>0) { $pathdiff = $godnature-$basenature; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $godnature; $cost += $basepathcost+4*($pathdiff+1)*$pathdiff-8; } } if ($godblood) { if ($baseblood>0) { $pathdiff = $godblood-$baseblood; $cost += 4*$pathdiff*($pathdiff+1); } else { $pathdiff = $godblood; $cost += $basepathcost+4*($pathdiff+1)*$pathdiff-8; } } print "$cost\n";