Steemnova - Recyclers and battle hall fixes

in #utopian-io3 years ago (edited)

Bug Fixes

Recyclers from galaxy view

Some time ago I found issue that if you're sending recyclers to debris from galaxy the bonus is not working.

Here is example of the 36k Metal and 36k Crystal on the debris. In total it is 72k of the resources.

Cargo capacity 20.000

So 4 recyclers should be sent. But there also exists special officer
Zrzut ekranu z 2018-03-21 21-15-04.png

So the cargo capacity is 40.000 and only 2 recyclers should be sent.

If I was sending recyclers from fleet view everything worked correctly.

But here is what happens:
Peek 2018-03-21 21-42.gif

After fix:
Peek 2018-03-21 21-39.gif

@@ -97,8 +97,9 @@ class ShowFleetAjaxPage extends AbstractGamePage
                                foreach($recElementIDs as $elementID)
-                                       $shipsNeed              = min(ceil($totalDebris / $pricelist[$elementID]['capacity']), $PLANET[$resource[$elementID]]);
-                                       $totalDebris    -= ($shipsNeed * $pricelist[$elementID]['capacity']);
+                                       $a = $pricelist[$elementID]['capacity'] * (1 + $USER['factor']['ShipStorage']);
+                                       $shipsNeed              = min(ceil($totalDebris / $a), $PLANET[$resource[$elementID]]);
+                                       $totalDebris    -= ($shipsNeed * $a);

I've found parameter which is used for the fleetview and I've used it.
$USER['factor']['ShipStorage'] - bonus value in % / 100

Battle hall sorting

This bug is different. It is possible to sort table in the battle hall (with the best battles) by date. It means that is possible to get the newest battles and by using the time/date and the location of the planets you can do attack on the returning fleet. It should be not possible because Phalax Sensor (which is needed for scanning) costs a lot and needs the moon.

Zrzut ekranu z 2018-03-21 21-29-49.png

+++ b/includes/pages/game/ShowBattleHallPage.class.php
@@ -27,21 +27,6 @@ class ShowBattleHallPage extends AbstractGamePage
        function show()
                global $USER, $LNG;
-               $order  = HTTP::_GP('order', 'units');
-               $sort   = HTTP::_GP('sort', 'desc');
-               $sort   = strtoupper($sort) === "DESC" ? "DESC" : "ASC";
-               switch($order)
-               {
-                       case 'date':
-                               $key = '%%TOPKB%%.time '.$sort;
-                               break;
-                       case 'units':
-                       default:
-                               $key = '%%TOPKB%%.units '.$sort;
-                               break;
-               }
                $db = Database::get();
                $sql = "SELECT *, (
@@ -57,7 +42,7 @@ class ShowBattleHallPage extends AbstractGamePage
                        FROM %%TOPKB_USERS%% INNER JOIN %%USERS%% ON uid = id
                        WHERE %%TOPKB_USERS%%.rid = %%TOPKB%%.`rid` AND `role` = 2
                ) as defender
-               FROM %%TOPKB%% WHERE universe = :universe ORDER BY ".$key." LIMIT 100;";
+               FROM %%TOPKB%% WHERE universe = :universe ORDER BY %%TOPKB%%.units DESC LIMIT 100;";

It was enough to change the query and remove the links for sorting.

+++ b/styles/templates/game/page.battleHall.default.tpl
@@ -11,8 +11,8 @@
-    <td><a href="game.php?page=battleHall&order=date&sort={if $sort == "ASC"}DESC{else}ASC{/if}"{if $order == "date"} style="font-weight:bold;"{/if}>{$LNG.tkb_datum}</a></td>
-       <td><a href="game.php?page=battleHall&order=units&sort={if $sort == "ASC"}DESC{else}ASC{/if}"{if $order == "units"} style="font-weight:bold;"{/if}>{$LNG.tkb_units}</a></td>
+    <td>{$LNG.tkb_datum}</td>
+       <td>{$LNG.tkb_units}</td>

Posted on - Rewarding Open Source Contributors


Thank you for the contribution. It has been approved.

You can contact us on Discord.

Thank you!

Hey @vladimir-simovic, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

ty for effort to improve.

Some new features will be soon :-)

Hey @dotevo I am @utopian-io. I have just upvoted you!


  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!


Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord