Bläddra i källkod

Several fixes and improvements in the runs and teams sections

Iñigo Valentin 6 år sedan
förälder
incheckning
a444007483

+ 2 - 1
application/Constant.php

@@ -470,7 +470,7 @@
         /**
          * Lumel Remains (Martial Cat).
          */
-        const KARZHAN_REMAINS_MARTIAL_CAT = 3202;
+        const LUMEL_REMAINS_MARTIAL_CAT = 3202;
 
         /**
          * Hall of water.
@@ -1714,6 +1714,7 @@
             "MONSTER_MAX_STARS" => 6,
             "MONSTER_NAME" => "",
             "MONSTER_IN_STORAGE" => false,
+            "MONSTER_TEAMS" => false,
             "RUNE_MIN_STARS" => 5,
             "RUNE_MAX_STARS" => 6,
             "RUNE_MIN_LEVEL" => 0,

+ 1 - 1
application/Controller.php

@@ -76,7 +76,7 @@
                         break;
                     case "NEW_TEAM":
                         require_once(PATH::ACTION . "new_team.php");
-                        action($db);
+                        error_log("NEW_TEAM: " . action($db));
                         return;
                         break;
                     case "SAVE_RUN_TEAM":

+ 10 - 6
application/action/new_team.php

@@ -39,6 +39,9 @@
         $area = filter_input(INPUT_POST, 'area');
         $stage = filter_input(INPUT_POST, 'stage');
         $difficulty = filter_input(INPUT_POST, 'difficulty');
+        if ($difficulty == ''){
+            $difficulty = null;
+        }
         $ids = filter_input(INPUT_POST, 'ids');
         $name = filter_input(INPUT_POST, 'name');
         $description = filter_input(INPUT_POST, 'description');
@@ -110,20 +113,19 @@
                 $difficulty = null;
                 break;
             case AREA_TYPE_ID::TARTARUS_LABYRINTH:
-                $stage = null;
-                if (!APPLICATION::valid_id("DIFFICULTY_ID", $difficulty)){
+                if ($difficulty != null && !APPLICATION::valid_id("DIFFICULTY_ID", $difficulty)){
                     return -43;
                 }
                 if ($id_count < 1 || $id_count > 5){
                     return -44;
                 }
-                if (!APPLICATION::valid_id("LABYRINTH_STAGES_ID", $area)){
+                if (!APPLICATION::valid_id("LABYRINTH_STAGES_ID", $stage)){
                     return -45;
                 }
                 break;
             case AREA_TYPE_ID::TRIAL_OF_ASCENSION:
-                if ($difficulty != 0 && $difficulty != DIFFICULTY_ID::NORMAL && $difficulty != DIFFICULTY_ID::HARD){
-                    return -46;
+                if ($difficulty != null && $difficulty != DIFFICULTY_ID::NORMAL && $difficulty != DIFFICULTY_ID::HARD){
+                    $difficulty = null;
                 }
                 $stage = null;
                 if ($id_count < 1 || $id_count > 5){
@@ -173,12 +175,14 @@
         $statement->bindValue(':area', $area);
         $statement->bindValue(':stage', $stage);
         $statement->bindValue(':difficulty', $difficulty);
+        error_log($statement);
         $res = $statement->execute();
         if (!$res){
             return -5;
         }
         foreach ($id as $i){
-            $s = "INSERT INTO team_unit VALUES ($team_id, $i);";
+            // TODO: Leader and front
+            $s = "INSERT INTO team_unit VALUES ($team_id, $i, 0, 0);";
             $db->query($s);
         }
         return 0;

+ 1 - 1
application/bin/log-run.py

@@ -75,7 +75,7 @@ def openDatabase():
     try:
         db = sqlite3.connect(kdb)
         cursor = db.cursor()
-        cursor.execute("attach '" + udb + "' as data;"')
+        cursor.execute('attach "' + udb + '" as data;')
         cursor.close()
         return db
     except sqlite3.IntegrityError as e:

+ 26 - 1
application/config.php

@@ -52,7 +52,7 @@
         const CSS = BASE_URL . "/css/";
 
         /**
-         * Paths to image resources.
+         * URLs to image resources.
          */
         const IMG = array(
             "BASE" => BASE_URL . "img/",
@@ -119,6 +119,31 @@
          */
         const VIEW = BASE_PATH . "../application/view/";
 
+        /**
+         * Paths to image resources.
+         */
+        const IMG = array(
+            "BASE" => BASE_PATH . "img/",
+            "UNKNOWN" => BASE_PATH . "img/unknown.png",
+            "ICON" => BASE_PATH . "img/icon/",
+            "LOGO" => BASE_PATH . "img/logo/",
+            "CURRENCY" => BASE_PATH . "img/currency/",
+            "UNIT" => BASE_PATH . "img/unit/",
+            "AREA" => BASE_PATH . "img/area/",
+            "SKILL" => BASE_PATH . "img/skill/",
+            "ESSENCE" => BASE_PATH . "img/essence/",
+            "RUNE" => BASE_PATH . "img/rune/",
+            "GRIND" => BASE_PATH . "img/grind/",
+            "ELEMENT" => BASE_PATH . "img/element/",
+            "SKILL_GUILD" => BASE_PATH . "img/skill_guild/",
+            "DECORATION" => BASE_PATH . "img/decoration/",
+            "SOURCE" => BASE_PATH . "img/source/",
+            "SKILL_LEADER" => BASE_PATH . "img/skill_leader/",
+            "INVENTORY" => BASE_PATH . "img/inventory/",
+            "EFFECT" => BASE_PATH . "img/effect/",
+            "BUILDING" => BASE_PATH . "img/building/",
+        );
+
         /**
          * Path to the helper files.
          */

+ 350 - 35
application/entity/K_Area.php

@@ -50,23 +50,25 @@
         public function __construct($db, $id, $type){
             parent::__construct($db);
             $this->id = $id;
+            $this->type = $type;
             $s = "
                 SELECT
                   id,
                   type,
                   name
                 FROM k_area
-                WHERE id = '$id'
+                WHERE
+                  id = '$id' AND
+                  type = '$type' 
                 ORDER BY type = '$type' DESC;
             ";
             $q = $this->db->query($s);
             $r = $q->fetchArray(SQLITE3_ASSOC);
             if ($r){
-                $this->type = $r["type"];
                 $this->name = HTML::e($r["name"]);
             }
             elseif($this->id > 1000){
-                $this->type = $AREA_TYPE::CAIROS_DUNGEON;
+                $this->type = AREA_TYPE_ID::CAIROS_DUNGEON;
                 $this->name = "Hall of Heroes";
             }
         }
@@ -86,24 +88,24 @@
             }
             elseif (
               (
-                $this->type == AREA_TYPE::SCENARIO ||
-                $this->type == AREA_TYPE::RIFT_DUNGEON ||
-                $this->type == AREA_TYPE::DIMENSIONAL_HOLE ||
-                $this->type == AREA_TYPE::RIFT_RAID ||
-                $this->type == AREA_TYPE::ARENA ||
-                $this->type == AREA_TYPE::GUILD_WAR ||
-                $this->type == AREA_TYPE::GUILD_SIEGE ||
-                $this->type == AREA_TYPE::TARTARUS_LABYRINTH ||
-                $this->type == AREA_TYPE::TRIAL_OF_ASCENSION ||
-                $this->type == AREA_TYPE::WORLD_BOSS ||
-                $this->type == AREA_TYPE::DIMENSIONAL_RIFT
+                $this->type == AREA_TYPE_ID::SCENARIO ||
+                //$this->type == AREA_TYPE_ID::RIFT_DUNGEON ||
+                //$this->type == AREA_TYPE_ID::DIMENSIONAL_HOLE ||
+                //$this->type == AREA_TYPE_ID::RIFT_RAID ||
+                $this->type == AREA_TYPE_ID::ARENA ||
+                $this->type == AREA_TYPE_ID::GUILD_WAR ||
+                $this->type == AREA_TYPE_ID::GUILD_SIEGE ||
+                //$this->type == AREA_TYPE_ID::TARTARUS_LABYRINTH ||
+                //$this->type == AREA_TYPE_ID::TRIAL_OF_ASCENSION ||
+                $this->type == AREA_TYPE_ID::WORLD_BOSS ||
+                $this->type == AREA_TYPE_ID::DIMENSIONAL_RIFT
               ) && file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")
             ){
                 return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
             }
