Mercurial > hg > batmud > misc
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 |
rev | line source |
---|---|
80 | 1 #!/usr/bin/perl -w |
2 use strict; | |
286 | 3 use warnings; |
4 my %taskList = (); | |
80 | 5 my @tmpList = (); |
6 my $wasFound = 0; | |
7 my $n; | |
286 | 8 my $nline = 0; |
80 | 9 |
10 ### Process and parse input logfile | |
286 | 11 while (defined(my $line = <STDIN>)) |
12 { | |
13 $nline++; | |
14 chomp($line); | |
15 | |
16 if ($line =~ /^New holy task '(.+)' is now available to you\.$/) | |
17 { | |
80 | 18 push(@tmpList, $1); |
19 $wasFound = 1; | |
20 $n = 0; | |
286 | 21 } |
22 elsif ($line =~ /^You now have '(.+)' at ([0-9]+)\% without special bonuses\.$/ && $wasFound) | |
23 { | |
24 my $tmpName = $1; | |
25 my $tmpPercentage = $2; | |
26 $n = 10; | |
27 | |
28 for my $taskName (@tmpList) | |
29 { | |
30 if (defined($taskList{$taskName}{$tmpName})) | |
31 { | |
32 if ($tmpPercentage < $taskList{$taskName}{$tmpName}) | |
33 { | |
80 | 34 $taskList{$taskName}{$tmpName} = $tmpPercentage; |
35 } | |
36 } | |
286 | 37 else |
38 { | |
39 $taskList{$taskName}{$tmpName} = $tmpPercentage; | |
40 } | |
80 | 41 } |
42 } | |
286 | 43 |
44 if ($n++ >= 6) | |
45 { | |
80 | 46 $wasFound = 0; |
286 | 47 for my $taskName (@tmpList) |
48 { | |
49 if (!defined($taskList{$taskName})) | |
50 { | |
80 | 51 $taskList{$taskName} = (); |
52 } | |
53 } | |
54 @tmpList = (); | |
55 } | |
56 } | |
57 | |
58 | |
286 | 59 sub print_separator() |
60 { | |
61 print "|--------------------------------------------------------------------|\n"; | |
62 } | |
63 | |
64 | |
80 | 65 ### Print out the results |
66 $n = 0; | |
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 | 72 print $taskName."\n"; |
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 | 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 | 82 print $skillName."=".$taskList{$taskName}{$skillName}."|"; |
83 } | |
84 print "\n"; | |
85 } | |
86 } | |
286 | 87 } |
88 else | |
89 { | |
90 my $sepLine = 0; | |
91 print ",--------------------------------------------------------------------.\n"; | |
92 print "| Task name | Skill/spell | Min |\n"; | |
93 print "+----------------------------------+---------------------------+-----+\n"; | |
94 for my $taskName (sort keys %taskList) | |
95 { | |
96 my $i = keys(%{$taskList{$taskName}}); | |
97 | |
98 if ($i == 0) | |
99 { | |
100 print_separator() if (!$sepLine); | |
101 printf "| %-32s |\n", $taskName; | |
102 print_separator(); | |
103 $sepLine = 1; | |
80 | 104 } |
286 | 105 elsif ($i == 1) |
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 | 109 printf "| %-32s | %-25s | %3d |\n", $taskName, $skillName, $taskList{$taskName}{$skillName}; |
110 } | |
111 $sepLine = 0; | |
80 | 112 } |
286 | 113 else |
114 { | |
115 print_separator() if (!$sepLine); | |
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 | 119 printf "| %-32s | %-25s | %3d |\n", "", $skillName, $taskList{$taskName}{$skillName}; |
120 } | |
121 print_separator(); | |
122 $sepLine = 1; | |
123 } | |
80 | 124 |
286 | 125 $n++; |
126 } | |
127 print "|-----------------+----------------+---------------------------+-----'\n"; | |
128 printf "| %3d tasks total |\n", $n; | |
129 print "`-----------------'\n"; | |
80 | 130 } |