Bladeren bron

Storage and lock badges in monster view. Fixd a problem with building and decoration IDs.

Iñigo Valentin 6 jaren geleden
bovenliggende
commit
b1f05f24c8

+ 4 - 2
application/bin/log-profile.py

@@ -305,9 +305,10 @@ def parseBuildings(db, data):
     print("Parsing buildings...")
     print("Parsing buildings...")
     uid = data["wizard_info"]["wizard_id"]
     uid = data["wizard_info"]["wizard_id"]
     for bui in data["building_list"]:
     for bui in data["building_list"]:
+        id = bui["building_id"]
         building = bui["building_master_id"]
         building = bui["building_master_id"]
         gain = bui["gain_per_hour"]
         gain = bui["gain_per_hour"]
-        insert(db, "building", (uid, building, gain))
+        insert(db, "building", (uid, id, building, gain))
     db.commit()
     db.commit()
 
 
 """
 """
@@ -320,9 +321,10 @@ def parseDecorations(db, data):
     print("Parsing decorations...")
     print("Parsing decorations...")
     uid = data["wizard_info"]["wizard_id"]
     uid = data["wizard_info"]["wizard_id"]
     for bui in data["deco_list"]:
     for bui in data["deco_list"]:
+        id = bui["deco_id"]
         building = bui["master_id"]
         building = bui["master_id"]
         level = bui["level"]
         level = bui["level"]
-        insert(db, "decoration", (uid, building, level))
+        insert(db, "decoration", (uid, id, building, level))
     db.commit()
     db.commit()
 
 
 """
 """

+ 36 - 0
application/entity/Unit.php

@@ -203,6 +203,11 @@
          */
          */
         public $experience_level_up = 0;
         public $experience_level_up = 0;
 
 
+        /**
+         * Indcates if the unit is in storage.
+         */
+        public $in_storage = false;
+
         /**
         /**
          * Unit title.
          * Unit title.
          * If Homunculus,it will be it's name.
          * If Homunculus,it will be it's name.
@@ -291,6 +296,8 @@
             if ($complete){
             if ($complete){
                 $this->load_runes();
                 $this->load_runes();
                 $this->load_teams();
                 $this->load_teams();
+                $this->check_storage();
+                $this->lock = $r["lock"];
                 $s =
                 $s =
                   "SELECT level " .
                   "SELECT level " .
                   "FROM " .
                   "FROM " .
@@ -323,6 +330,35 @@
             }
             }
         }
         }
 
 
+        /**
+         * Checks if the monster is in storage and sets $in_storage to true
+         * or false.
+         */
+        public function check_storage(){
+            global $BUILDING;
+            global $UID;
+            $s = "
+              SELECT 1
+              FROM
+                unit,
+                building
+              WHERE
+                unit.id = $this->id AND
+                unit.uid = '$UID' AND
+                building.uid = '$UID' AND
+                unit.building = building.id AND
+                building.building = '" . $BUILDING["MONSTER_STORAGE"] . "';
+            ";
+            error_log('S: ' . $s);
+            $q = $this->db->query($s);
+            if ($q->fetchArray(SQLITE3_ASSOC) == false){
+                $this->in_storage = false;
+            }
+            else{
+                $this->in_storage = true;
+            }
+        }
+
         /**
         /**
          * Loads the teams array, with the @{Team}s the unit is on.
          * Loads the teams array, with the @{Team}s the unit is on.
          */
          */

+ 11 - 0
application/helper/html.php

@@ -13,12 +13,16 @@
             $stars = $unit->stars;
             $stars = $unit->stars;
             $level = true;
             $level = true;
             $teams = (sizeof($unit->teams) > 0);
             $teams = (sizeof($unit->teams) > 0);
+            $lock = $unit->lock;
+            $storage = $unit->in_storage;
         }
         }
         elseif ($unit instanceof K_Unit){
         elseif ($unit instanceof K_Unit){
             $k = $unit;
             $k = $unit;
             $stars = $unit->base_stars;
             $stars = $unit->base_stars;
             $level = false;
             $level = false;
             $teams = 0;
             $teams = 0;
+            $lock = false;
+            $storage = false;
         }
         }
         else{
         else{
             return "";
             return "";
@@ -62,6 +66,13 @@
             }
             }
             $html .= "<img title='$title' src='" . $path["img"]["icon"] . "team.png'>";
             $html .= "<img title='$title' src='" . $path["img"]["icon"] . "team.png'>";
         }
         }