-            elseif ($this->type == AREA_TYPE::CAIROS_DUNGEON && in_array($this->id, $DUNGEON)){
+            elseif ($this->type == AREA_TYPE_ID::CAIROS_DUNGEON && APPLICATION::valid_id("DUNGEON_ID", $this->id)){
                 switch ($this->id){
-                    case DUNGEON::GIANTS_KEEP:
+                    case DUNGEON_ID::GIANTS_KEEP:
                         switch ($stage){
                             case 1:
                             case 6:
@@ -143,7 +145,7 @@
                                 break;
                         }
                         break;
-                    case DUNGEON::DRAGONS_LAIR:
+                    case DUNGEON_ID::DRAGONS_LAIR:
                         switch ($stage){
                             case 1:
                             case 6:
@@ -183,72 +185,72 @@
                                 break;
                         }
                         break;
-                    case DUNGEON::NECROPOLIS:
+                    case DUNGEON_ID::NECROPOLIS:
                         switch ($stage){
                             case 1:
                             case 6:
                                 // Water
-                                if (file_exists(PATH::BASE . "img/unit/000621301.png")){
-                                    return URL::IMG["UNIT"] . "000621301.png";
+                                if (file_exists(PATH::BASE . "img/unit/00062101.png")){
+                                    return URL::IMG["UNIT"] . "00062101.png";
                                 }
                                 break;
                                 break;
                             case 2:
                             case 7:
                                 // Fire
-                                if (file_exists(PATH::BASE . "img/unit/000621302.png")){
-                                    return URL::IMG["UNIT"] . "000621302.png";
+                                if (file_exists(PATH::BASE . "img/unit/00062102.png")){
+                                    return URL::IMG["UNIT"] . "00062102.png";
                                 }
                                 break;
                             case 3:
                             case 8:
                                 // Wind
-                                if (file_exists(PATH::BASE . "img/unit/000621303.png")){
-                                    return URL::IMG["UNIT"] . "000621303.png";
+                                if (file_exists(PATH::BASE . "img/unit/00062103.png")){
+                                    return URL::IMG["UNIT"] . "00062103.png";
                                 }
                                 break;
                             case 4:
                             case 9:
                                 // Light
-                                if (file_exists(PATH::BASE . "img/unit/000621304.png")){
-                                    return URL::IMG["UNIT"] . "000621304.png";
+                                if (file_exists(PATH::BASE . "img/unit/00062104.png")){
+                                    return URL::IMG["UNIT"] . "00062104.png";
                                 }
                                 break;
                             case 5:
                             case 10:
                                 // Dark
-                                if (file_exists(PATH::BASE . "img/unit/000621305.png")){
-                                    return URL::IMG["UNIT"] . "000621305.png";
+                                if (file_exists(PATH::BASE . "img/unit/00062105.png")){
+                                    return URL::IMG["UNIT"] . "00062105.png";
                                 }
                                 break;
                         }
                         break;
-                    case DUNGEON::HALL_OF_WATER:
+                    case DUNGEON_ID::HALL_OF_WATER:
                         if (file_exists(PATH::BASE . "img/unit/00060101.png")){
                             return URL::IMG["UNIT"] . "00060101.png";
                         }
                         break;
-                    case DUNGEON::HALL_OF_FIRE:
+                    case DUNGEON_ID::HALL_OF_FIRE:
                         if (file_exists(PATH::BASE . "img/unit/00060102.png")){
                             return URL::IMG["UNIT"] . "00060102.png";
                         }
                         break;
-                    case DUNGEON::HALL_OF_WIND:
+                    case DUNGEON_ID::HALL_OF_WIND:
                         if (file_exists(PATH::BASE . "img/unit/00060103.png")){
                             return URL::IMG["UNIT"] . "00060103.png";
                         }
                         break;
-                    case DUNGEON::HALL_OF_LIGHT:
+                    case DUNGEON_ID::HALL_OF_LIGHT:
                         if (file_exists(PATH::BASE . "img/unit/00060104.png")){
                             return URL::IMG["UNIT"] . "00060104.png";
                         }
                         break;
-                    case DUNGEON::HALL_OF_DARK:
+                    case DUNGEON_ID::HALL_OF_DARK:
                         if (file_exists(PATH::BASE . "img/unit/00060105.png")){
                             return $PATH["IMG"]["UNIT"] . "00060105.png";
                         }
                         break;
-                    case DUNGEON::HALL_OF_MAGIC:
+                    case DUNGEON_ID::HALL_OF_MAGIC:
                         if (file_exists(PATH::BASE . "img/unit/00062004.png")){
                             return URL::IMG["UNIT"] . "00062004.png";
                         }
@@ -259,7 +261,320 @@
                         }
                 }
             }
-            return URL::IMG["UNKNOWN"];
+            elseif ($this->type == AREA_TYPE_ID::RIFT_DUNGEON && APPLICATION::valid_id("ELEMENTAL_RIFT_DUNGEON_ID", $this->id)){
+                switch ($this->id){
+                    case ELEMENTAL_RIFT_DUNGEON_ID::ICE_BEAST:
+                        if (file_exists(PATH::BASE . "img/unit/00043001.png")){
+                            return URL::IMG["UNIT"] . "00043001.png";
+                        }
+                        break;
+                    case ELEMENTAL_RIFT_DUNGEON_ID::FIRE_BEAST:
+                        if (file_exists(PATH::BASE . "img/unit/00043002.png")){
+                            return URL::IMG["UNIT"] . "00043002.png";
+                        }
+                        break;
+                    case ELEMENTAL_RIFT_DUNGEON_ID::WIND_BEAST:
+                        if (file_exists(PATH::BASE . "img/unit/00043003.png")){
+                            return URL::IMG["UNIT"] . "00043003.png";
+                        }
+                        break;
+                    case ELEMENTAL_RIFT_DUNGEON_ID::LIGHT_BEAST:
+                        if (file_exists(PATH::BASE . "img/unit/00043004.png")){
+                            return URL::IMG["UNIT"] . "00043004.png";
+                        }
+                        break;
+                    case ELEMENTAL_RIFT_DUNGEON_ID::DARK_BEAST:
+                        if (file_exists(PATH::BASE . "img/unit/00043005.png")){
+                            return URL::IMG["UNIT"] . "00043005.png";
+                        }
+                        break;
+                    default:
+                        if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                            return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                        }
+                        break;
+                }
+            }
+            elseif ($this->type == AREA_TYPE_ID::RIFT_RAID){
+                if (file_exists(PATH::BASE . "img/unit/00044007.png")){
+                    return URL::IMG["UNIT"] . "00044007.png";
+                }
+            }
+            elseif ($this->type == AREA_TYPE_ID::DIMENSIONAL_HOLE){
+                switch ($this->id){
+                    case DUNGEON_ID::FOREST_OF_ROARING_BEASTS:
+                        if (file_exists(PATH::BASE . "img/unit/00047002.png")){
+                            return URL::IMG["UNIT"] . "00047002.png";
+                        }
+                        break;
+                    case DUNGEON_ID::SANCTUARY_OF_DREAMING_FAIRIES:
+                        if (file_exists(PATH::BASE . "img/unit/00047001.png")){
+                            return URL::IMG["UNIT"] . "00047001.png";
+                        }
+                        break;
+                    case DUNGEON_ID::CLIFF_OF_TOUGH_BEASTS_MEN:
+                        if (file_exists(PATH::BASE . "img/unit/00047002.png")){
+                            return URL::IMG["UNIT"] . "00047003.png";
+                        }
+                        break;
+                    case DUNGEON_ID::KARZHAN_REMAINS_WARBEAR:
+                        switch ($stage){
+                            case 1:
+                                if (file_exists(PATH::BASE . "img/unit/00010734.png")){
+                                    return URL::IMG["UNIT"] . "00010734.png";
+                                }
+                                break;
+                            case 2:
+                                if (file_exists(PATH::BASE . "img/unit/00010733.png")){
+                                    return URL::IMG["UNIT"] . "00010733.png";
+                                }
+                                break;
+                            case 3:
+                                if (file_exists(PATH::BASE . "img/unit/00010731.png")){
+                                    return URL::IMG["UNIT"] . "00010731.png";
+                                }
+                                break;
+                            case 4:
+                                if (file_exists(PATH::BASE . "img/unit/00010735.png")){
+                                    return URL::IMG["UNIT"] . "00010735.png";
+                                }
+                                break;
+                            case 5:
+                                if (file_exists(PATH::BASE . "img/unit/00010732.png")){
+                                    return URL::IMG["UNIT"] . "00010732.png";
+                                }
+                                break;
+                            default:
+                                if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                                    return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                                }
+                                break;
+                        }
+                        break;
+                    case DUNGEON_ID::KARZHAN_REMAINS_INUGAMI:
+                        switch ($stage){
+                            case 1:
+                                if (file_exists(PATH::BASE . "img/unit/00011031.png")){
+                                    return URL::IMG["UNIT"] . "00011031.png";
+                                }
+                                break;
+                            case 2:
+                                if (file_exists(PATH::BASE . "img/unit/00011033.png")){
+                                    return URL::IMG["UNIT"] . "00011033.png";
+                                }
+                                break;
+                            case 3:
+                                if (file_exists(PATH::BASE . "img/unit/00011032.png")){
+                                    return URL::IMG["UNIT"] . "00011032.png";
+                                }
+                                break;
+                            case 4:
+                                if (file_exists(PATH::BASE . "img/unit/00011034.png")){
+                                    return URL::IMG["UNIT"] . "00011034.png";
+                                }
+                                break;
+                            case 5:
+                                if (file_exists(PATH::BASE . "img/unit/00011035.png")){
+                                    return URL::IMG["UNIT"] . "00011035.png";
+                                }
+                                break;
+                            default:
+                                if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                                    return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                                }
+                                break;
+                        }
+                        break;
+                    case DUNGEON_ID::ELLUNIA_REMAINS_FAIRY:
+                        switch ($stage){
+                            case 1:
+                                if (file_exists(PATH::BASE . "img/unit/00010132.png")){
+                                    return URL::IMG["UNIT"] . "00010132.png";
+                                }
+                                break;
+                            case 2:
+                                if (file_exists(PATH::BASE . "img/unit/00010134.png")){
+                                    return URL::IMG["UNIT"] . "00010134.png";
+                                }
+                                break;
+                            case 3:
+                                if (file_exists(PATH::BASE . "img/unit/00010131.png")){
+                                    return URL::IMG["UNIT"] . "00010131.png";
+                                }
+                                break;
+                            case 4:
+                                if (file_exists(PATH::BASE . "img/unit/00010133.png")){
+                                    return URL::IMG["UNIT"] . "00010133.png";
+                                }
+                                break;
+                            case 5:
+                                if (file_exists(PATH::BASE . "img/unit/00010134.png")){
+                                    return URL::IMG["UNIT"] . "00010134.png";
+                                }
+                                break;
+                            default:
+                                if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                                    return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                                }
+                                break;
+                        }
+                        break;
+                    case DUNGEON_ID::ELLUNIA_REMAINS_PIXIE:
+                        switch ($stage){
+                            case 1:
+                                if (file_exists(PATH::BASE . "img/unit/00010334.png")){
+                                    return URL::IMG["UNIT"] . "00010334.png";
+                                }
+                                break;
+                            case 2:
+                                if (file_exists(PATH::BASE . "img/unit/00010332.png")){
+                                    return URL::IMG["UNIT"] . "00010332.png";
+                                }
+                                break;
+                            case 3:
+                                if (file_exists(PATH::BASE . "img/unit/00010335.png")){
+                                    return URL::IMG["UNIT"] . "00010335.png";
+                                }
+                                break;
+                            case 4:
+                                if (file_exists(PATH::BASE . "img/unit/00010333.png")){
+                                    return URL::IMG["UNIT"] . "00010333.png";
+                                }
+                                break;
+                            case 5:
+                                if (file_exists(PATH::BASE . "img/unit/00010331.png")){
+                                    return URL::IMG["UNIT"] . "00010331.png";
+                                }
+                                break;
+                            default:
+                                if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                                    return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                                }
+                                break;
+                        }
+                        break;
+                    case DUNGEON_ID::LUMEL_REMAINS_WEREWOLF:
+                        switch ($stage){
+                            case 1:
+                                if (file_exists(PATH::BASE . "img/unit/00014035.png")){
+                                    return URL::IMG["UNIT"] . "00014035.png";
+                                }
+                                break;
+                            case 2:
+                                if (file_exists(PATH::BASE . "img/unit/00014033.png")){
+                                    return URL::IMG["UNIT"] . "00014033.png";
+                                }
+                                break;
+                            case 3:
+                                if (file_exists(PATH::BASE . "img/unit/00014031.png")){
+                                    return URL::IMG["UNIT"] . "00014031.png";
+                                }
+                                break;
+                            case 4:
+                                if (file_exists(PATH::BASE . "img/unit/00014034.png")){
+                                    return URL::IMG["UNIT"] . "00014034.png";
+                                }
+                                break;
+                            case 5:
+                                if (file_exists(PATH::BASE . "img/unit/00014032.png")){
+                                    return URL::IMG["UNIT"] . "00014032.png";
+                                }
+                                break;
+                            default:
+                                if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                                    return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                                }
+                                break;
+                        }
+                        break;
+                    case DUNGEON_ID::LUMEL_REMAINS_MARTIAL_CAT:
+                        switch ($stage){
+                            case 1:
+                                if (file_exists(PATH::BASE . "img/unit/00015032.png")){
+                                    return URL::IMG["UNIT"] . "00015032.png";
+                                }
+                                break;
+                            case 2:
+                                if (file_exists(PATH::BASE . "img/unit/00015034.png")){
+                                    return URL::IMG["UNIT"] . "00015034.png";
+                                }
+                                break;
+                            case 3:
+                                if (file_exists(PATH::BASE . "img/unit/00015031.png")){
+                                    return URL::IMG["UNIT"] . "00015031.png";
+                                }
+                                break;
+                            case 4:
+                                if (file_exists(PATH::BASE . "img/unit/00015035.png")){
+                                    return URL::IMG["UNIT"] . "00015035.png";
+                                }
+                                break;
+                            case 5:
+                                if (file_exists(PATH::BASE . "img/unit/00015033.png")){
+                                    return URL::IMG["UNIT"] . "00015033.png";
+                                }
+                                break;
+                            default:
+                                if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                                    return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                                }
+                                break;
+                        }
+                        break;
+                    default:
+                        if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                            return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                        }
+                        break;
+                }
+            }
+            elseif ($this->type == AREA_TYPE_ID::TARTARUS_LABYRINTH){
+                switch ($stage){
+                    case LABYRINTH_STAGES_ID::TARTARUS:
+                        if (file_exists(PATH::BASE . "img/unit/00046001.png")){
+                            return URL::IMG["UNIT"] . "00046001.png";
+                        }
+                        break;
+                    case LABYRINTH_STAGES_ID::LEOS:
+                        if (file_exists(PATH::BASE . "img/unit/00046101.png")){
+                            return URL::IMG["UNIT"] . "00046101.png";
+                        }
+                        break;
+                    case LABYRINTH_STAGES_ID::KOTTOS:
+                        if (file_exists(PATH::BASE . "img/unit/00046102.png")){
+                            return URL::IMG["UNIT"] . "00046102.png";
+                        }
+                        break;
+                    case LABYRINTH_STAGES_ID::AQUILES:
+                        if (file_exists(PATH::BASE . "img/unit/00046103.png")){
+                            return URL::IMG["UNIT"] . "00046103.png";
+                        }
+                        break;
+                    default:
+                        if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                            return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                        }
+                        else{
+                            return URL::IMG["UNKNOWN"];
+                        }
+                }
+            }
+            elseif ($this->type == AREA_TYPE_ID::TRIAL_OF_ASCENSION){
+                if (file_exists(PATH::BASE . "img/area/TRIAL_OF_ASCENSION.png")){
+                    return URL::IMG["AREA"] . "TRIAL_OF_ASCENSION.png";
+                }
+                else{
+                    return URL::IMG["UNKNOWN"];
+                }
+            }
+            else{
+                if (file_exists(PATH::BASE . "img/area/" . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png")){
+                    return URL::IMG["AREA"] . str_pad($this->id, 9, '0', STR_PAD_LEFT) . ".png";
+                }
+                else{
+                    return URL::IMG["UNKNOWN"];
+                }
+            }
         }
 
     }

