Iñigo Valentin 7 жил өмнө
parent
commit
f9ea755cf0

+ 0 - 8
application/Controller.php

@@ -4,14 +4,6 @@
     require_once($path["helper"] . "db.php");
     require_once($path["helper"] . "db.php");
     require_once($path["helper"] . "text.php");
     require_once($path["helper"] . "text.php");
     require_once($path["helper"] . "net.php");
     require_once($path["helper"] . "net.php");
-    
-    
-    
-    
-    
-    
-    
-    
 
 
     /**
     /**
      * Application controller.
      * Application controller.

+ 5 - 4
application/entity/K_Fusion.php

@@ -171,12 +171,13 @@
               "        k_fusion.product = k_monster.id " .
               "        k_fusion.product = k_monster.id " .
               "    ) " .
               "    ) " .
               "  ); ";
               "  ); ";
-            error_log("ING: " . $s_m);
             $q_m = $this->db->query($s_m);
             $q_m = $this->db->query($s_m);
             while ($r_m = $q_m->fetchArray(SQLITE3_ASSOC)){
             while ($r_m = $q_m->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->ingredient, new Monster_Fusion($this->db, $r_m["id"]));
-                error_log("NEW awakens_from: " . $r_m["awakens_from"]);
-                array_push($this->ingredient_unawaken, new Monster_Fusion($this->db, $r_m["awakens_from"]));
+                $m = new Monster_Fusion($this->db, $r_m["id"]);
+                array_push($this->ingredient, $m);
+                $m = new Monster_Fusion($this->db, $r_m["awakens_from"]);
+                $m->load_essences();
+                array_push($this->ingredient_unawaken, $m);
             }
             }
         }
         }
     }
     }

+ 77 - 44
application/entity/K_Monster.php

@@ -257,7 +257,7 @@
                 $this->can_awaken = $r["can_awaken"];
                 $this->can_awaken = $r["can_awaken"];
                 $this->awaken_bonus = $r["awaken_bonus"];
                 $this->awaken_bonus = $r["awaken_bonus"];
                 $this->skill_ups_to_max = $r["skill_ups_to_max"];
                 $this->skill_ups_to_max = $r["skill_ups_to_max"];
-                if ($complete && $r["leader_skill"]){
+                if (strlen($r["leader_skill"]) > 0){
                     $this->leader_skill = new K_Leader_Skill($this->db, $r["leader_skill"]);
                     $this->leader_skill = new K_Leader_Skill($this->db, $r["leader_skill"]);
                 }
                 }
                 $this->base_hp = $r["base_hp"];
                 $this->base_hp = $r["base_hp"];
@@ -281,49 +281,82 @@
                 $this->craft_cost = $r["craft_cost"];
                 $this->craft_cost = $r["craft_cost"];
             }
             }
             if ($complete){
             if ($complete){
-                $s =
-                "SELECT " .
-                "  skill " .
-                "FROM " .
-                "  k_skill, " .
-                "  k_monster_skill " .
-                "WHERE " .
-                "  id = skill AND " .
-                "  monster = $id " .
-                "ORDER BY slot; ";
-                $q = $this->db->query($s);
-                while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                    array_push($this->skill, new K_Skill($this->db, $r["skill"]));
-                }
-                $s =
-                "SELECT " .
-                "  element, " .
-                "  grade, " .
-                "  amount " .
-                "FROM k_monster_essence " .
-                "WHERE " .
-                "  monster = $id " .
-                "ORDER BY " .
-                "  element <> 'Magic', " .
-                "  grade <> 'Low', " .
-                "  grade <> 'Mid'; ";
-                $q = $this->db->query($s);
-                while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                    $e = [
-                        "element" => $r["element"],
-                        "grade" => $r["grade"],
-                        "amount" => $r["amount"]
-                    ];
-                    array_push($this->essences, $e);
-                }
-                $s =
-                "SELECT source " .
-                "FROM k_monster_source " .
-                "WHERE monster = $id; ";
-                $q = $this->db->query($s);
-                while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                    array_push($this->sources, new K_Source($this->db, $r["source"]));
-                }
+                $this->load_essences();
+                $this->load_skills();
+                $this->load_sources();
+            }
+        }
+
+        /**
+         * Loads the information about the essences to awake the monster. 
+         * It is autoatically called at construction time if the
+         * $complete parameter is true (by default). No point in calling it
+         * twice.
+         */
+        public function load_essences(){
+            $this->essences = [];
+            $s =
+              "SELECT " .
+              "  element, " .
+              "  grade, " .
+              "  amount " .
+              "FROM k_monster_essence " .
+              "WHERE " .
+              "  monster = " . $this->id . " " .
+              "ORDER BY " .
+              "  element <> 'Magic', " .
+              "  grade <> 'Low', " .
+              "  grade <> 'Mid'; ";
+            $q = $this->db->query($s);
+            while ($r = $q->fetchArray(SQLITE3_ASSOC)){
+                $e = [
+                    "element" => $r["element"],
+                    "grade" => $r["grade"],
+                    "amount" => $r["amount"]
+                ];
+                array_push($this->essences, $e);
+            }
+        }
+
+        /**
+         * Loads the information about the monster skills. 
+         * It is autoatically called at construction time if the
+         * $complete parameter is true (by default). No point in calling it
+         * twice.
+         */
+        public function load_skills(){
+            $this->skill = [];
+            $s =
+              "SELECT " .
+              "  skill " .
+              "FROM " .
+              "  k_skill, " .
+              "  k_monster_skill " .
+              "WHERE " .
+              "  id = skill AND " .
+              "  monster = " . $this->id . " " .
+              "ORDER BY slot; ";
+            $q = $this->db->query($s);
+            while ($r = $q->fetchArray(SQLITE3_ASSOC)){
+                array_push($this->skill, new K_Skill($this->db, $r["skill"]));
+            }
+        }
+
+        /**
+         * Loads the information about the monster sources. 
+         * It is autoatically called at construction time if the
+         * $complete parameter is true (by default). No point in calling it
+         * twice.
+         */
+        public function load_sources(){
+            $this->sources = [];
+            $s =
+              "SELECT source " .
+              "FROM k_monster_source " .
+              "WHERE monster = " . $this->id . ";";
+            $q = $this->db->query($s);
+            while ($r = $q->fetchArray(SQLITE3_ASSOC)){
+                array_push($this->sources, new K_Source($this->db, $r["source"]));
             }
             }
         }
         }
 
 

