ソースを参照

Monster, runes, and report pages working with the new data.

Iñigo Valentin 7 年 前
コミット
96c7e20dd1
40 ファイル変更1609 行追加1518 行削除
  1. 63 354
      application/Constant.php
  2. 1 0
      application/Controller.php
  3. 73 0
      application/entity/K_Rune_Set.php
  4. 46 0
      application/entity/K_Unit.php
  5. 119 2
      application/entity/Rune.php
  6. 12 12
      application/entity/Unit.php
  7. 14 13
      application/page/Monster_Page.php
  8. 17 16
      application/page/Monsters_Page.php
  9. 26 24
      application/page/Report_Runeupgrade_Page.php
  10. 45 62
      application/page/Report_Skillup_Page.php
  11. 27 64
      application/view/monster.php
  12. 1 1
      application/view/monsters.php
  13. 246 230
      application/view/report_runeupgrade.php
  14. 35 66
      application/view/report_skillup.php
  15. 40 48
      application/view/runes.php
  16. 623 0
      data.sql
  17. 105 226
      install_base.py
  18. 99 390
      install_user.py
  19. 17 10
      public/css/ui.css
  20. BIN
      public/img/layout/rune/01.png
  21. BIN
      public/img/layout/rune/02.png
  22. BIN
      public/img/layout/rune/03.png
  23. BIN
      public/img/layout/rune/04.png
  24. BIN
      public/img/layout/rune/05.png
  25. BIN
      public/img/layout/rune/06.png
  26. BIN
      public/img/layout/rune/07.png
  27. BIN
      public/img/layout/rune/08.png
  28. BIN
      public/img/layout/rune/10.png
  29. BIN
      public/img/layout/rune/11.png
  30. BIN
      public/img/layout/rune/13.png
  31. BIN
      public/img/layout/rune/14.png
  32. BIN
      public/img/layout/rune/15.png
  33. BIN
      public/img/layout/rune/16.png
  34. BIN
      public/img/layout/rune/17.png
  35. BIN
      public/img/layout/rune/18.png
  36. BIN
      public/img/layout/rune/19.png
  37. BIN
      public/img/layout/rune/20.png
  38. BIN
      public/img/layout/rune/21.png
  39. BIN
      public/img/layout/rune/22.png
  40. BIN
      public/img/layout/rune/23.png

+ 63 - 354
application/Constant.php

@@ -23,298 +23,7 @@
         "SCROLL_LEGENDARY_WIND" => 14,
     ];
 
-    
-    $SECRET_DUNGEON = [
-        # Secret dungeon ID: Monster Com2US ID
-        "1011" => 10103,
-        "1012" => 10105,
-        "1013" => 10201,
-        "1014" => 10202,
-        "1015" => 10203,
-        "1016" => 10204,
-        "1017" => 10205,
-        "1018" => 10301,
-        "1019" => 10302,
-        "1020" => 10303,
-        "1021" => 10304,
-        "1022" => 10305,
-        "1023" => 10401,
-        "1024" => 10402,
-        "1025" => 10403,
-        "1026" => 10404,
-        "1027" => 10601,
-        "1028" => 10602,
-        "1029" => 10603,
-        "1030" => 10604,
-        "1031" => 10702,
-        "1032" => 10703,
-        "1033" => 10705,
-        "1034" => 10801,
-        "1035" => 10802,
-        "1036" => 10803,
-        "1037" => 10901,
-        "1038" => 10902,
-        "1039" => 10903,
-        "1040" => 10905,
-        "1041" => 11101,
-        "1042" => 11103,
-        "1043" => 11104,
-        "1044" => 11105,
-        "1045" => 12101,
-        "1046" => 12102,
-        "1047" => 12103,
-        "1048" => 13201,
-        "1049" => 13202,
-        "1050" => 13203,
-        "1051" => 13204,
-        "1052" => 13205,
-        "1053" => 14801,
-        "1054" => 14802,
-        "1055" => 14803,
-        "1056" => 14804,
-        "1057" => 15201,
-        "1058" => 15203,
-        "1059" => 13604,
-        "1060" => 13605,
-        "1061" => 12605,
-        "1062" => 12814,
-        "2011" => 10101,
-        "2012" => 10102,
-        "2013" => 10104,
-        "2014" => 10405,
-        "2015" => 10501,
-        "2016" => 10502,
-        "2017" => 10503,
-        "2018" => 10504,
-        "2019" => 10505,
-        "2020" => 10605,
-        "2021" => 10701,
-        "2022" => 10704,
-        "2023" => 10804,
-        "2024" => 10805,
-        "2025" => 10904,
-        "2026" => 11001,
-        "2027" => 11002,
-        "2028" => 11003,
-        "2029" => 11004,
-        "2030" => 11005,
-        "2031" => 11102,
-        "2032" => 11301,
-        "2033" => 11302,
-        "2034" => 11303,
-        "2035" => 11304,
-        "2036" => 11305,
-        "2037" => 11401,
-        "2038" => 11402,
-        "2039" => 11403,
-        "2040" => 11404,
-        "2041" => 11405,
-        "2042" => 11501,
-        "2043" => 11502,
-        "2044" => 11503,
-        "2045" => 11504,
-        "2046" => 11505,
-        "2047" => 11701,
-        "2048" => 11702,
-        "2049" => 11703,
-        "2050" => 11704,
-        "2051" => 11705,
-        "2052" => 12001,
-        "2053" => 12002,
-        "2054" => 12003,
-        "2055" => 12004,
-        "2056" => 12005,
-        "2057" => 12104,
-        "2058" => 12105,
-        "2059" => 13701,
-        "2060" => 13702,
-        "2061" => 13703,
-        "2062" => 13704,
-        "2063" => 13705,
-        "2064" => 14001,
-        "2065" => 14002,
-        "2066" => 14003,
-        "2067" => 14004,
-        "2068" => 14005,
-        "2069" => 14805,
-        "2070" => 15001,
-        "2071" => 15002,
-        "2072" => 15003,
-        "2073" => 15004,
-        "2074" => 15005,
-        "2075" => 15202,
-        "2076" => 15204,
-        "2077" => 15205,
-        "2078" => 15301,
-        "2079" => 15303,
-        "2080" => 15305,
-        "2081" => 15401,
-        "2082" => 15402,
-        "2083" => 15403,
-        "2084" => 16001,
-        "2085" => 16002,
-        "2086" => 16003,
-        "2087" => 16004,
-        "2088" => 16005,
-        "2089" => 14901,
-        "2090" => 14902,
-        "2091" => 14903,
-        "2092" => 14904,
-        "2093" => 14905,
-        "2094" => 15601,
-        "2095" => 15602,
-        "2096" => 15603,
-        "2097" => 15604,
-        "2098" => 15605,
-        "2099" => 16501,
-        "2100" => 16502,
-        "2101" => 16503,
-        "2102" => 16504,
-        "2103" => 16505,
-        "2104" => 15901,
-        "2105" => 15902,
-        "2106" => 15903,
-        "2107" => 15904,
-        "2108" => 15905,
-        "2109" => 17201,
-        "2110" => 17202,
-        "2111" => 17203,
-        "2112" => 17204,
-        "2113" => 17205,
-        "2114" => 17701,
-        "2115" => 17702,
-        "2116" => 17703,
-        "2117" => 17704,
-        "2118" => 17705,
-        "2119" => 17801,
-        "2120" => 17802,
-        "2121" => 17803,
-        "2122" => 17804,
-        "2123" => 17805,
-        "3011" => 12705,
-        "3012" => 12905,
-        "3013" => 13005,
-        "3014" => 13105,
-        "3015" => 12805,
-        "2124" => 15801,
-        "2125" => 15802,
-        "2126" => 15803,
-        "2127" => 15804,
-        "2128" => 15805,
-        "2129" => 18501,
-        "2130" => 18502,
-        "2131" => 18503,
-        "2132" => 18504,
-        "2133" => 18505,
-        "2134" => 18402,
-        "2135" => 18405,
-        "2136" => 18701,
-        "2137" => 18702,
-        "2138" => 18703,
-        "2139" => 18704,
-        "2140" => 18705,
-        "2141" => 19001,
-        "2142" => 19002,
-        "2143" => 19003,
-        "2144" => 19004,
-        "2145" => 19005,
-        "2146" => 19501,
-        "2147" => 19502,
-        "2148" => 19503,
-        "2149" => 19504,
-        "2150" => 19505,
-        "2151" => 20201,
-        "2152" => 20202,
-        "2153" => 20203,
-        "2154" => 20204,
-        "2155" => 20205,
-        "2156" => 20701,
-        "2157" => 20702,
-        "2158" => 20703,
-        "2159" => 20704,
-        "2160" => 20705,
-        "2161" => 20801,
-        "2162" => 20802,
-        "2163" => 20803,
-        "2164" => 20804,
-        "2165" => 20805,
-        "2166" => 20301,
-        "2167" => 20302,
-        "2168" => 20303,
-        "2169" => 20304,
-        "2170" => 20305,
-    ];
-
-    SHOP_ITEM = [
-        "BOX_UNKNOWN_MAGIC" => 1300008,
-        "BOX_MYSTICAL_MAGIC" => 1300009,
-        "BOX_LEGENDARY_MAGIC" => 1300012,
-        "CRAFT_LOW" => 1401001,
-        "CRAFT_LOW" => 1401002,
-        "CRAFT_LOW" => 1401003,
-        "CRAFT_LOW" => 1401004,
-        "CRAFT_LOW" => 1401005,
-        "CRAFT_LOW" => 1401006,
-        "CRAFT_LOW" => 1401007,
-        "CRAFT_LOW" => 1401008,
-        "CRAFT_LOW" => 1401009,
-        "CRAFT_LOW" => 1401010,
-        "CRAFT_LOW" => 1401011,
-        "CRAFT_LOW" => 1401012,
-        "CRAFT_LOW" => 1401013,
-        "CRAFT_LOW" => 1401014,
-        "CRAFT_LOW" => 1401015,
-        "CRAFT_LOW" => 1401016,
-        "CRAFT_LOW" => 1401017,
-        "CRAFT_LOW" => 1401018,
-        "CRAFT_LOW" => 1401019,
-        "CRAFT_LOW" => 1401020,
-        "CRAFT_LOW" => 1401021,
-        "CRAFT_MID" => 1402001,
-        "CRAFT_MID" => 1402002,
-        "CRAFT_MID" => 1402003,
-        "CRAFT_MID" => 1402004,
-        "CRAFT_MID" => 1402005,
-        "CRAFT_MID" => 1402006,
-        "CRAFT_MID" => 1402007,
-        "CRAFT_MID" => 1402008,
-        "CRAFT_MID" => 1402009,
-        "CRAFT_MID" => 1402010,
-        "CRAFT_MID" => 1402011,
-        "CRAFT_MID" => 1402012,
-        "CRAFT_MID" => 1402013,
-        "CRAFT_MID" => 1402014,
-        "CRAFT_MID" => 1402015,
-        "CRAFT_MID" => 1402016,
-        "CRAFT_MID" => 1402017,
-        "CRAFT_MID" => 1402018,
-        "CRAFT_MID" => 1402019,
-        "CRAFT_MID" => 1402020,
-        "CRAFT_MID" => 1402021,
-        "CRAFT_HIGH" => 1403001,
-        "CRAFT_HIGH" => 1403002,
-        "CRAFT_HIGH" => 1403003,
-        "CRAFT_HIGH" => 1403004,
-        "CRAFT_HIGH" => 1403005,
-        "CRAFT_HIGH" => 1403006,
-        "CRAFT_HIGH" => 1403007,
-        "CRAFT_HIGH" => 1403008,
-        "CRAFT_HIGH" => 1403009,
-        "CRAFT_HIGH" => 1403010,
-        "CRAFT_HIGH" => 1403011,
-        "CRAFT_HIGH" => 1403012,
-        "CRAFT_HIGH" => 1403013,
-        "CRAFT_HIGH" => 1403014,
-        "CRAFT_HIGH" => 1403015,
-        "CRAFT_HIGH" => 1403016,
-        "CRAFT_HIGH" => 1403017,
-        "CRAFT_HIGH" => 1403018,
-        "CRAFT_HIGH" => 1403019,
-        "CRAFT_HIGH" => 1403020,
-        "CRAFT_HIGH" => 1403021,
-    ];
-
-    # TODO: Move these definitions to the models if not already done, delete this file.
+    // TODO => Move these definitions to the models if not already done, delete this file.
 
     $ELEMENT = [
         "WATER" => 1,
@@ -334,7 +43,7 @@
         "MATERIAL" => 5
     ];
 