+ 5 - 4
application/entity/Run.php

@@ -163,16 +163,16 @@
             $this->dtime = $r["dtime"];
             $type = 0;
             if (APPLICATION::valid_id("RAID_RIFT_DUNGEON_ID", $r["area"]) && $r["stage"] < 1){
-                $type = AREA_TYPE::RIFT_RAID_DUNGEON;
+                $type = AREA_TYPE_ID::RIFT_RAID_DUNGEON;
             }
             elseif (APPLICATION::valid_id("SCENARIO_ID", $r["area"])){
-                $type = AREA_TYPE::SCENARIO;
+                $type = AREA_TYPE_ID::SCENARIO;
             }
             elseif (APPLICATION::valid_id("ELEMENTAL_RIFT_DUNGEON_ID", $r["area"]) && $r["stage"] < 1){
-                $type = AREA_TYPE::ELEMENTAL_RIFT_DUNGEON;
+                $type = AREA_TYPE_ID::ELEMENTAL_RIFT_DUNGEON;
             }
             elseif (APPLICATION::valid_id("DUNGEON_ID", $r["area"])){
-                $type = AREA_TYPE::CAIROS_DUNGEON;
+                $type = AREA_TYPE_ID::CAIROS_DUNGEON;
             }
             $this->area = new K_Area($this->db, $r["area"], $type);
             $this->stage = $r["stage"];