+ 19 - 8
application/entity/Monster.php

@@ -257,14 +257,25 @@
             $this->priority = $r["priority"];
             $this->priority = $r["priority"];
             $this->notes = $r["notes"];
             $this->notes = $r["notes"];
             if ($complete){
             if ($complete){
-                $s =
-                "SELECT rune " .
-                "FROM monster_rune " .
-                "WHERE monster = '$this->id'; ";
-                $q = $this->db->query($s);
-                while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                    array_push($this->rune, new Rune($this->db, $r["rune"]));
-                }
+                $this->load_runes();
+            }
+        }
+
+        /**
+         * Loads the information about the equiped runes. 
+         * It is autoatically called at construction time if the
+         * $complete parameter is true (by default). No point in calling it
+         * twice.
+         */
+        public function load_runes(){
+            $this->rune = [];
+            $s =
+              "SELECT rune " .
+              "FROM monster_rune " .
+              "WHERE monster = '$this->id'; ";
+            $q = $this->db->query($s);
+            while ($r = $q->fetchArray(SQLITE3_ASSOC)){
+                array_push($this->rune, new Rune($this->db, $r["rune"]));
             }
             }
         }
         }
     }
     }

+ 9 - 3
application/page/Catalog_Page.php

@@ -21,7 +21,7 @@
             "element" => "",
             "element" => "",
             "name" => "",
             "name" => "",
             "min_stars" => 1,
             "min_stars" => 1,
-            "max_stars" => 6,
+            "max_stars" => 5,
         ];
         ];
 
 
         /**
         /**
@@ -73,7 +73,7 @@
         /**
         /**
          * Builds the query to the rune table using the selected or default
          * Builds the query to the rune table using the selected or default
          * filters.
          * filters.
-         * 
+         *
          * @return The query to be executed.
          * @return The query to be executed.
          */
          */
         private function build_query(){
         private function build_query(){
@@ -84,7 +84,13 @@
             if ($this->filters["name"] != ""){
             if ($this->filters["name"] != ""){
                 $s = $s . " AND monster IN (SELECT id FROM k_monster WHERE upper(name) LIKE '%" . strtoupper($this->filters["name"]) . "%') ";
                 $s = $s . " AND monster IN (SELECT id FROM k_monster WHERE upper(name) LIKE '%" . strtoupper($this->filters["name"]) . "%') ";
             }
             }
-            $s = $s . " ORDER BY element, natural_stars;";
+            $s = $s . " ORDER BY " .
+            "  element = 'Fire' DESC, " .
+            "  element = 'Water' DESC, " .
+            "  element = 'Wind' DESC, " .
+            "  element = 'Light' DESC, " .
+            "  element = 'Dark' DESC, " .
+            "  natural_stars; ";
             return $s;
             return $s;
         }
         }
     }
     }

