annotate nun/tasks/findreqs.pl @ 337:992d8c1c72e6 misc

Indentation and formatting cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 29 Jun 2016 18:22:32 +0300
parents f749342539de
children 6f4baa8abf82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #!/usr/bin/perl -w
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 use strict;
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
3 use warnings;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
4 my %taskList = ();
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 my @tmpList = ();
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 my $wasFound = 0;
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 my $n;
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
8 my $nline = 0;
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 ### Process and parse input logfile
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
11 while (defined(my $line = <STDIN>))
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
12 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
13 $nline++;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
14 chomp($line);
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
15
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
16 if ($line =~ /^New holy task '(.+)' is now available to you\.$/)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
17 {
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 push(@tmpList, $1);
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 $wasFound = 1;
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 $n = 0;
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
21 }
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
22 elsif ($line =~ /^You now have '(.+)' at ([0-9]+)\% without special bonuses\.$/ && $wasFound)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
23 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
24 my $tmpName = $1;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
25 my $tmpPercentage = $2;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
26 $n = 10;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
27
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
28 for my $taskName (@tmpList)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
29 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
30 if (defined($taskList{$taskName}{$tmpName}))
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
31 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
32 if ($tmpPercentage < $taskList{$taskName}{$tmpName})
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
33 {
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 $taskList{$taskName}{$tmpName} = $tmpPercentage;
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 }
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
37 else
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
38 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
39 $taskList{$taskName}{$tmpName} = $tmpPercentage;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
40 }
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 }
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
43
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
44 if ($n++ >= 6)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
45 {
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 $wasFound = 0;
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
47 for my $taskName (@tmpList)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
48 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
49 if (!defined($taskList{$taskName}))
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
50 {
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 $taskList{$taskName} = ();
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 @tmpList = ();
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
59 sub print_separator()
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
60 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
61 print "|--------------------------------------------------------------------|\n";
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
62 }
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
63
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
64
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 ### Print out the results
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 $n = 0;
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 if ($#ARGV >= 0) {
337
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
68 if ($ARGV[0] eq "-tasks")
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
69 {
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
70 for my $taskName (sort keys %taskList)
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
71 {
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 print $taskName."\n";
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 }
337
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
74 }
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
75 elsif ($ARGV[0] eq "-dump")
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
76 {
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
77 for my $taskName (sort keys %taskList)
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
78 {
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 print $taskName."|";
337
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
80 for my $skillName (sort keys %{$taskList{$taskName}})
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
81 {
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 print $skillName."=".$taskList{$taskName}{$skillName}."|";
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 print "\n";
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 }
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 }
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
87 }
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
88 else
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
89 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
90 my $sepLine = 0;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
91 print ",--------------------------------------------------------------------.\n";
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
92 print "| Task name | Skill/spell | Min |\n";
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
93 print "+----------------------------------+---------------------------+-----+\n";
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
94 for my $taskName (sort keys %taskList)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
95 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
96 my $i = keys(%{$taskList{$taskName}});
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
97
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
98 if ($i == 0)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
99 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
100 print_separator() if (!$sepLine);
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
101 printf "| %-32s |\n", $taskName;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
102 print_separator();
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
103 $sepLine = 1;
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 }
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
105 elsif ($i == 1)
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
106 {
337
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
107 for my $skillName (sort keys %{$taskList{$taskName}})
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
108 {
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
109 printf "| %-32s | %-25s | %3d |\n", $taskName, $skillName, $taskList{$taskName}{$skillName};
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
110 }
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
111 $sepLine = 0;
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 }
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
113 else
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
114 {
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
115 print_separator() if (!$sepLine);
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
116 printf "| %-66s |\n", $taskName;
337
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
117 for my $skillName (sort keys %{$taskList{$taskName}})
992d8c1c72e6 Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 286
diff changeset
118 {
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
119 printf "| %-32s | %-25s | %3d |\n", "", $skillName, $taskList{$taskName}{$skillName};
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
120 }
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
121 print_separator();
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
122 $sepLine = 1;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
123 }
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124
286
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
125 $n++;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
126 }
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
127 print "|-----------------+----------------+---------------------------+-----'\n";
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
128 printf "| %3d tasks total |\n", $n;
f749342539de Various cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
129 print "`-----------------'\n";
80
c7983aa2a708 Added tasks.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 }