Mercurial > hg > batmud > maputils
comparison www/info.php @ 2763:78ad0e51b7b5
Improve wizards.txt parser, add functionality for specifying alternative /
additional names as some wizards have used more than one.
Also other improvements in wizard data handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 12 Mar 2024 15:47:58 +0200 |
parents | 164aa519640d |
children |
comparison
equal
deleted
inserted
replaced
2762:4caa26c12052 | 2763:78ad0e51b7b5 |
---|---|
51 { | 51 { |
52 return strcmp($a["name"], $b["name"]); | 52 return strcmp($a["name"], $b["name"]); |
53 } | 53 } |
54 | 54 |
55 | 55 |
56 /* Print table of wizards | 56 // Get area counts |
57 */ | |
58 foreach ($locTable as $location) | 57 foreach ($locTable as $location) |
59 { | 58 { |
60 foreach ($location["authors"] as $wiz) | 59 foreach ($location["authors"] as $wiz) |
61 { | 60 { |
62 $name = $wiz["name"]; | 61 $name = $wiz["name"]; |
62 | |
63 // Many wizards do not have an entry in wizard info table | |
63 if (!isset($wizTable[$name])) | 64 if (!isset($wizTable[$name])) |
64 $wizTable[$name] = array("name" => $name, "areas" => 0); | 65 { |
66 $wizTable[$name] = [ | |
67 "name" => $name, | |
68 "names" => [], | |
69 "areas" => 0, | |
70 ]; | |
71 } | |
72 | |
65 $wizTable[$name]["areas"]++; | 73 $wizTable[$name]["areas"]++; |
66 } | 74 } |
67 } | 75 } |
68 | 76 |
69 if (count($wizTable) > 0) | 77 // Make alphabetically sorted table of wizards |
78 foreach ($wizTable as $name => $data) | |
79 $alphaTable[$name[0]][$name] = $data; | |
80 | |
81 ksort($alphaTable, SORT_STRING); | |
82 | |
83 // Print wizards alphabetically per first character of name | |
84 foreach ($alphaTable as $alpha => $data) | |
85 if (count($data) > 0) | |
70 { | 86 { |
71 /* Make alphabetically sorted table of wizards | 87 usort($data, "wizardSort"); |
72 */ | |
73 foreach ($wizTable as $alpha => $data) | |
74 $alphaTable[$alpha[0]][] = $data; | |
75 | 88 |
76 ksort($alphaTable, SORT_STRING); | 89 $letter = strtoupper($alpha); |
90 echo "<h3><a id=\"ch".$letter."\"></a>".$letter."</h3>\n"; | |
91 echo "<div class=\"locTable\">\n"; | |
77 | 92 |
93 foreach ($data as $name => $wizard) | |
94 { | |
95 echo | |
96 " <div class=\"locWizard ". | |
97 (isset($wizard["desc"]) ? "locWizHasDesc" : "locWizHasNoDesc")."\">". | |
98 "<a href=\"loc.php?a=".$wizard["name"]."\">".$wizard["name"]."</a>"; | |
78 | 99 |
79 /* Print wizards alphabetically per first character of name | 100 if ($wizard["areas"] > 0) |
80 */ | 101 echo " <span class=\"locWizNumAreas\">(".$wizard["areas"].")</span>"; |
81 $totalWiz = 0; | |
82 $maxRow = 6; | |
83 foreach ($alphaTable as $alpha => $data) | |
84 if (count($data) > 0) | |
85 { | |
86 usort($data, "wizardSort"); | |
87 | |
88 $letter = strtoupper($alpha); | |
89 echo "<h3><a id=\"ch".$letter."\"></a>".$letter."</h3>\n"; | |
90 echo "<div class=\"locTable\">\n"; | |
91 $n = 0; | |
92 | |
93 foreach ($data as $wizard) | |
94 { | |
95 $totalWiz++; | |
96 | |
97 echo | |
98 " <div class=\"locWizard ".((count($wizard) > 2 || isset($wizard["desc"])) ? "locWizHasDesc" : "locWizHasNoDesc")."\">". | |
99 "<a href=\"loc.php?a=".$wizard["name"]."\">".$wizard["name"]."</a>"; | |
100 | |
101 if ($wizard["areas"] > 0) | |
102 echo " <span class=\"locWizNumAreas\">(".$wizard["areas"].")</span>"; | |
103 | |
104 echo "</div>\n"; | |
105 } | |
106 | 102 |
107 echo "</div>\n"; | 103 echo "</div>\n"; |
108 } | 104 } |
109 | 105 |
110 echo "<p><b>".$totalWiz."</b> wizards.</p>\n". | 106 echo "</div>\n"; |
111 "</div>\n"; // end of contents div | 107 } |
112 | 108 |
113 // Print out the alpha link index | 109 echo |
114 mpPrintExtraBoxAlphaList("ch", $alphaTable); | 110 "<p><b>".count($wizTable)."</b> wizards.</p>\n". |
115 } | 111 "</div>\n"; // end of contents div |
116 else | 112 |
117 { | 113 // Print out the alpha link index |
118 echo "<p><b>No wizards known!</b></p>\n". | 114 mpPrintExtraBoxAlphaList("ch", $alphaTable); |
119 "</div>\n"; // end of contents div | |
120 } | |
121 | 115 |
122 mpPrintPageFooter(FALSE); | 116 mpPrintPageFooter(FALSE); |
123 ?> | 117 ?> |