@@ -286,6 +286,7 @@
                 $rune = new Rune($this->db, $r["id"]);
                 if (!isset($rune->id)){
                     $rune->id = $r["id"];
+                    $rune->level = 0;
                     $rune->assigned_to = null;
                     $rune->type = new K_Rune_Set($this->db, $r["type"]);
                     $rune->slot = $r["slot"];

+ 1 - 1
application/entity/Rune.php

@@ -317,7 +317,7 @@
         /**
          * Calculates name variables.
          */
-        private function refresh_names(){
+        public function refresh_names(){
             $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);

+ 25 - 4
application/entity/Team.php

@@ -47,6 +47,16 @@
          */
         public $unit = [];
 
+        /**
+         * @var int ID of the leader unit.
+         */
+        public $leader;
+
+        /**
+         * @var int[] List of IDs of the frontline units.
+         */
+        public $frontline = [];
+
         /**
          * @var Area Area the team is designed for.
          */
@@ -60,7 +70,7 @@
         /**
          * @var int difficulty the team is designed for. It can be null.
          *
-         * @see DIFFICULTY
+         * @see DIFFICULTY_ID
          */
         public $difficulty;
 
@@ -99,16 +109,27 @@
             $this->stage = $r["stage"];
             if ($complete){
                 $s = "
-                  SELECT unit
+                  SELECT
+                    unit,
+                    leader,
+                    front
                   FROM team_unit
-                  WHERE team = '$id';
+                  WHERE team = '$id'
+                  ORDER BY 
+                    front DESC,
+                    leader DESC;
                 ";
                 $q = $this->db->query($s);
                 while ($r = $q->fetchArray(SQLITE3_ASSOC)){
                     array_push($this->unit, new Unit($this->db, $r["unit"], false));
+                    if ($r["leader"] == 1){
+                        $this->leader = $r["unit"];
+                    }
+                    if ($r["front"] == 1){
+                        array_push($this->frontline, $r["unit"]);
+                    }
                 }
             }
         }
-
     }
 ?>