+ 24 - 10
application/page/Monster_Info_Page.php

@@ -17,6 +17,17 @@
          */
          */
         public $monster = [];
         public $monster = [];
 
 
+        /**
+         * IDs to other monsters of thef family
+         */
+        public $family = [
+            "Fire" => null,
+            "Water" => null,
+            "Wind" => null,
+            "Light" => null,
+            "Dark" => null,
+        ];
+
         /**
         /**
          * Constructor.
          * Constructor.
          *
          *
@@ -32,11 +43,7 @@
             $this->view = $path["view"] . "monster_info.php";
             $this->view = $path["view"] . "monster_info.php";
             $title = "";
             $title = "";
             $monster = new K_Monster($db, $id);
             $monster = new K_Monster($db, $id);
-            error_log("ID  : " . $monster->id);
-            error_log("FROM: " . $monster->awakens_from);
-            error_log("TO  : " . $monster->awakens_to);
             if ($monster->can_awaken == 0){
             if ($monster->can_awaken == 0){
-                error_log("CAN_AWAKEN 0 -> SILVER");
                 // Silver star monster.
                 // Silver star monster.
                 $this->monster[0] = $monster;
                 $this->monster[0] = $monster;
                 $this->monster[1] = null;
                 $this->monster[1] = null;
@@ -44,7 +51,6 @@
                 $title = $this->monster[0]->element . " " . $this->monster[0]->name;
                 $title = $this->monster[0]->element . " " . $this->monster[0]->name;
             }
             }
             elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
             elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && $monster->awakens_from == ""){
-                error_log(" -> DEGFAULT PURPLE");
                 // Default purple (Rainbowmon or King Angelmon)
                 // Default purple (Rainbowmon or King Angelmon)
                 $this->monster[0] = null;
                 $this->monster[0] = null;
                 $this->monster[1] = $monster;
                 $this->monster[1] = $monster;
@@ -52,29 +58,37 @@
                 $title = $this->monster[1]->name;
                 $title = $this->monster[1]->name;
             }
             }
             elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
             elseif ($monster->can_awaken == 1 && $monster->awakens_to == "" && strlen($monster->awakens_from) > 0){
-                error_log("NORMAL MONSTER AWAKEN, no 2a. FROM: " . $monster->awakens_from);
                 // Normal monster, already awakened, no 2a.
                 // Normal monster, already awakened, no 2a.
                 $this->monster[0] = new K_Monster($db, $monster->awakens_from);
                 $this->monster[0] = new K_Monster($db, $monster->awakens_from);
                 $this->monster[1] = $monster;
                 $this->monster[1] = $monster;
                 $this->monster[2] = null;
                 $this->monster[2] = null;
                 $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
                 $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
+                $monster = $this->monster[0];
             }
             }
             elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
             elseif ($monster->can_awaken == 1 && strlen($monster->awakens_to) > 0 && $monster->awakens_from == ""){
                 // Normal monster, not awakened, may have 2a.
                 // Normal monster, not awakened, may have 2a.
                 $this->monster[0] = $monster;
                 $this->monster[0] = $monster;
                 $this->monster[1] = new K_Monster($db, $this->monster[0]->awakens_to);
                 $this->monster[1] = new K_Monster($db, $this->monster[0]->awakens_to);
                 if ($this->monster[1]->awakens_to == ""){
                 if ($this->monster[1]->awakens_to == ""){
-                    error_log("NORMAL MONSTER, GOLD, NO 2a");
                     $this->monster[2] = null;
                     $this->monster[2] = null;
                 }
                 }
                 else{
                 else{
-                    error_log("NORMAL MONSTER, GOLD, WITH 2a");
                     $this->monster[2] = new K_Monster($db, $this->monster[1]->awakens_to);
                     $this->monster[2] = new K_Monster($db, $this->monster[1]->awakens_to);
                 }
                 }
                 $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
                 $title = $this->monster[1]->name . " - " .$this->monster[0]->element . " " . $this->monster[0]->name;
             }
             }
-            else{
-                error_log("UNKNOWN");
+
+            $s =
+              "SELECT " .
+              "  id, " .
+              "  element " .
+              "FROM k_monster " .
+              "WHERE " .
+              "  family_id = " . $monster->family_id . " AND " .
+              "  element <> '" . $monster->element . "';";
+            $q_mon = $this->db->query($s);
+            while ($r = $q_mon->fetchArray(SQLITE3_ASSOC)){
+                $this->family[$r["element"]] = $r["id"];
             }
             }
 
 
             $this->title = $title ." - SWDB";
             $this->title = $title ." - SWDB";

+ 10 - 2
application/page/Monsters_Page.php

@@ -99,7 +99,7 @@
         /**
         /**
          * Builds the query to the rune table using the selected or default
          * Builds the query to the rune table using the selected or default
          * filters.
          * filters.
-         * 
+         *
          * @return The query to be executed.
          * @return The query to be executed.
          */
          */
         private function build_query(){
         private function build_query(){
@@ -116,7 +116,15 @@
             if (!$this->filters["without_runes"]){
             if (!$this->filters["without_runes"]){
                 $s = $s . " AND monster.id IN (SELECT DISTINCT monster FROM monster_rune) ";
                 $s = $s . " AND monster.id IN (SELECT DISTINCT monster FROM monster_rune) ";
             }
             }
-            $s = $s . " ORDER BY stars DESC, level DESC, element;";
+            $s = $s .
+              " ORDER BY " .
+              "  stars DESC, " .
+              "  level DESC, " .
+              "  element = 'Fire' DESC, " .
+              "  element = 'Water' DESC, " .
+              "  element = 'Wind' DESC, " .
+              "  element = 'Light' DESC, " .
+              "  element = 'Dark' DESC; ";
             return $s;
             return $s;
         }
         }
 
 

