Explorar o código

Siege defenses parsed and displayed. Artifact efficiency working for inventory and drops. Records shown again in th home page. Fixed errors in the Punisher Crypt logging.

Iñigo Valentin %!s(int64=5) %!d(string=hai) anos
pai
achega
a81c2cf7aa

+ 28 - 1
application/API/v1/profile/PUT.php

@@ -605,6 +605,33 @@ function parse_profile($db, $player_id, $json){
             $position ++;
         }
     }
+    
+    // Parse siege defenses.
+    $i = 0;
+    foreach ($json->{"guildsiege_defense_unit_list"} as $defense){
+        $statement = $db->prepare("
+          INSERT INTO defense (
+            player,
+            area_type,
+            slot,
+            unit,
+            position
+          ) VALUES (
+            :player,
+            :area_type,
+            :slot,
+            :unit,
+            :position
+          );
+        ");
+        $statement->bindValue(":player", $player_id, SQLITE3_INTEGER);
+        $statement->bindValue(":area_type", AREA_TYPE_ID::GUILD_SIEGE, SQLITE3_INTEGER);
+        $statement->bindValue(":slot", floor($i / 3), SQLITE3_INTEGER);
+        $statement->bindValue(":unit", $defense, SQLITE3_INTEGER);
+        $statement->bindValue(":position", ($i % 3) + 1, SQLITE3_INTEGER);
+        $statement->execute();
+        $i ++;
+    }
 
     // Parse buildings
     foreach($json->{"building_list"} as $building){
@@ -1191,7 +1218,7 @@ function parse_records($db, $player_id, $json){
             $statement = $db->prepare("
               DELETE FROM record
               WHERE
-                player = :player_id AND
+                player = :player AND
                 area_type = :area_type AND
                 area = :area;
             ");

+ 0 - 2
application/API/v1/run/POST.php

@@ -868,7 +868,6 @@ function log_cairos_run($db, $id, $player_id, $json){
         :rank
       );
     ");
-
     // Bind data and insert
     $statement->bindValue(":player", $player_id, SQLITE3_INTEGER);
     $statement->bindValue(":id", $id, SQLITE3_INTEGER);
@@ -1546,7 +1545,6 @@ try{
     else{
         $id = 1;
     }
-
     // Run parsing function
     $result = "500 Unknown Error";
     switch($command){

+ 2 - 3
application/Constant.php

@@ -266,7 +266,7 @@ final class EFFECT_AREA_ID{
     /**
      * Guild content (battle, siege, Labyrinth).
      */
-    const GUILD = 5;
+    const GUILD = 4;
 };
 
 /**
@@ -565,7 +565,7 @@ final class CAIROS_DUNGEON_ID{
     /**
      * Steel Fortress
      */
-    const STEEL_FORTRESS = 9602; // TODO: Find out
+    const STEEL_FORTRESS = 9602; 
 
     /**
      * Hall of Light.
@@ -990,7 +990,6 @@ final class INVENTORY_TYPE_ID{
     
     /**
      * Artifact.
-     * @todo Every artifact or an specific type? verify.
      */
     const ARTIFACT = 73;
 

+ 1 - 1
application/action/optimize_get_options.php

@@ -15,7 +15,7 @@
  * Reads the POST parameters looking for the following KEYS:
  *  player: The player ID.
  *  unit: The unit ID.
- *  tuning: {@todo Document properly}.
+ *  tuning: 1: All +12; 2: Even +15, odd + 12; 3: All +15.
  *  options: JSON with rune sets.
  *
  * @return int|string a JSON with the runes on success, negative integers on error. 0 if no errors

+ 1 - 7
application/action/optimize_get_rune_list.php

@@ -17,8 +17,7 @@
  *  mode: Game mode ({@see GAME_MODE_ID}).
  *  unit: Unit ID.
  *  source: Source of the runes to select (assigned, unassigned, ...).
- *  limit: {@todo: Currently not in use. Implement or delete}.
- *  tuning: {@todo Document properly}.
+ *  tuning: 1: All +12; 2: Even +15, odd + 12; 3: All +15.
  *  set[]: Selected rune sets ({@see RUNE_SET_ID}).
  *  
  * Then it selects all the runes matching the cryteria.
@@ -77,11 +76,6 @@ function action(){
         return -4;
     }
 
-    $limit = intval(filter_input(INPUT_POST, 'limit'));
-    if ($limit == 0){
-        return -5;
-    }
-
     $tuning = filter_input(INPUT_POST, 'tuning');
     if ($tuning == null){
         return -6;

+ 1 - 1
application/action/save_run_team.php

@@ -17,7 +17,7 @@
  *  run: Run ID.
  *  name: New team name.
  *  description: New team description.
- *  score: New team score {@todo implement}.
+ *  score: New team score, defaults to 0.
  * Validates the data and creates the team in the database.
  * 
  * @return int 201 on success, HTTP erro status codes on error.

+ 1 - 1
application/entity/Area.php

@@ -153,7 +153,7 @@ class Area extends Entity{
                     return APPLICATION::img("UNIT", 62403);
                     break;
                 case DUNGEON_ID::PUNISHERS_CRYPT:
-                    return APPLICATION::img("UNIT", 62403);
+                    return APPLICATION::img("UNIT", 62604);
                     break;
                 case DUNGEON_ID::HALL_OF_WATER:
                     return APPLICATION::img("UNIT", 60101);

+ 7 - 4
application/entity/Artifact.php

@@ -307,6 +307,9 @@ class Artifact extends Entity{
      * @return float Efficiency
      */
     private function calculate_efficiency(){
+        if (! $this->flag_stats){
+            $this->load_stats();
+        }
         $eff = [0.0, 0.0, 0.0, 0.0];
 
         $query = "
@@ -404,16 +407,16 @@ class Artifact extends Entity{
     private function calculate_maximum_efficiency(){
         $max_efficiency = $this->efficiency;
         if ($this->level < 12){
-            $max_efficiency += (1/8);
+            $max_efficiency += (100/8);
         }
         if ($this->level < 9){
-            $max_efficiency += (1/8);
+            $max_efficiency += (100/8);
         }
         if ($this->level < 6){
-            $max_efficiency += (1/8);
+            $max_efficiency += (100/8);
         }
         if ($this->level < 3){
-            $max_efficiency += (1/8);
+            $max_efficiency += (100/8);
         }
         return $max_efficiency;
     }

+ 32 - 10
application/entity/Player.php

@@ -149,7 +149,6 @@ class Player extends Entity{
 
     /**
      * @var Unit[] Siege defenses.
-     * @todo Implement
      */
     private $siege_defense = [];
 
@@ -348,25 +347,48 @@ class Player extends Entity{
         $statement = get_context()->get_db()->prepare("
             SELECT
               unit,
-              position
+              slot
             FROM defense
             WHERE
               player = :player AND
               area_type = :area_type
-            ORDER BY position;
+            ORDER BY
+              slot,
+              position;
         ");
-        $statement->bindValue(':id', $this->id, SQLITE3_TEXT);
+        $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
         $statement->bindValue(':area_type', AREA_TYPE_ID::GUILD_WAR, SQLITE3_INTEGER);
         $q = $statement->execute();
         while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-            if ($r["position"] <= 3){
-                array_push($this->gw_defense[0], new Unit($r["unit"], false));
-            }
-            else{
-                array_push($this->gw_defense[1], new Unit($r["unit"], false));
-            }
+            array_push($this->gw_defense[$r["slot"]], new Unit($r["unit"], false));
         }
         // TODO: Siege defenses
+        $statement = get_context()->get_db()->prepare("
+            SELECT
+              unit,
+              position
+            FROM defense
+            WHERE
+              player = :player AND
+              area_type = :area_type
+            ORDER BY
+              slot,
+              position;
+        ");
+        $statement->bindValue(':player', $this->id, SQLITE3_TEXT);
+        $statement->bindValue(':area_type', AREA_TYPE_ID::GUILD_SIEGE, SQLITE3_INTEGER);
+        $q = $statement->execute();
+        $i = 0;
+        $siege = [null, null, null];
+        while ($r = $q->fetchArray(SQLITE3_ASSOC)){
+            $siege[$i] = new Unit($r["unit"]);
+            $i ++;
+            if ($i == 3){
+                array_push($this->siege_defense, $siege);
+                $i = 0;
+                $siege = [null, null, null];
+            }
+        }
         $this->flag_defense = true;
     }
 

+ 1 - 1
application/entity/Record.php

@@ -143,7 +143,7 @@ class Record extends Entity{
             front DESC,
             leader DESC;
         ");
-        $statement->bindValue(':player', $$this->player, SQLITE3_TEXT);
+        $statement->bindValue(':player', $this->player, SQLITE3_TEXT);
         $statement->bindValue(':area_type', $this->area->get_type(), SQLITE3_TEXT);
         $statement->bindValue(':area', $this->get_area()->get_id(), SQLITE3_TEXT);
         $q = $statement->execute();

+ 0 - 1
application/entity/Run.php

@@ -24,7 +24,6 @@ require_once(PATH::ENTITY . "Rune_Set.php");
  * Represent a saved run in a playable area.
  *
  * @category Entity
- * @todo Consider artifact drops.
  */
 class Run extends Entity{
     

+ 68 - 30
application/view/home.php

@@ -130,11 +130,6 @@
 <?php
                                 $first = true;
                                 foreach (get_context()->get_player()->get_arena_defense() as $defense){
-?>
-                                    <div class='monster_panel'>
-                                        <?=HTML::unit_panel($defense)?>
-                                    </div>
-<?php
                                     if (
                                       $first && 
                                       null != $defense->get_monster()->get_leader_skill() &&
@@ -150,6 +145,11 @@
 <?php
                                     }
                                     $first = false;
+?>
+                                    <div class='monster_panel'>
+                                        <?=HTML::unit_panel($defense)?>
+                                    </div>
+<?php
                                 }
 ?>
                             </div>
@@ -161,11 +161,6 @@
                                 $first = true;
                                 // TODO: Watch if null
                                 foreach (get_context()->get_player()->get_gw_defense()[0] as $defense){
-?>
-                                    <div class='monster_panel'>
-                                        <?=HTML::unit_panel($defense)?>
-                                    </div>
-<?php
                                     if (
                                       $first &&
                                       null != $defense->get_monster()->get_leader_skill() &&
@@ -181,19 +176,53 @@
 <?php
                                     }
                                     $first = false;
+?>
+                                    <div class='monster_panel'>
+                                        <?=HTML::unit_panel($defense)?>
+                                    </div>
+<?php
                                 }
+                                
 ?>
                                 <hr/>
 <?php
                                 $first = true;
                                 // TODO: Watch if null
                                 foreach (get_context()->get_player()->get_gw_defense()[1] as $defense){
+                                        // TODO: Guild content, not arena.
+                                        if (
+                                          $first &&
+                                          null != $defense->get_monster()->get_leader_skill() &&
+                                          (
+                                            $defense->get_monster()->get_leader_skill()->get_area() == EFFECT_AREA_ID::GENERAL ||
+                                            $defense->get_monster()->get_leader_skill()->get_area() == EFFECT_AREA_ID::GUILD
+                                          )
+                                        ){
+?>
+                                        <div class='skill'>
+                                            <img class='skill_img' title='<?=$defense->get_monster()->get_leader_skill()->get_description()?>' src='<?=$defense->get_monster()->get_leader_skill()->get_image()?>'/>
+                                        </div>
+<?php
+                                    }
+                                    $first = false;
 ?>
                                     <div class='monster_panel'>
                                         <?=HTML::unit_panel($defense)?>
                                     </div>
 <?php
-                                        // TODO: Guild content, not arena.
+                                }
+?>
+                            </div>
+                            <div id='placements_siege'>
+                                <h5>
+                                    Siege Battle defenses:
+                                </h5>
+<?php
+                                
+                                foreach (get_context()->get_player()->get_siege_defense() as $formation){
+                                    $first = true;
+                                    foreach($formation as $defense){
+
                                         if (
                                           $first &&
                                           null != $defense->get_monster()->get_leader_skill() &&
@@ -203,12 +232,21 @@
                                           )
                                         ){
 ?>
-                                        <div class='skill'>
-                                            <img class='skill_img' title='<?=$defense->get_monster()->get_leader_skill()->get_description()?>' src='<?=$defense->get_monster()->get_leader_skill()->get_image()?>'/>
+                                            <div class='skill'>
+                                                <img class='skill_img' title='<?=$defense->get_monster()->get_leader_skill()->get_description()?>' src='<?=$defense->get_monster()->get_leader_skill()->get_image()?>'/>
+                                            </div>
+<?php
+                                        }
+                                        $first = false;
+?>
+                                        <div class='monster_panel'>
+                                            <?=HTML::unit_panel($defense)?>
                                         </div>
 <?php
                                     }
-                                    $first = false;
+?>
+                                    <hr/>
+    <?php
                                 }
 ?>
                             </div>
@@ -236,7 +274,7 @@
                             <br/>
 <?php
                             // Decorations
-$                           $half = sizeof(get_context()->get_player()->get_decorations()) / 2;
+                            $half = sizeof(get_context()->get_player()->get_decorations()) / 2;
                             $i = 0;
                             foreach (get_context()->get_player()->get_decorations() as $decoration){
                                 if ($i == $half){
@@ -456,42 +494,42 @@ $                           $half = sizeof(get_context()->get_player()->get_deco
 ?>
                                         <tr>
                                             <td class='record_dungeon'>
-                                                <img title='<?=$record->area->name?>' class='area' src='<?=$record->area->get_image()?>'/>
+                                                <img title='<?=$record->get_area()->get_name()?>' class='area' src='<?=$record->get_area()->get_image()?>'/>
                                             </td>
                                             <td class='record_info'>
                                                 <span class='title'>
 <?php
                                                     $title = "";
-                                                    switch ($record->area->type){
+                                                    switch ($record->get_area()->get_type()){
                                                         case AREA_TYPE_ID::CAIROS_DUNGEON:
-                                                            $title = $record->area->name . " " . $record->stage . "F";
+                                                            $title = $record->get_area()->get_name() . " " . $record->get_stage() . "F";
                                                             break;
                                                         case AREA_TYPE_ID::RIFT_DUNGEON:
-                                                            $title = $record->area->name;
+                                                            $title = $record->get_area()->get_name();
                                                             break;
                                                         case AREA_TYPE_ID::RIFT_RAID:
-                                                            $title = $record->area->name;
+                                                            $title = $record->get_area()->get_name();
 
                                                     }
 ?>
                                                     <?=$title?>
                                                 </span>
 <?php
-                                                if ($record->area->type == AREA_TYPE_ID::RIFT_DUNGEON){
+                                                if ($record->get_area()->get_type() == AREA_TYPE_ID::RIFT_DUNGEON){
 ?>
                                                     <span class='score'>
-                                                        <?=$record->score?>
+                                                        <?=$record->get_score()?>
                                                     </span>
                                                     <span class='rank'>
-                                                        <?=$record->rank?>
+                                                        <?=$record->get_rank()?>
                                                     </span>
 <?php
                                                 }
                                                 else{
-                                                    $s = floor($record->time / 1000);
+                                                    $s = floor($record->get_time() / 1000);
                                                     $m = floor($s / 60);
                                                     $s = floor($s % 60);
-                                                    $ms = ($record-> time - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
+                                                    $ms = ($record->get_time() - (1000 * 60 * $m) - (1000 * 60 * $s) / 100);
                                                     $s = str_pad($s, 2, '0', STR_PAD_LEFT);
                                                     $ms = str_pad($ms, 2, '0', STR_PAD_LEFT);
 ?>
@@ -504,7 +542,7 @@ $                           $half = sizeof(get_context()->get_player()->get_deco
                                             </td>
 <?php
                                             $class_frontline = "";
-                                            if ($record->area->type == AREA_TYPE_ID::RIFT_DUNGEON || $record->area->type == AREA_TYPE_ID::RIFT_RAID){
+                                            if ($record->get_area()->get_type() == AREA_TYPE_ID::RIFT_DUNGEON || $record->get_area()->get_type() == AREA_TYPE_ID::RIFT_RAID){
                                                 $class_frontline = "frontlines";
                                             }
 ?>
@@ -512,8 +550,8 @@ $                           $half = sizeof(get_context()->get_player()->get_deco
 <?php
                                                 $prev_front = false;
                                                 $front = "undefined";
-                                                foreach ($record->party as $party){
-                                                    $front = in_array($party->id, $record->frontline);
+                                                foreach ($record->get_party() as $party){
+                                                    $front = in_array($party->get_id(), $record->get_frontline());
                                                     if ($front != "undefined" && $prev_front != $front){
 ?>
                                                         <hr class='frontline'/>
@@ -527,14 +565,14 @@ $                           $half = sizeof(get_context()->get_player()->get_deco
                                                     }
                                                     if ($disabled == ""){
 ?>
-                                                        <a target='_blank' href='/<?=get_context()->get_player()->get_id()?>/monster/<?=$party->id?>'>
+                                                        <a target='_blank' href='/<?=get_context()->get_player()->get_id()?>/units/<?=$party->get_id()?>'>
 <?php
                                                     }
 ?>
                                                     <div class='monster_panel <?=$disabled?>'>
                                                         <?=HTML::unit_panel($party)?>
 <?php
-                                                            if ($party->id == $record->leader){
+                                                            if ($party->get_id() == $record->get_leader()){
 ?>
                                                                 <img alt='Leader' class='leader' src='<?=URL::IMG["ICON"]?>leader.png'/>
 <?php

+ 1 - 1
install_data/02_CREATE_DATA.sql

@@ -239,7 +239,7 @@ CREATE TABLE data.run_party(
 );
 CREATE TABLE data.run_drop_enchantment(
     run INT NOT NULL REFERENCES run(id),
-    id INT NOT NULL PRIMARY KEY,
+    id INT NOT NULL,
     type INT NOT NULL, --REFERENCES key.enchantment(id), -- TODO: Duplicated??
     quality INT NOT NULL, --REFERENCES key.quality(id),
     rune INT NOT NULL, --REFERENCES key.rune_set(id),

+ 35 - 2
public/css/home.css

@@ -66,12 +66,28 @@ article#profile div#placements div#placements_rep div.monster_panel{
     font-size: 45%;
     margin: 0.2em;
 }
-
+article#profile div#placements div#placements_arena div.skill{
+    display: inline-block;
+    vertical-align: middle;
+    margin-top: -1.5em;
+}
+article#profile div#placements div#placements_arena div.skill img{
+    width:2em;
+    height: 2em;
+}
 article#profile div#placements div#placements_arena div.monster_panel{
     font-size: 35%;
     margin: 0.15em;
 }
-
+article#profile div#placements div#placements_gw div.skill{
+    display: inline-block;
+    vertical-align: middle;
+    margin-top: -1.5em;
+}
+article#profile div#placements div#placements_gw div.skill img{
+    width:2em;
+    height: 2em;
+}
 article#profile div#placements div#placements_gw div.monster_panel{
     font-size: 40%;
     margin: 0.2em;
@@ -80,6 +96,23 @@ article#profile div#placements div#placements_gw hr{
     width: 12em;
     margin: 0.1em auto;
 }
+article#profile div#placements div#placements_siege div.skill{
+    display: inline-block;
+    vertical-align: middle;
+    margin-top: -1.5em;
+}
+article#profile div#placements div#placements_siege div.skill img{
+    width:2em;
+    height: 2em;
+}
+article#profile div#placements div#placements_siege div.monster_panel{
+    font-size: 40%;
+    margin: 0.2em;
+}
+article#profile div#placements div#placements_siege hr{
+    width: 12em;
+    margin: 0.1em auto;
+}
 
 article#profile div#building div.building_panel{
     display: inline-block;