#!/usr/bin/perl
# 
# nethackintrinsics.pl

# I modified the function X11_PutStr in the nethack source so that all
# messages would be printed to stdout, which I can then redirect to a file.
# This script goes through the message transcript and tries to find out
# what intrinsics you have, how you got them, and which ones you need.
#
# Currently the only two intrinsics which cannot be scrapped from the
# message log are invsibility and speed.  There is no message from
# invisibility and the speed intrinsic can be confused with other ways of
# gaining temporary speed (e.g. from a wand).

# input file, transcript of nethack game
defined($ARGV[0]) || die "Missing boring input filename.";
open(IN,"<$ARGV[0]") || die "Can't open boring input file.";

# array to hold input file; remove new lines
my @file = ();
foreach $line (<IN>){
	chomp($line);
	push(@file,$line);
}

# list of intrinsics
my @attrs = ();
my $i=0;
push(@{ $attrs[$i++] },('You feel a momentary chill.','fire'));
push(@{ $attrs[$i++] },('Your health currently feels amplified!','shock'));
push(@{ $attrs[$i++] },('You feel full of hot air.','cold'));
push(@{ $attrs[$i++] },('You feel healthy.','poison'));
push(@{ $attrs[$i++] },('You feel wide awake.','sleep'));
push(@{ $attrs[$i++] },('You feel very firm','disintegration'));
push(@{ $attrs[$i++] },('You feel a strange mental acuity.','telepathy'));
push(@{ $attrs[$i++] },('You feel in control of yourself','teleport control'));
# add more with this template:
#push(@{ $attrs[$i++] },('',''));

print "Intrinsics you HAVE:\n";
for($i=0;$i<scalar(@attrs);++$i){
	print "- ".$attrs[$i][1]."\n" if (/$attrs[$i][0]/i ~~ @file);
}
print "\n";
print "Intrinsics you MAY NEED:\n";
for($i=0;$i<scalar(@attrs);++$i){
	print "- ".$attrs[$i][1]."\n" if !(/$attrs[$i][0]/i ~~ @file);
}
