Explorar el Código

Scenario and Dungeons automatically logged. Runes captured.

Iñigo Valentin hace 6 años
padre
commit
c322c61eef

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

@@ -122,7 +122,7 @@ def parseRun(db, data):
     for party in data["party"]:
         unit_id = party["unit_id"]
         unit_master_id = party["unit_master_id"]
-        insert(db, "run_party", (id, unit_id, unit_master_id))
+        insert(db, "run_party", (id, unit_master_id, unit_id))
     db.commit()
 
 """

+ 1 - 1
application/entity/K_Area.php

@@ -64,7 +64,7 @@
          * @return path to the image, or a path to a fixed unknown image if it
          *         doesn't exist.
          */
-        public function get_image(){
+        public function get_image($stage = null){
             global $base_dir;
             global $path;
             global $AREA_TYPE;

+ 22 - 3
application/entity/Run.php

@@ -6,6 +6,7 @@
     require_once($path["entity"] . "Rune.php");
     require_once($path["entity"] . "Inventory.php");
     require_once($path["entity"] . "K_Area.php");
+    require_once($path["entity"] . "K_Rune_Set.php");
 
 
     /**
@@ -271,20 +272,29 @@
                 FROM run_drop_rune
                 WHERE run = $this->id;
             ";
+            if ($this->id == 9){
+                error_log("DEBUG RUNE: " . $s);
+            }
             $q = $this->db->query($s);
-            $r = $q->fetchArray(SQLITE3_ASSOC);
             while ($r = $q->fetchArray(SQLITE3_ASSOC)){
-                $rune = new Rune($this->id, $r["id"]);
+                $rune = new Rune($this->db, $r["id"]);
+                //if ($this->id == 9){
+                    error_log("DEBUG RUNE ID: " . $rune->id);
+                //}
                 if (!isset($rune->id)){
+                    if ($this->id == 9){
+                        error_log("DEBUG RUNE: NEW");
+                    }
                     $rune->id = $r["id"];
                     $rune->assigned_to = null;
-                    $rune->type = $r["type"];
+                    $rune->type = new K_Rune_Set($this->db, $r["type"]);
                     $rune->slot = $r["slot"];
                     $rune->stars = $r["stars"];
                     $rune->ancient = $r["ancient"];
                     $rune->quality = $r["quality"];
                     $rune->original_quality = $r["quality"];
                     $rune->value = $r["value"];
+                    $rune->value = 0;
                     $rune->efficiency = $r["efficiency"];
                     // TODO: Calculate?
                     $rune->max_efficiency = $r["efficiency"];
@@ -294,12 +304,21 @@
                     $rune->innate_stat_value = $r["innate_stat_value"];
                     $rune->substat_1 = $r["substat_1"];
                     $rune->substat_1_value = $r["substat_1_value"];
+                    $rune->substat_1_enchant = 0;
+                    $rune->substat_1_grind = 0;
                     $rune->substat_2 = $r["substat_2"];
                     $rune->substat_2_value = $r["substat_2_value"];
+                    $rune->substat_2_enchant = 0;
+                    $rune->substat_2_grind = 0;
                     $rune->substat_3 = $r["substat_3"];
                     $rune->substat_3_value = $r["substat_3_value"];
+                    $rune->substat_3_enchant = 0;
+                    $rune->substat_3_grind = 0;
                     $rune->substat_4 = $r["substat_4"];
                     $rune->substat_4_value = $r["substat_4_value"];
+                    $rune->substat_4_enchant = 0;
+                    $rune->substat_4_grind = 0;
+                    $rune->refresh_names();
                 }
                 array_push($this->rune, $rune);
             }

+ 15 - 8
application/entity/Rune.php

@@ -284,16 +284,23 @@
                 $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);
+                $this->refresh_names();
             }
         }
+        
+        /**
+         * Decodes some properties and assigns name variables.
+         */
+        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);
+            $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.

+ 16 - 16
application/view/runs.php

@@ -75,7 +75,7 @@
                             <tr>
                                 <td class='area'>
                                     <div class='area'>
-                                        <img title='<?=$run->area->name?>' class='area' src='<?=$run->area->get_image()?>'/>
+                                        <img title='<?=$run->area->name?>' class='area' src='<?=$run->area->get_image($run->stage)?>'/>
 <?php
                                         if ($run->stage > 0){
 ?>
@@ -155,46 +155,46 @@
                                     if ($run->energy > 0){
 ?>
                                         <div class='item'>
-                                            <img title='Energy' src='<?=$path["img"]["layout"]?>currency/energy.png'/>
-                                            <span><?=$run->energy?></span>
+                                            <img class='item' title='Energy' src='<?=$path["img"]["layout"]?>currency/energy.png'/>
+                                            <span class='item'><?=$run->energy?></span>
                                         </div>
 <?php
                                     }
                                     if ($run->mana > 0){
 ?>
                                         <div class='item'>
-                                            <img title='Mana' src='<?=$path["img"]["layout"]?>currency/mana.png'/>
-                                            <span><?=$run->mana?></span>
+                                            <img class='item' title='Mana' src='<?=$path["img"]["layout"]?>currency/mana.png'/>
+                                            <span class='item'><?=$run->mana?></span>
                                         </div>
 <?php
                                     }
                                     if ($run->crystal > 0){
 ?>
                                         <div class='item'>
-                                            <img title='Crystal' src='<?=$path["img"]["layout"]?>currency/crystal.png'/>
-                                            <span><?=$run->crystal?></span>
+                                            <img class='item' title='Crystal' src='<?=$path["img"]["layout"]?>currency/crystal.png'/>
+                                            <span class='item'><?=$run->crystal?></span>
                                         </div>
 <?php
                                     }
                                     foreach ($run->unit as $unit){
 ?>
                                         <div class='item'>
-                                            <img title='<?$unit->title?>' src='<?=$unit->get_image()?>'/>
+                                            <img class='item' title='<?$unit->title?>' src='<?=$unit->get_image()?>'/>
                                         </div>
 <?php
                                     }
                                     foreach ($run->item as $item){
 ?>
                                         <div class='item'>
-                                            <img title='<?$item->name?>' src='<?=$item->get_image()?>'/>
+                                            <img class='item' title='<?$item->name?>' src='<?=$item->get_image()?>'/>
                                         </div>
 <?php
                                     }
                                     foreach ($run->sd as $sd){
 ?>
                                         <div class='item'>
-                                            <img title='<?$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
-                                            <img title=' ' src='<?=$path["img"]["layout"]?>misc/mask-sd.png'/>
+                                            <img class='item' title='<?$sd->unit->title?>' src='<?=$sd->unit->get_image()?>'/>
+                                            <img class='item' title=' ' src='<?=$path["img"]["layout"]?>misc/mask-sd.png'/>
                                             <span><?=$sq->quantity?></span>
                                         </div>
 <?php
@@ -202,8 +202,8 @@
                                     foreach ($run->unit_piece as $piece){
 ?>
                                         <div class='item'>
-                                            <img title='<?$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
-                                            <img title=' ' src='<?=$path["img"]["layout"]?>misc/mask-piece.png'/>
+                                            <img class='item' title='<?$piece->unit->title?>' src='<?=$piece->unit->get_image()?>'/>
+                                            <img class='item' title=' ' src='<?=$path["img"]["layout"]?>misc/mask-piece.png'/>
                                             <span><?=$piece->quantity?></span>
                                         </div>
 <?php
@@ -211,7 +211,7 @@
                                     if ($run->shapeshifting > 0){
 ?>
                                         <div class='item'>
-                                            <img title='Shapeshifting Stones' src='<?=$path["img"]["layout"]?>currency/costumestone.png'/>
+                                            <img class='item' title='Shapeshifting Stones' src='<?=$path["img"]["layout"]?>currency/costumestone.png'/>
                                             <span><?=$run->shapeshifting?></span>
                                         </div>
 <?php
@@ -219,8 +219,8 @@
                                     foreach ($run->rune as $rune){
 ?>
                                         <div class='item item_rune'>
-                                            <img title='Rune' src='src='<?=$path["img"]["layout"]?>rune/base.png'/>
-                                            <?=htm_rune_table($rune)?>
+                                            <img class='item' title='Rune' src='<?=$path["img"]["layout"]?>rune/base.png'/>
+                                            <?=html_rune_table($rune)?>
                                         </div>
 <?php
                                     }

+ 21 - 15
public/css/runs.css

@@ -4,8 +4,8 @@ table#runs{
     width: 100%;
 }
 
-table#runs td{
-    border-top: 0.1em solid #999999;
+table#runs td.area, td.date, td.team, td.time, td.reward{
+    border-top: 0.1em solid #99999977;
 }
 
 table#runs td.area div.area{
@@ -16,6 +16,8 @@ table#runs td.area div.area{
 
 table#runs td.area div.area img.area{
     position: absolute;
+    top: 0;
+    left: 0;
     width: 2em;
     height: 2em;
     border: 0.2em solid #555555;
@@ -26,7 +28,7 @@ table#runs td.area div.area img.area{
 table#runs td.area div.area span.stage{
     position: absolute;
     top: 1.3em;
-    left: 1em;
+    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;
@@ -34,12 +36,15 @@ table#runs td.area div.area span.stage{
 
 table#runs td.area div.area span.difficulty{
     position: absolute;
-    top: 0.3em;
-    left: 0.3em;
+    top: 0em;
+    left: 0;
+    width: 1.8em;
+    text-align: right;
 }
 table#runs td.area div.area span.difficulty img.difficulty{
-    height: 0.7em;
-    width: 0.7em;
+    height: 0.6em;
+    width: 0.6em;
+    margin: 0 -0.3em;
     filter: sepia(100%) saturate(500%) hue-rotate(10deg) saturate(200%) drop-shadow(0 0 0.1em #000) drop-shadow(0 0 0.1em #000) drop-shadow(0 0 0.1em #000);
 }
 
@@ -65,6 +70,7 @@ table#runs td.time span.ms{
 }
 
 table#runs td.reward div.item{
+    display: inline-block;
     width: 1.6em;
     height: 1.6em;
     position: relative;
@@ -73,17 +79,17 @@ table#runs td.reward div.item{
     background-color: #777777;
 }
 
-table#runs td.reward div.item img{
+table#runs td.reward div.item img.item{
     width: 1.6em;
     height: 1.6em;
 }
 
-table#runs td.reward div.item span{
+table#runs td.reward div.item span.item{
     position: absolute;
-    left: 0.6em;
-    top: 1.2em;
-    font-size: 75%;
-    width: 1.4em;
+    left: 0;
+    top: 1.6em;
+    font-size: 60%;
+    width: 2.6em;
     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;
 }
@@ -91,8 +97,8 @@ table#runs td.reward div.item span{
 table#runs td.reward div.item_rune table.rune{
     display: none;
     position: absolute;
-    left: 1.8em;
-    top: 0;
+    right: 1.8em;
+    bottom: 0;
     font-size: 75%;
 }
 

+ 52 - 66
swex-plugin/swdb.js

@@ -40,10 +40,17 @@ module.exports = {
                     this.temp[wizardID] = {};
                 }
                 if (command === 'BattleScenarioStart') {
-                    proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV RUN START: ${resp}` })
                     //for (var key in req) {
-                    //    proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV REQ: ${key}: ${req[key]}` })
+                    //    this.log('DEBUG', `IVV SCE START: ${key}: ${req[key]}`);
                     //}
+                    if (req["helper_list"] != null || req["mentor_helper_list"] != null || req["npc_friend_helper_list"] != null ){
+                        //this.log('DEBUG', `IVV MENTOR 1`);
+                        this.temp[wizardID].helper = 1;
+                    }
+                    else{
+                        //this.log('DEBUG', `IVV MENTOR 0`);
+                        this.temp[wizardID].helper = 0;
+                    }
                     this.temp[wizardID].area = req.region_id;
                     this.temp[wizardID].stage = req.stage_no;
                     this.temp[wizardID].difficulty = req.difficulty;
@@ -199,6 +206,9 @@ module.exports = {
         log = true;
 
         if (command === 'BattleDungeonResult') {
+            for (var key in req) {
+                this.log("DEBUG", `IVV DUNGEON REQ: ${key}: ${req[key]}`);
+            }
             if (req.dungeon_id > 10000){
                 // Hall of Heroes or unknown
                 log = false;
@@ -206,12 +216,18 @@ module.exports = {
             run.area = req.dungeon_id;
             run.stage = req.stage_id;
             run.difficulty = 0
+            // TODO: Read request
+            run.helper = 0;
         }
 
         if (command === 'BattleScenarioResult') {
-            for (var key in this.temp[wizardID]) {
-                this.log("DEBUG", `IVV TEMP: ${key}: ${this.temp[wizardID][key]}`);
-            }
+            //for (var key in this.temp[wizardID]) {
+            //    this.log("DEBUG", `IVV TEMP: ${key}: ${this.temp[wizardID][key]}`);
+            //}
+            //for (var key in req) {
+            //    this.log("DEBUG", `IVV REQ: ${key}: ${req[key]}`);
+            //}
+            run.helper = this.temp[wizardID].helper;
             run.area = this.temp[wizardID].area;
             run.stage = this.temp[wizardID].stage;
             run.difficulty = this.temp[wizardID].difficulty;
@@ -224,6 +240,7 @@ module.exports = {
             run.area = req.dungeon_id;
             run.stage = req.stage_id;
             run.difficulty = 0
+            run.helper = 0;
         }
         run.uid = wizardID;
         run.win = resp.win_lose; // 1/0 2 is lost in scenario
@@ -238,7 +255,7 @@ module.exports = {
         run.crystal = reward.crystal ? reward.crystal : 0;
         
         // TODO: GET
-        run.helper = 0;
+        //run.helper = 0;
 
         run.rune = {};
         run.unit = 0;
@@ -254,9 +271,9 @@ module.exports = {
 
             if (reward.crate.rune) {
                 const rune = reward.crate.rune;
-                //for (var key in rune) {
-                //    this.proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV RUNE: ${key}: ${rune[key]}` })
-                //}
+                for (var key in rune) {
+                    this.proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `IVV RUNE: ${key}: ${rune[key]}` })
+                }
                 run.rune.id = rune.rune_id;
                 run.rune.grade = rune.class;
                 run.rune.value = rune.sell_value;
@@ -270,6 +287,14 @@ module.exports = {
                     run.rune.innate = rune.prefix_eff[0];
                     run.rune.innate_value = rune.prefix_eff[1];
                 }
+                run.rune['substat_1'] = 0;
+                run.rune['substat_1_value'] = 0;
+                run.rune['substat_2'] = 0;
+                run.rune['substat_2_value'] = 0;
+                run.rune['substat_3'] = 0;
+                run.rune['substat_3_value'] = 0;
+                run.rune['substat_4'] = 0;
+                run.rune['substat_4_value'] = 0;
                 rune.sec_eff.forEach((substat, i) => {
                     run.rune[`substat_${i + 1}`] = substat[0];
                     run.rune[`substat_${i + 1}_value`] = substat[1];
@@ -303,13 +328,16 @@ module.exports = {
         }
 
         json_rune = '[';
-        if (run.rune.length > 0){
+        if (run.rune.id != undefined){
+            json_rune += '{';
             json_rune += `"id": "${run.rune.id}", `;
-            json_rune += `"grade": "${run.rune.grade}", `;
-            json_rune += `"set": "${run.rune.set}", `;
+            json_rune += `"stars": "${run.rune.grade}", `;
+            json_rune += `"type": "${run.rune.set}", `;
             json_rune += `"slot": "${run.rune.slot}", `;
             json_rune += `"efficiency": "${run.rune.efficiency}", `;
             json_rune += `"quality": "${run.rune.quality}", `;
+            // TODO: Get
+            json_rune += `"ancient": 0, `;
             json_rune += `"value": "${run.rune.value}", `;
             json_rune += `"main_stat": "${run.rune.main}", `;
             json_rune += `"main_stat_value": "${run.rune.main_value}", `;
@@ -320,23 +348,28 @@ module.exports = {
             json_rune += `"substat_2": "${run.rune.substat_2}", `;
             json_rune += `"substat_2_value": "${run.rune.substat_2_value}", `;
             json_rune += `"substat_3": "${run.rune.substat_3}", `;
-            json_rune += `"substat_4_value": "${run.rune.substat_3_value}", `;
+            json_rune += `"substat_3_value": "${run.rune.substat_3_value}", `;
             json_rune += `"substat_4": "${run.rune.substat_4}", `;
             json_rune += `"substat_4_value": "${run.rune.substat_4_value}"`;
+            json_rune += '}';
         }
         json_rune = json_rune + "]";
 
         json_item = '[';
         if (run.item.length > 0){
+            json_item += '{';
             json_item += `"id": "${run.item.id}", `;
             json_item += `"quantity": "${run.item.quantity}"`;
+            json_item += '}';
         }
         json_item = json_item + "]";
 
         json_unit_pieces = '[';
         if (run.unit_pieces.length > 0){
+            json_unit_pieces += '{';
             json_unit_pieces += `"id": "${run.unit_pieces.id}", `;
-            json_unit_pieces += `"quantity": "${run.unit_pieces.quantity}" `;
+            json_unit_pieces += `"quantity": "${run.unit_pieces.quantity}"`;
+            json_unit_pieces += '}';
         }
         json_unit_pieces = json_unit_pieces + "]";
 
@@ -365,8 +398,8 @@ module.exports = {
         json += `"unit": ${run.unit}, `;
         json += `"unit_pieces": ${json_unit_pieces}, `;
         json += `"shapeshifting": ${run.shapeshifting}, `;
-        json += `"party": ${json_party}`, ;
-        json += `"helper": "${run.helper}", `;
+        json += `"party": ${json_party}, `;
+        json += `"helper": "${run.helper}"`;
         json += `}`;
         this.log('DEBUG', `json: ${json}`)
         //const filename = sanitize(`${wizardName}-${wizardID}-runs.csv`);
@@ -382,55 +415,6 @@ module.exports = {
             value: json
         }
 
-        // npm install -S request eyespect
-        /*var url = this.target_host + ':' + this.target_port + '/' + this.target_url;
-        var options = {
-            method: 'post',
-            body: postData,
-            json: false, //json: true,
-            url: url
-        }
-        request(options, function (err, res, body) {
-            if (err) {
-                this.log('ERROR', `REQUEST ERROR ${err}, `)
-                //return
-            }
-            //var headers = res.headers
-            //var statusCode = res.statusCode
-            //inspect(headers, 'headers')
-            //inspect(statusCode, 'statusCode')
-            //inspect(body, 'body')
-        })*/
-        
-        /*const req_options = setRequestAuth(
-        {
-            json: true,
-            body: { data: { request: req, response: resp, __version: acceptedCommands.__version } }
-        },
-            wizard_id
-        );*/
-
-        // Send it
-        /*var url = this.target_host + ':' + this.target_port + '/' + this.target_url;
-        request.post(url, postData, (error, response, body) => {
-            if (error) {
-                this.log('error',`Error: ${error.message}`);
-                //return;
-            }
-
-            // Log message to proxy window
-            if (response.statusCode === 200) {
-                this.log('success',`${command} logged successfully`);
-            }
-            else {
-                if (response.statusCode == 401) {
-                    this.log('error',`SWARFARM Authentication failure: ${body.detail}`);
-                } else {
-                    this.log('error',`Error ${response.statusCode}: ${body.detail}`);
-                }
-            }
-        });*/
-        
         var querystring = require('querystring');
         var http = require('http');
         var fs = require('fs');
@@ -451,12 +435,14 @@ module.exports = {
         };
 
         // Set up the request
+        var resp = ""
         var post_req = http.request(post_options, function(res) {
             res.setEncoding('utf8');
             res.on('data', function (chunk) {
-                this.log("DEBUG", 'Response: ' + chunk);
+                resp = chunk;
             });
         });
+        
 
         // post the data
         post_req.write(post_data);