浏览代码

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

Iñigo Valentin 6 年之前
父节点
当前提交
b1f05f24c8
共有 8 个文件被更改,包括 63 次插入8 次删除
  1. 4 2
      application/bin/log-profile.py
  2. 36 0
      application/entity/Unit.php
  3. 11 0
      application/helper/html.php
  4. 3 1
      install_data/setup.sql
  5. 9 5
      public/css/ui.css
  6. 二进制
      public/img/icon/lock.png
  7. 二进制
      public/img/icon/storage.png
  8. 二进制
      public/img/icon/team.png

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

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

+ 36 - 0
application/entity/Unit.php

@@ -203,6 +203,11 @@
          */
         public $experience_level_up = 0;
 
+        /**
+         * Indcates if the unit is in storage.
+         */
+        public $in_storage = false;
+
         /**
          * Unit title.
          * If Homunculus,it will be it's name.
@@ -291,6 +296,8 @@
             if ($complete){
                 $this->load_runes();
                 $this->load_teams();
+                $this->check_storage();
+                $this->lock = $r["lock"];
                 $s =
                   "SELECT level " .
                   "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.
          */

+ 11 - 0
application/helper/html.php

@@ -13,12 +13,16 @@
             $stars = $unit->stars;
             $level = true;
             $teams = (sizeof($unit->teams) > 0);
+            $lock = $unit->lock;
+            $storage = $unit->in_storage;
         }
         elseif ($unit instanceof K_Unit){
             $k = $unit;
             $stars = $unit->base_stars;
             $level = false;
             $teams = 0;
+            $lock = false;
+            $storage = false;
         }
         else{
             return "";
@@ -62,6 +66,13 @@
             }
             $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";
         return $html;
     }

+ 3 - 1
install_data/setup.sql

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

+ 9 - 5
public/css/ui.css

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

二进制
public/img/icon/lock.png


二进制
public/img/icon/storage.png


二进制
public/img/icon/team.png