+        if ($lock == 1){
+            $html .= "<img title='Locked' src='" . $path["img"]["icon"] . "lock.png'>";
+        }
+        if ($storage){
+            $html .= "<img title='In storage' src='" . $path["img"]["icon"] . "storage.png'>";
+        }
+
         $html .= "</span>\n";
         $html .= "</span>\n";
         return $html;
         return $html;
     }
     }

+ 3 - 1
install_data/setup.sql

@@ -270,7 +270,7 @@ CREATE TABLE IF NOT EXISTS defense(
 CREATE TABLE IF NOT EXISTS unit(
 CREATE TABLE IF NOT EXISTS unit(
     uid INT NOT NULL REFERENCES player(id),
     uid INT NOT NULL REFERENCES player(id),
     id INT PRIMARY KEY NOT NULL,
     id INT PRIMARY KEY NOT NULL,
-    building TEXT, -- TODO
+    building INT,
     unit INT NOT NULL REFERENCES unit(id),
     unit INT NOT NULL REFERENCES unit(id),
     level INT NOT NULL CHECK(level BETWEEN 1 AND 40),
     level INT NOT NULL CHECK(level BETWEEN 1 AND 40),
     stars INT INT NOT NULL CHECK(stars BETWEEN 1 AND 6),
     stars INT INT NOT NULL CHECK(stars BETWEEN 1 AND 6),
@@ -337,11 +337,13 @@ CREATE TABLE IF NOT EXISTS rune(
 CREATE TABLE IF NOT EXISTS building(
 CREATE TABLE IF NOT EXISTS building(
     -- No primary key, can have multiple towers
     -- No primary key, can have multiple towers
     uid INT NOT NULL REFERENCES player(id),
     uid INT NOT NULL REFERENCES player(id),
+    id INT NOT NULL,
     building INT NOT NULL REFERENCES k_building(id),
     building INT NOT NULL REFERENCES k_building(id),
     gain INT NOT NULL CHECK(gain >= 0)
     gain INT NOT NULL CHECK(gain >= 0)
 );
 );
 CREATE TABLE IF NOT EXISTS decoration(
 CREATE TABLE IF NOT EXISTS decoration(
     uid INT NOT NULL REFERENCES player(id),
     uid INT NOT NULL REFERENCES player(id),
+    id INT NOT NULL,
     decoration INT NOT NULL REFERENCES k_decoration(id),
     decoration INT NOT NULL REFERENCES k_decoration(id),
     level INT NOT NULL CHECK(level > 0),
     level INT NOT NULL CHECK(level > 0),
     PRIMARY KEY (uid, decoration)
     PRIMARY KEY (uid, decoration)

+ 9 - 5
public/css/ui.css

@@ -566,22 +566,26 @@ div.monster_panel span.level{
 
 
 div.monster_panel span.badges{
 div.monster_panel span.badges{
     position: absolute;
     position: absolute;
-    width: 90%;
+    width: 1.6em;
     text-align: left;
     text-align: left;
-    bottom: 0.2em;
-    left: 0.2em;
+    top: 1.5em;
+    bottom: 0.6em;
+    left: 0.1em;
     z-index: 1;
     z-index: 1;
     pointer-events: none;
     pointer-events: none;
     display: block;
     display: block;
+    transform: rotate(180deg);
 }
 }
 
 
 div.monster_panel span.badges img{
 div.monster_panel span.badges img{
-    width: 1.4em;
-    height: 1.4em;
+    width: 1em;
+    height: 1em;
     /* filter: drop-shadow(0 0 0.3em #ffffff) drop-shadow(0 0 0.1em #ffffff); */
     /* filter: drop-shadow(0 0 0.3em #ffffff) drop-shadow(0 0 0.1em #ffffff); */
     border-radius: 50%;
     border-radius: 50%;
     border: 0.15em solid #000000;
     border: 0.15em solid #000000;
     background-color: #ffffff;
     background-color: #ffffff;
+    transform: rotate(180deg);
+    margin: -0.11em 0 -0.11em 0;
 }
 }
 
 
 /**
 /**

BIN
public/img/icon/lock.png


BIN
public/img/icon/storage.png


BIN
public/img/icon/team.png