+ 12 - 1
application/page/Report_Runeupgrade_Page.php

@@ -100,7 +100,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){
+                if (strlen($rune_alt->assigned_to) > 0){
                     $rune_alt->assigned_to = new Unit($this->db, $rune_alt->assigned_to);
                 }
                 array_push($rupgrade["alternative"], $rune_alt);
@@ -146,6 +146,12 @@
             else{
                 $this->filters["MONSTER_IN_STORAGE"] = false;
             }
+            if (isset($_GET["monster_teams"]) && $_GET["monster_teams"] == "on"){
+                $this->filters["MONSTER_TEAMS"] = true;
+            }
+            else{
+                $this->filters["MONSTER_TEAMS"] = false;
+            }
             if (isset($_GET["monster_name"]) && strlen($_GET["monster_name"]) > 0){
                 $this->filters["MONSTER_NAME"] = SQLite3::escapeString($_GET["monster_name"]);
             }
@@ -256,6 +262,7 @@
                   $cond
                 )
               ORDER BY
+                (SELECT COUNT(DISTINCT(area_type || area)) FROM team, team_unit WHERE team.id = team_unit.team AND team_unit.unit = unit.id AND team.uid = '$UID') DESC,
                 unit.stars DESC,
                 unit.level DESC,
                 unit.id,