-    $LEADER_STAT = [
+    $STAT = [
         "HP" => 1,
         "ATK" => 2,
         "DEF" => 3,
@@ -345,7 +54,7 @@
         "ACCURACY" => 8,
     ];
 
-    $LEADER_AREA = [
+    $EFFECT_AREA = [
         "GENERAL" => 0,
         "ARENA" => 1,
         "DUNGEON" => 2,
@@ -353,63 +62,63 @@
     ];
 
     $BUILDING = [
-        'SUMMONERS_TOWER': 1,
-        'SUMMONHENGE': 2,
-        'POND_OF_MANA': 3,
-        'CRYSTAL_MINE': 4,
-        'GATEWAY': 8,
-        'TEMPLE_OF_WISHES': 10,
-        'MAGIC_SHOP': 11,
-        'ANCIENT_STONES': 12,
-        'ARCANE_TOWER': 14,
-        'CRYSTAL_TITAN': 15,
-        'FUSION_HEXAGRAM': 16,
-        'FUSE_CENTER': 17,
-        'POWER_UP_CIRCLE': 20,
-        'TRANQUIL_FOREST': 22,
-        'GUSTY_CLIFFS': 23,
-        'DEEP_FOREST_ENT': 24,
-        'MONSTER_STORAGE': 25,
-        'TRANSMOGRIFICATION_BUILDING': 27,
+        'SUMMONERS_TOWER' => 1,
+        'SUMMONHENGE' => 2,
+        'POND_OF_MANA' => 3,
+        'CRYSTAL_MINE' => 4,
+        'GATEWAY' => 8,
+        'TEMPLE_OF_WISHES' => 10,
+        'MAGIC_SHOP' => 11,
+        'ANCIENT_STONES' => 12,
+        'ARCANE_TOWER' => 14,
+        'CRYSTAL_TITAN' => 15,
+        'FUSION_HEXAGRAM' => 16,
+        'FUSE_CENTER' => 17,
+        'POWER_UP_CIRCLE' => 20,
+        'TRANQUIL_FOREST' => 22,
+        'GUSTY_CLIFFS' => 23,
+        'DEEP_FOREST_ENT' => 24,
+        'MONSTER_STORAGE' => 25,
+        'TRANSMOGRIFICATION_BUILDING' => 27,
     ];
 
     $DECORATION = [
-        'GUARDSTONE': 4,
-        'MANA_FOUNTAIN': 5,
-        'SKY_TRIBE_TOTEM': 6,
-        'ARCANE_BOOSTER_TOWER': 7,
-        'CRYSTAL_ALTAR': 8,
-        'ANCIENT_SWORD': 9,
-        'SANCTUM_OF_ENERGY': 10,
-        'MYSTERIOUS_PLANT': 11,
-        'FIRE_SANCTUARY': 15,
-        'WATER_SANCTUARY': 16,
-        'WIND_SANCTUARY': 17,
-        'LIGHT_SANCTUARY': 18,
-        'DARK_SANCTUARY': 19,
-        'FALLEN_ANCIENT_GUARDIAN': 31,
-        'CRYSTAL_ROCK': 34,
-        'FAIRY_TREE': 35,
-        'FLAG_OF_BATTLE': 36,
-        'FLAG_OF_RAGE': 37,
-        'FLAG_OF_HOPE': 38,
-        'FLAG_OF_WILL': 39,
+        'GUARDSTONE' => 4,
+        'MANA_FOUNTAIN' => 5,
+        'SKY_TRIBE_TOTEM' => 6,
+        'ARCANE_BOOSTER_TOWER' => 7,
+        'CRYSTAL_ALTAR' => 8,
+        'ANCIENT_SWORD' => 9,
+        'SANCTUM_OF_ENERGY' => 10,
+        'MYSTERIOUS_PLANT' => 11,
+        'FIRE_SANCTUARY' => 15,
+        'WATER_SANCTUARY' => 16,
+        'WIND_SANCTUARY' => 17,
+        'LIGHT_SANCTUARY' => 18,
+        'DARK_SANCTUARY' => 19,
+        'FALLEN_ANCIENT_GUARDIAN' => 31,
+        'CRYSTAL_ROCK' => 34,
+        'FAIRY_TREE' => 35,
+        'FLAG_OF_BATTLE' => 36,
+        'FLAG_OF_RAGE' => 37,
+        'FLAG_OF_HOPE' => 38,
+        'FLAG_OF_WILL' => 39,
     ];
 
     $INVENTORY_TYPE = [
-        'MONSTER': 1,
-        'CURRENCY': 6,
-        'RUNE': 8,
-        'SCROLL': 9,
-        'BOOSTER': 10,
-        'ESSENCES': 11,
-        'MONSTER_PIECE': 12,
-        # '': 15, Unknown. Appears in inventory_info with qty 0
-        'GUILD_MONSTER_PIECE': 19,
-        'RAINBOWMON': 25,   # Possibly material monsters in general. Appears when wish returns a rainbowmon.
-        'RUNE_CRAFT': 27,
-        'CRAFT_STUFF': 29,
-        'ENHANCING_MONSTER': 61,
+        'MONSTER' => 1,
+        'CURRENCY' => 6,
+        'RUNE' => 8,
+        'SCROLL' => 9,
+        'BOOSTER' => 10,
+        'ESSENCES' => 11,
+        'MONSTER_PIECE' => 12,
+        # '' => 15, Unknown. Appears in inventory_info with qty 0
+        'GUILD_MONSTER_PIECE' => 19,
+        'RAINBOWMON' => 25,   # Possibly material monsters in general. Appears when wish returns a rainbowmon.
+        'RUNE_CRAFT' => 27,
+        'CRAFT_STUFF' => 29,
+        'ENHANCING_MONSTER' => 61,
     ];
 
     $INVENTORY = [
@@ -469,7 +178,7 @@
         "RAINBOWMON_4_30" => 143140430,
         "RAINBOWMON_5_1" => 143140501,
         "DEVILMON" => 151050101,
-        'SUPER_ANGELMON' => 217140115
+        "SUPER_ANGELMON" => 217140115
     ];
 
     $RUNE_SET = [
@@ -496,18 +205,18 @@
         "TOLERANCE" => 23,
     ];
 
-    $STAT = [
+    $RUNE_STAT = [
         "HP" => 1,
-        "HP_PCT" => 2,
+        "HP%" => 2,
         "ATK" => 3,
-        "ATK_PCT" => 4,
+        "ATK%" => 4,
         "DEF" => 5,
-        "DEF_PCT" => 6,
+        "DEF%" => 6,
         "SPD" => 8,
-        "CRIT_RATE_PCT" => 9,
-        "CRIT_DMG_PCT" => 10,
-        "RESIST_PCT" => 11,
-        "ACCURACY_PCT" => 12,
+        "CRR" => 9,
+        "CRD" => 10,
+        "RES" => 11,
+        "ACC" => 12,
     ];
 
     $QUALITY = [

+ 1 - 0
application/Controller.php

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

+ 73 - 0
application/entity/K_Rune_Set.php

@@ -0,0 +1,73 @@
+<?php
+
+    require_once($path["entity"] . "Entity.php");
+
+    /**
+     * A rune set.
+     *
+     * Represents an object from the table 'k_rune_set'.
+     */
+    class K_Rune_Set extends Entity{
+
+        /**
+         * Set identifier.
+         */
+        public $id;
+
+        /**
+         * Set name.
+         */
+        public $name;
+
+        /**
+         * Required number of runes to activate the set.
+         */
+        public $amount;
+
+        /**
+         * Set description.
+         */
+        public $description;
+
+        /**
+         * Constructor.
+         *
+         * Searches the database and retrieves the information about the
+         * skill level, populating it and it's items.
+         *
+         * @param SQLite3 $db Connection to the database.
+         * @param int $skill Effect identifier.
+         */
+        public function __construct($db, $id){
+            global $path;
+            parent::__construct($db);
+            $s =
+              "SELECT " .
+              "  id, " .
+              "  name, " .
+              "  amount, " .
+              "  description " .
+              "FROM k_rune_set " .
+              "WHERE id = $id;";
+            $q = $this->db->query($s);
+            $r = $q->fetchArray(SQLITE3_ASSOC);
+            if ($r){
+                $this->id = $r["id"];
+                $this->name = $r["name"];
+                $this->amount = $r["amount"];
+                $this->description = $r["description"];
+            }
+        }
+
+        public function get_image(){
+            global $base_dir;
+            global $path;
+            if (file_exists($base_dir . "img/layout/rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png")){
+                return $path["img"]["layout"] . "rune/" . str_pad($this->id, 2, '0', STR_PAD_LEFT) . ".png";
+            }
+            else{
+                return $path["img"]["layout"] . "unknown.png";
+            }
+        }
+    }
+?>

+ 46 - 0
application/entity/K_Unit.php

@@ -33,11 +33,21 @@
          */
         public $element;
 
+        /**
+         * Element name (title case)
+         */
+        public $element_name;
+
         /**
          * Monster archetype.
          */
         public $archetype;
 
+        /**
+         * Archetype name (title case).
+         */
+        public $archetype_name;
+
         /**
          * Default star level.
          */
@@ -200,6 +210,8 @@
          */
         public function __construct($db, $id, $complete = true){
             global $path;
+            global $ELEMENT;
+            global $ARCHETYPE;
             parent::__construct($db);
             $s =
               "SELECT " .
@@ -243,7 +255,41 @@
                 $this->family = $r["family"];
                 $this->name = $r["name"];
                 $this->element = $r["element"];
+                switch($this->element){
+                    case $ELEMENT["WATER"]:
+                        $this->element_name = "Water";
+                        break;
+                    case $ELEMENT["FIRE"]:
+                        $this->element_name = "Fire";
+                        break;
+                    case $ELEMENT["WIND"]:
+                        $this->element_name = "Wind";
+                        break;
+                    case $ELEMENT["LIGHT"]:
+                        $this->element_name = "Light";
+                        break;
+                    case $ELEMENT["DARK"]:
+                        $this->element_name = "Dark";
+                        break;
+                }
                 $this->archetype = $r["archetype"];
+                switch($this->archetype){
+                    case $ARCHETYPE["ATTACK"]:
+                        $this->archetype_name = "Attack";
+                        break;
+                    case $ARCHETYPE["DEFENSE"]:
+                        $this->archetype_name = "Defense";
+                        break;
+                    case $ARCHETYPE["HP"]:
+                        $this->archetype_name = "HP";
+                        break;
+                    case $ARCHETYPE["SUPPORT"]:
+                        $this->archetype_name = "Support";
+                        break;
+                    case $ARCHETYPE["MATERIAL"]:
+                        $this->archetype_name = "Material";
+                        break;
+                }
                 $this->base_stars = $r["base_stars"];
                 $this->natural_stars = $r["natural_stars"];
                 $this->obtainable = $r["obtainable"];

+ 119 - 2
application/entity/Rune.php

@@ -1,6 +1,7 @@
 <?php
 
     require_once($path["entity"] . "Entity.php");
+    require_once($path["entity"] . "K_Rune_Set.php");
 
 
     /**
@@ -26,7 +27,7 @@
         public $assigned_to;
 
         /**
-         * Name of the set.
+         * {@see K_Rune_Set}.
          */
         public $type;
 
@@ -39,6 +40,11 @@
          * Rune stars.
          */
         public $stars;
+        
+        /**
+         * Indicates if the rune is legendary.
+         */
+        public $legendary;
 
         /**
          * Level of the rune.
@@ -55,6 +61,16 @@
          */
         public $original_quality;
 
+        /**
+         * Rune quality name (uppercase).
+         */
+        public $quality_name;
+
+        /**
+         * Rune original quality name (uppercase).
+         */
+        public $original_quality_name;
+
         /**
          * Price of the rune.
          */
@@ -75,6 +91,11 @@
          */
         public $main_stat;
 
+        /**
+         * Main stat name (uppercase).
+         */
+        public $main_stat_name;
+
         /**
          * Main stat value of the rune.
          */
@@ -85,6 +106,11 @@
          */
         public $innate_stat;
 
+        /**
+         * Extra stat name (uppercase).
+         */
+        public $innate_stat_name;
+
         /**
          * Extra stat value of the rune.
          */
@@ -100,6 +126,11 @@
          */
         public $substat_1;
 
+        /**
+         * Substat 1 name (uppercase).
+         */
+        public $substat_1_name;
+
         /**
          * Substat 1 value of the rune.
          */
@@ -115,6 +146,11 @@
          */
         public $substat_2;
 
+        /**
+         * Substat 2 name (uppercase).
+         */
+        public $substat_2_name;
+
         /**
          * Substat 2 value of the rune.
          */
@@ -130,6 +166,11 @@
          */
         public $substat_3;
 
+        /**
+         * Substat 3 name (uppercase).
+         */
+        public $substat_3_name;
+
         /**
          * Substat 3 value of the rune.
          */
@@ -145,6 +186,11 @@
          */
         public $substat_4;
 
+        /**
+         * Substat 4 name (uppercase).
+         */
+        public $substat_4_name;
+
         /**
          * Substat 4 value of the rune.
          */
@@ -175,6 +221,7 @@
               "  slot, " .
               "  stars, " .
               "  level, " .
+              "  ancient, " .
               "  quality, " .
               "  original_quality, " .
               "  value, " .
@@ -207,10 +254,11 @@
             if ($r){
                 $this->id = $r["id"];
                 $this->assigned_to = $r["assigned_to"];
-                $this->type = $r["type"];
+                $this->type = new K_Rune_Set($this->db, $r["type"]);
                 $this->slot = $r["slot"];
                 $this->stars = $r["stars"];
                 $this->level = $r["level"];
+                $this->ancient = $r["ancient"];
                 $this->quality = $r["quality"];
                 $this->original_quality = $r["original_quality"];
                 $this->value = $r["value"];
@@ -236,6 +284,75 @@
                 $this->substat_4_value = $r["substat_4_value"];
                 $this->substat_4_enchant = $r["substat_4_enchant"];
                 $this->substat_4_grind = $r["substat_4_grind"];
+                $this->main_stat_name = $this->stat_name($this->main_stat);
+                $this->innate_stat_name = $this->stat_name($this->innate_stat);
+                $this->substat_1_name = $this->stat_name($this->substat_1);
+                $this->substat_2_name = $this->stat_name($this->substat_2);
+                $this->substat_3_name = $this->stat_name($this->substat_3);
+                $this->substat_4_name = $this->stat_name($this->substat_4);
+                $this->quality_name = $this->quality_name($this->quality);
+                $this->original_quality_name = $this->quality_name($this->original_quality);
+            }
+        }
+
+        /**
+         * Gets a stat name frm the maps.
+         *
+         * @param int $stat Stat id.
+         * @return string Stat name (Uppercase)
+         */
+        private function stat_name($stat){
+            global $RUNE_STAT;
+            switch ($stat){
+                case $RUNE_STAT["HP"]:
+                    return "HP";
+                case $RUNE_STAT["HP%"]:
+                    return "HP%";
+                case $RUNE_STAT["ATK"]:
+                    return "ATK";
+                case $RUNE_STAT["ATK%"]:
+                    return "ATK%";
+                case $RUNE_STAT["DEF"]:
+                    return "DEF";
+                case $RUNE_STAT["DEF%"]:
+                    return "DEF%";
+                case $RUNE_STAT["SPD"]:
+                    return "SPD";
+                case $RUNE_STAT["CRR"]:
+                    return "CRR";
+                case $RUNE_STAT["CRD"]:
+                    return "CRD";
+                case $RUNE_STAT["RES"]:
+                    return "RES";
+                case $RUNE_STAT["ACC"]:
+                    return "ACC";
+                default:
+                    return "";
+            }
+        }
+
+        /**
+         * Gets a stat name frm the maps.
+         *
+         * @param int $q Quality id.
+         * @return string Quality (Uppercase)
+         */
+        private function quality_name($q){
+        error_log("QQQ ". $q);
+            global $QUALITY;
+            switch ($q){
+                case $QUALITY["NORMAL"]:
+                    return "NORMAL";
+                case $QUALITY["MAGIC"]:
+                    return "MAGIC";
+                case $QUALITY["RARE"]:
+                    return "RARE";
+                case $QUALITY["HERO"]:
+                    return "HERO";
+                case $QUALITY["LEGEND"]:
+                    return "LEGEND";
+                default:
+                    return "";
             }
         }
 

+ 12 - 12
application/entity/Unit.php

@@ -295,7 +295,6 @@
                   "WHERE " .
                   "  stars = $this->stars AND " .
                   "  level = $this->level;";
-                error_log($s);
                 $q = $this->db->query($s);
                 $r = $q->fetchArray(SQLITE3_ASSOC);
                 $this->experience_level = $r["exp"];
@@ -339,38 +338,39 @@
          * @param int $value Stat increase value.
          */
         private function sum_rune_stat($stat, $value){
+            global $RUNE_STAT;
             switch ($stat){
-                case "ATK":
+                case $RUNE_STAT["ATK"]:
                     $this->rune_attack += $value;
                     break;
-                case "DEF":
+                case $RUNE_STAT["DEF"]:
                     $this->rune_defense += $value;
                     break;
-                case "HP":
+                case $RUNE_STAT["HP"]:
                     $this->rune_hp += $value;
                     break;
-                case "SPD":
+                case $RUNE_STAT["SPD"]:
                     $this->rune_speed += $value;
                     break;
-                case "CRR":
+                case $RUNE_STAT["CRR"]:
                     $this->rune_crit_rate += $value;
                     break;
-                case "CRD":
+                case $RUNE_STAT["CRD"]:
                     $this->rune_crit_damage += $value;
                     break;
-                case "ACC":
+                case $RUNE_STAT["ACC"]:
                     $this->rune_accuracy += $value;
                     break;
-                case "RES":
+                case $RUNE_STAT["RES"]:
                     $this->rune_resistance += $value;
                     break;
-                case "ATK%":
+                case $RUNE_STAT["ATK%"]:
                     $this->rune_attack += ($this->attack * $value / 100);
                     break;
-                case "DEF%":
+                case $RUNE_STAT["DEF%"]:
                     $this->rune_defense += ($this->defense * $value / 100);
                     break;
-                case "HP%":
+                case $RUNE_STAT["HP%"]:
                     $this->rune_hp += ($this->hp * $value / 100);
                     break;
             }

+ 14 - 13
application/page/Monster_Page.php

@@ -24,11 +24,11 @@
             "spd" => 0,
             "crd" => 0,
             "elm" => [
-                "Fire" => 0,
-                "Water" => 0,
-                "Wind" => 0,
-                "Light" => 0,
-                "Dark" => 0
+                0 => 0,
+                1 => 0,
+                2 => 0,
+                3 => 0,
+                4 => 0
             ]
         ];
 
@@ -57,21 +57,22 @@
          * $building_stats array.
          */
         private function calculate_buildings(){
+            global $EFFECT_AREA;
             $s =
               "SELECT " .
               "  affected_stat, " .
               "  bonus, " .
               "  element " .
               "FROM " .
-              "  k_building, " .
-              "  k_building_level, " .
-              "  building " .
+              "  k_decoration, " .
+              "  k_decoration_level, " .
+              "  decoration " .
               "WHERE " .
-              "  k_building.id = building.building AND " .
-              "  building.building = k_building_level.building AND " .
-              "  building.level = k_building_level.level AND " .
-              "  area = 'Everywhere' AND " .
-              "  affected_stat IN ('ATK', 'DEF', 'HP', 'SPD', 'CRI Dmg');";
+              "  k_decoration.id = decoration.decoration AND " .
+              "  decoration.decoration = k_decoration_level.decoration AND " .
+              "  decoration.level = k_decoration_level.level AND " .
+              "  area = " . $EFFECT_AREA["GENERAL"] . " AND " .
+              "  affected_stat IS NOT NULL;";
             $q = $this->db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 switch($r["affected_stat"]){

+ 17 - 16
application/page/Monsters_Page.php

@@ -35,11 +35,11 @@
             "spd" => 0,
             "crd" => 0,
             "elm" => [
-                "Fire" => 0,
-                "Water" => 0,
-                "Wind" => 0,
-                "Light" => 0,
-                "Dark" => 0
+                0 => 0,
+                1 => 0,
+                2 => 0,
+                3 => 0,
+                4 => 0
             ]
         ];
 
@@ -133,37 +133,38 @@
          * $building_stats array.
          */
         private function calculate_buildings(){
+            global $STAT;
             $s =
               "SELECT " .
               "  affected_stat, " .
               "  bonus, " .
               "  element " .
               "FROM " .
-              "  k_building, " .
-              "  k_building_level, " .
-              "  building " .
+              "  k_decoration, " .
+              "  k_decoration_level, " .
+              "  decoration " .
               "WHERE " .
-              "  k_building.id = building.building AND " .
-              "  building.building = k_building_level.building AND " .
-              "  building.level = k_building_level.level AND " .
+              "  k_decoration.id = decoration.decoration AND " .
+              "  decoration.decoration = k_decoration_level.decoration AND " .
+              "  decoration.level = k_decoration_level.level AND " .
               "  area = 'Everywhere' AND " .
               "  affected_stat IN ('ATK', 'DEF', 'HP', 'SPD', 'CRI Dmg');";
             $q = $this->db->query($s);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                 switch($r["affected_stat"]){
-                    case "DEF":
+                    case $STAT["DEF"]:
                         $this->building_stats["def"] += $r["bonus"];
                         break;
-                    case "HP":
+                    case $STAT["HP"]:
                         $this->building_stats["hp"] += $r["bonus"];
                         break;
-                    case "SPD":
+                    case $STAT["SPD"]:
                         $this->building_stats["spd"] += $r["bonus"];
                         break;
-                    case "CRI Dmg":
+                    case $STAT["CRIT_DMG"]:
                         $this->building_stats["crd"] += $r["bonus"];
                         break;
-                    case "ATK":
+                    case $STAT["ATK"]:
                         if(strlen($r["element"]) > 0){
                             $this->building_stats["elm"][$r["element"]] += $r["bonus"];
                         }

+ 26 - 24
application/page/Report_Runeupgrade_Page.php

@@ -1,7 +1,7 @@
  <?php
 
     require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Monster.php");
+    require_once($path["entity"] . "Unit.php");
     require_once($path["entity"] . "Rune.php");
 
     /**
@@ -41,7 +41,7 @@
          * List of available upgrades. Can be described as:
          * $upgrades = [
          *   [
-         *     monster (Monster),
+         *     unit (Unit),
          *     upgrade = [
          *       [
          *         rune (Rune),
@@ -74,17 +74,17 @@
             $upgrade = null;
             $rupgrade = null;
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                if ($r["monster"] != $prev_monster){
+                if ($r["unit"] != $prev_monster){
                     if ($prev_rune != ""){
                         array_push($upgrade["upgrade"], $rupgrade);
                     }
                     if ($prev_monster != ""){
                         array_push($this->upgrades, $upgrade);
                     }
-                    $prev_monster = $r["monster"];
+                    $prev_monster = $r["unit"];
                     $prev_rune = "";
                     $upgrade = [
-                        "monster" => new Monster($this->db, $r["monster"]),
+                        "unit" => new Unit($this->db, $r["unit"]),
                         "upgrade" => [],
                     ];
                     $rupgrade = [
@@ -105,7 +105,7 @@
                 $rune_alt = new Rune($this->db, $r["alternative"]);
                 // If the alternative rune isassigned
                 if ($this->filters["alternative_source"] > 0 && strlen($rune_alt->assigned_to) > 0){
-                    $rune_alt->assigned_to = new Monster($this->db, $rune_alt->assigned_to);
+                    $rune_alt->assigned_to = new Unit($this->db, $rune_alt->assigned_to);
                 }
                 array_push($rupgrade["alternative"], $rune_alt);
             }
@@ -124,11 +124,11 @@
          */
         private function parse_filters(){
             // Monster
-            if (isset($_GET["monster_min_stars"]) && intval($_GET["monster_min_stars"]) > 0 && intval($_GET["mnster_min_stars"]) < 7){
+            if (isset($_GET["monster_min_stars"]) && intval($_GET["monster_min_stars"]) > 0 && intval($_GET["monster_min_stars"]) < 7){
                 $this->filters["monster_min_stars"] = $_GET["monster_min_stars"];
             }
-            if (isset($_GET["monster_max_stars"]) && intval($_GET["max_stars"]) > 0 && intval($_GET["monster_max_stars"]) < 7){
-                $this->filters["mnster_max_stars"] = $_GET["monster_max_stars"];
+            if (isset($_GET["monster_max_stars"]) && intval($_GET["monster_max_stars"]) > 0 && intval($_GET["monster_max_stars"]) < 7){
+                $this->filters["monster_max_stars"] = $_GET["monster_max_stars"];
             }
             if (isset($_GET["monster_in_storage"]) && $_GET["monster_in_storage"] == "on"){
                 $this->filters["monster_in_storage"] = true;
@@ -146,11 +146,11 @@
             if (isset($_GET["rune_max_stars"]) && intval($_GET["rune_max_stars"]) > 0 && intval($_GET["rune_max_stars"]) < 7){
                 $this->filters["rune_max_stars"] = $_GET["rune_max_stars"];
             }
-            if (isset($_GET["rune_min_level"]) && intval($_GET["rune_min_level"]) >= 0 && intval($_GET["mnster_min_level"]) <= 15){
+            if (isset($_GET["rune_min_level"]) && intval($_GET["rune_min_level"]) >= 0 && intval($_GET["rune_min_level"]) <= 15){
                 $this->filters["rune_min_level"] = $_GET["rune_min_level"];
             }
             if (isset($_GET["rune_max_level"]) && intval($_GET["max_level"]) >= 0 && intval($_GET["rune_max_level"]) <= 15){
-                $this->filters["mnster_max_level"] = $_GET["rune_max_level"];
+                $this->filters["rune_max_level"] = $_GET["rune_max_level"];
             }
             if (isset($_GET["rune_min_quality"]) && intval($_GET["rune_min_quality"]) >= 0 && intval($_GET["rune_min_quality"]) < 5){
                 $this->filters["rune_min_quality"] = $_GET["rune_min_quality"];
@@ -185,10 +185,10 @@
                 }
             }
             // Alternatives
-            if (isset($_GET["alternative_min_stars"]) && intval($_GET["alternative_min_stars"]) > 0 && intval($_GET["mnster_min_stars"]) < 7){
+            if (isset($_GET["alternative_min_stars"]) && intval($_GET["alternative_min_stars"]) > 0 && intval($_GET["alternative_min_stars"]) < 7){
                 $this->filters["alternative_min_stars"] = $_GET["alternative_min_stars"];
             }
-            if (isset($_GET["alternative_min_level"]) && intval($_GET["alternative_min_level"]) >= 0 && intval($_GET["mnster_min_level"]) <= 15){
+            if (isset($_GET["alternative_min_level"]) && intval($_GET["alternative_min_level"]) >= 0 && intval($_GET["alternative_min_level"]) <= 15){
                 $this->filters["alternative_min_level"] = $_GET["alternative_min_level"];
             }
             if (isset($_GET["alternative_min_original_quality"]) && intval($_GET["alternative_min_original_quality"]) >= 0 && intval($_GET["alternative_min_original_quality"]) < 5){
@@ -211,17 +211,19 @@
         private function build_query(){
             $s =
               "SELECT " .
-              "  monster.id AS monster, " .
+              "  unit.id AS unit, " .
               "  rune.id AS id, " .
               "  rune_alt.id AS alternative " .
               "FROM " .
               "  rune, " .
               "  rune rune_alt, " .
-              "  monster " .
+              "  unit, " .
+              "  k_unit " .
               "WHERE " .
-              "  monster.id = rune.assigned_to AND " .
-              "  monster.stars >= " . $this->filters["monster_min_stars"] . " AND " .
-              "  monster.stars <= " . $this->filters["monster_max_stars"] . " AND " .
+              "  unit.id = rune.assigned_to AND " .
+              "  unit.unit = k_unit.id AND " .
+              "  unit.stars >= " . $this->filters["monster_min_stars"] . " AND " .
+              "  unit.stars <= " . $this->filters["monster_max_stars"] . " AND " .
               "  rune.stars >= " . $this->filters["rune_min_stars"] . " AND " .
               "  rune.stars <= " . $this->filters["rune_max_stars"] . " AND " .
               "  rune.level >= " . $this->filters["rune_min_level"] . " AND " .
@@ -248,7 +250,7 @@
                     $s = $s . 
                       " ( " .
                       " rune_alt.assigned_to IS NULL OR " .
-                      " rune_alt.assigned_to IN (SELECT id FROM monster m WHERE m.stars < monster.stars) " .
+                      " rune_alt.assigned_to IN (SELECT id FROM unit m WHERE m.stars < unit.stars) " .
                       " ) AND ";
                     break;
                 // Case 2: Assigned or unassigned.
@@ -287,10 +289,10 @@
                     break;
             }
             if (strlen($this->filters["monster_name"]) > 0){
-                $s = $s . " AND monster.name LIKE = '%" . $this->filters["monster_name"] . "%' ";
+                $s = $s . " AND k_unit.name LIKE = '%" . $this->filters["monster_name"] . "%' ";
             }
             if (!$this->filters["monster_in_storage"]){
-                $s = $s . " AND monster.in_storage = 0 ";
+                //$s = $s . " AND unit.in_storage = 0 ";
             }
             if (count($this->filters["rune_slot"]) > 0){
                 $s = $s . " AND rune.slot IN ( ";
@@ -301,9 +303,9 @@
             }
             $s = $s .
               "ORDER BY " .
-              "  monster.stars DESC, " .
-              "  monster.level DESC, " .
-              "  monster.id, " .
+              "  unit.stars DESC, " .
+              "  unit.level DESC, " .
+              "  unit.id, " .
               "  rune.slot, " .
               "  id, " .
               "  rune_alt.stars DESC, " .

+ 45 - 62
application/page/Report_Skillup_Page.php

@@ -1,7 +1,7 @@
  <?php
 
     require_once($path["page"] . "Page.php");
-    require_once($path["entity"] . "Monster.php");
+    require_once($path["entity"] . "Unit.php");
 
     /**
      * Urgent Skillup report page.
@@ -11,7 +11,7 @@
         /**
          * Array of @{see Monsters}s.
          */
-        public $monsters = [];
+        public $units = [];
 
         /**
          * The filters the page can handle.
@@ -25,7 +25,8 @@
             "without_runes" => false,
             "family" => false,
             "maxed" => false,
-            "2a" => false
+            "2a" => false,
+            "homunculus" => false
         ];
 
         /**
@@ -45,7 +46,7 @@
             error_log($s_mon);
             $q_mon = $this->db->query($s_mon);
             while ($r_mon = $q_mon->fetchArray(SQLITE3_ASSOC)){
-                array_push($this->monsters, new Monster($db, $r_mon["id"]));
+                array_push($this->units, new Unit($db, $r_mon["id"]));
             }
             $this->title = "Urgent skill-ups - SWDB";
             $this->description = "Monster in need os skilling up";
@@ -84,6 +85,10 @@
             if (isset($_GET["2a"]) && $_GET["2a"] == "on"){
                 $this->filters["2a"] = true;
             }
+            if (isset($_GET["homunculus"]) && $_GET["homunculus"] == "on"){
+                $this->filters["homunculus"] = true;
+            }
+
             return;
         }
 
@@ -96,85 +101,63 @@
         private function build_query(){
             $s =
               "SELECT DISTINCT " .
-              "  monster.id AS id, " .
-              "  sum( " .
-              "    CASE k_skill.slot " .
-              "      WHEN 1 THEN (monster.skill_1_level - 1) * 1 " .
-              "      WHEN 2 THEN (monster.skill_2_level - 1) * 1.5 " .
-              "      WHEN 3 THEN (monster.skill_3_level - 1) * 2 " .
-              "      WHEN 4 THEN (monster.skill_4_level - 1) * 2.5 " .
-              "      END " .
-              "  ) AS ponderated_level, " .
-              "  sum( " .
-              "    CASE k_skill.slot " .
-              "      WHEN 1 THEN (monster.skill_1_level - 1) " .
-              "      WHEN 2 THEN (monster.skill_2_level - 1) " .
-              "      WHEN 3 THEN (monster.skill_3_level - 1) " .
-              "      WHEN 4 THEN (monster.skill_4_level - 1) " .
-              "      END " .
-              "    ) AS level, " .
-              "  sum( " .
-              "    CASE k_skill.slot " .
-              "      WHEN 1 THEN (k_skill.max_level - 1) * 1 " .
-              "      WHEN 2 THEN (k_skill.max_level - 1) * 1.5 " .
-              "      WHEN 3 THEN (k_skill.max_level - 1) * 2 " .
-              "      WHEN 4 THEN (k_skill.max_level - 1) * 2.5 " .
-              "      END " .
-              "  ) AS ponderated_max_level, " .
-              "  sum( " .
-              "    CASE k_skill.slot " .
-              "      WHEN 1 THEN (k_skill.max_level - 1) " .
-              "      WHEN 2 THEN (k_skill.max_level - 1) " .
-              "      WHEN 3 THEN (k_skill.max_level - 1) " .
-              "      WHEN 4 THEN (k_skill.max_level - 1) " .
-              "      END " .
-              "  ) AS max_level " .
+              "  unit.id AS id, " .
+              "  sum(unit_skill.level * ((k_skill.slot + 1) / 2)) AS ponderated_lvl, " .
+              "  sum(unit_skill.level) AS lvl, " .
+              "  sum(k_skill.max_level * ((k_skill.slot + 1) / 2)) AS ponderated_max_lvl, " .
+              "  sum(k_skill.max_level) AS max_lvl " .
               "FROM " .
-              "  monster, " .
-              "  k_monster_skill, " .
-              "  k_skill, " .
-              "  k_monster " .
+              "  unit, " .
+              "  k_unit, " .
+              "  unit_skill, " .
+              "  k_unit_skill, " .
+              "  k_skill " .
               "WHERE " .
-              "  monster.monster = k_monster_skill.monster AND " .
-              "  k_skill.id = k_monster_skill.skill AND " .
-              "  k_monster.id = monster.monster AND " .
-              "  k_skill.max_level > 1 AND " .
-              "  monster.stars >= " . $this->filters["min_stars"] . " AND " .
-              "  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"] . " ";
+              "  unit.unit = k_unit.id AND " .
+              "  unit_skill.unit = unit.id AND " .
+              "  unit_skill.skill = k_unit_skill.skill AND " .
+              "  k_unit.id = k_unit_skill.unit AND " .
+              "  k_skill.id = k_unit_skill.skill AND " .
+              "  unit.stars >= " . $this->filters["min_stars"] . " AND " .
+              "  unit.stars <= " . $this->filters["max_stars"] . " AND " .
+              "  k_unit.natural_stars >= " . $this->filters["min_natural_stars"] . " AND " .
+              "  k_unit.natural_stars <= " . $this->filters["max_natural_stars"] . " ";
             if (!$this->filters["in_storage"]){
-                $s = $s . " AND monster.in_storage = 0 ";
+                // TODO
+                //$s = $s . " AND unit.in_storage = 0 ";
             }
             if (!$this->filters["without_runes"]){
-                $s = $s . " AND monster.id IN (SELECT DISTINCT monster FROM monster_rune) ";
+                $s = $s . " AND unit.id IN (SELECT DISTINCT assigned_to FROM 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"] . ")) ";
+                $s = $s . " AND unit.unit NOT IN (SELECT id FROM k_unit m WHERE family IN (SELECT family FROM k_unit k WHERE k.family = m.family 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 ";
+                    $s = $s . " AND k_unit.id <> 19114 AND k_unit.id <> 19104 ";
                 }
                 // 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 ";
+                    $s = $s . " AND k_unit.id <> 23015 AND k_unit.id <> 23005 ";
                 }
             }
             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 . " AND (k_unit.awakens_from IS NULL OR k_unit.awakens_to IS NOT NULL OR k_unit.base_stars - k_unit.natural_stars = 1) ";
+            }
+            if (!$this->filters["homunculus"]){
+                $s = $s . " AND k_unit.homunculus <> 1 ";
             }
             $s = $s .
-              "GROUP BY monster.id ";
+              "GROUP BY unit.id ";
             if (!$this->filters["maxed"]){
-                $s = $s . " HAVING ponderated_level < ponderated_max_level ";
+                $s = $s . " HAVING ponderated_lvl < ponderated_max_lvl ";
             }
             $s = $s .
               "ORDER BY " .
-              "  ponderated_level * 100 / ponderated_max_level, " .
-              "  monster.stars DESC, " .
-              "  monster.level DESC, " .
-              "  level * 100 / max_level, " .
-              "  max_level - level DESC; ";
+              "  ponderated_lvl * 100 / ponderated_max_lvl, " .
+              "  unit.stars DESC; " .
+              "  unit.level DESC, " .
+              "  lvl * 100 / max_lvl, " .
+              "  max_lvl - lvl DESC; ";
             return $s;
         }
     }

+ 27 - 64
application/view/monster.php

@@ -75,7 +75,7 @@
                             }
 ?>
                         </span>
-                        <img title='<?=$mon_title?>' class='monster border_<?=$page->unit->unit->element?>' src='<?=$page->unit->unit->get_image()?>'/>
+                        <img title='<?=$mon_title?>' class='monster border_<?=$page->unit->unit->element_name?>' src='<?=$page->unit->unit->get_image()?>'/>
                         <span class='level'>
                             <?=$page->unit->level?>
                         </span>
@@ -105,9 +105,9 @@
                     </div>
                 </div>
 <?php
-                $building_attack = floor(($page->unit->base_attack * $page->building_stats["atk"] / 100) + ($page->unit->base_attack * $page->building_stats["elm"][$page->unit->unit->element] / 100));
-                $building_defense = floor($page->building_stats["def"] * $page->unit->base_defense / 100);
-                $building_hp = floor($page->building_stats["hp"] * $page->unit->base_hp / 100);
+                $building_attack = floor(($page->unit->attack * $page->building_stats["atk"] / 100) + ($page->unit->attack * $page->building_stats["elm"][$page->unit->unit->element] / 100));
+                $building_defense = floor($page->building_stats["def"] * $page->unit->defense / 100);
+                $building_hp = floor($page->building_stats["hp"] * $page->unit->hp / 100);
                 $building_speed = $page->building_stats["spd"];
                 $building_crit_rate = 0;
                 $building_crit_damage = $page->building_stats["crd"];
@@ -300,7 +300,6 @@
                         if ($skill->max_level > 1){
                             $absolute_level += $cur_lvl - 1;
                             $ponderated_level += ($cur_lvl - 1) * (1 + ($skill_num / 2));
-                            error_log("MULTIPLIER: " . (1 + ($skill_num / 2)));
                             $ponderated_max_level += ($skill->max_level - 1) * (1 + ($skill_num / 2));
                         }
                         $max_lvl = $skill->max_level;
@@ -416,9 +415,9 @@
                     <table class='rune'>
                         <tr>
                             <td class='icon'>
-                                <div class='rune_panel rune_slot_<?=$rune->slot?> rune_level_<?=$rune->level?> rune_quality_<?=$rune->quality?> rune_original_quality_<?=$rune->original_quality?>'>
+                                <div class='rune_panel rune_slot_<?=$rune->slot?> rune_level_<?=$rune->level?> rune_quality_<?=strtolower($rune->quality_name)?> rune_original_quality_<?=strtolower($rune->original_quality_name)?> rune_ancient_<?=$rune->ancient?>'>
                                     <img class='rune_base' src=<?=$path["img"]["layout"]?>rune/base.png/>
-                                    <img class='rune_icon' src='<?=$path["img"]["layout"]?>rune/<?=$rune->type?>.png'/>
+                                    <img class='rune_icon' src='<?=$rune->type->get_image()?>'/>
                                     <span class='rune_stars'>
 <?php
                                         for ($i = 0; $i < $rune->stars; $i ++){
@@ -438,12 +437,12 @@
                                     <tr class='main_stat'>
                                         <td class='stat'>
 <?php
-                                            if (in_array($rune->main_stat, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                $stat_name = str_replace("%", "", $rune->main_stat);
+                                            if (in_array($rune->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->main_stat_name);
                                                 $stat_value = "+ " . $rune->main_stat_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->main_stat;
+                                                $stat_name = $rune->main_stat_name;
                                                 $stat_value = "+ " . $rune->main_stat_value;
                                             }
 ?>
@@ -460,12 +459,12 @@
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (strpos($rune->innate_stat, "%") !== false){
-                                                $stat_name = str_replace("%", "", $rune->innate_stat);
+                                            elseif (in_array($rune->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->innate_stat_name);
                                                 $stat_value = "+ " . $rune->innate_stat_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->innate_stat;
+                                                $stat_name = $rune->innate_stat_name;
                                                 $stat_value = "+ " . $rune->innate_stat_value;
                                             }
 ?>
@@ -482,8 +481,8 @@
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (strpos($rune->substat_1, "%") !== false){
-                                                $stat_name = str_replace("%", "", $rune->substat_1);
+                                            elseif (in_array($rune->substat_1_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_1_name);
                                                 $stat_value = "+ " . $rune->substat_1_value . "%";
                                             }
                                             else{
@@ -510,12 +509,12 @@
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (strpos($rune->substat_2, "%") !== false){
-                                                $stat_name = str_replace("%", "", $rune->substat_2);
+                                            elseif (in_array($rune->substat_2_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_2_name);
                                                 $stat_value = "+ " . $rune->substat_2_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->substat_2;
+                                                $stat_name = $rune->substat_2_name;
                                                 $stat_value = "+ " . $rune->substat_2_value;
                                             }
                                             if ($rune->substat_2_craft == 1){
@@ -538,12 +537,12 @@
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (strpos($rune->substat_3, "%") !== false){
-                                                $stat_name = str_replace("%", "", $rune->substat_3);
+                                            elseif (in_array($rune->substat_3_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_3_name);
                                                 $stat_value = "+ " . $rune->substat_3_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->substat_3;
+                                                $stat_name = $rune->substat_3_name;
                                                 $stat_value = "+ " . $rune->substat_3_value;
                                             }
                                             if ($rune->substat_3_craft == 1){
@@ -566,12 +565,12 @@
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (strpos($rune->substat_4, "%") !== false){
-                                                $stat_name = str_replace("%", "", $rune->substat_4);
+                                            elseif (in_array($rune->substat_4_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_4_name);
                                                 $stat_value = "+ " . $rune->substat_4_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->substat_4;
+                                                $stat_name = $rune->substat_4_name;
                                                 $stat_value = "+ " . $rune->substat_4_value;
                                             }
                                             if ($rune->substat_4_craft == 1){
@@ -590,50 +589,14 @@
                                 </table>
                             </td>
                             <td class='details'>
-<?php
-                                switch ($rune->quality){
-                                    case 0:
-                                        $q = "Normal";
-                                        break;
-                                    case 1:
-                                        $q = "Magic";
-                                        break;
-                                    case 2:
-                                        $q = "Rare";
-                                        break;
-                                    case 3:
-                                        $q = "Hero";
-                                        break;
-                                    case 4:
-                                        $q = "Legend";
-                                        break;
-                                }
-                                switch ($rune->original_quality){
-                                    case 0:
-                                        $oq = "Normal";
-                                        break;
-                                    case 1:
-                                        $oq = "Magic";
-                                        break;
-                                    case 2:
-                                        $oq = "Rare";
-                                        break;
-                                    case 3:
-                                        $oq = "Hero";
-                                        break;
-                                    case 4:
-                                        $oq = "Legend";
-                                        break;
-                                }
-?>
                                 <table class='table_details'>
                                     <tr>
                                         <td class='title'>
                                             Quality:
                                         </td>
                                         <td class='value'>
-                                            <span class='quality quality_<?=strtolower($q)?>'>
-                                                <?=$q?>
+                                            <span class='quality quality_<?=strtolower($rune->quality_name)?>'>
+                                                <?=$rune->quality_name?>
                                             </span>
                                         </td>
                                     </tr>
@@ -642,8 +605,8 @@
                                             Original quality:
                                         </td>
                                         <td class='value'>
-                                            <span class='quality quality_<?=strtolower($oq)?>'>
-                                                <?=$oq?>
+                                            <span class='quality quality_<?=strtolower($rune->original_quality_name)?>'>
+                                                <?=$rune->original_quality_name?>
                                             </span>
                                         </td>
                                     </tr>

+ 1 - 1
application/view/monsters.php

@@ -160,7 +160,7 @@
                                         }
 ?>
                                     </span>
-                                    <img title='<?=$mon_title?>' class='monster border_<?=$mon->unit->element?>' src='<?=$mon->unit->get_image()?>'/>
+                                    <img title='<?=$mon_title?>' class='monster border_<?=$mon->unit->element_name?>' src='<?=$mon->unit->get_image()?>'/>
                                     <span class='level'>
                                         <?=$mon->level?>
                                     </span>

+ 246 - 230
application/view/report_runeupgrade.php

@@ -427,14 +427,14 @@
         </section> <!-- #filters -->
 <?php
             foreach ($page->upgrades as $upgrade){
-                if ($upgrade["monster"]->monster->awakens_from == "" && $upgrade["monster"]->monster->awakens_to == ""){
+                if ($upgrade["unit"]->unit->awakens_from == "" && $upgrade["unit"]->unit->awakens_to == ""){
                     // No to, no from, silver monster.
                     $star_class ="star_silver";
-                    $mon_title = $upgrade["monster"]->monster->element . " " . $upgrade["monster"]->monster->name;
+                    $mon_title = $upgrade["unit"]->unit->element_name . " " . $upgrade["unit"]->unit->name;
                 }
-                elseif ($upgrade["monster"]->monster->awakens_from =! "" && $upgrade["monster"]->monster->awakens_to == ""){
+                elseif ($upgrade["unit"]->unit->awakens_from =! "" && $upgrade["unit"]->unit->awakens_to == ""){
                     // Already awakened
-                    if ($upgrade["monster"]->monster->base_stars - $upgrade["monster"]->monster->natural_stars == 1){
+                    if ($upgrade["unit"]->unit->base_stars - $upgrade["unit"]->unit->natural_stars == 1){
                         // Normal awaken.
                         $star_class ="star_purple";
                     }
@@ -442,12 +442,12 @@
                         // Second awaken.
                         $star_class ="star_red";
                     }
-                    $mon_title = $upgrade["monster"]->monster->name;
+                    $mon_title = $upgrade["unit"]->unit->name;
                 }
-                elseif ($upgrade["monster"]->monster->awakens_to =! ""){
+                elseif ($upgrade["unit"]->unit->awakens_to =! ""){
                     // Awakeable.
                     $star_class ="star_gold";
-                    $mon_title = $upgrade["monster"]->monster->element . " " . $upgrade["monster"]->monster->name;
+                    $mon_title = $upgrade["unit"]->unit->element . " " . $upgrade["unit"]->unit->name;
                 }
 ?>
             <section class='content'>
@@ -462,16 +462,16 @@
                             <div class='monster_panel'>
                                 <span class='stars'>
 <?php
-                                        for ($i = 0; $i < $upgrade["monster"]->stars; $i ++){
+                                        for ($i = 0; $i < $upgrade["unit"]->stars; $i ++){
 ?>
                                         <img class='star <?=$star_class?>' src='<?=$path["img"]["layout"] . "icon/star.png"?>'/>
 <?php
                                         }
 ?>
                                 </span>
-                                <img title='<?=$mon_title?>' class='monster border_<?=$upgrade["monster"]->monster->element?>' src='<?=$upgrade["monster"]->monster->get_image()?>'/>
+                                <img title='<?=$mon_title?>' class='monster border_<?=$upgrade["unit"]->unit->element_name?>' src='<?=$upgrade["unit"]->unit->get_image()?>'/>
                                 <span class='level'>
-                                    Lv. <?=$upgrade["monster"]->level?>
+                                    Lv. <?=$upgrade["unit"]->level?>
                                 </span>
                             </div>
                         </div> <!-- .profile -->
@@ -483,9 +483,9 @@
                         <table class='rune'>
                             <tr>
                                 <td class='icon'>
-                                    <div class='rune_panel rune_slot_<?=$rupgrade["rune"]->slot?> rune_level_<?=$rupgrade["rune"]->level?> rune_quality_<?=$rupgrade["rune"]->quality?> rune_original_quality_<?=$rupgrade["rune"]->original_quality?>'>
+                                    <div class='rune_panel rune_slot_<?=$rupgrade["rune"]->slot?> rune_level_<?=$rupgrade["rune"]->level?> rune_quality_<?=strtolower($rupgrade["rune"]->quality_name)?> rune_original_quality_<?=strtolower($rupgrade["rune"]->original_quality_name)?> rune_ancient_<?=$rupgrade["rune"]->ancient?>'>
                                         <img class='rune_base' src='<?=$path["img"]["layout"]?>rune/base.png'/>
-                                        <img class='rune_icon' src='<?=$path["img"]["layout"]?>rune/<?=$rupgrade["rune"]->type?>.png'/>
+                                        <img class='rune_icon' src='<?=$rupgrade["rune"]->type->get_image()?>'/>
                                         <span class='rune_stars'>
 <?php
                                                 for ($i = 0; $i < $rupgrade["rune"]->stars; $i ++){
@@ -505,14 +505,14 @@
                                         <tr class='main_stat'>
                                             <td class='stat'>
 <?php
-                                                    if (in_array($rupgrade["rune"]->main_stat, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                        $stat_name = str_replace("%", "", $rupgrade["rune"]->main_stat);
-                                                        $stat_value = "+ " . $rupgrade["rune"]->main_stat_value . "%";
-                                                    }
-                                                    else{
-                                                        $stat_name = $rupgrade["rune"]->main_stat;
-                                                        $stat_value = "+ " . $rupgrade["rune"]->main_stat_value;
-                                                    }
+                                                if (in_array($rupgrade["rune"]->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                    $stat_name = str_replace("%", "", $rupgrade["rune"]->main_stat_name);
+                                                    $stat_value = "+ " . $rupgrade["rune"]->main_stat_value . "%";
+                                                }
+                                                else{
+                                                    $stat_name = $rupgrade["rune"]->main_stat_name;
+                                                    $stat_value = "+ " . $rupgrade["rune"]->main_stat_value;
+                                                }
 ?>
                                                 <?=$stat_name?>
                                             </td>
@@ -523,18 +523,18 @@
                                         <tr class='innate_stat'>
                                             <td class='stat'>
 <?php
-                                                    if (strlen($rupgrade["rune"]->innate_stat) == 0){
-                                                        $stat_name = "&nbsp;";
-                                                        $stat_value = "";
-                                                    }
-                                                    elseif (in_array($rupgrade["rune"]->innate_stat, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                        $stat_name = str_replace("%", "", $rupgrade["rune"]->innate_stat);
-                                                        $stat_value = "+ " . $rupgrade["rune"]->innate_stat_value . "%";
-                                                    }
-                                                    else{
-                                                        $stat_name = $rupgrade["rune"]->innate_stat;
-                                                        $stat_value = "+ " . $rupgrade["rune"]->innate_stat_value;
-                                                    }
+                                                if (strlen($rupgrade["rune"]->innate_stat_name) == 0){
+                                                    $stat_name = "&nbsp;";
+                                                    $stat_value = "";
+                                                }
+                                                elseif (in_array($rupgrade["rune"]->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                    $stat_name = str_replace("%", "", $rupgrade["rune"]->innate_stat_name);
+                                                    $stat_value = "+ " . $rupgrade["rune"]->innate_stat_value . "%";
+                                                }
+                                                else{
+                                                    $stat_name = $rupgrade["rune"]->innate_stat_name;
+                                                    $stat_value = "+ " . $rupgrade["rune"]->innate_stat_value;
+                                                }
 ?>
                                                 <?=$stat_name?>
                                             </td>
@@ -545,162 +545,170 @@
                                         <tr class=substat>
                                             <td class='stat'>
 <?php
-                                                    if (strlen($rupgrade["rune"]->substat_1) == 0){
+                                                    if (strlen($rupgrade["rune"]->substat_1_name) == 0){
                                                         $stat_name = "&nbsp;";
                                                         $stat_value = "";
                                                     }
-                                                    elseif (in_array($rupgrade["rune"]->substat_1, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                        $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_1);
+                                                    elseif (in_array($rupgrade["rune"]->substat_1_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                        $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_1_name);
                                                         $stat_value = "+ " . $rupgrade["rune"]->substat_1_value . "%";
                                                     }
                                                     else{
-                                                        $stat_name = $rupgrade["rune"]->substat_1;
+                                                        $stat_name = $rupgrade["rune"]->substat_1_name;
                                                         $stat_value = "+ " . $rupgrade["rune"]->substat_1_value;
                                                     }
-                                                    if ($rupgrade["rune"]->substat_1_craft == 1){
-                                                        $craft = "craft";
-                                                    }
-                                                    else{
-                                                        $craft = "";
+                                                    $grind = "";
+                                                    if ($rupgrade["rune"]->substat_1_grind > 0){
+                                                        $grind = "+" . $rupgrade["rune"]->substat_1_grind;
+                                                        if (in_array($rupgrade["rune"]->substat_1_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                            $grind = $grind . "%";
+                                                        }
                                                     }
 ?>
                                                 <?=$stat_name?>
                                             </td>
-                                            <td class='value <?=$craft?>'>
+                                            <td class='value'>
                                                 <?=$stat_value?>
+                                                <span class='grind grind_<?=$grind?>'>
+                                                    <?=$grind?>
+                                                </span>
+<?php
+                                                if ($rupgrade["rune"]->substat_1_enchant == 1){
+?>
+                                                    <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                }
+?>
                                             </td>
                                         </tr>
                                         <tr class=substat>
                                             <td class='stat'>
 <?php
-                                                    if (strlen($rupgrade["rune"]->substat_2) == 0){
-                                                        $stat_name = "&nbsp;";
-                                                        $stat_value = "";
-                                                    }
-                                                    elseif (in_array($rupgrade["rune"]->substat_2, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                        $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_2);
-                                                        $stat_value = "+ " . $rupgrade["rune"]->substat_2_value . "%";
-                                                    }
-                                                    else{
-                                                        $stat_name = $rupgrade["rune"]->substat_2;
-                                                        $stat_value = "+ " . $rupgrade["rune"]->substat_2_value;
-                                                    }
-                                                    if ($rupgrade["rune"]->substat_2_craft == 1){
-                                                        $craft = "craft";
-                                                    }
-                                                    else{
-                                                        $craft = "";
+                                                if (strlen($rupgrade["rune"]->substat_2_name) == 0){
+                                                    $stat_name = "&nbsp;";
+                                                    $stat_value = "";
+                                                }
+                                                elseif (in_array($rupgrade["rune"]->substat_2_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                    $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_2_name);
+                                                    $stat_value = "+ " . $rupgrade["rune"]->substat_2_value . "%";
+                                                }
+                                                else{
+                                                    $stat_name = $rupgrade["rune"]->substat_2_name;
+                                                    $stat_value = "+ " . $rupgrade["rune"]->substat_2_value;
+                                                }
+                                                $grind = "";
+                                                if ($rupgrade["rune"]->substat_2_grind > 0){
+                                                    $grind = "+" . $rupgrade["rune"]->substat_2_grind;
+                                                    if (in_array($rupgrade["rune"]->substat_2_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                        $grind = $grind . "%";
                                                     }
+                                                }
 ?>
                                                 <?=$stat_name?>
                                             </td>
-                                            <td class='value <?=$craft?>'>
+                                            <td class='value'>
                                                 <?=$stat_value?>
+                                                <span class='grind grind_<?=$grind?>'>
+                                                    <?=$grind?>
+                                                </span>
+<?php
+                                                if ($rupgrade["rune"]->substat_2_enchant == 1){
+?>
+                                                    <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                }
+?>
                                             </td>
                                         </tr>
                                         <tr class=substat>
                                             <td class='stat'>
 <?php
-                                                    if (strlen($rupgrade["rune"]->substat_3) == 0){
-                                                        $stat_name = "&nbsp;";
-                                                        $stat_value = "";
-                                                    }
-                                                    elseif (in_array($rupgrade["rune"]->substat_3, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                        $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_3);
-                                                        $stat_value = "+ " . $rupgrade["rune"]->substat_3_value . "%";
-                                                    }
-                                                    else{
-                                                        $stat_name = $rupgrade["rune"]->substat_3;
-                                                        $stat_value = "+ " . $rupgrade["rune"]->substat_3_value;
-                                                    }
-                                                    if ($rupgrade["rune"]->substat_3_craft == 1){
-                                                        $craft = "craft";
-                                                    }
-                                                    else{
-                                                        $craft = "";
+                                                if (strlen($rupgrade["rune"]->substat_3_name) == 0){
+                                                    $stat_name = "&nbsp;";
+                                                    $stat_value = "";
+                                                }
+                                                elseif (in_array($rupgrade["rune"]->substat_3_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                    $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_3_name);
+                                                    $stat_value = "+ " . $rupgrade["rune"]->substat_3_value . "%";
+                                                }
+                                                else{
+                                                    $stat_name = $rupgrade["rune"]->substat_3_name;
+                                                    $stat_value = "+ " . $rupgrade["rune"]->substat_3_value;
+                                                }
+                                                $grind = "";
+                                                if ($rupgrade["rune"]->substat_3_grind > 0){
+                                                    $grind = "+" . $rupgrade["rune"]->substat_3_grind;
+                                                    if (in_array($rupgrade["rune"]->substat_3_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                        $grind = $grind . "%";
                                                     }
+                                                }
 ?>
                                                 <?=$stat_name?>
                                             </td>
-                                            <td class='value <?=$craft?>'>
+                                            <td class='value'>
                                                 <?=$stat_value?>
+                                                <span class='grind grind_<?=$grind?>'>
+                                                    <?=$grind?>
+                                                </span>
+<?php
+                                                if ($rupgrade["rune"]->substat_3_enchant == 1){
+?>
+                                                    <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                }
+?>
                                             </td>
                                         </tr>
                                         <tr class=substat>
                                             <td class='stat'>
 <?php
-                                                    if (strlen($rupgrade["rune"]->substat_4) == 0){
-                                                        $stat_name = "&nbsp;";
-                                                        $stat_value = "";
-                                                    }
-                                                    elseif (in_array($rupgrade["rune"]->substat_4, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                        $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_4);
-                                                        $stat_value = "+ " . $rupgrade["rune"]->substat_4_value . "%";
-                                                    }
-                                                    else{
-                                                        $stat_name = $rupgrade["rune"]->substat_4;
-                                                        $stat_value = "+ " . $rupgrade["rune"]->substat_4_value;
-                                                    }
-                                                    if ($rupgrade["rune"]->substat_4_craft == 1){
-                                                        $craft = "craft";
-                                                    }
-                                                    else{
-                                                        $craft = "";
+                                                if (strlen($rupgrade["rune"]->substat_4_name) == 0){
+                                                    $stat_name = "&nbsp;";
+                                                    $stat_value = "";
+                                                }
+                                                elseif (in_array($rupgrade["rune"]->substat_4_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                    $stat_name = str_replace("%", "", $rupgrade["rune"]->substat_4_name);
+                                                    $stat_value = "+ " . $rupgrade["rune"]->substat_4_value . "%";
+                                                }
+                                                else{
+                                                    $stat_name = $rupgrade["rune"]->substat_4_name;
+                                                    $stat_value = "+ " . $rupgrade["rune"]->substat_4_value;
+                                                }
+                                                $grind = "";
+                                                if ($rupgrade["rune"]->substat_4_grind > 0){
+                                                    $grind = "+" . $rupgrade["rune"]->substat_4_grind;
+                                                    if (in_array($rupgrade["rune"]->substat_4_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                        $grind = $grind . "%";
                                                     }
-?>
+                                                }
+                                                ?>
                                                 <?=$stat_name?>
                                             </td>
-                                            <td class='value <?=$craft?>'>
+                                            <td class='value'>
                                                 <?=$stat_value?>
+                                                <span class='grind grind_<?=$grind?>'>
+                                                    <?=$grind?>
+                                                </span>
+<?php
+                                                if ($rupgrade["rune"]->substat_4_enchant == 1){
+?>
+                                                    <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                }
+?>
                                             </td>
                                         </tr>
                                     </table>
                                 </td>
                                 <td class='details'>
-<?php
-                                        switch ($rupgrade["rune"]->quality){
-                                            case 0:
-                                                $q = "Normal";
-                                                break;
-                                            case 1:
-                                                $q = "Magic";
-                                                break;
-                                            case 2:
-                                                $q = "Rare";
-                                                break;
-                                            case 3:
-                                                $q = "Hero";
-                                                break;
-                                            case 4:
-                                                $q = "Legend";
-                                                break;
-                                        }
-                                        switch ($rupgrade["rune"]->original_quality){
-                                            case 0:
-                                                $oq = "Normal";
-                                                break;
-                                            case 1:
-                                                $oq = "Magic";
-                                                break;
-                                            case 2:
-                                                $oq = "Rare";
-                                                break;
-                                            case 3:
-                                                $oq = "Hero";
-                                                break;
-                                            case 4:
-                                                $oq = "Legend";
-                                                break;
-                                        }
-?>
                                     <table class='table_details'>
                                         <tr>
                                             <td class='title'>
                                                 Quality:
                                             </td>
                                             <td class='value'>
-                                                <span class='quality quality_<?=strtolower($q)?>'>
-                                                    <?=$q?>
+                                                <span class='quality quality_<?=strtolower($rupgrade["rune"]->quality_name)?>'>
+                                                    <?=$rupgrade["rune"]->quality_name?>
                                                 </span>
                                             </td>
                                         </tr>
@@ -709,8 +717,8 @@
                                                 Original quality:
                                             </td>
                                             <td class='value'>
-                                                <span class='quality quality_<?=strtolower($oq)?>'>
-                                                    <?=$oq?>
+                                                <span class='quality quality_<?=strtolower($rupgrade["rune"]->original_quality_name)?>'>
+                                                    <?=$rupgrade["rune"]->original_quality_name?>
                                                 </span>
                                             </td>
                                         </tr>
@@ -757,9 +765,9 @@
                                 <table class='rune alternative'>
                                     <tr>
                                         <td class='icon'>
-                                            <div class='rune_panel rune_slot_<?=$alternative->slot?> rune_level_<?=$alternative->level?> rune_quality_<?=$alternative->quality?> rune_original_quality_<?=$alternative->original_quality?>'>
+                                            <div class='rune_panel rune_slot_<?=$alternative->slot?> rune_level_<?=$alternative->level?> rune_quality_<?=strtolower($alternative->quality_name)?> rune_original_quality_<?=strtolower($alternative->original_quality_name)?> rune_ancient_<?=$alternative->ancient?>'>
                                                 <img class='rune_base' src='<?=$path["img"]["layout"]?>rune/base.png'/>
-                                                <img class='rune_icon' src='<?=$path["img"]["layout"]?>rune/<?=$alternative->type?>.png'/>
+                                                <img class='rune_icon' src='<?=$alternative->type->get_image()?>'/>
                                                 <span class='rune_stars'>
 <?php
                                                         for ($i = 0; $i < $alternative->stars; $i ++){
@@ -778,7 +786,7 @@
 ?>
                                                 <div class='assigned'>
                                                     <a target='blank' href='/monsters/<?=$alternative->assigned_to->id?>'>
-                                                        <img title='<?=$alternative->assigned_to->monster->name?>' class='monster_image border_<?=$alternative->assigned_to->monster->element?>' src='<?=$alternative->assigned_to->monster->get_image()?>'/>
+                                                        <img title='<?=$alternative->assigned_to->unit->name?>' class='monster_image border_<?=$alternative->assigned_to->unit->element?>' src='<?=$alternative->assigned_to->unit->get_image()?>'/>
                                                     </a>
                                                 </div>
 <?php
@@ -790,12 +798,12 @@
                                                 <tr class='main_stat'>
                                                     <td class='stat'>
 <?php
-                                                            if (in_array($alternative->main_stat, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                                $stat_name = str_replace("%", "", $alternative->main_stat);
+                                                            if (in_array($alternative->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                $stat_name = str_replace("%", "", $alternative->main_stat_name);
                                                                 $stat_value = "+ " . $alternative->main_stat_value . "%";
                                                             }
                                                             else{
-                                                                $stat_name = $alternative->main_stat;
+                                                                $stat_name = $alternative->main_stat_name;
                                                                 $stat_value = "+ " . $alternative->main_stat_value;
                                                             }
 ?>
@@ -808,16 +816,16 @@
                                                 <tr class='innate_stat'>
                                                     <td class='stat'>
 <?php
-                                                            if (strlen($alternative->innate_stat) == 0){
+                                                            if (strlen($alternative->innate_stat_name) == 0){
                                                                 $stat_name = "&nbsp;";
                                                                 $stat_value = "";
                                                             }
-                                                            elseif (in_array($alternative->innate_stat, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                                $stat_name = str_replace("%", "", $alternative->innate_stat);
+                                                            elseif (in_array($alternative->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                $stat_name = str_replace("%", "", $alternative->innate_stat_name);
                                                                 $stat_value = "+ " . $alternative->innate_stat_value . "%";
                                                             }
                                                             else{
-                                                                $stat_name = $alternative->innate_stat;
+                                                                $stat_name = $alternative->innate_stat_name;
                                                                 $stat_value = "+ " . $alternative->innate_stat_value;
                                                             }
 ?>
@@ -830,162 +838,170 @@
                                                 <tr class=substat>
                                                     <td class='stat'>
 <?php
-                                                            if (strlen($alternative->substat_1) == 0){
+                                                            if (strlen($alternative->substat_1_name) == 0){
                                                                 $stat_name = "&nbsp;";
                                                                 $stat_value = "";
                                                             }
-                                                            elseif (in_array($alternative->substat_1, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                                $stat_name = str_replace("%", "", $alternative->substat_1);
+                                                            elseif (in_array($alternative->substat_1_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                $stat_name = str_replace("%", "", $alternative->substat_1_name);
                                                                 $stat_value = "+ " . $alternative->substat_1_value . "%";
                                                             }
                                                             else{
-                                                                $stat_name = $alternative->substat_1;
+                                                                $stat_name = $alternative->substat_1_name;
                                                                 $stat_value = "+ " . $alternative->substat_1_value;
                                                             }
-                                                            if ($alternative->substat_1_craft == 1){
-                                                                $craft = "craft";
-                                                            }
-                                                            else{
-                                                                $craft = "";
+                                                            $grind = "";
+                                                            if ($alternative->substat_1_grind > 0){
+                                                                $grind = "+" . $alternative->substat_1_grind;
+                                                                if (in_array($alternative->substat_1_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                    $grind = $grind . "%";
+                                                                }
                                                             }
 ?>
                                                         <?=$stat_name?>
                                                     </td>
-                                                    <td class='value <?=$craft?>'>
+                                                    <td class='value'>
                                                         <?=$stat_value?>
+                                                        <span class='grind grind_<?=$grind?>'>
+                                                            <?=$grind?>
+                                                        </span>
+<?php
+                                                        if ($alternative->substat_1_enchant == 1){
+?>
+                                                            <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                        }
+?>
                                                     </td>
                                                 </tr>
                                                 <tr class=substat>
                                                     <td class='stat'>
 <?php
-                                                            if (strlen($alternative->substat_2) == 0){
+                                                            if (strlen($alternative->substat_2_name) == 0){
                                                                 $stat_name = "&nbsp;";
                                                                 $stat_value = "";
                                                             }
-                                                            elseif (in_array($alternative->substat_2, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                                $stat_name = str_replace("%", "", $alternative->substat_2);
+                                                            elseif (in_array($alternative->substat_2_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                $stat_name = str_replace("%", "", $alternative->substat_2_name);
                                                                 $stat_value = "+ " . $alternative->substat_2_value . "%";
                                                             }
                                                             else{
-                                                                $stat_name = $alternative->substat_2;
+                                                                $stat_name = $alternative->substat_2_name;
                                                                 $stat_value = "+ " . $alternative->substat_2_value;
                                                             }
-                                                            if ($alternative->substat_2_craft == 1){
-                                                                $craft = "craft";
-                                                            }
-                                                            else{
-                                                                $craft = "";
+                                                            $grind = "";
+                                                            if ($alternative->substat_2_grind > 0){
+                                                                $grind = "+" . $alternative->substat_2_grind;
+                                                                if (in_array($alternative->substat_2_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                    $grind = $grind . "%";
+                                                                }
                                                             }
-?>
+                                                            ?>
                                                         <?=$stat_name?>
                                                     </td>
-                                                    <td class='value <?=$craft?>'>
+                                                    <td class='value'>
                                                         <?=$stat_value?>
+                                                        <span class='grind grind_<?=$grind?>'>
+                                                            <?=$grind?>
+                                                        </span>
+<?php
+                                                        if ($alternative->substat_2_enchant == 1){
+?>
+                                                            <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                        }
+?>
                                                     </td>
                                                 </tr>
                                                 <tr class=substat>
                                                     <td class='stat'>
 <?php
-                                                            if (strlen($alternative->substat_3) == 0){
+                                                            if (strlen($alternative->substat_3_name) == 0){
                                                                 $stat_name = "&nbsp;";
                                                                 $stat_value = "";
                                                             }
-                                                            elseif (in_array($alternative->substat_3, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                                $stat_name = str_replace("%", "", $alternative->substat_3);
+                                                            elseif (in_array($alternative->substat_3_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                $stat_name = str_replace("%", "", $alternative->substat_3_name);
                                                                 $stat_value = "+ " . $alternative->substat_3_value . "%";
                                                             }
                                                             else{
-                                                                $stat_name = $alternative->substat_3;
+                                                                $stat_name = $alternative->substat_3_name;
                                                                 $stat_value = "+ " . $alternative->substat_3_value;
                                                             }
-                                                            if ($alternative->substat_3_craft == 1){
-                                                                $craft = "craft";
+                                                            $grind = "";
+                                                            if ($alternative->substat_3_grind > 0){
+                                                                $grind = "+" . $alternative->substat_3_grind;
+                                                                if (in_array($alternative->substat_3_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                    $grind = $grind . "%";
+                                                                }
                                                             }
-                                                            else{
-                                                                $craft = "";
-                                                            }
-?>
+                                                            ?>
                                                         <?=$stat_name?>
                                                     </td>
-                                                    <td class='value <?=$craft?>'>
+                                                    <td class='value'>
                                                         <?=$stat_value?>
+                                                        <span class='grind grind_<?=$grind?>'>
+                                                            <?=$grind?>
+                                                        </span>
+<?php
+                                                        if ($alternative->substat_3_enchant == 1){
+?>
+                                                            <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                        }
+?>
                                                     </td>
                                                 </tr>
                                                 <tr class=substat>
                                                     <td class='stat'>
 <?php
-                                                            if (strlen($alternative->substat_4) == 0){
+                                                            if (strlen($alternative->substat_4_name) == 0){
                                                                 $stat_name = "&nbsp;";
                                                                 $stat_value = "";
                                                             }
-                                                            elseif (in_array($alternative->substat_4, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                                $stat_name = str_replace("%", "", $alternative->substat_4);
+                                                            elseif (in_array($alternative->substat_4_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                $stat_name = str_replace("%", "", $alternative->substat_4_name);
                                                                 $stat_value = "+ " . $alternative->substat_4_value . "%";
                                                             }
                                                             else{
-                                                                $stat_name = $alternative->substat_4;
+                                                                $stat_name = $alternative->substat_4_name;
                                                                 $stat_value = "+ " . $alternative->substat_4_value;
                                                             }
-                                                            if ($alternative->substat_4_craft == 1){
-                                                                $craft = "craft";
-                                                            }
-                                                            else{
-                                                                $craft = "";
+                                                            $grind = "";
+                                                            if ($alternative->substat_4_grind > 0){
+                                                                $grind = "+" . $alternative->substat_4_grind;
+                                                                if (in_array($alternative->substat_4_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                                    $grind = $grind . "%";
+                                                                }
                                                             }
-?>
+                                                            ?>
                                                         <?=$stat_name?>
                                                     </td>
-                                                    <td class='value <?=$craft?>'>
+                                                    <td class='value'>
                                                         <?=$stat_value?>
+                                                        <span class='grind grind_<?=$grind?>'>
+                                                            <?=$grind?>
+                                                        </span>
+<?php
+                                                        if ($alternative->substat_4_enchant == 1){
+?>
+                                                            <img title='Enchanted' src='<?=$path["img"]["layout"]?>rune/enchanted.png'/>
+<?php
+                                                        }
+?>
                                                     </td>
                                                 </tr>
                                             </table>
                                         </td>
                                         <td class='details'>
-<?php
-                                                switch ($alternative->quality){
-                                                    case 0:
-                                                        $q = "Normal";
-                                                        break;
-                                                    case 1:
-                                                        $q = "Magic";
-                                                        break;
-                                                    case 2:
-                                                        $q = "Rare";
-                                                        break;
-                                                    case 3:
-                                                        $q = "Hero";
-                                                        break;
-                                                    case 4:
-                                                        $q = "Legend";
-                                                        break;
-                                                }
-                                                switch ($alternative->original_quality){
-                                                    case 0:
-                                                        $oq = "Normal";
-                                                        break;
-                                                    case 1:
-                                                        $oq = "Magic";
-                                                        break;
-                                                    case 2:
-                                                        $oq = "Rare";
-                                                        break;
-                                                    case 3:
-                                                        $oq = "Hero";
-                                                        break;
-                                                    case 4:
-                                                        $oq = "Legend";
-                                                        break;
-                                                }
-?>
                                             <table class='table_details'>
                                                 <tr>
                                                     <td class='title'>
                                                         Quality:
                                                     </td>
                                                     <td class='value'>
-                                                        <span class='quality quality_<?=strtolower($q)?>'>
-                                                            <?=$q?>
+                                                        <span class='quality quality_<?=strtolower($alternative->quality_name)?>'>
+                                                            <?=$alternative->quality_name?>
                                                         </span>
                                                     </td>
                                                 </tr>
@@ -994,8 +1010,8 @@
                                                         Original quality:
                                                     </td>
                                                     <td class='value'>
-                                                        <span class='quality quality_<?=strtolower($oq)?>'>
-                                                            <?=$oq?>
+                                                        <span class='quality quality_<?=strtolower($alternative->original_quality_name)?>'>
+                                                            <?=$alternative->original_quality_name?>
                                                         </span>
                                                     </td>
                                                 </tr>

+ 35 - 66
application/view/report_skillup.php

@@ -81,6 +81,18 @@
                     </tr>
                     <tr>
                         <td class='filter' colspan='2'>
+<?php
+                            $checked = "";
+                            if ($page->filters["homunculus"]){
+                                $checked = "checked";
+                            }
+?>
+                            <input type='checkbox' name='homunculus' <?=$checked?>/>
+                            Include Homunculus.
+                        </td>
+                    </tr>
+                    <tr>
+                        <td class='filter' colspan='2'>
 <?php
                             $checked = "";
                             if ($page->filters["in_storage"]){
@@ -123,30 +135,15 @@
         </section> <!-- #filters -->
 <?php
         $index = 1;
-        foreach ($page->monsters as $mon){
-            if ($mon->monster->awakens_from == "" && $mon->monster->awakens_to == ""){
-                // No to, no from, silver monster.
-                $star_src = $path["img"]["layout"] . "icon/star_silver.png";
-                $mon_title = $mon->monster->element . " " . $mon->monster->name;
-            }
-            elseif ($mon->monster->awakens_from =! "" && $mon->monster->awakens_to == ""){
-                // Already awakened.
-                $star_src = $path["img"]["layout"] . "icon/star_aw.png";
-                $mon_title = $mon->monster->name;
-            }
-            elseif ($mon->monster->awakens_to =! ""){
-                // Awakeable.
-                $star_src = $path["img"]["layout"] . "icon/star.png";
-                $mon_title = $mon->monster->element . " " . $mon->monster->name;
-            }
-            if ($mon->monster->awakens_from == "" && $mon->monster->awakens_to == ""){
+        foreach ($page->units as $unit){
+            if ($unit->unit->awakens_from == "" && $unit->unit->awakens_to == ""){
                 // No to, no from, silver monster.
                 $star_class ="star_silver";
-                $mon_title = $mon->monster->element . " " . $mon->monster->name;
+                $unit_title = $unit->unit->element . " " . $unit->unit->name;
             }
-            elseif ($mon->monster->awakens_from =! "" && $mon->monster->awakens_to == ""){
+            elseif ($unit->unit->awakens_from =! "" && $unit->unit->awakens_to == ""){
                 // Already awakened
-                if ($mon->monster->base_stars - $mon->monster->natural_stars == 1){
+                if ($unit->unit->base_stars - $unit->unit->natural_stars == 1){
                     // Normal awaken.
                     $star_class = "star_purple";
                 }
@@ -154,32 +151,32 @@
                     // Second awaken.
                     $star_class = "star_red";
                 }
-                $mon_title = $mon->monster->name;
+                $unit_title = $unit->unit->name;
             }
-            elseif ($mon->monster->awakens_to =! ""){
+            elseif ($unit->unit->awakens_to =! ""){
                 // Awakeable.
                 $star_class = "star_gold";
-                $mon_title = $mon->monster->element . " " . $mon->monster->name;
+                $unit_title = $unit->unit->element . " " . $unit->unit->name;
             }
             switch ($index % 10){
                 case 1:
-                    $index_title = $index . "<span class='superindex'>st</span> - " . $mon_title;
+                    $index_title = $index . "<span class='superindex'>st</span> - " . $unit_title;
                     break;
                 case 2:
-                    $index_title = $index . "<span class='superindex'>nd</span> - " . $mon_title;
+                    $index_title = $index . "<span class='superindex'>nd</span> - " . $unit_title;
                     break;
                 case 3:
-                    $index_title = $index . "<span class='superindex'>rd</span> - " . $mon_title;
+                    $index_title = $index . "<span class='superindex'>rd</span> - " . $unit_title;
                     break;
                 default:
-                    $index_title = $index . "<span class='superindex'>th</span> - " . $mon_title;
+                    $index_title = $index . "<span class='superindex'>th</span> - " . $unit_title;
                     break;
             }
             switch ($index % 100){
                 case 11:
                 case 12:
                 case 13:
-                    $index_title = $index . "<span class='superindex'>th</span> - " . $mon_title;
+                    $index_title = $index . "<span class='superindex'>th</span> - " . $unit_title;
                     break;
             }
 ?>
@@ -195,63 +192,35 @@
                             <div class='monster_panel'>
                                 <span class='stars'>
 <?php
-                                    for ($i = 0; $i < $mon->stars; $i ++){
+                                    for ($i = 0; $i < $unit->stars; $i ++){
 ?>
                                         <img class='star <?=$star_class?>' src='<?=$path["img"]["layout"] . "icon/star.png"?>'/>
 <?php
                                     }
 ?>
                                 </span>
-                                <img title='<?=$mon_title?>' class='monster border_<?=$mon->monster->element?>' src='<?=$mon->monster->get_image()?>'/>
+                                <img title='<?=$unit_title?>' class='monster border_<?=$unit->unit->element_name?>' src='<?=$unit->unit->get_image()?>'/>
                                 <span class='level'>
-                                    <?=$mon->level?>
+                                    <?=$unit->level?>
                                 </span>
                             </div>
                         </div> <!-- .profile -->
                         <div class='skills'>
 <?php
-                            $skill_num = 1;
+                            $skill_num = 0;
                             $absolute_level = 0;
                             $absolute_max_level = 0;
                             $ponderated_level = 0;
                             $ponderated_max_level = 0;
-                            foreach ($mon->monster->skill as $skill){
+                            foreach ($unit->unit->skill as $skill){
                                 if ($skill->max_level > 1){
                                     $absolute_max_level += $skill->max_level - 1;
                                 }
-                                switch ($skill_num){
-                                    case 1:
-                                        $cur_lvl = $mon->skill_1_level;
-                                        if ($skill->max_level > 1){
-                                            $absolute_level += $cur_lvl - 1;
-                                            $ponderated_level += $cur_lvl - 1;
-                                            $ponderated_max_level += $skill->max_level - 1;
-                                        }
-                                        break;
-                                    case 2:
-                                        $cur_lvl = $mon->skill_2_level;
-                                        if ($skill->max_level > 1){
-                                            $absolute_level += $cur_lvl - 1;
-                                            $ponderated_level += ($cur_lvl - 1) * 1.5;
-                                            $ponderated_max_level += ($skill->max_level - 1) * 1.5;
-                                        }
-                                        break;
-                                    case 3:
-                                        $cur_lvl = $mon->skill_3_level;
-                                        if ($skill->max_level > 1){
-                                            $absolute_level += $cur_lvl - 1;
-                                            $ponderated_level += ($cur_lvl - 1) * 2.0;
-                                            $ponderated_max_level += ($skill->max_level - 1) * 2.0;
-                                        }
-                                        break;
-                                    case 4:
-                                        $cur_lvl = $mon->skill_4_level;
-                                        if ($skill->max_level > 1){
-                                            $absolute_level += $cur_lvl - 1;
-                                            $ponderated_level += ($cur_lvl - 1) * 2.5;
-                                            $ponderated_max_level += ($skill->max_level - 1) * 2.5;
-                                        }
-                                        break;
+                                $cur_lvl = $unit->skill_levels[$skill_num];
+                                if ($skill->max_level > 1){
+                                    $absolute_level += $cur_lvl - 1;
+                                    $ponderated_level += ($cur_lvl - 1) * (1 + ($skill_num / 2));
+                                    $ponderated_max_level += ($skill->max_level - 1) * (1 + ($skill_num / 2));
                                 }
                                 $max_lvl = $skill->max_level;
                                 if ($max_lvl == $cur_lvl){

+ 40 - 48
application/view/runes.php

@@ -773,9 +773,9 @@
                     <table class='rune'>
                         <tr>
                             <td class='icon'>
-                                <div class='rune_panel rune_slot_<?=$rune->slot?> rune_level_<?=$rune->level?> rune_quality_<?=$rune->quality?> rune_original_quality_<?=$rune->original_quality?>'>
+                                <div class='rune_panel rune_slot_<?=$rune->slot?> rune_level_<?=$rune->level?> rune_quality_<?=strtolower($rune->quality_name)?> rune_original_quality_<?=strtolower($rune->original_quality)?> rune_legendary_<?=$rune->legendary?>'>
                                     <img class='rune_base' src='<?=$path["img"]["layout"]?>rune/base.png'/>
-                                    <img class='rune_icon' src='<?=$path["img"]["layout"]?>rune/<?=$rune->type?>.png'/>
+                                    <img class='rune_icon' src='<?=$rune->type->get_image()?>'/>
                                     <span class='rune_stars'>
 <?php
                                         for ($i = 0; $i < $rune->stars; $i ++){
@@ -794,7 +794,7 @@
 ?>
                                     <div class='assigned'>
                                         <a target='blank' href='/monsters/<?=$rune->assigned_to->id?>'>
-                                            <img title='<?=$rune->assigned_to->unit->name?>' class='monster_image border_<?=$rune->assigned_to->unit->element?>' src='<?=$rune->assigned_to->unit->get_image()?>'/>
+                                            <img title='<?=$rune->assigned_to->unit->name?>' class='monster_image border_<?=$rune->assigned_to->unit->element_name?>' src='<?=$rune->assigned_to->unit->get_image()?>'/>
                                         </a>
                                     </div>
 <?php
@@ -806,12 +806,12 @@
                                     <tr class='main_stat'>
                                         <td class='stat'>
 <?php
-                                            if (in_array($rune->main_stat, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                $stat_name = str_replace("%", "", $rune->main_stat);
+                                            if (in_array($rune->main_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->main_stat_name);
                                                 $stat_value = $rune->main_stat_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->main_stat;
+                                                $stat_name = $rune->main_stat_name;
                                                 $stat_value = $rune->main_stat_value;
                                             }
 ?>
@@ -824,16 +824,16 @@
                                     <tr class='innate_stat'>
                                         <td class='stat'>
 <?php
-                                            if (strlen($rune->innate_stat) == 0){
+                                            if (strlen($rune->innate_stat_name) == 0){
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (in_array($rune->innate_stat, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                $stat_name = str_replace("%", "", $rune->innate_stat);
+                                            elseif (in_array($rune->innate_stat_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->innate_stat_name);
                                                 $stat_value = $rune->innate_stat_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->innate_stat;
+                                                $stat_name = $rune->innate_stat_name;
                                                 $stat_value = $rune->innate_stat_value;
                                             }
 ?>
@@ -846,31 +846,32 @@
                                     <tr class=substat>
                                         <td class='stat'>
 <?php
-                                            if (strlen($rune->substat_1) == 0){
+                                            if (strlen($rune->substat_1_name) == 0){
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (in_array($rune->substat_1, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                $stat_name = str_replace("%", "", $rune->substat_1);
+                                            elseif (in_array($rune->substat_1_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_1_name);
                                                 $stat_value = $rune->substat_1_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->substat_1;
+                                                $stat_name = $rune->substat_1_name;
                                                 $stat_value = $rune->substat_1_value;
                                             }
                                             $grind = "";
                                             if ($rune->substat_1_grind > 0){
                                                 $grind = "+" . $rune->substat_1_grind;
-                                                if (in_array($rune->substat_1, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                if (in_array($rune->substat_1_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
                                                     $grind = $grind . "%";
                                                 }
                                             }
 ?>
                                             <?=$stat_name?>
                                         </td>
-                                        <td class='value <?=$craft?>'>
+                                        <td class='value'>
                                             <?=$stat_value?>
-                                            <span class='grind'><?=$grind?>
+                                            <span class='grind grind_<?=$grind?>'>
+                                                <?=$grind?>
                                             </span>
 <?php
                                             if ($rune->substat_1_enchant == 1){
@@ -884,34 +885,31 @@
                                     <tr class=substat>
                                         <td class='stat'>
 <?php
-                                            if (strlen($rune->substat_2) == 0){
+                                            if (strlen($rune->substat_2_name) == 0){
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (in_array($rune->substat_2, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                $stat_name = str_replace("%", "", $rune->substat_2);
+                                            elseif (in_array($rune->substat_2_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_2_name);
                                                 $stat_value = $rune->substat_2_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->substat_2;
+                                                $stat_name = $rune->substat_2_name;
                                                 $stat_value = $rune->substat_2_value;
                                             }
                                             $grind = "";
                                             if ($rune->substat_2_grind > 0){
                                                 $grind = "+" . $rune->substat_2_grind;
-                                                if (in_array($rune->substat_2, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                if (in_array($rune->substat_2_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
                                                     $grind = $grind . "%";
                                                 }
                                             }
-                                            else{
-                                                $craft = "";
-                                            }
                                             ?>
                                             <?=$stat_name?>
                                         </td>
-                                        <td class='value <?=$craft?>'>
+                                        <td class='value'>
                                             <?=$stat_value?>
-                                            <span class='grind'>
+                                            <span class='grind grind_<?=$grind?>'>
                                                 <?=$grind?>
                                             </span>
 <?php
@@ -926,34 +924,31 @@
                                     <tr class=substat>
                                         <td class='stat'>
 <?php
-                                            if (strlen($rune->substat_3) == 0){
+                                            if (strlen($rune->substat_3_name) == 0){
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (in_array($rune->substat_3, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                $stat_name = str_replace("%", "", $rune->substat_3);
+                                            elseif (in_array($rune->substat_3_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_3_name);
                                                 $stat_value = $rune->substat_3_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->substat_3;
+                                                $stat_name = $rune->substat_3_name;
                                                 $stat_value = $rune->substat_3_value;
                                             }
                                             $grind = "";
                                             if ($rune->substat_3_grind > 0){
                                                 $grind = "+" . $rune->substat_3_grind;
-                                                if (in_array($rune->substat_3, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                if (in_array($rune->substat_3_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
                                                     $grind = $grind . "%";
                                                 }
                                             }
-                                            else{
-                                                $craft = "";
-                                            }
-                                            ?>
+?>
                                             <?=$stat_name?>
                                         </td>
-                                        <td class='value <?=$craft?>'>
+                                        <td class='value'>
                                             <?=$stat_value?>
-                                            <span class='grind'>
+                                            <span class='grind grind_<?=$grind?>'>
                                                 <?=$grind?>
                                             </span>
 <?php
@@ -968,34 +963,31 @@
                                     <tr class=substat>
                                         <td class='stat'>
 <?php
-                                            if (strlen($rune->substat_4) == 0){
+                                            if (strlen($rune->substat_4_name) == 0){
                                                 $stat_name = "&nbsp;";
                                                 $stat_value = "";
                                             }
-                                            elseif (in_array($rune->substat_4, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
-                                                $stat_name = str_replace("%", "", $rune->substat_4);
+                                            elseif (in_array($rune->substat_4_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                $stat_name = str_replace("%", "", $rune->substat_4_name);
                                                 $stat_value = $rune->substat_4_value . "%";
                                             }
                                             else{
-                                                $stat_name = $rune->substat_4;
+                                                $stat_name = $rune->substat_4_name;
                                                 $stat_value = $rune->substat_4_value;
                                             }
                                             $grind = "";
                                             if ($rune->substat_4_grind > 0){
                                                 $grind = "+" . $rune->substat_4_grind;
-                                                if (in_array($rune->substat_4, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
+                                                if (in_array($rune->substat_4_name, array("CRR", "CRD", "RES", "ACC", "HP%", "ATK%", "DEF%"))){
                                                     $grind = $grind . "%";
                                                 }
                                             }
-                                            else{
-                                                $craft = "";
-                                            }
                                             ?>
                                             <?=$stat_name?>
                                         </td>
-                                        <td class='value <?=$craft?>'>
+                                        <td class='value'>
                                             <?=$stat_value?>
-                                            <span class='grind'>
+                                            <span class='grind grind_<?=$grind?>'>
                                                 <?=$grind?>
                                             </span>
 <?php

+ 623 - 0
data.sql

@@ -0,0 +1,623 @@
+CREATE TABLE IF NOT EXISTS k_difficulty(id INT, name TEXT);
+
+CREATE TABLE IF NOT EXISTS k_source(id INT, name TEXT, description TEXT, farmable_source INT);
+
+CREATE TABLE IF NOT EXISTS k_element(id INT, name TEXT, strong_against INT, weak_against INT);
+
+CREATE TABLE IF NOT EXISTS k_secret_dungeon(unit TEXT);
+
+CREATE TABLE IF NOT EXISTS k_archetype(id INT, name TEXT, description TEXT);
+
+CREATE TABLE IF NOT EXISTS k_stat(id INT, name TEXT);
+
+CREATE TABLE IF NOT EXISTS k_effect_area(id INT, name TEXT);
+
+CREATE TABLE IF NOT EXISTS k_decoration(id INT, area TEXT, affected_stat TEXT, element TEXT, name TEXT, description TEXT, max_level INT);
+
+CREATE TABLE IF NOT EXISTS k_building(id INT, name TEXT, description TEXT);
+
+CREATE TABLE IF NOT EXISTS k_inventory_type(id INT, name TEXT, description TEXT);
+
+CREATE TABLE IF NOT EXISTS k_inventory(id INT, name TEXT, description TEXT);
+
+CREATE TABLE IF NOT EXISTS k_enhance(id INT, name TEXT, description TEXT);
+
+CREATE TABLE IF NOT EXISTS k_rune_set(id INT, name TEXT, amount INT, description TEXT);
+
+CREATE TABLE IF NOT EXISTS k_rune_stat(id INT, name TEXT);
+
+CREATE TABLE IF NOT EXISTS k_quality(id INT, name TEXT);
+
+CREATE TABLE IF NOT EXISTS k_craft(id INT, name TEXT);
+
+CREATE TABLE IF NOT EXISTS k_experience(stars INT, level INT, exp INT);
+
+
+INSERT INTO k_difficulty VALUES (0, 'Easy');
+INSERT INTO k_difficulty VALUES (1, 'Normal');
+INSERT INTO k_difficulty VALUES (2, 'Hard');
+INSERT INTO k_difficulty VALUES (3, 'Hell');
+
+INSERT INTO k_source VALUES (1, 'Unknow Scroll', '', 1);
+INSERT INTO k_source VALUES (2, 'Mystical Scroll', '', 1);
+INSERT INTO k_source VALUES (3, 'Light & Dark Scroll', '', 1);
+INSERT INTO k_source VALUES (4, 'Water Scroll', '', 1);
+INSERT INTO k_source VALUES (5, 'Fire Scroll', '', 1);
+INSERT INTO k_source VALUES (6, 'Wind Scroll', '', 1);
+INSERT INTO k_source VALUES (7, 'Legendary Scroll', '', 1);
+INSERT INTO k_source VALUES (8, 'Summon Stones', '', 1);
+INSERT INTO k_source VALUES (9, 'Summon Pieces', '', 1);
+INSERT INTO k_source VALUES (10, 'Light & Dark Pieces', '', 1);
+INSERT INTO k_source VALUES (11, 'Transcendence Scroll', '', 1);
+INSERT INTO k_source VALUES (12, 'Legendary Water Scroll', '', 1);
+INSERT INTO k_source VALUES (13, 'Legendary Fire Scroll', '', 1);
+INSERT INTO k_source VALUES (14, 'Legendary Wind Scroll', '', 1);
+
+INSERT INTO k_secret_dungeon VALUES ('10103');
+INSERT INTO k_secret_dungeon VALUES ('10105');
+INSERT INTO k_secret_dungeon VALUES ('10201');
+INSERT INTO k_secret_dungeon VALUES ('10202');
+INSERT INTO k_secret_dungeon VALUES ('10203');
+INSERT INTO k_secret_dungeon VALUES ('10204');
+INSERT INTO k_secret_dungeon VALUES ('10205');
+INSERT INTO k_secret_dungeon VALUES ('10301');
+INSERT INTO k_secret_dungeon VALUES ('10302');
+INSERT INTO k_secret_dungeon VALUES ('10303');
+INSERT INTO k_secret_dungeon VALUES ('10304');
+INSERT INTO k_secret_dungeon VALUES ('10305');
+INSERT INTO k_secret_dungeon VALUES ('10401');
+INSERT INTO k_secret_dungeon VALUES ('10402');
+INSERT INTO k_secret_dungeon VALUES ('10403');
+INSERT INTO k_secret_dungeon VALUES ('10404');
+INSERT INTO k_secret_dungeon VALUES ('10601');
+INSERT INTO k_secret_dungeon VALUES ('10602');
+INSERT INTO k_secret_dungeon VALUES ('10603');
+INSERT INTO k_secret_dungeon VALUES ('10604');
+INSERT INTO k_secret_dungeon VALUES ('10702');
+INSERT INTO k_secret_dungeon VALUES ('10703');
+INSERT INTO k_secret_dungeon VALUES ('10705');
+INSERT INTO k_secret_dungeon VALUES ('10801');
+INSERT INTO k_secret_dungeon VALUES ('10802');
+INSERT INTO k_secret_dungeon VALUES ('10803');
+INSERT INTO k_secret_dungeon VALUES ('10901');
+INSERT INTO k_secret_dungeon VALUES ('10902');
+INSERT INTO k_secret_dungeon VALUES ('10903');
+INSERT INTO k_secret_dungeon VALUES ('10905');
+INSERT INTO k_secret_dungeon VALUES ('11101');
+INSERT INTO k_secret_dungeon VALUES ('11103');
+INSERT INTO k_secret_dungeon VALUES ('11104');
+INSERT INTO k_secret_dungeon VALUES ('11105');
+INSERT INTO k_secret_dungeon VALUES ('12101');
+INSERT INTO k_secret_dungeon VALUES ('12102');
+INSERT INTO k_secret_dungeon VALUES ('12103');
+INSERT INTO k_secret_dungeon VALUES ('13201');
+INSERT INTO k_secret_dungeon VALUES ('13202');
+INSERT INTO k_secret_dungeon VALUES ('13203');
+INSERT INTO k_secret_dungeon VALUES ('13204');
+INSERT INTO k_secret_dungeon VALUES ('13205');
+INSERT INTO k_secret_dungeon VALUES ('14801');
+INSERT INTO k_secret_dungeon VALUES ('14802');
+INSERT INTO k_secret_dungeon VALUES ('14803');
+INSERT INTO k_secret_dungeon VALUES ('14804');
+INSERT INTO k_secret_dungeon VALUES ('15201');
+INSERT INTO k_secret_dungeon VALUES ('15203');
+INSERT INTO k_secret_dungeon VALUES ('13604');
+INSERT INTO k_secret_dungeon VALUES ('13605');
+INSERT INTO k_secret_dungeon VALUES ('12605');
+INSERT INTO k_secret_dungeon VALUES ('12814');
+INSERT INTO k_secret_dungeon VALUES ('10101');
+INSERT INTO k_secret_dungeon VALUES ('10102');
+INSERT INTO k_secret_dungeon VALUES ('10104');
+INSERT INTO k_secret_dungeon VALUES ('10405');
+INSERT INTO k_secret_dungeon VALUES ('10501');
+INSERT INTO k_secret_dungeon VALUES ('10502');
+INSERT INTO k_secret_dungeon VALUES ('10503');
+INSERT INTO k_secret_dungeon VALUES ('10504');
+INSERT INTO k_secret_dungeon VALUES ('10505');
+INSERT INTO k_secret_dungeon VALUES ('10605');
+INSERT INTO k_secret_dungeon VALUES ('10701');
+INSERT INTO k_secret_dungeon VALUES ('10704');
+INSERT INTO k_secret_dungeon VALUES ('10804');
+INSERT INTO k_secret_dungeon VALUES ('10805');
+INSERT INTO k_secret_dungeon VALUES ('10904');
+INSERT INTO k_secret_dungeon VALUES ('11001');
+INSERT INTO k_secret_dungeon VALUES ('11002');
+INSERT INTO k_secret_dungeon VALUES ('11003');
+INSERT INTO k_secret_dungeon VALUES ('11004');
+INSERT INTO k_secret_dungeon VALUES ('11005');
+INSERT INTO k_secret_dungeon VALUES ('11102');
+INSERT INTO k_secret_dungeon VALUES ('11301');
+INSERT INTO k_secret_dungeon VALUES ('11302');
+INSERT INTO k_secret_dungeon VALUES ('11303');
+INSERT INTO k_secret_dungeon VALUES ('11304');
+INSERT INTO k_secret_dungeon VALUES ('11305');
+INSERT INTO k_secret_dungeon VALUES ('11401');
+INSERT INTO k_secret_dungeon VALUES ('11402');
+INSERT INTO k_secret_dungeon VALUES ('11403');
+INSERT INTO k_secret_dungeon VALUES ('11404');
+INSERT INTO k_secret_dungeon VALUES ('11405');
+INSERT INTO k_secret_dungeon VALUES ('11501');
+INSERT INTO k_secret_dungeon VALUES ('11502');
+INSERT INTO k_secret_dungeon VALUES ('11503');
+INSERT INTO k_secret_dungeon VALUES ('11504');
+INSERT INTO k_secret_dungeon VALUES ('11505');
+INSERT INTO k_secret_dungeon VALUES ('11701');
+INSERT INTO k_secret_dungeon VALUES ('11702');
+INSERT INTO k_secret_dungeon VALUES ('11703');
+INSERT INTO k_secret_dungeon VALUES ('11704');
+INSERT INTO k_secret_dungeon VALUES ('11705');
+INSERT INTO k_secret_dungeon VALUES ('12001');
+INSERT INTO k_secret_dungeon VALUES ('12002');
+INSERT INTO k_secret_dungeon VALUES ('12003');
+INSERT INTO k_secret_dungeon VALUES ('12004');
+INSERT INTO k_secret_dungeon VALUES ('12005');
+INSERT INTO k_secret_dungeon VALUES ('12104');
+INSERT INTO k_secret_dungeon VALUES ('12105');
+INSERT INTO k_secret_dungeon VALUES ('13701');
+INSERT INTO k_secret_dungeon VALUES ('13702');
+INSERT INTO k_secret_dungeon VALUES ('13703');
+INSERT INTO k_secret_dungeon VALUES ('13704');
+INSERT INTO k_secret_dungeon VALUES ('13705');
+INSERT INTO k_secret_dungeon VALUES ('14001');
+INSERT INTO k_secret_dungeon VALUES ('14002');
+INSERT INTO k_secret_dungeon VALUES ('14003');
+INSERT INTO k_secret_dungeon VALUES ('14004');
+INSERT INTO k_secret_dungeon VALUES ('14005');
+INSERT INTO k_secret_dungeon VALUES ('14805');
+INSERT INTO k_secret_dungeon VALUES ('15001');
+INSERT INTO k_secret_dungeon VALUES ('15002');
+INSERT INTO k_secret_dungeon VALUES ('15003');
+INSERT INTO k_secret_dungeon VALUES ('15004');
+INSERT INTO k_secret_dungeon VALUES ('15005');
+INSERT INTO k_secret_dungeon VALUES ('15202');
+INSERT INTO k_secret_dungeon VALUES ('15204');
+INSERT INTO k_secret_dungeon VALUES ('15205');
+INSERT INTO k_secret_dungeon VALUES ('15301');
+INSERT INTO k_secret_dungeon VALUES ('15303');
+INSERT INTO k_secret_dungeon VALUES ('15305');
+INSERT INTO k_secret_dungeon VALUES ('15401');
+INSERT INTO k_secret_dungeon VALUES ('15402');
+INSERT INTO k_secret_dungeon VALUES ('15403');
+INSERT INTO k_secret_dungeon VALUES ('16001');
+INSERT INTO k_secret_dungeon VALUES ('16002');
+INSERT INTO k_secret_dungeon VALUES ('16003');
+INSERT INTO k_secret_dungeon VALUES ('16004');
+INSERT INTO k_secret_dungeon VALUES ('16005');
+INSERT INTO k_secret_dungeon VALUES ('14901');
+INSERT INTO k_secret_dungeon VALUES ('14902');
+INSERT INTO k_secret_dungeon VALUES ('14903');
+INSERT INTO k_secret_dungeon VALUES ('14904');
+INSERT INTO k_secret_dungeon VALUES ('14905');
+INSERT INTO k_secret_dungeon VALUES ('15601');
+INSERT INTO k_secret_dungeon VALUES ('15602');
+INSERT INTO k_secret_dungeon VALUES ('15603');
+INSERT INTO k_secret_dungeon VALUES ('15604');
+INSERT INTO k_secret_dungeon VALUES ('15605');
+INSERT INTO k_secret_dungeon VALUES ('16501');
+INSERT INTO k_secret_dungeon VALUES ('16502');
+INSERT INTO k_secret_dungeon VALUES ('16503');
+INSERT INTO k_secret_dungeon VALUES ('16504');
+INSERT INTO k_secret_dungeon VALUES ('16505');
+INSERT INTO k_secret_dungeon VALUES ('15901');
+INSERT INTO k_secret_dungeon VALUES ('15902');
+INSERT INTO k_secret_dungeon VALUES ('15903');
+INSERT INTO k_secret_dungeon VALUES ('15904');
+INSERT INTO k_secret_dungeon VALUES ('15905');
+INSERT INTO k_secret_dungeon VALUES ('17201');
+INSERT INTO k_secret_dungeon VALUES ('17202');
+INSERT INTO k_secret_dungeon VALUES ('17203');
+INSERT INTO k_secret_dungeon VALUES ('17204');
+INSERT INTO k_secret_dungeon VALUES ('17205');
+INSERT INTO k_secret_dungeon VALUES ('17701');
+INSERT INTO k_secret_dungeon VALUES ('17702');
+INSERT INTO k_secret_dungeon VALUES ('17703');
+INSERT INTO k_secret_dungeon VALUES ('17704');
+INSERT INTO k_secret_dungeon VALUES ('17705');
+INSERT INTO k_secret_dungeon VALUES ('17801');
+INSERT INTO k_secret_dungeon VALUES ('17802');
+INSERT INTO k_secret_dungeon VALUES ('17803');
+INSERT INTO k_secret_dungeon VALUES ('17804');
+INSERT INTO k_secret_dungeon VALUES ('17805');
+INSERT INTO k_secret_dungeon VALUES ('12705');
+INSERT INTO k_secret_dungeon VALUES ('12905');
+INSERT INTO k_secret_dungeon VALUES ('13005');
+INSERT INTO k_secret_dungeon VALUES ('13105');
+INSERT INTO k_secret_dungeon VALUES ('12805');
+INSERT INTO k_secret_dungeon VALUES ('15801');
+INSERT INTO k_secret_dungeon VALUES ('15802');
+INSERT INTO k_secret_dungeon VALUES ('15803');
+INSERT INTO k_secret_dungeon VALUES ('15804');
+INSERT INTO k_secret_dungeon VALUES ('15805');
+INSERT INTO k_secret_dungeon VALUES ('18501');
+INSERT INTO k_secret_dungeon VALUES ('18502');
+INSERT INTO k_secret_dungeon VALUES ('18503');
+INSERT INTO k_secret_dungeon VALUES ('18504');
+INSERT INTO k_secret_dungeon VALUES ('18505');
+INSERT INTO k_secret_dungeon VALUES ('18402');
+INSERT INTO k_secret_dungeon VALUES ('18405');
+INSERT INTO k_secret_dungeon VALUES ('18701');
+INSERT INTO k_secret_dungeon VALUES ('18702');
+INSERT INTO k_secret_dungeon VALUES ('18703');
+INSERT INTO k_secret_dungeon VALUES ('18704');
+INSERT INTO k_secret_dungeon VALUES ('18705');
+INSERT INTO k_secret_dungeon VALUES ('19001');
+INSERT INTO k_secret_dungeon VALUES ('19002');
+INSERT INTO k_secret_dungeon VALUES ('19003');
+INSERT INTO k_secret_dungeon VALUES ('19004');
+INSERT INTO k_secret_dungeon VALUES ('19005');
+INSERT INTO k_secret_dungeon VALUES ('19501');
+INSERT INTO k_secret_dungeon VALUES ('19502');
+INSERT INTO k_secret_dungeon VALUES ('19503');
+INSERT INTO k_secret_dungeon VALUES ('19504');
+INSERT INTO k_secret_dungeon VALUES ('19505');
+INSERT INTO k_secret_dungeon VALUES ('20201');
+INSERT INTO k_secret_dungeon VALUES ('20202');
+INSERT INTO k_secret_dungeon VALUES ('20203');
+INSERT INTO k_secret_dungeon VALUES ('20204');
+INSERT INTO k_secret_dungeon VALUES ('20205');
+INSERT INTO k_secret_dungeon VALUES ('20701');
+INSERT INTO k_secret_dungeon VALUES ('20702');
+INSERT INTO k_secret_dungeon VALUES ('20703');
+INSERT INTO k_secret_dungeon VALUES ('20704');
+INSERT INTO k_secret_dungeon VALUES ('20705');
+INSERT INTO k_secret_dungeon VALUES ('20801');
+INSERT INTO k_secret_dungeon VALUES ('20802');
+INSERT INTO k_secret_dungeon VALUES ('20803');
+INSERT INTO k_secret_dungeon VALUES ('20804');
+INSERT INTO k_secret_dungeon VALUES ('20805');
+INSERT INTO k_secret_dungeon VALUES ('20301');
+INSERT INTO k_secret_dungeon VALUES ('20302');
+INSERT INTO k_secret_dungeon VALUES ('20303');
+INSERT INTO k_secret_dungeon VALUES ('20304');
+INSERT INTO k_secret_dungeon VALUES ('20305');
+
+INSERT INTO k_element VALUES (1, 'Water', 2, 3);
+INSERT INTO k_element VALUES (2, 'Fire', 3, 1);
+INSERT INTO k_element VALUES (3, 'Wind', 1, 2);
+INSERT INTO k_element VALUES (4, 'Light', 5, 5);
+INSERT INTO k_element VALUES (5, 'Dark', 4, 4);
+INSERT INTO k_element VALUES (6, 'Pure', null, null);
+
+INSERT INTO k_archetype VALUES (0, 'None', '');
+INSERT INTO k_archetype VALUES (1, 'Attack', '');
+INSERT INTO k_archetype VALUES (2, 'Defense', '');
+INSERT INTO k_archetype VALUES (3, 'HP', '');
+INSERT INTO k_archetype VALUES (4, 'Support', '');
+INSERT INTO k_archetype VALUES (5, 'Material', '');
+
+INSERT INTO k_stat VALUES (1, 'HP');
+INSERT INTO k_stat VALUES (2, 'ATK');
+INSERT INTO k_stat VALUES (3, 'DEF');
+INSERT INTO k_stat VALUES (4, 'SPD');
+INSERT INTO k_stat VALUES (5, 'CRIT_RATE');
+INSERT INTO k_stat VALUES (6, 'CRIT_DMG');
+INSERT INTO k_stat VALUES (7, 'RES');
+INSERT INTO k_stat VALUES (8, 'ACC');
+
+INSERT INTO k_effect_area VALUES (1, 'General');
+INSERT INTO k_effect_area VALUES (1, 'Arena');
+INSERT INTO k_effect_area VALUES (2, 'Dungeon');
+INSERT INTO k_effect_area VALUES (5, 'Guild');
+
+INSERT INTO k_decoration VALUES (4, 1, 3, null, 'Guardstone', '', 10);
+INSERT INTO k_decoration VALUES (15, 1, 2, 2, 'Fire Sanctuary', '', 10);
+INSERT INTO k_decoration VALUES (16, 1, 2, 1, 'Water Sanctuary', '', 10);
+INSERT INTO k_decoration VALUES (17, 1, 2, 3, 'Wind Sanctuary', '', 10);
+INSERT INTO k_decoration VALUES (18, 1, 2, 4, 'Light Sanctuary', '', 10);
+INSERT INTO k_decoration VALUES (19, 1, 2, 5, 'Dark Sanctuary', '', 10);
+INSERT INTO k_decoration VALUES (31, 1, 6, null, 'Fallen Ancient Guardian', '', 10);
+INSERT INTO k_decoration VALUES (6, 1, 4, null, 'Sky Tribe Totem', '', 10);
+INSERT INTO k_decoration VALUES (8, 1, 1, null, 'Crystal Altar', '', 10);
+INSERT INTO k_decoration VALUES (36, 5, 2, null, 'Flag of Battle', '', 10);
+INSERT INTO k_decoration VALUES (37, 5, 6, null, 'Flag of Rage', '', 10);
+INSERT INTO k_decoration VALUES (38, 5, 1, null, 'Flag of Hope', '', 10);
+INSERT INTO k_decoration VALUES (39, 5, 3, null, 'Flag of Will', '', 10);
+INSERT INTO k_decoration VALUES (9, 1, 2, null, 'Ancient Sword', '', 10);
+INSERT INTO k_decoration VALUES (7, 1, null, null, 'Arcane Booster Tower', '', 10);
+INSERT INTO k_decoration VALUES (34, 1, null, null, 'Crystal Rock', '', 10);
+INSERT INTO k_decoration VALUES (11, 1, null, null, 'Mysterious Plant', '', 10);
+INSERT INTO k_decoration VALUES (5, 1, null, null, 'Mana Fountain', '', 10);
+INSERT INTO k_decoration VALUES (10, 1, null, null, 'Sanctum of Energy', '', 10);
+INSERT INTO k_decoration VALUES (35, 1, null, null, 'Fairy Tree', '', 10);
+
+INSERT INTO k_building VALUES(1, 'Summoners Tower', '');
+INSERT INTO k_building VALUES(2, 'Summonhenge', '');
+INSERT INTO k_building VALUES(3, 'Pond of Mana', '');
+INSERT INTO k_building VALUES(4, 'Crystal Mine', '');
+INSERT INTO k_building VALUES(8, 'Gateway', '');
+INSERT INTO k_building VALUES(10, 'Temple of Wishes', '');
+INSERT INTO k_building VALUES(11, 'Magic Shop', '');
+INSERT INTO k_building VALUES(12, 'Ancient Stones', '');
+INSERT INTO k_building VALUES(14, 'Arcane Tower', '');
+INSERT INTO k_building VALUES(15, 'Crystal Titan', '');
+INSERT INTO k_building VALUES(16, 'Fusion Hexagram', '');
+INSERT INTO k_building VALUES(17, 'Fuse Center', '');
+INSERT INTO k_building VALUES(20, 'Power Up Circle', '');
+INSERT INTO k_building VALUES(22, 'Tranquil Forest', '');
+INSERT INTO k_building VALUES(23, 'Gusty Cliffs', '');
+INSERT INTO k_building VALUES(24, 'Deep Forest Ent', '');
+INSERT INTO k_building VALUES(25, 'Monster Storage', '');
+INSERT INTO k_building VALUES(27, 'Transmogrification Building', '');
+
+INSERT INTO k_inventory_type VALUES(1, 'Monster', '');
+INSERT INTO k_inventory_type VALUES(6, 'Currency', '');
+INSERT INTO k_inventory_type VALUES(8, 'Rune', '');
+INSERT INTO k_inventory_type VALUES(9, 'Scroll', '');
+INSERT INTO k_inventory_type VALUES(10, 'Booster', '');
+INSERT INTO k_inventory_type VALUES(11, 'Essences', '');
+INSERT INTO k_inventory_type VALUES(12, 'Monster Piece', '');
+INSERT INTO k_inventory_type VALUES(15, 'UNKNOWN', 'Appears in inventory_info with qty 0');
+INSERT INTO k_inventory_type VALUES(19, 'Guild Monster Piece', '');
+INSERT INTO k_inventory_type VALUES(19, 'Rainbowmon', ''); -- Possibly material monsters in general. Appears when wish returns a rainbowmon.
+INSERT INTO k_inventory_type VALUES(27, 'Rune Craft', '');
+INSERT INTO k_inventory_type VALUES(29, 'Craft Stuff', '');
+INSERT INTO k_inventory_type VALUES(61, 'Enhancing Monster', '');
+
+INSERT INTO k_inventory VALUES(11006, 'Essence of Magic (low)', '');
+INSERT INTO k_inventory VALUES(12006, 'Essence of Magic (mid)', '');
+INSERT INTO k_inventory VALUES(13006, 'Essence of Magic (high)', '');
+INSERT INTO k_inventory VALUES(11001, 'Essence of Water (low)', '');
+INSERT INTO k_inventory VALUES(12001, 'Essence of Water (mid)', '');
+INSERT INTO k_inventory VALUES(13001, 'Essence of Water (high)', '');
+INSERT INTO k_inventory VALUES(11002, 'Essence of Fire (low)', '');
+INSERT INTO k_inventory VALUES(12002, 'Essence of Fire (mid)', '');
+INSERT INTO k_inventory VALUES(13002, 'Essence of Fire (high)', '');
+INSERT INTO k_inventory VALUES(11003, 'Essence of Wind (low)', '');
+INSERT INTO k_inventory VALUES(12003, 'Essence of Wind (mid)', '');
+INSERT INTO k_inventory VALUES(13003, 'Essence of Wind (high)', '');
+INSERT INTO k_inventory VALUES(11004, 'Essence of Light (low)', '');
+INSERT INTO k_inventory VALUES(12004, 'Essence of Light (mid)', '');
+INSERT INTO k_inventory VALUES(13004, 'Essence of Light (high)', '');
+INSERT INTO k_inventory VALUES(11005, 'Essence of Dark (low)', '');
+INSERT INTO k_inventory VALUES(12005, 'Essence of Dark (mid)', '');
+INSERT INTO k_inventory VALUES(13005, 'Essence of Dark (high)', '');
+INSERT INTO k_inventory VALUES(1001, 'Wood', '');
+INSERT INTO k_inventory VALUES(1002, 'Leather', '');
+INSERT INTO k_inventory VALUES(1003, 'Rock', '');
+INSERT INTO k_inventory VALUES(1004, 'Ore', '');
+INSERT INTO k_inventory VALUES(1005, 'Mithril', '');
+INSERT INTO k_inventory VALUES(1006, 'Cloth', '');
+INSERT INTO k_inventory VALUES(2001, 'Rune Piece', '');
+INSERT INTO k_inventory VALUES(3001, 'Powder', '');
+INSERT INTO k_inventory VALUES(4001, 'Symbol of Harmony', '');
+INSERT INTO k_inventory VALUES(4002, 'Symbol of Transcendance', '');
+INSERT INTO k_inventory VALUES(4003, 'Symbol of Chaos', '');
+INSERT INTO k_inventory VALUES(5001, 'Crystal of Water', '');
+INSERT INTO k_inventory VALUES(5002, 'Crystal of Fire', '');
+INSERT INTO k_inventory VALUES(5003, 'Crystal of Wind', '');
+INSERT INTO k_inventory VALUES(5004, 'Crystal of Light', '');
+INSERT INTO k_inventory VALUES(5005, 'Crystal of Dark', '');
+INSERT INTO k_inventory VALUES(6001, 'Crystal of Magic', '');
+INSERT INTO k_inventory VALUES(7001, 'Crystal of Pure', '');
+
+--    $ENHANCE_MONSTER = [
+--        "WATER_ANGELMON" => 142110115,
+--        "FIRE_ANGELMON" => 142120115,
+--        "WIND_ANGELMON" => 142130115,
+--        "LIGHT_ANGELMON" => 142140115,
+--        "DARK_ANGELMON" => 142150115,
+--        "WATER_KING_ANGELMON" => 182110115,
+--        "FIRE_KING_ANGELMON" => 182120115,
+--        "WIND_KING_ANGELMON" => 182130115,
+--        "LIGHT_KING_ANGELMON" => 182140115,
+--        "DARK_KING_ANGELMON" => 182150115,
+--        "RAINBOWMON_2_20" => 143140220,
+--        "RAINBOWMON_3_1" => 143140301,
+--        "RAINBOWMON_3_25" => 143140325,
+--        "RAINBOWMON_4_1" => 143140401,
+--        "RAINBOWMON_4_30" => 143140430,
+--        "RAINBOWMON_5_1" => 143140501,
+--        "DEVILMON" => 151050101,
+--        'SUPER_ANGELMON' => 217140115
+--    ];
+
+INSERT INTO k_rune_set VALUES(1, 'Energy', 2, '');
+INSERT INTO k_rune_set VALUES(2, 'Guard', 2, '');
+INSERT INTO k_rune_set VALUES(3, 'Swift', 2, '');
+INSERT INTO k_rune_set VALUES(4, 'Blade', 2, '');
+INSERT INTO k_rune_set VALUES(5, 'Rage', 2, '');
+INSERT INTO k_rune_set VALUES(6, 'Focus', 2, '');
+INSERT INTO k_rune_set VALUES(7, 'Endure', 2, '');
+INSERT INTO k_rune_set VALUES(8, 'Fatal', 2, '');
+INSERT INTO k_rune_set VALUES(10, 'Despair', 2, '');
+INSERT INTO k_rune_set VALUES(11, 'Vampire', 2, '');
+INSERT INTO k_rune_set VALUES(13, 'Violent', 2, '');
+INSERT INTO k_rune_set VALUES(14, 'Nemesis', 2, '');
+INSERT INTO k_rune_set VALUES(15, 'Will', 2, '');
+INSERT INTO k_rune_set VALUES(16, 'Shield', 2, '');
+INSERT INTO k_rune_set VALUES(17, 'Revenge', 2, '');
+INSERT INTO k_rune_set VALUES(18, 'Destroy', 2, '');
+INSERT INTO k_rune_set VALUES(19, 'Fight', 2, '');
+INSERT INTO k_rune_set VALUES(20, 'Determination', 2, '');
+INSERT INTO k_rune_set VALUES(21, 'Enhance', 2, '');
+INSERT INTO k_rune_set VALUES(22, 'Accuracy', 2, '');
+INSERT INTO k_rune_set VALUES(23, 'Tolerance', 2, '');
+
+INSERT INTO k_rune_stat VALUES(1, 'HP');
+INSERT INTO k_rune_stat VALUES(2, 'HP%');
+INSERT INTO k_rune_stat VALUES(3, 'ATK');
+INSERT INTO k_rune_stat VALUES(4, 'ATK%');
+INSERT INTO k_rune_stat VALUES(5, 'DEF');
+INSERT INTO k_rune_stat VALUES(6, 'DEF%');
+INSERT INTO k_rune_stat VALUES(8, 'SPD');
+INSERT INTO k_rune_stat VALUES(9, 'CRIT_RATE');
+INSERT INTO k_rune_stat VALUES(10, 'CRIT_DMG');
+INSERT INTO k_rune_stat VALUES(11, 'RES');
+INSERT INTO k_rune_stat VALUES(12, 'ACC');
+
+INSERT INTO k_quality VALUES(1, 'Normal');
+INSERT INTO k_quality VALUES(2, 'Magic');
+INSERT INTO k_quality VALUES(3, 'Rare');
+INSERT INTO k_quality VALUES(4, 'Hero');
+INSERT INTO k_quality VALUES(5, 'Legend');
+
+INSERT INTO k_craft VALUES(1, 'Enchant_gem');
+INSERT INTO k_craft VALUES(2, 'Grindstone');
+INSERT INTO k_craft VALUES(3, 'Immemorial_gem');
+INSERT INTO k_craft VALUES(4, 'Immemorial_grindstone');
+
+INSERT INTO k_experience VALUES (1, 1, 460);
+INSERT INTO k_experience VALUES (2, 1, 552);
+INSERT INTO k_experience VALUES (3, 1, 662);
+INSERT INTO k_experience VALUES (4, 1, 796);
+INSERT INTO k_experience VALUES (5, 1, 952);
+INSERT INTO k_experience VALUES (6, 1, 1150);
+INSERT INTO k_experience VALUES (1, 2, 516);
+INSERT INTO k_experience VALUES (2, 2, 619);
+INSERT INTO k_experience VALUES (3, 2, 743);
+INSERT INTO k_experience VALUES (4, 2, 892);
+INSERT INTO k_experience VALUES (5, 2, 1068);
+INSERT INTO k_experience VALUES (6, 2, 1290);
+INSERT INTO k_experience VALUES (1, 3, 579);
+INSERT INTO k_experience VALUES (2, 3, 695);
+INSERT INTO k_experience VALUES (3, 3, 834);
+INSERT INTO k_experience VALUES (4, 3, 1002);
+INSERT INTO k_experience VALUES (5, 3, 1199);
+INSERT INTO k_experience VALUES (6, 3, 1447);
+INSERT INTO k_experience VALUES (1, 4, 650);
+INSERT INTO k_experience VALUES (2, 4, 779);
+INSERT INTO k_experience VALUES (3, 4, 936);
+INSERT INTO k_experience VALUES (4, 4, 1124);
+INSERT INTO k_experience VALUES (5, 4, 1344);
+INSERT INTO k_experience VALUES (6, 4, 1624);
+INSERT INTO k_experience VALUES (1, 5, 728);
+INSERT INTO k_experience VALUES (2, 5, 875);
+INSERT INTO k_experience VALUES (3, 5, 1049);
+INSERT INTO k_experience VALUES (4, 5, 1261);
+INSERT INTO k_experience VALUES (5, 5, 1509);
+INSERT INTO k_experience VALUES (6, 5, 1823);
+INSERT INTO k_experience VALUES (1, 6, 818);
+INSERT INTO k_experience VALUES (2, 6, 981);
+INSERT INTO k_experience VALUES (3, 6, 1178);
+INSERT INTO k_experience VALUES (4, 6, 1415);
+INSERT INTO k_experience VALUES (5, 6, 1693);
+INSERT INTO k_experience VALUES (6, 6, 2044);
+INSERT INTO k_experience VALUES (1, 7, 918);
+INSERT INTO k_experience VALUES (2, 7, 1102);
+INSERT INTO k_experience VALUES (3, 7, 1321);
+INSERT INTO k_experience VALUES (4, 7, 1587);
+INSERT INTO k_experience VALUES (5, 7, 1899);
+INSERT INTO k_experience VALUES (6, 7, 2294);
+INSERT INTO k_experience VALUES (1, 8, 1029);
+INSERT INTO k_experience VALUES (2, 8, 1235);
+INSERT INTO k_experience VALUES (3, 8, 1483);
+INSERT INTO k_experience VALUES (4, 8, 1781);
+INSERT INTO k_experience VALUES (5, 8, 2131);
+INSERT INTO k_experience VALUES (6, 8, 2574);
+INSERT INTO k_experience VALUES (1, 9, 1155);
+INSERT INTO k_experience VALUES (2, 9, 1386);
+INSERT INTO k_experience VALUES (3, 9, 1663);
+INSERT INTO k_experience VALUES (4, 9, 1998);
+INSERT INTO k_experience VALUES (5, 9, 2392);
+INSERT INTO k_experience VALUES (6, 9, 2888);
+INSERT INTO k_experience VALUES (1, 10, 1296);
+INSERT INTO k_experience VALUES (2, 10, 1555);
+INSERT INTO k_experience VALUES (3, 10, 1866);
+INSERT INTO k_experience VALUES (4, 10, 2243);
+INSERT INTO k_experience VALUES (5, 10, 2682);
+INSERT INTO k_experience VALUES (6, 10, 3240);
+INSERT INTO k_experience VALUES (1, 11, 1455);
+INSERT INTO k_experience VALUES (2, 11, 1745);
+INSERT INTO k_experience VALUES (3, 11, 2094);
+INSERT INTO k_experience VALUES (4, 11, 2515);
+INSERT INTO k_experience VALUES (5, 11, 3010);
+INSERT INTO k_experience VALUES (6, 11, 3635);
+INSERT INTO k_experience VALUES (1, 12, 1631);
+INSERT INTO k_experience VALUES (2, 12, 1958);
+INSERT INTO k_experience VALUES (3, 12, 2350);
+INSERT INTO k_experience VALUES (4, 12, 2823);
+INSERT INTO k_experience VALUES (5, 12, 3378);
+INSERT INTO k_experience VALUES (6, 12, 4079);
+INSERT INTO k_experience VALUES (1, 13, 1831);
+INSERT INTO k_experience VALUES (2, 13, 2197);
+INSERT INTO k_experience VALUES (3, 13, 2636);
+INSERT INTO k_experience VALUES (4, 13, 3167);
+INSERT INTO k_experience VALUES (5, 13, 3789);
+INSERT INTO k_experience VALUES (6, 13, 4576);
+INSERT INTO k_experience VALUES (1, 14, 2054);
+INSERT INTO k_experience VALUES (2, 14, 2465);
+INSERT INTO k_experience VALUES (3, 14, 2957);
+INSERT INTO k_experience VALUES (4, 14, 3553);
+INSERT INTO k_experience VALUES (5, 14, 4252);
+INSERT INTO k_experience VALUES (6, 14, 5135);
+INSERT INTO k_experience VALUES (1, 15, 0);
+INSERT INTO k_experience VALUES (2, 15, 2765);
+INSERT INTO k_experience VALUES (3, 15, 3319);
+INSERT INTO k_experience VALUES (4, 15, 3987);
+INSERT INTO k_experience VALUES (5, 15, 4770);
+INSERT INTO k_experience VALUES (6, 15, 5762);
+INSERT INTO k_experience VALUES (2, 16, 3103);
+INSERT INTO k_experience VALUES (3, 16, 3723);
+INSERT INTO k_experience VALUES (4, 16, 4473);
+INSERT INTO k_experience VALUES (5, 16, 5352);
+INSERT INTO k_experience VALUES (6, 16, 6464);
+INSERT INTO k_experience VALUES (2, 17, 3481);
+INSERT INTO k_experience VALUES (3, 17, 4178);
+INSERT INTO k_experience VALUES (4, 17, 5019);
+INSERT INTO k_experience VALUES (5, 17, 6006);
+INSERT INTO k_experience VALUES (6, 17, 7252);
+INSERT INTO k_experience VALUES (2, 18, 3906);
+INSERT INTO k_experience VALUES (3, 18, 4687);
+INSERT INTO k_experience VALUES (4, 18, 5631);
+INSERT INTO k_experience VALUES (5, 18, 6738);
+INSERT INTO k_experience VALUES (6, 18, 8138);
+INSERT INTO k_experience VALUES (2, 19, 4423);
+INSERT INTO k_experience VALUES (3, 19, 5307);
+INSERT INTO k_experience VALUES (4, 19, 6376);
+INSERT INTO k_experience VALUES (5, 19, 7628);
+INSERT INTO k_experience VALUES (6, 19, 9214);
+INSERT INTO k_experience VALUES (2, 20, 0);
+INSERT INTO k_experience VALUES (3, 20, 6009);
+INSERT INTO k_experience VALUES (4, 20, 7219);
+INSERT INTO k_experience VALUES (5, 20, 8638);
+INSERT INTO k_experience VALUES (6, 20, 10431);
+INSERT INTO k_experience VALUES (3, 21, 6802);
+INSERT INTO k_experience VALUES (4, 21, 8172);
+INSERT INTO k_experience VALUES (5, 21, 9779);
+INSERT INTO k_experience VALUES (6, 21, 11811);
+INSERT INTO k_experience VALUES (3, 22, 7703);
+INSERT INTO k_experience VALUES (4, 22, 9254);
+INSERT INTO k_experience VALUES (5, 22, 11072);
+INSERT INTO k_experience VALUES (6, 22, 13371);
+INSERT INTO k_experience VALUES (3, 23, 8720);
+INSERT INTO k_experience VALUES (4, 23, 10476);
+INSERT INTO k_experience VALUES (5, 23, 12535);
+INSERT INTO k_experience VALUES (6, 23, 15140);
+INSERT INTO k_experience VALUES (3, 24, 9962);
+INSERT INTO k_experience VALUES (4, 24, 11969);
+INSERT INTO k_experience VALUES (5, 24, 14321);
+INSERT INTO k_experience VALUES (6, 24, 17296);
+INSERT INTO k_experience VALUES (3, 25, 0);
+INSERT INTO k_experience VALUES (4, 25, 13673);
+INSERT INTO k_experience VALUES (5, 25, 16360);
+INSERT INTO k_experience VALUES (6, 25, 19758);
+INSERT INTO k_experience VALUES (4, 26, 15619);
+INSERT INTO k_experience VALUES (5, 26, 18690);
+INSERT INTO k_experience VALUES (6, 26, 22572);
+INSERT INTO k_experience VALUES (4, 27, 17844);
+INSERT INTO k_experience VALUES (5, 27, 21350);
+INSERT INTO k_experience VALUES (6, 27, 25786);
+INSERT INTO k_experience VALUES (4, 28, 20386);
+INSERT INTO k_experience VALUES (5, 28, 24392);
+INSERT INTO k_experience VALUES (6, 28, 29458);
+INSERT INTO k_experience VALUES (4, 29, 23495);
+INSERT INTO k_experience VALUES (5, 29, 28113);
+INSERT INTO k_experience VALUES (6, 29, 33954);
+INSERT INTO k_experience VALUES (4, 30, 0);
+INSERT INTO k_experience VALUES (5, 30, 32404);
+INSERT INTO k_experience VALUES (6, 30, 39134);
+INSERT INTO k_experience VALUES (5, 31, 37348);
+INSERT INTO k_experience VALUES (6, 31, 45107);
+INSERT INTO k_experience VALUES (5, 32, 43048);
+INSERT INTO k_experience VALUES (6, 32, 51990);
+INSERT INTO k_experience VALUES (5, 33, 49617);
+INSERT INTO k_experience VALUES (6, 33, 59924);
+INSERT INTO k_experience VALUES (5, 34, 57188);
+INSERT INTO k_experience VALUES (6, 34, 69068);
+INSERT INTO k_experience VALUES (5, 35, 0);
+INSERT INTO k_experience VALUES (6, 35, 76085);
+INSERT INTO k_experience VALUES (6, 36, 83816);
+INSERT INTO k_experience VALUES (6, 37, 92332);
+INSERT INTO k_experience VALUES (6, 38, 101712);
+INSERT INTO k_experience VALUES (6, 39, 112046);
+INSERT INTO k_experience VALUES (6, 40, 0);

+ 105 - 226
install_base.py

@@ -27,20 +27,8 @@ def createDatabase(name):
         db = sqlite3.connect(name)
         cursor = db.cursor()
         cursor.execute('''
-            CREATE TABLE IF NOT EXISTS k_building(
-                id TEXT,
-                com2us_id TEXT,
-                area TEXT,
-                affected_stat TEXT,
-                element TEXT,
-                name TEXT,
-                description TEXT,
-                max_level INT
-            );
-        ''')
-        cursor.execute('''
-            CREATE TABLE IF NOT EXISTS k_building_level(
-                building TEXT,
+            CREATE TABLE IF NOT EXISTS k_decoration_level(
+                decoration TEXT,
                 level INT,
                 bonus INT,
                 cost INT
@@ -63,6 +51,20 @@ def createDatabase(name):
         ''')
         cursor.execute('''
             CREATE TABLE IF NOT EXISTS k_skill(
+                id TEXT,
+                name TEXT,
+                description TEXT,
+                slot INT,
+                cooltime INT,
+                hits INT,
+                passive INT,
+                aoe INT,
+                max_level INT,
+                multiplier_formula TEXT
+            );
+        ''')
+        cursor.execute('''
+            CREATE TABLE IF NOT EXISTS k_skill_tmp(
                 id TEXT,
                 com2us_id TEXT,
                 name TEXT,
@@ -92,15 +94,42 @@ def createDatabase(name):
             );
         ''')
         cursor.execute('''
-            CREATE TABLE IF NOT EXISTS k_source(
-                id INT,
+            CREATE TABLE IF NOT EXISTS k_unit(
+                id TEXT,
+                family TEXT,
                 name TEXT,
-                description TEXT,
-                farmable_source INT
+                element TEXT,
+                archetype TEXT,
+                base_stars INT,
+                natural_stars INT,
+                obtainable INT,
+                can_awaken INT,
+                awaken_bonus TEXT,
+                skill_ups_to_max INT,
+                leader_skill INT,
+                hp INT,
+                attack INT,
+                defense INT,
+                speed INT,
+                crit_rate INT,
+                crit_damage INT,
+                resistance INT,
+                accuracy INT,
+                raw_hp INT,
+                raw_attack INT,
+                raw_defense INT,
+                max_lvl_hp INT,
+                max_lvl_attack INT,
+                max_lvl_defense INT,
+                awakens_from INT,
+                awakens_to INT,
+                fusion_food INT,
+                homunculus INT,
+                craft_cost INT
             );
         ''')
         cursor.execute('''
-            CREATE TABLE IF NOT EXISTS k_unit(
+            CREATE TABLE IF NOT EXISTS k_unit_tmp(
                 id TEXT,
                 com2us_id TEXT,
                 family TEXT,
@@ -164,19 +193,6 @@ def createDatabase(name):
                 ingredient TEXT
             );
         ''')
-        cursor.execute('''
-            CREATE TABLE IF NOT EXISTS k_craft(
-                id INT,
-                name INT
-            );
-        ''')
-        cursor.execute('''
-            CREATE TABLE IF NOT EXISTS k_experience(
-                stars INT,
-                level INT,
-                exp INT
-            );
-        ''')
         cursor.execute('''
             CREATE TABLE IF NOT EXISTS player(
                 uid TEXT,
@@ -273,6 +289,7 @@ def createDatabase(name):
                 type TEXT,
                 slot INT,
                 stars INT,
+                ancient INT,
                 level INT,
                 quality INT,
                 original_quality INT,
@@ -305,9 +322,30 @@ def createDatabase(name):
             CREATE TABLE IF NOT EXISTS building(
                 uid TEXT,
                 building INT,
+                gain INT
+            );
+        ''')
+        cursor.execute('''
+            CREATE TABLE IF NOT EXISTS decoration(
+                uid TEXT,
+                decoration INT,
                 level INT
             );
         ''')
+        cursor.execute('''
+            CREATE TABLE IF NOT EXISTS inventory(
+                uid TEXT,
+                id TEXT,
+                type TEXT,
+                amount INT
+            );
+        ''')
+        cursor.execute('''
+            CREATE TABLE IF NOT EXISTS summon_special(
+                week TEXT,
+                unit TEXT
+            );
+        ''')
         db.commit()
         cursor.close()
         return db
@@ -385,7 +423,7 @@ def parseBuildings(db, url):
             name = building["name"]
             description = building["description"]
             max_level = building["max_level"]
-            insert(db, "k_building", (id, com2us_id, area, affected_stat, element, name, description, max_level))
+            insert(db, "k_building_tmp", (id, com2us_id, area, affected_stat, element, name, description, max_level))
             lv = 0
             for bonus in building["stat_bonus"]:
                 insert(db, "k_building_level", (id, lv, bonus, building["upgrade_cost"][lv]))
@@ -422,7 +460,7 @@ def parseSkills(db, url):
             aoe = skill["aoe"]
             max_level = skill["max_level"]
             multiplier_formula = skill["multiplier_formula"]
-            insert(db, "k_skill", (id, com2us_id, name, description, slot, cooltime, hits, passive, aoe, max_level, multiplier_formula))
+            insert(db, "k_skill_tmp", (id, com2us_id, name, description, slot, cooltime, hits, passive, aoe, max_level, multiplier_formula))
             insert(db, "k_skill_level", (id, 1, ""))
             if (max_level > 1):
                 lv = 2
@@ -595,7 +633,7 @@ def parseMonsters(db, url):
             fusion_food = mon["fusion_food"]
             homunculus = mon["homunculus"]
             craft_cost = mon["craft_cost"]
-            insert(db, "k_unit", (id, com2us_id, family_id, name, element, archetype, base_stars, natural_stars, obtainable, can_awaken, awaken_bonus, skill_ups_to_max, leader_skill, hp, attack, defense, speed, crit_rate, crit_damage, resistance, accuracy, raw_hp, raw_attack, raw_defense, max_lvl_hp, max_lvl_attack, max_lvl_defense, awakens_from, awakens_to, fusion_food, homunculus, craft_cost))
+            insert(db, "k_unit_tmp", (id, com2us_id, family_id, name, element, archetype, base_stars, natural_stars, obtainable, can_awaken, awaken_bonus, skill_ups_to_max, leader_skill, hp, attack, defense, speed, crit_rate, crit_damage, resistance, accuracy, raw_hp, raw_attack, raw_defense, max_lvl_hp, max_lvl_attack, max_lvl_defense, awakens_from, awakens_to, fusion_food, homunculus, craft_cost))
             if awaken_mats_fire_low > 0:
                 insert(db, "k_unit_essence", (id, "Fire", "Low", awaken_mats_fire_low))
             if awaken_mats_fire_mid > 0:
@@ -730,214 +768,55 @@ Changes IDS from swarfarm formats to swex formats.
 def useSwexIds(db):
     print("Updating IDs...")
     cursor = db.cursor()
-    cursor.execute('UPDATE k_building_level SET building = (SELECT com2us_id FROM k_building WHERE building = id)');
-    #db.commit()
-    #cursor.execute('ALTER TABLE k_building_level DROP COLUMN com2us_id')
-    cursor.execute('UPDATE k_building SET id = com2us_id');
-    #db.commit()
-    #cursor.execute('ALTER TABLE k_building_level DROP COLUMN com2us_id')
-    cursor.execute('UPDATE k_skill_level SET skill = (SELECT com2us_id FROM k_skill WHERE skill = id)');
-    cursor.execute('UPDATE k_skill_effect SET skill = (SELECT com2us_id FROM k_skill WHERE skill = id)');
-    cursor.execute('UPDATE k_unit_skill SET skill = (SELECT com2us_id FROM k_skill WHERE skill = id)');
-    cursor.execute('UPDATE k_skill SET id = com2us_id');
-    #db.commit()
-    #cursor.execute('ALTER TABLE k_skill DROP COLUMN com2us_id')
-    cursor.execute('UPDATE k_unit_skill SET unit = (SELECT com2us_id FROM k_unit WHERE unit = k_unit.id)');
-    cursor.execute('UPDATE k_unit_source SET unit = (SELECT com2us_id FROM k_unit WHERE unit = k_unit.id)');
-    cursor.execute('UPDATE k_unit_essence SET unit = (SELECT com2us_id FROM k_unit WHERE unit = k_unit.id)');
-    cursor.execute('UPDATE k_fusion SET product = (SELECT com2us_id FROM k_unit WHERE product = k_unit.id)');
-    cursor.execute('UPDATE k_fusion SET ingredient = (SELECT com2us_id FROM k_unit WHERE ingredient = k_unit.id)');
-    cursor.execute('UPDATE k_unit SET awakens_from = (SELECT com2us_id FROM k_unit un WHERE k_unit.awakens_from = un.id)');
-    cursor.execute('UPDATE k_unit SET awakens_to = (SELECT com2us_id FROM k_unit un WHERE k_unit.awakens_to = un.id)');
-    cursor.execute('UPDATE k_unit SET id = com2us_id');
+    #cursor.execute('UPDATE k_building_level SET building = (SELECT com2us_id FROM k_building WHERE building = id)')
+    #cursor.execute('UPDATE k_building_tmp SET id = com2us_id')
+    cursor.execute('UPDATE k_skill_level SET skill = (SELECT com2us_id FROM k_skill_tmp WHERE skill = id)')
+    cursor.execute('UPDATE k_skill_effect SET skill = (SELECT com2us_id FROM k_skill_tmp WHERE skill = id)')
+    cursor.execute('UPDATE k_unit_skill SET skill = (SELECT com2us_id FROM k_skill_tmp WHERE skill = id)')
+    cursor.execute('UPDATE k_skill_tmp SET id = com2us_id')
+    cursor.execute('UPDATE k_unit_skill SET unit = (SELECT com2us_id FROM k_unit_tmp WHERE unit = k_unit_tmp.id)')
+    cursor.execute('UPDATE k_unit_source SET unit = (SELECT com2us_id FROM k_unit_tmp WHERE unit = k_unit_tmp.id)')
+    cursor.execute('UPDATE k_unit_essence SET unit = (SELECT com2us_id FROM k_unit_tmp WHERE unit = k_unit_tmp.id)')
+    cursor.execute('UPDATE k_fusion SET product = (SELECT com2us_id FROM k_unit_tmp WHERE product = k_unit_tmp.id)')
+    cursor.execute('UPDATE k_fusion SET ingredient = (SELECT com2us_id FROM k_unit_tmp WHERE ingredient = k_unit_tmp.id)')
+    cursor.execute('UPDATE k_unit_tmp SET awakens_from = (SELECT com2us_id FROM k_unit_tmp un WHERE k_unit_tmp.awakens_from = un.id)')
+    cursor.execute('UPDATE k_unit_tmp SET awakens_to = (SELECT com2us_id FROM k_unit_tmp un WHERE k_unit_tmp.awakens_to = un.id)')
+    cursor.execute('UPDATE k_unit_tmp SET id = com2us_id')
+    cursor.execute('UPDATE k_unit_tmp SET element = (SELECT id FROM k_element WHERE k_element.name = k_unit_tmp.element)')
+    cursor.execute('UPDATE k_unit_tmp SET archetype = (SELECT id FROM k_archetype WHERE k_archetype.name = k_unit_tmp.archetype) WHERE archetype IS NOT NULL')
+    db.commit()
+    #cursor.execute('INSERT INTO k_building SELECT id, area, affected_stat, element, name, description, max_level FROM k_building_tmp')
+    cursor.execute('INSERT INTO k_skill SELECT id, name, description, slot, cooltime, hits, passive, aoe, max_level, multiplier_formula FROM k_skill_tmp')
+    cursor.execute('INSERT INTO k_unit SELECT id, family, name, element, archetype, base_stars, natural_stars, obtainable, can_awaken, awaken_bonus, skill_ups_to_max, leader_skill, hp, attack, defense, speed, crit_rate, crit_damage, resistance, accuracy, raw_hp, raw_attack, raw_defense, max_lvl_hp, max_lvl_attack, max_lvl_defense, awakens_from, awakens_to, fusion_food, homunculus, craft_cost FROM k_unit_tmp')
     db.commit()
-    #cursor.execute('ALTER TABLE k_unit DROP COLUMN com2us_id')
+    #cursor.execute('DROP TABLE k_building_tmp')
+    cursor.execute('DROP TABLE k_skill_tmp')
+    cursor.execute('DROP TABLE k_unit_tmp')
     cursor.close()
 
 def staticData(db):
     print("Procesing data...")
     cursor = db.cursor()
-    cursor.execute('INSERT INTO k_experience VALUES (1, 1, 460)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 1, 552)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 1, 662)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 1, 796)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 1, 952)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 1, 1150)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 2, 516)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 2, 619)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 2, 743)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 2, 892)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 2, 1068)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 2, 1290)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 3, 579)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 3, 695)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 3, 834)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 3, 1002)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 3, 1199)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 3, 1447)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 4, 650)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 4, 779)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 4, 936)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 4, 1124)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 4, 1344)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 4, 1624)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 5, 728)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 5, 875)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 5, 1049)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 5, 1261)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 5, 1509)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 5, 1823)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 6, 818)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 6, 981)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 6, 1178)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 6, 1415)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 6, 1693)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 6, 2044)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 7, 918)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 7, 1102)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 7, 1321)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 7, 1587)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 7, 1899)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 7, 2294)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 8, 1029)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 8, 1235)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 8, 1483)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 8, 1781)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 8, 2131)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 8, 2574)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 9, 1155)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 9, 1386)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 9, 1663)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 9, 1998)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 9, 2392)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 9, 2888)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 10, 1296)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 10, 1555)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 10, 1866)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 10, 2243)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 10, 2682)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 10, 3240)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 11, 1455)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 11, 1745)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 11, 2094)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 11, 2515)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 11, 3010)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 11, 3635)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 12, 1631)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 12, 1958)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 12, 2350)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 12, 2823)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 12, 3378)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 12, 4079)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 13, 1831)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 13, 2197)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 13, 2636)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 13, 3167)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 13, 3789)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 13, 4576)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 14, 2054)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 14, 2465)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 14, 2957)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 14, 3553)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 14, 4252)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 14, 5135)')
-    cursor.execute('INSERT INTO k_experience VALUES (1, 15, 0)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 15, 2765)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 15, 3319)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 15, 3987)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 15, 4770)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 15, 5762)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 16, 3103)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 16, 3723)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 16, 4473)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 16, 5352)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 16, 6464)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 17, 3481)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 17, 4178)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 17, 5019)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 17, 6006)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 17, 7252)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 18, 3906)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 18, 4687)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 18, 5631)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 18, 6738)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 18, 8138)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 19, 4423)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 19, 5307)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 19, 6376)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 19, 7628)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 19, 9214)')
-    cursor.execute('INSERT INTO k_experience VALUES (2, 20, 0)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 20, 6009)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 20, 7219)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 20, 8638)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 20, 10431)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 21, 6802)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 21, 8172)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 21, 9779)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 21, 11811)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 22, 7703)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 22, 9254)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 22, 11072)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 22, 13371)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 23, 8720)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 23, 10476)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 23, 12535)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 23, 15140)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 24, 9962)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 24, 11969)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 24, 14321)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 24, 17296)')
-    cursor.execute('INSERT INTO k_experience VALUES (3, 25, 0)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 25, 13673)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 25, 16360)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 25, 19758)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 26, 15619)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 26, 18690)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 26, 22572)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 27, 17844)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 27, 21350)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 27, 25786)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 28, 20386)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 28, 24392)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 28, 29458)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 29, 23495)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 29, 28113)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 29, 33954)')
-    cursor.execute('INSERT INTO k_experience VALUES (4, 30, 0)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 30, 32404)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 30, 39134)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 31, 37348)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 31, 45107)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 32, 43048)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 32, 51990)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 33, 49617)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 33, 59924)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 34, 57188)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 34, 69068)')
-    cursor.execute('INSERT INTO k_experience VALUES (5, 35, 0)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 35, 76085)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 36, 83816)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 37, 92332)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 38, 101712)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 39, 112046)')
-    cursor.execute('INSERT INTO k_experience VALUES (6, 40, 0)')
+    with open("data.sql", "r") as data:
+        for line in data:
+            if len(line) > 1:
+                cursor.execute(line)
     db.commit()
-    #cursor.execute('ALTER TABLE k_unit DROP COLUMN com2us_id')
     cursor.close()
 
 """
 Begin script
 """
 db = createDatabase('application/sw.sqlite')
-parseBuildings(db, 'https://swarfarm.com/api/v2/buildings/')
+staticData(db)
+#parseBuildings(db, 'https://swarfarm.com/api/v2/buildings/')
 parseEffects(db, 'https://swarfarm.com/api/v2/skill-effects/')
 parseSkills(db, 'https://swarfarm.com/api/v2/skills/')
 parseLeaderSkills(db, 'https://swarfarm.com/api/v2/leader-skills/')
-parseSources(db, 'https://swarfarm.com/api/v2/monster-sources/')
+#parseSources(db, 'https://swarfarm.com/api/v2/monster-sources/')
 parseMonsters(db, 'https://swarfarm.com/api/v2/monsters/')
 parseFusions(db, 'https://swarfarm.com/api/v2/fusions/')
-parseCraft(db, 'https://swarfarm.com/api/v2/craft-materials/')
+#parseCraft(db, 'https://swarfarm.com/api/v2/craft-materials/')
 removeImperfect(db)
 useSwexIds(db)
-staticData(db)
+

+ 99 - 390
install_user.py

@@ -30,11 +30,15 @@ def openDatabase(name):
     try:
         db = sqlite3.connect(name)
         cursor = db.cursor()
+        cursor.execute('''DELETE FROM scenario''')
+        cursor.execute('''DELETE FROM defense''')
         cursor.execute('''DELETE FROM unit''')
-        #cursor.execute('''DELETE FROM monster_rune''')
         cursor.execute('''DELETE FROM rune''')
         cursor.execute('''DELETE FROM player''')
         cursor.execute('''DELETE FROM building''')
+        cursor.execute('''DELETE FROM decoration''')
+        cursor.execute('''DELETE FROM inventory''')
+        cursor.execute('''DELETE FROM summon_special''')
         db.commit()
         cursor.close()
         return db
@@ -147,10 +151,25 @@ Parses buildings (table building).
 def parseBuildings(db, data):
     print("Parsing buildings...")
     uid = data["wizard_info"]["wizard_id"]
+    for bui in data["building_list"]:
+        building = bui["wizard_id"]
+        gain = bui["gain_per_hour"]
+        insert(db, "building", (uid, building, gain))
+    db.commit()
+
+"""
+Parses decoration buildings (table dcoration).
+
+:param db: Sqlite database connection.
+:param data: Data in SWEX json file.
+"""
+def parseDecorations(db, data):
+    print("Parsing decorations...")
+    uid = data["wizard_info"]["wizard_id"]
     for bui in data["deco_list"]:
         building = bui["master_id"]
         level = bui["level"]
-        insert(db, "building", (uid, building, level))
+        insert(db, "decoration", (uid, building, level))
     db.commit()
 
 """
@@ -192,6 +211,40 @@ def parseUnits(db, data):
             insert(db, "unit_skill", (uid, id, skill_id, skill_level))
     db.commit()
 
+"""
+Parses inventory data (table inventory).
+
+:param db: Sqlite database connection.
+:param data: Data in SWEX json file.
+"""
+def parseInventory(db, data):
+    print("Parsing inventory...")
+    uid = data["wizard_info"]["wizard_id"]
+    for item in data["inventory_info"]:
+        id = item["wizard_id"]
+        type = item["item_master_type"]
+        # TODO: Master id?
+        amount = item["item_quantity"]
+        insert(db, "inventory", (uid, id, type, amount))
+
+"""
+Parses summon stone list (table summon_special).
+
+:param db: Sqlite database connection.
+:param data: Data in SWEX json file.
+"""
+def parseSummonSpecial(db, data):
+    print("Parsing Summon stone monster list...")
+    uid = data["wizard_info"]["wizard_id"]
+    for unit in data["summon_special_info"]["this"]:
+        insert(db, "summon_special", (0, unit))
+    for unit in data["summon_special_info"]["next"]:
+        insert(db, "summon_special", (1, unit))
+    for unit in data["summon_special_info"]["third"]:
+        insert(db, "summon_special", (2, unit))
+    for unit in data["summon_special_info"]["fourth"]:
+        insert(db, "summon_special", (3, unit))
+
 """
 Parses rune data (table rune).
 
@@ -201,60 +254,35 @@ Parses rune data (table rune).
 def parseRunes(db, data):
     print("Parsing runes...")
     uid = data["wizard_info"]["wizard_id"]
+    # Unequipped runes
     for rune in data["runes"]:
         id = rune["rune_id"]
         assigned_to = rune["occupied_id"]
         if assigned_to == 0:
             assigned_to = None
         runeset = rune["set_id"]
-        if runeset == 1:
-            runeset = 'Energy'
-        elif runeset == 2:
-            runeset = 'Guard'
-        elif runeset == 3:
-            runeset = 'Swift'
-        elif runeset == 4:
-            runeset = 'Blade'
-        elif runeset == 5:
-            runeset = 'Rage'
-        elif runeset == 6:
-            runeset = 'Focus'
-        elif runeset == 7:
-            runeset = 'Endure'
-        elif runeset == 8:
-            runeset = 'Fatal'
-        elif runeset == 10:
-            runeset = 'Despair'
-        elif runeset == 11:
-            runeset = 'Vampire'
-        elif runeset == 13:
-            runeset = 'Violent'
-        elif runeset == 14:
-            runeset = 'Nemesis'
-        elif runeset == 15:
-            runeset = 'Will'
-        elif runeset == 16:
-            runeset = 'Shield'
-        elif runeset == 17:
-            runeset = 'Revenge'
-        elif runeset == 18:
-            runeset = 'Destroy'
-        elif runeset == 19:
-            runeset = 'Fight'
-        elif runeset == 20:
-            runeset = 'Determination'
-        elif runeset == 21:
-            runeset = 'Enhance'
-        elif runeset == 22:
-            runeset = 'Accuracy'
-        elif runeset == 23:
-            runeset = 'Tolerance'
         slot = rune["slot_no"]
         stars = rune["class"]
+        ancient = 0
         level = rune["upgrade_curr"]
-        quality = rune["rank"] - 1
-        original_quality = rune["extra"] - 1
+        original_quality = rune["extra"]
         value = rune["sell_value"]
+        if stars > 10:
+            ancient = 1
+            stars = stars - 10
+            original_quality = original_quality - 10
+        if level >= 12:
+            quality = 4
+        elif level >= 9:
+            quality = 3
+        elif level >= 6:
+            quality = 2
+        elif level >= 3:
+            quality = 1
+        else:
+            quality = 0
+        if original_quality > quality:
+            quality = original_quality
         # TODO: Calculate
         #efficiency = rune["efficiency"]
         #max_efficiency = rune["max_efficiency"]
@@ -308,154 +336,8 @@ def parseRunes(db, data):
             substat_4_value = 0
             substat_4_enchant = 0
             substat_4_grind = 0
-
-        """
-        Human readable stat names (as of 2019-08-16):
-            STAT_HP = 1
-            STAT_HP_PCT = 2
-            STAT_ATK = 3
-            STAT_ATK_PCT = 4
-            STAT_DEF = 5
-            STAT_DEF_PCT = 6
-            STAT_SPD = 7
-            STAT_CRIT_RATE_PCT = 8
-            STAT_CRIT_DMG_PCT = 9
-            STAT_RESIST_PCT = 10
-            STAT_ACCURACY_PCT = 11
-        """
-        if (main_stat == 1):
-            main_stat = "HP"
-        elif (main_stat == 2):
-            main_stat = "HP%"
-        elif (main_stat == 3):
-            main_stat = "ATK"
-        elif (main_stat == 4):
-            main_stat = "ATK%"
-        elif (main_stat == 5):
-            main_stat = "DEF"
-        elif (main_stat == 6):
-            main_stat = "DEF%"
-        elif (main_stat == 8):
-            main_stat = "SPD"
-        elif (main_stat == 9):
-            main_stat = "CRR"
-        elif (main_stat == 10):
-            main_stat = "CRD"
-        elif (main_stat == 11):
-            main_stat = "RES"
-        elif (main_stat == 12):
-            main_stat = "ACC"
-        if (innate_stat == 1):
-            innate_stat = "HP"
-        elif (innate_stat == 2):
-            innate_stat = "HP%"
-        elif (innate_stat == 3):
-            innate_stat = "ATK"
-        elif (innate_stat == 4):
-            innate_stat = "ATK%"
-        elif (innate_stat == 5):
-            innate_stat = "DEF"
-        elif (innate_stat == 6):
-            innate_stat = "DEF%"
-        elif (innate_stat == 8):
-            innate_stat = "SPD"
-        elif (innate_stat == 9):
-            innate_stat = "CRR"
-        elif (innate_stat == 10):
-            innate_stat = "CRD"
-        elif (innate_stat == 11):
-            innate_stat = "RES"
-        elif (innate_stat == 12):
-            innate_stat = "ACC"
-        if (substat_1 == 1):
-            substat_1 = "HP"
-        elif (substat_1 == 2):
-            substat_1 = "HP%"
-        elif (substat_1 == 3):
-            substat_1 = "ATK"
-        elif (substat_1 == 4):
-            substat_1 = "ATK%"
-        elif (substat_1 == 5):
-            substat_1 = "DEF"
-        elif (substat_1 == 6):
-            substat_1 = "DEF%"
-        elif (substat_1 == 8):
-            substat_1 = "SPD"
-        elif (substat_1 == 9):
-            substat_1 = "CRR"
-        elif (substat_1 == 10):
-            substat_1 = "CRD"
-        elif (substat_1 == 11):
-            substat_1 = "RES"
-        elif (substat_1 == 12):
-            substat_1 = "ACC"
-        if (substat_2 == 1):
-            substat_2 = "HP"
-        elif (substat_2 == 2):
-            substat_2 = "HP%"
-        elif (substat_2 == 3):
-            substat_2 = "ATK"
-        elif (substat_2 == 4):
-            substat_2 = "ATK%"
-        elif (substat_2 == 5):
-            substat_2 = "DEF"
-        elif (substat_2 == 6):
-            substat_2 = "DEF%"
-        elif (substat_2 == 8):
-            substat_2 = "SPD"
-        elif (substat_2 == 9):
-            substat_2 = "CRR"
-        elif (substat_2 == 10):
-            substat_2 = "CRD"
-        elif (substat_2 == 11):
-            substat_2 = "RES"
-        elif (substat_2 == 12):
-            substat_2 = "ACC"
-        if (substat_3 == 1):
-            substat_3 = "HP"
-        elif (substat_3 == 2):
-            substat_3 = "HP%"
-        elif (substat_3 == 3):
-            substat_3 = "ATK"
-        elif (substat_3 == 4):
-            substat_3 = "ATK%"
-        elif (substat_3 == 5):
-            substat_3 = "DEF"
-        elif (substat_3 == 6):
-            substat_3 = "DEF%"
-        elif (substat_3 == 8):
-            substat_3 = "SPD"
-        elif (substat_3 == 9):
-            substat_3 = "CRR"
-        elif (substat_3 == 10):
-            substat_3 = "CRD"
-        elif (substat_3 == 11):
-            substat_3 = "RES"
-        elif (substat_3 == 12):
-            substat_3 = "ACC"
-        if (substat_4 == 1):
-            substat_4 = "HP"
-        elif (substat_4 == 2):
-            substat_4 = "HP%"
-        elif (substat_4 == 3):
-            substat_4 = "ATK"
-        elif (substat_4 == 4):
-            substat_4 = "ATK%"
-        elif (substat_4 == 5):
-            substat_4 = "DEF"
-        elif (substat_4 == 6):
-            substat_4 = "DEF%"
-        elif (substat_4 == 8):
-            substat_4 = "SPD"
-        elif (substat_4 == 9):
-            substat_4 = "CRR"
-        elif (substat_4 == 10):
-            substat_4 = "CRD"
-        elif (substat_4 == 11):
-            substat_4 = "RES"
-        elif (substat_4 == 12):
-            substat_4 = "ACC"
-        insert(db, "rune", (uid, id, assigned_to, runeset, slot, stars, level, quality, original_quality, value, efficiency, max_efficiency, main_stat, main_stat_value, innate_stat, innate_stat_value, substat_1, substat_1_value, substat_1_enchant, substat_1_grind, substat_2, substat_2_value, substat_2_enchant, substat_2_grind, substat_3, substat_3_value, substat_3_enchant, substat_3_grind, substat_4, substat_4_value, substat_4_enchant, substat_4_grind))
+        insert(db, "rune", (uid, id, assigned_to, runeset, slot, stars, ancient, level, quality, original_quality, value, efficiency, max_efficiency, main_stat, main_stat_value, innate_stat, innate_stat_value, substat_1, substat_1_value, substat_1_enchant, substat_1_grind, substat_2, substat_2_value, substat_2_enchant, substat_2_grind, substat_3, substat_3_value, substat_3_enchant, substat_3_grind, substat_4, substat_4_value, substat_4_enchant, substat_4_grind))
+    # Equipped runes
     for mon in data["unit_list"]:
         for rune in mon["runes"]:
             id = rune["rune_id"]
@@ -463,54 +345,28 @@ def parseRunes(db, data):
             if assigned_to == 0:
                 assigned_to = None
             runeset = rune["set_id"]
-            if runeset == 1:
-                runeset = 'Energy'
-            elif runeset == 2:
-                runeset = 'Guard'
-            elif runeset == 3:
-                runeset = 'Swift'
-            elif runeset == 4:
-                runeset = 'Blade'
-            elif runeset == 5:
-                runeset = 'Rage'
-            elif runeset == 6:
-                runeset = 'Focus'
-            elif runeset == 7:
-                runeset = 'Endure'
-            elif runeset == 8:
-                runeset = 'Fatal'
-            elif runeset == 10:
-                runeset = 'Despair'
-            elif runeset == 11:
-                runeset = 'Vampire'
-            elif runeset == 13:
-                runeset = 'Violent'
-            elif runeset == 14:
-                runeset = 'Nemesis'
-            elif runeset == 15:
-                runeset = 'Will'
-            elif runeset == 16:
-                runeset = 'Shield'
-            elif runeset == 17:
-                runeset = 'Revenge'
-            elif runeset == 18:
-                runeset = 'Destroy'
-            elif runeset == 19:
-                runeset = 'Fight'
-            elif runeset == 20:
-                runeset = 'Determination'
-            elif runeset == 21:
-                runeset = 'Enhance'
-            elif runeset == 22:
-                runeset = 'Accuracy'
-            elif runeset == 23:
-                runeset = 'Tolerance'
             slot = rune["slot_no"]
             stars = rune["class"]
+            ancient = 0
             level = rune["upgrade_curr"]
-            quality = rune["rank"] - 1
-            original_quality = rune["extra"] - 1
+            original_quality = rune["extra"]
             value = rune["sell_value"]
+            if stars > 10:
+                ancient = 1
+                stars = stars - 10
+                original_quality = original_quality - 10
+            if level >= 12:
+                quality = 4
+            elif level >= 9:
+                quality = 3
+            elif level >= 6:
+                quality = 2
+            elif level >= 3:
+                quality = 1
+            else:
+                quality = 0
+            if original_quality > quality:
+                quality = original_quality
             # TODO: Calculate
             #efficiency = rune["efficiency"]
             #max_efficiency = rune["max_efficiency"]
@@ -564,154 +420,7 @@ def parseRunes(db, data):
                 substat_4_value = 0
                 substat_4_enchant = 0
                 substat_4_grind = 0
-    
-            """
-            Human readable stat names (as of 2019-08-16):
-                STAT_HP = 1
-                STAT_HP_PCT = 2
-                STAT_ATK = 3
-                STAT_ATK_PCT = 4
-                STAT_DEF = 5
-                STAT_DEF_PCT = 6
-                STAT_SPD = 7
-                STAT_CRIT_RATE_PCT = 8
-                STAT_CRIT_DMG_PCT = 9
-                STAT_RESIST_PCT = 10
-                STAT_ACCURACY_PCT = 11
-            """
-            if (main_stat == 1):
-                main_stat = "HP"
-            elif (main_stat == 2):
-                main_stat = "HP%"
-            elif (main_stat == 3):
-                main_stat = "ATK"
-            elif (main_stat == 4):
-                main_stat = "ATK%"
-            elif (main_stat == 5):
-                main_stat = "DEF"
-            elif (main_stat == 6):
-                main_stat = "DEF%"
-            elif (main_stat == 8):
-                main_stat = "SPD"
-            elif (main_stat == 9):
-                main_stat = "CRR"
-            elif (main_stat == 10):
-                main_stat = "CRD"
-            elif (main_stat == 11):
-                main_stat = "RES"
-            elif (main_stat == 12):
-                main_stat = "ACC"
-            if (innate_stat == 1):
-                innate_stat = "HP"
-            elif (innate_stat == 2):
-                innate_stat = "HP%"
-            elif (innate_stat == 3):
-                innate_stat = "ATK"
-            elif (innate_stat == 4):
-                innate_stat = "ATK%"
-            elif (innate_stat == 5):
-                innate_stat = "DEF"
-            elif (innate_stat == 6):
-                innate_stat = "DEF%"
-            elif (innate_stat == 8):
-                innate_stat = "SPD"
-            elif (innate_stat == 9):
-                innate_stat = "CRR"
-            elif (innate_stat == 10):
-                innate_stat = "CRD"
-            elif (innate_stat == 11):
-                innate_stat = "RES"
-            elif (innate_stat == 12):
-                innate_stat = "ACC"
-            if (substat_1 == 1):
-                substat_1 = "HP"
-            elif (substat_1 == 2):
-                substat_1 = "HP%"
-            elif (substat_1 == 3):
-                substat_1 = "ATK"
-            elif (substat_1 == 4):
-                substat_1 = "ATK%"
-            elif (substat_1 == 5):
-                substat_1 = "DEF"
-            elif (substat_1 == 6):
-                substat_1 = "DEF%"
-            elif (substat_1 == 8):
-                substat_1 = "SPD"
-            elif (substat_1 == 9):
-                substat_1 = "CRR"
-            elif (substat_1 == 10):
-                substat_1 = "CRD"
-            elif (substat_1 == 11):
-                substat_1 = "RES"
-            elif (substat_1 == 12):
-                substat_1 = "ACC"
-            if (substat_2 == 1):
-                substat_2 = "HP"
-            elif (substat_2 == 2):
-                substat_2 = "HP%"
-            elif (substat_2 == 3):
-                substat_2 = "ATK"
-            elif (substat_2 == 4):
-                substat_2 = "ATK%"
-            elif (substat_2 == 5):
-                substat_2 = "DEF"
-            elif (substat_2 == 6):
-                substat_2 = "DEF%"
-            elif (substat_2 == 8):
-                substat_2 = "SPD"
-            elif (substat_2 == 9):
-                substat_2 = "CRR"
-            elif (substat_2 == 10):
-                substat_2 = "CRD"
-            elif (substat_2 == 11):
-                substat_2 = "RES"
-            elif (substat_2 == 12):
-                substat_2 = "ACC"
-            if (substat_3 == 1):
-                substat_3 = "HP"
-            elif (substat_3 == 2):
-                substat_3 = "HP%"
-            elif (substat_3 == 3):
-                substat_3 = "ATK"
-            elif (substat_3 == 4):
-                substat_3 = "ATK%"
-            elif (substat_3 == 5):
-                substat_3 = "DEF"
-            elif (substat_3 == 6):
-                substat_3 = "DEF%"
-            elif (substat_3 == 8):
-                substat_3 = "SPD"
-            elif (substat_3 == 9):
-                substat_3 = "CRR"
-            elif (substat_3 == 10):
-                substat_3 = "CRD"
-            elif (substat_3 == 11):
-                substat_3 = "RES"
-            elif (substat_3 == 12):
-                substat_3 = "ACC"
-            if (substat_4 == 1):
-                substat_4 = "HP"
-            elif (substat_4 == 2):
-                substat_4 = "HP%"
-            elif (substat_4 == 3):
-                substat_4 = "ATK"
-            elif (substat_4 == 4):
-                substat_4 = "ATK%"
-            elif (substat_4 == 5):
-                substat_4 = "DEF"
-            elif (substat_4 == 6):
-                substat_4 = "DEF%"
-            elif (substat_4 == 8):
-                substat_4 = "SPD"
-            elif (substat_4 == 9):
-                substat_4 = "CRR"
-            elif (substat_4 == 10):
-                substat_4 = "CRD"
-            elif (substat_4 == 11):
-                substat_4 = "RES"
-            elif (substat_4 == 12):
-                substat_4 = "ACC"
-            insert(db, "rune", (uid, id, assigned_to, runeset, slot, stars, level, quality, original_quality, value, efficiency, max_efficiency, main_stat, main_stat_value, innate_stat, innate_stat_value, substat_1, substat_1_value, substat_1_enchant, substat_1_grind, substat_2, substat_2_value, substat_2_enchant, substat_2_grind, substat_3, substat_3_value, substat_3_enchant, substat_3_grind, substat_4, substat_4_value, substat_4_enchant, substat_4_grind))
+            insert(db, "rune", (uid, id, assigned_to, runeset, slot, stars, ancient, level, quality, original_quality, value, efficiency, max_efficiency, main_stat, main_stat_value, innate_stat, innate_stat_value, substat_1, substat_1_value, substat_1_enchant, substat_1_grind, substat_2, substat_2_value, substat_2_enchant, substat_2_grind, substat_3, substat_3_value, substat_3_enchant, substat_3_grind, substat_4, substat_4_value, substat_4_enchant, substat_4_grind))
     db.commit()
 
 
@@ -729,11 +438,11 @@ parsePlayer(db, data)
 parseScenarios(db, data)
 parseDefense(db, data)
 parseBuildings(db, data)
+parseDecorations(db, data)
 # TODO homunculus_skill_list
 parseUnits(db, data)
-# TODO summon_special_info
-# TODO inventory_info
+parseSummonSpecial(db, data)
+parseInventory(db, data)
 parseRunes(db, data)
-#parseMonsters(db, 'https://swarfarm.com/api/v2/profiles/' + USER +  '/monsters/')
-#db.commit()
+# TODO rune_craft_item_list
 

+ 17 - 10
public/css/ui.css

@@ -380,19 +380,19 @@ div.rune_panel{
     position: relative;
     text-align: center;
 }
-div.rune_panel.rune_quality_0{ /* Normal */
+div.rune_panel.rune_quality_normal{ /* Normal */
     background-image: repeating-radial-gradient(#ffffff, #cccccc 30%, #ffffff 60%);
 }
-div.rune_panel.rune_quality_1{ /* Magic */
+div.rune_panel.rune_quality_magic{ /* Magic */
     background-image: repeating-radial-gradient(#aaffaa, #88cc88 30%, #aaffaa 60%);
 }
-div.rune_panel.rune_quality_2{ /* Rare */
+div.rune_panel.rune_quality_rare{ /* Rare */
     background-image: repeating-radial-gradient(#aaaaff, #8888cc 30%, #aaaaff 60%);
 }
-div.rune_panel.rune_quality_3{ /* Hero */
+div.rune_panel.rune_quality_hero{ /* Hero */
     background-image: repeating-radial-gradient(#ffaacc, #cc88aa 30%, #ffaacc 60%);
 }
-div.rune_panel.rune_quality_4{ /* Legend */
+div.rune_panel.rune_quality_legend{ /* Legend */
     background-image: repeating-radial-gradient(#f48200, #b76201 30%, #f48200 60%);
 }
 div.rune_panel img.rune_base{
@@ -403,6 +403,9 @@ div.rune_panel img.rune_base{
     top: 0;
     left: 0;
 }
+div.rune_panel.rune_ancient_1 img.rune_base{
+    filter: brightness(150%) contrast(90%) saturate(100%) drop-shadow(0 0 0.3em #ffffff) drop-shadow(0 0 0.1em #ffffff);
+}
 div.rune_panel.rune_slot_1 img.rune_base{
     transform: rotate(0deg);
 }
@@ -449,19 +452,19 @@ div.rune_panel.rune_slot_6 img.rune_icon{
     top: 2.9em;
     left: 3.5em;
 }
-div.rune_panel.rune_original_quality_0 img.rune_icon{
+div.rune_panel.rune_original_quality_normal img.rune_icon{
     filter: sepia(100%) saturate(500%) grayscale(100%);
 }
-div.rune_panel.rune_original_quality_1 img.rune_icon{
+div.rune_panel.rune_original_quality_magic img.rune_icon{
     filter: sepia(100%) saturate(500%) hue-rotate(60deg);
 }
-div.rune_panel.rune_original_quality_2 img.rune_icon{
+div.rune_panel.rune_original_quality_rare img.rune_icon{
     filter: sepia(100%) saturate(500%) hue-rotate(120deg);
 }
-div.rune_panel.rune_original_quality_3 img.rune_icon{
+div.rune_panel.rune_original_quality_hero img.rune_icon{
     filter: sepia(100%) saturate(500%) hue-rotate(230deg);
 }
-div.rune_panel.rune_original_quality_4 img.rune_icon{
+div.rune_panel.rune_original_quality_legend img.rune_icon{
     filter: sepia(100%) saturate(500%) hue-rotate(330deg);
 }
 div.rune_panel span.rune_stars{
@@ -649,6 +652,7 @@ table.rune td.stats table td.value{
     text-align: left;
     padding-left: 0.2em;
     vertical-align: middle;
+    white-space: nowrap;
 }
 table.rune td.stats table td.value span.grind{
     color: #ff7700;
@@ -657,6 +661,9 @@ table.rune td.stats table td.value span.grind{
     font-weight: bold;
     margin-left: -0.4em;
 }
+table.rune td.stats table td.value span.grind_{
+    display: none;
+}
 table.rune td.stats table td.value img{
     width: 1em;
     height: 1em;

BIN
public/img/layout/rune/01.png


BIN
public/img/layout/rune/02.png


BIN
public/img/layout/rune/03.png


BIN
public/img/layout/rune/04.png


BIN
public/img/layout/rune/05.png


BIN
public/img/layout/rune/06.png


BIN
public/img/layout/rune/07.png


BIN
public/img/layout/rune/08.png


BIN
public/img/layout/rune/10.png


BIN
public/img/layout/rune/11.png


BIN
public/img/layout/rune/13.png


BIN
public/img/layout/rune/14.png


BIN
public/img/layout/rune/15.png


BIN
public/img/layout/rune/16.png


BIN
public/img/layout/rune/17.png


BIN
public/img/layout/rune/18.png


BIN
public/img/layout/rune/19.png


BIN
public/img/layout/rune/20.png


BIN
public/img/layout/rune/21.png


BIN
public/img/layout/rune/22.png


BIN
public/img/layout/rune/23.png