Prechádzať zdrojové kódy

Improvements to the skill-up report.

Iñigo Valentin 7 rokov pred
rodič
commit
aef6291de2

+ 45 - 4
application/page/Report_Skillup_Page.php

@@ -3,7 +3,6 @@
     require_once($path["page"] . "Page.php");
     require_once($path["entity"] . "Monster.php");
 
-
     /**
      * Urgent Skillup report page.
      */
@@ -14,13 +13,19 @@
          */
         public $monsters = [];
 
+        /**
+         * The filters the page can handle.
+         */
         public $filters = [
             "min_stars" => 5,
             "max_stars" => 6,
             "min_natural_stars" => 5,
             "max_natural_stars" => 5,
             "in_storage" => true,
-            "without_runes" => true
+            "without_runes" => true,
+            "family" => false,
+            "maxed" => false,
+            "2a" => false
         ];
 
         /**
@@ -47,6 +52,10 @@
             $this->canonical = $root . "report/skillups";
         }
 
+        /**
+         * Parses the request looking for the selected filters, validates them
+         * and adds them to the $filters array.
+         */
         private function parse_filters(){
             if (isset($_GET["min_stars"]) && intval($_GET["min_stars"]) > 0 && intval($_GET["min_stars"]) < 7){
                 $this->filters["min_stars"] = $_GET["min_stars"];
@@ -66,9 +75,24 @@
             if (isset($_GET["without_runes"]) && $_GET["without_runes"] != "on"){
                 $this->filters["without_runes"] = false;
             }
+            if (isset($_GET["family"]) && $_GET["family"] == "on"){
+                $this->filters["family"] = true;
+            }
+            if (isset($_GET["maxed"]) && $_GET["maxed"] == "on"){
+                $this->filters["maxed"] = true;
+            }
+            if (isset($_GET["2a"]) && $_GET["2a"] == "on"){
+                $this->filters["2a"] = true;
+            }
             return;
         }
 
+        /**
+         * Builds the query to the rune table using the selected or default
+         * filters.
+         *
+         * @return The query to be executed.
+         */
         private function build_query(){
             $s =
               "SELECT DISTINCT " .
@@ -119,15 +143,32 @@
               "  monster.stars <= " . $this->filters["max_stars"] . " AND " .
               "  k_monster.natural_stars >= " . $this->filters["min_natural_stars"] . " AND " .
               "  k_monster.natural_stars <= " . $this->filters["max_natural_stars"] . " ";
-              
             if (!$this->filters["in_storage"]){
                 $s = $s . " AND monster.in_storage = 0 ";
             }
             if (!$this->filters["without_runes"]){
                 $s = $s . " AND monster.id IN (SELECT DISTINCT monster FROM monster_rune) ";
             }
+            if ($this->filters["family"]){
+                $s = $s . " AND monster.monster NOT IN (SELECT id FROM k_monster m WHERE family_id IN (SELECT family_id FROM k_monster k WHERE k.family_id = m.family_id AND k.natural_stars < m.natural_stars AND k.natural_stars < " . $this->filters["min_natural_stars"] . ")) ";
+                // Special case: Eirgar (Dark Vampire lord). Nat5 can be powered with 4 star Vampires.
+                if ($this->filters["min_natural_stars"] >= 5){
+                    $s = $s . " AND k_monster.id <> 1279 AND k_monster.id <> 1280 ";
+                }
+                // Special case: Fran (Light Fairy Queen). Nat3 can be powered with 2 star Fairies.
+                if ($this->filters["min_natural_stars"] >= 3){
+                    $s = $s . " AND k_monster.id <> 417 AND k_monster.id <> 418 ";
+                }
+            }
+            if (!$this->filters["2a"]){
+                $s = $s . " AND (k_monster.awakens_from IS NULL OR k_monster.awakens_to IS NOT NULL OR k_monster.base_stars - k_monster.natural_stars = 1) ";
+            }
+            $s = $s .
+              "GROUP BY monster.id ";
+            if (!$this->filters["maxed"]){
+                $s = $s . " HAVING ponderated_level < ponderated_max_level ";
+            }
             $s = $s .
-              "GROUP BY monster.id " .
               "ORDER BY " .
               "  ponderated_level * 100 / ponderated_max_level, " .
               "  monster.stars DESC, " .

+ 18 - 0
application/view/report.php

@@ -60,6 +60,18 @@
                                     <input type='number' name='max_natural_stars' min='1' max='5' value='5'/>
                                 </td>
                             </tr>
+                            <tr>
+                                <td class='filter' colspan='2'>
+                                    <input type='checkbox' name='family'/>
+                                    Show monsters with family with lower grade.
+                                </td>
+                            </tr>
+                            <tr>
+                                <td class='filter' colspan='2'>
+                                    <input type='checkbox' name='2a'/>
+                                    Include second-awakened monsters.
+                                </td>
+                            </tr>
                             <tr>
                                 <td class='filter' colspan='2'>
                                     <input type='checkbox' name='in_storage'/>
@@ -72,6 +84,12 @@
                                     Show monsters without runes
                                 </td>
                             </tr>
+                            <tr>
+                            <td class='filter' colspan='2'>
+                                <input type='checkbox' name='maxed' <?=$checked?>/>
+                                Show fully skilled-up monster
+                            </td>
+                            </tr>
                         </table>
                         <div id='filter_apply'>
                             <input type='submit' value='Apply'/>

+ 36 - 0
application/view/report_skillup.php

@@ -57,6 +57,30 @@
                     </tr>
                     <tr>
                         <td class='filter' colspan='2'>
+<?php
+                            $checked = "";
+                            if ($page->filters["family"]){
+                                $checked = "checked";
+                            }
+?>
+                            <input type='checkbox' name='family' <?=$checked?>/>
+                            Show monsters with family with lower grade.
+                        </td>
+                    </tr>
+                    <tr>
+                        <td class='filter' colspan='2'>
+<?php
+                            $checked = "";
+                            if ($page->filters["2a"]){
+                                $checked = "checked";
+                            }
+?>
+                            <input type='checkbox' name='2a' <?=$checked?>/>
+                            Include second-awakened monsters.
+                        </td>
+                    </tr>
+                    <tr>
+                        <td class='filter' colspan='2'>
 <?php
                             $checked = "";
                             if ($page->filters["in_storage"]){
@@ -79,6 +103,18 @@
                             Show monsters without runes
                         </td>
                     </tr>
+                    <tr>
+                        <td class='filter' colspan='2'>
+<?php
+                            $checked = "";
+                            if ($page->filters["maxed"]){
+                                $checked = "checked";
+                            }
+?>
+                            <input type='checkbox' name='maxed' <?=$checked?>/>
+                            Show fully skilled-up monster
+                        </td>
+                    </tr>
                 </table>
                 <div id='filter_apply'>
                     <input type='submit' value='Apply'/>

+ 1 - 0
start_server

@@ -15,3 +15,4 @@ echo "PUBLIC: " $server_public $host;
 php -S $host:$port -t public/ >> server.log 2>&1  &
 pid=$!
 echo $pid > .php_pid
+chmod a+w .php_pid