@@ -367,6 +374,9 @@
             if (!$this->filters["MONSTER_IN_STORAGE"]){
                 $s = $s . " AND unit.building <> " . BUILDING_ID::MONSTER_STORAGE;
             }
+            if (!$this->filters["MONSTER_TEAMS"]){
+                $s = $s . " AND unit.id in (SELECT unit FROM team, team_unit WHERE team.id = team_unit.team AND team_unit.unit = unit.id AND team.uid = '$UID') ";
+            }
             if (count($this->filters["RUNE_SLOT"]) > 0){
                 $s = $s . " AND rune.slot IN ( ";
                 foreach($this->filters["RUNE_SLOT"] as $t){
@@ -376,6 +386,7 @@
             }
             $s = $s . "
               ORDER BY
+                (SELECT COUNT(DISTINCT(area_type || area)) FROM team, team_unit WHERE team.id = team_unit.team AND team_unit.unit = unit.id AND team.uid = '$UID') DESC,
                 unit.stars DESC,
                 unit.level DESC,
                 unit.id,

BIN
application/sw.sqlite


+ 14 - 2
application/view/inc/filter_report_runeupgrade.php

@@ -36,7 +36,7 @@
         </script>
         <form action='/<?=$UID?>/report/runeupgrade/' method='get' id='custom_filter_runes' class='custom_filter'>
             <span class='custom_filter_title'>Custom filters:</span>
-            <select name='custom_filter' onChange='customFilterDescription(this.value);' onload='alert("LOAD");customFilterDescription("<?=$_GET["custom_filter"]?>");'>
+            <select name='custom_filter' onChange='customFilterDescription(this.value);' onload='customFilterDescription("<?=$_GET["custom_filter"]?>");'>
                 <option> </option>
 <?php
                  foreach($custom_filters AS $filter){
@@ -64,7 +64,7 @@
 <form action='/<?=$UID?>/report/runeupgrade/' method='get' id='filter_runeupgrade' class='filter'>
     <table>
         <tr>
-            <td class='filter filter_title' rowspan='2'>
+            <td class='filter filter_title' rowspan='3'>
                 <span>
                     Monster
                 </span>
@@ -91,6 +91,18 @@
                 <label for='filter_monster_in_storage'>Show monsters in storage</label>
             </td>
         </tr>
+        </tr>
+            <td class='filter' colspan='4'>
+<?php
+                $checked = "";
+                if ($filters["MONSTER_TEAMS"]){
+                    $checked = "checked";
+                }
+?>
+                <input type='checkbox' name='monster_teams' id='filter_monster_teams' <?=$checked?>/>
+                <label for='filter_monster_teams'>Only show monsters in teams</label>
+            </td>
+        </tr>
         <tr>
             <td class='filter filter_title filter_separator' rowspan='5'>
                 <span>

+ 2 - 2
application/view/report_runeupgrade.php

@@ -45,8 +45,8 @@
             function toggleFilters(){
                 var content = document.getElementById('filters_content');
                 var slid = document.getElementById('filters_slid');
-                if (content.style.maxHeight != '30em'){
-                    content.style.maxHeight = '30em';
+                if (content.style.maxHeight != '40em'){
+                    content.style.maxHeight = '40em';
                     slid.style.transform = 'rotate(90deg)';
                 }
                 else{

+ 1 - 2
application/view/runs.php

@@ -39,7 +39,7 @@
         <meta name='twitter:url' content='<?=$page->canonical?>'/>
         <meta name='robots' content='index follow'/>
         <script>
-        
+
             /**
              * Shows or hiddes the save team form.
              *
@@ -109,7 +109,6 @@
             <article id='filters_content'>
 <?php
                 $filters = $page->filters;
-                $custom_filters = $page->custom_filters;
                 include __DIR__ . "/inc/filter_runs.php";
 ?>
             </article>

+ 37 - 15
application/view/teams.php

@@ -100,8 +100,9 @@
                         area = document.getElementById('new_area_rift_dungeon').options[document.getElementById('new_area_rift_dungeon').selectedIndex].value;
                         break;
                     case '<?=AREA_TYPE_ID::RIFT_RAID?>':
-                        area = document.getElementById('new_area_rift_raid').options[document.getElementById('new_area_rift_raid').selectedIndex].value;
+                        //area = document.getElementById('new_area_rift_raid').options[document.getElementById('new_area_rift_raid').selectedIndex].value;
                         stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
+                        area = stage;
                         break;
                     case '<?=AREA_TYPE_ID::ARENA?>':
                         break;
@@ -110,10 +111,12 @@
                     case '<?=AREA_TYPE_ID::GUILD_SIEGE?>':
                         break;
                     case '<?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>':
+                        area = <?=AREA_TYPE_ID::TARTARUS_LABYRINTH?>;
                         difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
-                        stage = document.getElementById('new_area_stage').options[document.getElementById('new_area_stage').selectedIndex].value;
+                        stage = document.getElementById('new_area_tartarus_labyrinth').options[document.getElementById('new_area_tartarus_labyrinth').selectedIndex].value;
                         break;
                     case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
+                        area = <?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>;
                         difficulty = document.getElementById('new_area_difficulty').options[document.getElementById('new_area_difficulty').selectedIndex].value;
                         break;
                     case '<?=AREA_TYPE_ID::DIMENSIONAL_HOLE?>':
@@ -400,7 +403,9 @@
                         max_units = 6;
                         break;
                     case '<?=AREA_TYPE_ID::RIFT_RAID?>':
-                        document.getElementById('new_area_rift_raid').style.display = 'inline';
+                        //document.getElementById('new_area_rift_raid').style.display = 'inline';
+                        populateStage(5);
+                        document.getElementById('new_area_stage').style.display = 'inline';
                         max_units = 6
                         break;
                     case '<?=AREA_TYPE_ID::ARENA?>':
@@ -421,7 +426,8 @@
                         break;
                     case '<?=AREA_TYPE_ID::TRIAL_OF_ASCENSION?>':
                         max_units = 5;
-                        //document.getElementById('new_area_trial_of_ascension').style.display = 'inline';
+                        document.getElementById('new_area_difficulty').style.display = 'inline';
+                        populateDifficulty(false, true);
                         break;
                     case '<?=AREA_TYPE_ID::WORLD_BOSS?>':
                         //max_units = 5;
@@ -571,31 +577,46 @@
                         <tr>
                             <td class='team <?=$odd?>'>
                                 <h4>
-                                    <?=$team->name?>
-                                </h4>
+                                    <img title='<?=$team->area->name?>' class='area' src='<?=$team->area->get_image($team->stage)?>'/>
 <?php
-                                $area = $team->area->name;
-                                if (intval($team->stage) > 0){
-                                    $area = $area . " - " . $team->stage;
-                                }
+                                    if ($team->stage > 0 && $team->area->type != AREA_TYPE_ID::TARTARUS_LABYRINTH){
+?>
+                                        <span class='stage'><?=$team->stage?></span>
+<?php
+                                    }
 ?>
-                                <h5>
-                                    <?=$area?>
-                                </h5>
+                                    <span class='team_name'><?=$team->name?></span>
+                                </h4>
                             </td>
                             <td class='description <?=$odd?>'>
                                 <?=$team->description?>
                             </td>
                             <td class='units <?=$odd?>'>
 <?php
+                                $prev_front = false;
+                                $front = "undefined";
                                 foreach ($team->unit as $unit){
+                                    $front = in_array($unit->id, $team->frontline);
+                                    if ($front != "undefined" && $prev_front != $front){
+?>
+                                        <hr class='frontline'/>
+<?php
+                                    }
 ?>
                                     <a href='/<?=$UID?>/monsters/<?=$unit->id?>'>
                                         <div class='monster_panel'>
                                             <?=HTML::unit_panel($unit)?>
+<?php
+                                            if ($unit->id == $team->leader){
+?>
+                                                <img alt='Leader' class='leader' src='<?=URL::IMG["ICON"]?>leader.png'/>
+<?php
+                                            }
+?>
                                         </div>
                                     </a>
 <?php
+                                    $prev_front = $front;
                                 }
 ?>
                             </td>
@@ -687,7 +708,9 @@
                                 <option value='<?=DUNGEON_ID::SANCTUARY_OF_DREAMING_FAIRIES?>'>Sanctuary of Dreaming Fairies</option>
                                 <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_FAIRY?>'>Ellunia Remains (Fairy)</option>
                                 <option value='<?=DUNGEON_ID::ELLUNIA_REMAINS_PIXIE?>'>Ellunia Remains (Pixie)</option>
-                                <!-- TODO: Lumel -->
+                                <option value='<?=DUNGEON_ID::CLIFF_OF_TOUGH_BEASTS_MEN?>'>cliff of Tough Beasts Men</option>
+                                <option value='<?=DUNGEON_ID::LUMEL_REMAINS_WEREWOLF?>'>Lumel Remains (Werewolf)</option>
+                                <option value='<?=DUNGEON_ID::LUMEL_REMAINS_MARTIAL_CAT?>'>Lumel Remains (Martial Cat)</option>
                             </select>
                             <select id='new_area_tartarus_labyrinth' class='new_area' onChange='selectNewArea();'>
                                 <option value=''> </option>
@@ -701,7 +724,6 @@
                                 <option value='<?=LABYRINTH_STAGES_ID::COOL_TIME?>'>Cool Time Stage</option>
                                 <option value='<?=LABYRINTH_STAGES_ID::SPEED_LIMIT?>'>Speed Limit Stage</option>
                                 <option value='<?=LABYRINTH_STAGES_ID::TIME_LIMIT?>'>Time Limit Stage</option>
-                                <!-- TODO: Lumel -->
                             </select>
                             <select id='new_area_difficulty'>
                             </select>

+ 1 - 0
install_data/install_base.sql

@@ -136,6 +136,7 @@ INSERT INTO k_area VALUES(2,4,'Rift of Worlds - level 2');
 INSERT INTO k_area VALUES(3,4,'Rift of Worlds - level 3');
 INSERT INTO k_area VALUES(4,4,'Rift of Worlds - level 4');
 INSERT INTO k_area VALUES(5,4,'Rift of Worlds - level 5');
+INSERT INTO k_area VALUES(9,9,'Tartarus Labyrinth');
 CREATE TABLE k_decoration(
     id INT NOT NULL PRIMARY KEY,
     area REFERENCES k_area_type(id),

+ 2 - 0
install_data/install_data.sql

@@ -192,6 +192,8 @@ CREATE TABLE run_drop_shapeshifting(
 CREATE TABLE team_unit(
     team INT NOT NULL REFERENCES team(id),
     unit INT NOT NULL REFERENCES unit(id),
+    leader INT NOT NULL DEFAULT 0,
+    front INT NOT NULL DEFAULT 0,
     PRIMARY KEY(team, unit)
 );
 CREATE TABLE run(

+ 40 - 3
public/css/teams.css

@@ -20,11 +20,39 @@ table#teams td.odd{
 }
 
 table#teams td.team h4{
-    margin: 0.2em;
+    position: relative;
+    margin: 0.1em;
 }
 
-table#teams td.team h5{
-    margin: 0.1em;
+table#teams td.team h4 img.area{
+    top: 0;
+    left: 0;
+    width: 2em;
+    height: 2em;
+    border: 0.2em solid #555555;
+    border-radius: 0.5em;
+    background-color: #777777;
+}
+
+table#teams td.team h4 span.stage{
+    position: absolute;
+    top: 1.3em;
+    left: 0;
+    width: 2em;
+    text-align: right;
+    text-shadow: 0 0 0.3em #000, 0 0 0.3em #000, 0 0 0.3em #000, 0 0 0.2em #000, 0 0 0.1em #000, 0 0 0.1em #000;
+    pointer-events: none;
+}
+
+table#teams td.units{
+    width: 12em;
+}
+
+table#teams td.units hr.frontline{
+    display: block;
+    width: 9em;
+    margin: -0.6em 0 0.2em 0;
+    color: #666666;
 }
 
 table#teams td.units div.monster_panel{
@@ -32,6 +60,15 @@ table#teams td.units div.monster_panel{
     margin-bottom: -2em;
 }
 
+table#teams td.units div.monster_panel img.leader{
+    width: 5em;
+    height: 5em;
+    display: block;
+    position: absolute;
+    top: -1.7em;
+    left: -0.7em;
+}
+
 section#new_team{
     z-index: 1;
     display: none;