+ 2 - 2
application/view/catalog.php

@@ -77,9 +77,9 @@
                         </td>
                         </td>
                         <td class='filter' id='filter_stars'>
                         <td class='filter' id='filter_stars'>
                             <span>Stars:</span>
                             <span>Stars:</span>
-                            <input type='number' name='min_stars' id='filter_stars_min' min='1' max='6' value='<?=$page->filters["min_stars"]?>'/>
+                            <input type='number' name='min_stars' id='filter_stars_min' min='1' max='5' value='<?=$page->filters["min_stars"]?>'/>
                             -
                             -
-                            <input type='number' name='max_stars' id='filter_stars_max' min='1' max='6' value='<?=$page->filters["max_stars"]?>'/>
+                            <input type='number' name='max_stars' id='filter_stars_max' min='1' max='5' value='<?=$page->filters["max_stars"]?>'/>
                         </td>
                         </td>
                     </tr>
                     </tr>
                     <tr>
                     <tr>

+ 4 - 5
application/view/fusion.php

@@ -120,7 +120,7 @@
                                     }
                                     }
                                     $mon_title = $mon_title . " - " . $owned->stars . "* - Lv." . $owned->level;
                                     $mon_title = $mon_title . " - " . $owned->stars . "* - Lv." . $owned->level;
 ?>
 ?>
-                                    <a target="_blank" title='<?=$monster_title?>' href='/monsters/<?=$owned->id?>'>
+                                    <a target="_blank" title='<?=$mon_title?>' href='/monsters/<?=$owned->id?>'>
                                         <div class='monster_panel'>
                                         <div class='monster_panel'>
                                             <span class='stars'>
                                             <span class='stars'>
 <?php
 <?php
@@ -223,7 +223,7 @@
                                                 }
                                                 }
                                                 $mon_title = $mon_title . " - " . $owned->stars . "* - Lv." . $owned->level;
                                                 $mon_title = $mon_title . " - " . $owned->stars . "* - Lv." . $owned->level;
 ?>
 ?>
-                                                <a target="_blank" title='<?=$monster_title?>' href='/monsters/<?=$owned->id?>'>
+                                                <a target="_blank" title='<?=$mon_title?>' href='/monsters/<?=$owned->id?>'>
                                                     <div class='monster_panel'>
                                                     <div class='monster_panel'>
                                                         <span class='stars'>
                                                         <span class='stars'>
 <?php
 <?php
@@ -326,7 +326,7 @@
                                                             }
                                                             }
                                                             $mon_title = $mon_title . " - " . $owned->stars . "* - Lv." . $owned->level;
                                                             $mon_title = $mon_title . " - " . $owned->stars . "* - Lv." . $owned->level;
 ?>
 ?>
-                                                            <a target="_blank" title='<?=$monster_title?>' href='/monsters/<?=$owned->id?>'>
+                                                            <a target="_blank" title='<?=$mon_title?>' href='/monsters/<?=$owned->id?>'>
                                                                 <div class='monster_panel'>
                                                                 <div class='monster_panel'>
                                                                     <span class='stars'>
                                                                     <span class='stars'>
 <?php
 <?php
