Mercurial > hg > batmud > misc
annotate nun/tasks/findreqs.pl @ 357:b5959a81c3f5 misc
Cleanup.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 27 Jun 2018 15:02:21 +0300 |
parents | 102ac4f0bd22 |
children | 362bd68d5686 |
rev | line source |
---|---|
80 | 1 #!/usr/bin/perl -w |
2 use strict; | |
286 | 3 use warnings; |
4 my %taskList = (); | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
5 my %taskNames = (); |
80 | 6 my @tmpList = (); |
7 my $wasFound = 0; | |
8 my $n; | |
286 | 9 my $nline = 0; |
80 | 10 |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
11 |
80 | 12 ### Process and parse input logfile |
286 | 13 while (defined(my $line = <STDIN>)) |
14 { | |
15 $nline++; | |
16 chomp($line); | |
17 | |
18 if ($line =~ /^New holy task '(.+)' is now available to you\.$/) | |
19 { | |
80 | 20 push(@tmpList, $1); |
21 $wasFound = 1; | |
22 $n = 0; | |
286 | 23 } |
24 elsif ($line =~ /^You now have '(.+)' at ([0-9]+)\% without special bonuses\.$/ && $wasFound) | |
25 { | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
26 my $tmpName = lc($1); |
286 | 27 my $tmpPercentage = $2; |
28 $n = 10; | |
29 | |
30 for my $taskName (@tmpList) | |
31 { | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
32 my $lcName = lc($taskName); |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
33 if (defined($taskList{$lcName}{$tmpName})) |
286 | 34 { |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
35 if ($tmpPercentage < $taskList{$lcName}{$tmpName}) |
286 | 36 { |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
37 $taskList{$lcName}{$tmpName} = $tmpPercentage; |
80 | 38 } |
39 } | |
286 | 40 else |
41 { | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
42 $taskList{$lcName}{$tmpName} = $tmpPercentage; |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
43 $taskNames{$lcName} = $taskName; |
286 | 44 } |
80 | 45 } |
46 } | |
286 | 47 |
48 if ($n++ >= 6) | |
49 { | |
80 | 50 $wasFound = 0; |
286 | 51 for my $taskName (@tmpList) |
52 { | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
53 my $lcName = lc($taskName); |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
54 if (!defined($taskList{$lcName})) |
286 | 55 { |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
56 $taskList{$lcName} = {}; |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
57 $taskNames{$lcName} = $taskName; |
80 | 58 } |
59 } | |
60 @tmpList = (); | |
61 } | |
62 } | |
63 | |
64 | |
286 | 65 sub print_separator() |
66 { | |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
67 print "|------------------------------------------------------------------------|\n"; |
286 | 68 } |
69 | |
70 | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
71 sub print_line($$$) |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
72 { |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
73 my ($task, $skill, $perc) = @_; |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
74 printf "| %-36s | %-25s | %3d |\n", $task, $skill, $perc; |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
75 } |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
76 |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
77 |
80 | 78 ### Print out the results |
79 $n = 0; | |
80 if ($#ARGV >= 0) { | |
337
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
81 if ($ARGV[0] eq "-tasks") |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
82 { |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
83 for my $taskName (sort keys %taskList) |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
84 { |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
85 print $taskNames{$taskName}."\n"; |
80 | 86 } |
337
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
87 } |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
88 elsif ($ARGV[0] eq "-dump") |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
89 { |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
90 for my $taskName (sort keys %taskList) |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
91 { |
357 | 92 my @list = map { |
93 $_."=".$taskList{$taskName}{$_} | |
94 } sort keys %{$taskList{$taskName}}; | |
95 | |
96 print $taskNames{$taskName}."|".join("|", @list)."\n"; | |
80 | 97 } |
98 } | |
286 | 99 } |
100 else | |
101 { | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
102 my $separator = 0; |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
103 print ",------------------------------------------------------------------------.\n"; |
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
104 print "| Task name | Skill/spell | Min |\n"; |
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
105 print "+--------------------------------------+---------------------------+-----+\n"; |
286 | 106 for my $taskName (sort keys %taskList) |
107 { | |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
108 my $nreqs = scalar keys(%{$taskList{$taskName}}); |
286 | 109 |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
110 if ($nreqs == 0) |
286 | 111 { |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
112 # No requirement data for task |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
113 print_separator() if ($separator); |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
114 printf "| %-36s | %-31s |\n", $taskName, "UNKNOWN or no requirements"; |
286 | 115 print_separator(); |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
116 $separator = 1; |
80 | 117 } |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
118 elsif ($nreqs == 1) |
286 | 119 { |
337
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
120 for my $skillName (sort keys %{$taskList{$taskName}}) |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
121 { |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
122 print_line($taskNames{$taskName}, $skillName, $taskList{$taskName}{$skillName}); |
286 | 123 } |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
124 $separator = 1; |
80 | 125 } |
286 | 126 else |
127 { | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
128 print_separator() if ($separator); |
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
129 printf "| %-70s |\n", $taskNames{$taskName}; |
337
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
130 for my $skillName (sort keys %{$taskList{$taskName}}) |
992d8c1c72e6
Indentation and formatting cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents:
286
diff
changeset
|
131 { |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
132 print_line("", $skillName, $taskList{$taskName}{$skillName}); |
286 | 133 } |
134 print_separator(); | |
356
102ac4f0bd22
Make findreqs.pl more forgiving to inaccuracies in log data.
Matti Hamalainen <ccr@tnsp.org>
parents:
355
diff
changeset
|
135 $separator = 0; |
286 | 136 } |
80 | 137 |
286 | 138 $n++; |
139 } | |
355
6f4baa8abf82
Make this script a bit better. Also fix the ASCII table width for tasks that
Matti Hamalainen <ccr@tnsp.org>
parents:
337
diff
changeset
|
140 print "|-----------------+--------------------+---------------------------+-----'\n"; |
286 | 141 printf "| %3d tasks total |\n", $n; |
142 print "`-----------------'\n"; | |
80 | 143 } |