@@ -356,7 +356,6 @@
                                     </div><!-- .ingredients -->
                                     </div><!-- .ingredients -->
                                 </div><!-- .f4 -->
                                 </div><!-- .f4 -->
 <?php
 <?php
-                                $num0 ++;
                             } // foreach ($fusion->product->owned as $owned)
                             } // foreach ($fusion->product->owned as $owned)
 ?>
 ?>
                             <!-- Last ingredient, non fuseable -->
                             <!-- Last ingredient, non fuseable -->
@@ -447,7 +446,7 @@
                                                     }
                                                     }
 ?>
 ?>
                                                 </span>
                                                 </span>
-                                                <img title='<?=$owned_title?>' class='monster border_<?=$owned->monster->element?>' src='<?=$owned->monster->get_image()?>'/>
+                                                <img title='<?=$mon_title?>' class='monster border_<?=$owned->monster->element?>' src='<?=$owned->monster->get_image()?>'/>
                                                 <span class='level'>
                                                 <span class='level'>
                                                     <?=$owned->level?>
                                                     <?=$owned->level?>
                                                 </span>
                                                 </span>

+ 32 - 0
application/view/monster_info.php

@@ -58,6 +58,38 @@
                 <section class='content'>
                 <section class='content'>
                     <h2>
                     <h2>
                         <?=$mon_title?>
                         <?=$mon_title?>
+                        <span class='family'>
+<?php
+                            //for ($f = 0; $f < 5; $f++){
+                            foreach (Array("Fire", "Water", "Wind", "Light", "Dark") as $element){
+                                //$element = array_keys($page->family)[$f];
+                                //$id = $page->family[$f];
+                                $id = $page->family[$element];
+                                $current = "";
+                                $disabled = "";
+                                if ($element == $page->monster[$i]->element){
+                                    $current = "current";
+                                }
+                                elseif ($id == null){
+                                    $disabled = "disabled";
+                                }
+                                $url = "/catalog/$id";
+                                if ($current == "" && $disabled == ""){
+?>
+                                    <a href='<?=$url?>'>
+<?php
+                                }
+?>
+                                <img class='family <?=$current?> <?=$disabled?>' src='<?=$path["img"]["content"] . "element/$element.png"?>'/>
+<?php
+                                if ($current == "" && $disabled == ""){
+?>
+                                    </a>
+<?php
+                                }
+                            }
+?>
+                        </span>
                     </h2>
                     </h2>
                     <article class='stage'>
                     <article class='stage'>
                         <div class='profile'>
                         <div class='profile'>

+ 0 - 1
install_base.py

@@ -654,7 +654,6 @@ wil be cut.
 :param db: Sqlite database connection.
 :param db: Sqlite database connection.
 """
 """
 def removeImperfect():
 def removeImperfect():
-    SELECT id, element, name FROM k_monster WHERE awakens_from IN (SELECT id FROM k_monster WHERE name LIKE 'Imperfect %');
     cursor = db.cursor()
     cursor = db.cursor()
     cursor.execute('''
     cursor.execute('''
         UPDATE k_monster
         UPDATE k_monster

+ 22 - 9
public/css/monster_info.css

@@ -1,13 +1,26 @@
-{
-    display: block;
-    width: 98%;
-    margin: auto;
-    text-align: center;
+section h2 span.family{
+    float: right;
 }
 }
-@media screen and (max-width : 990px){
-    {
-        width: 100%;
-    }
+
+section h2 span.family img.family{
+    max-width: 2em;
+    max-height: 2em;
+    margin: -0.5em;
+    width: 90%;
+    height: 90%;
+}
+
+section h2 span.family img.family.current{
+    max-width: 2.5em;
+    max-height: 2.5em;
+    margin: -0.5em;
+    width: 100%;
+    height: 100%;
+}
+
+section h2 span.family img.family.disabled{
+    filter: sepia(100%) saturate(10%);
+    opacity: 0.5;
 }
 }
 
 
 article.stage{
 article.stage{

+ 2 - 5
public/index.php

@@ -1,13 +1,10 @@
 <?php
 <?php
-	//set_include_path('./');
-    //require_once("../application/config/config.php");
     include __DIR__ . "/../application/config.php";
     include __DIR__ . "/../application/config.php";
     include_once($path["controller"]);
     include_once($path["controller"]);
 
 
-    $request = $_SERVER['REQUEST_URI'];
+    //$request = $_SERVER['REQUEST_URI'];
+    $request = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
     $params = explode('/', $request);
     $params = explode('/', $request);
-    // Here you should probably gather the rest as params
 
 
-    // Call the action
     $controller = new Controller($params);
     $controller = new Controller($params);
 ?>
 ?>