Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.96 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * This is the script that will ensure that when a player works
  5.  * certain considerations will be taken into account and a final
  6.  * product output determined. The script also subtracts health
  7.  * from the player, gives stock points to the product bank,
  8.  * subtracts taxes and deposits the amount into the country account,
  9.  * pays the worker.
  10.  * ==============================================================
  11.  */
  12.  
  13. if ($page == 'work')
  14. {
  15.                 //Get the stock divitions
  16.                 require_once ('brains/var.stock_divide.php');
  17.  
  18.                 if ($work = $mysqli->query("SELECT * FROM player WHERE id = '$player_id'"))
  19.                 {
  20.                                 while ($result_work = $work->fetch_assoc())
  21.                                 {
  22.                                                 //===================================================================
  23.                                                 //===========================DO==THE==MATH===========================
  24.                                                 //===================================================================
  25.                                                 $health_multi = 3 * ($health / 100);
  26.                                                 $level_multi = $level / 100;
  27.                                                 $skill_multi = $skill * $health_multi / 100;
  28.                                                 if ($skill < "150")
  29.                                                 {
  30.                                                                 $noob_boost = 100 - $skill;
  31.                                                                 $work_multi = (3.5 + ($skill_multi * 0.5)) * $health_multi * (1 + 1 + 1) * 8 + $noob_boost;
  32.                                                 } else
  33.                                                 {
  34.                                                                 $work_multi = (3.5 + ($skill_multi * 1)) * $health_multi * $level_multi * 8;
  35.                                                 }
  36.                                                 $new_health = $health - 2;
  37.                                                 $new_skill = $skill + 2;
  38.                                                 $new_level = $level + 1;
  39.                                                 $new_stock = $current_stock + $work_multi;
  40.                                                 $new_currency = $local_currency + $wage;
  41.                                                 //==================================================================
  42.                                                 //==================================================================
  43.                                                 //==================================================================
  44.  
  45.  
  46.                                                 print "<h3>Welcome to your work</h3>
  47.                                                                        <p>You have just worked for " .
  48.                                                                 $company_name . " and this is how well you did</p>
  49.                                                                        <table width=\"30%\" cellpadding=\"5\" border=\"0\">
  50.                                                                        <tr>
  51.                                                                             <td>Your Work Health</td>
  52.                                                                             <td>" .
  53.                                                                 $result_work['health'] . "</td>
  54.                                                                        </tr>
  55.                                                                        <tr>
  56.                                                                            
  57.                                                                             <td>Your Work result</td>
  58.                                                                             <td>" .
  59.                                                                 round($work_multi, 3) . "</td>
  60.                                                                        </tr>
  61.                                                                        <tr>
  62.                                                                            
  63.                                                                             <td>1 Star food Produced</td>
  64.                                                                             <td>" .
  65.                                                                 round($work_multi / $food[0], 3) . "</td>
  66.                                                                        </tr>
  67.                                                                          <tr>
  68.                                                                            
  69.                                                                             <td>2 Star food Produced</td>
  70.                                                                             <td>" .
  71.                                                                 round($work_multi / $food[1], 3) . "</td>
  72.                                                                        </tr>
  73.                                                                        <tr>
  74.                                                                            
  75.                                                                             <td>3 Star food Produced</td>
  76.                                                                             <td>" .
  77.                                                                 round($work_multi / $food[2], 3) . "</td>
  78.                                                                        </tr>
  79.                                                                        <tr>
  80.                                                                            
  81.                                                                             <td>4 Star food Produced</td>
  82.                                                                             <td>" .
  83.                                                                 round($work_multi / $food[3], 3) . "</td>
  84.                                                                        </tr>
  85.                                                                        <tr>
  86.                                                                            
  87.                                                                             <td>5 Star food Produced</td>
  88.                                                                             <td>" .
  89.                                                                 round($work_multi / $food[4], 3) . "</td>
  90.                                                                        </tr>
  91.                                                                        <tr>
  92.                                                                            
  93.                                                                             <td>It has made you tired. You need food!. You health is now:</td>
  94.                                                                             <td>" .
  95.                                                                 $new_health . "</td>
  96.                                                                        </tr>
  97.                                                                        <tr>
  98.                                                                            
  99.                                                                             <td>You earned:</td>
  100.                                                                             <td>" .
  101.                                                                 round($wage) . "HAR</td>
  102.                                                                        </tr>
  103.                                                                        </table>";
  104.  
  105.  
  106.                                                 //update the database
  107.  
  108.  
  109.                                                 $q_player = "UPDATE player SET health = '$new_health', skill = '$new_skill', level = '$new_level' WHERE id = '$player_id' ";
  110.                                                 $q_stock = "UPDATE stock_bank SET units = '$new_stock' WHERE company = '$employment' ";
  111.                                                 $q_work_log = "INSERT INTO work_log (player, round, day, health, units) VALUES ('$player_id', '$round', '$day', '$health', '$work_multi')";
  112.                                                 $q_wage = "UPDATE bank_citizen SET har='$new_currency'";
  113.                                                 $mysqli->query($q_player);
  114.                                                 $mysqli->query($q_stock);
  115.                                                 $mysqli->query($q_work_log);
  116.                                                 $mysqli->query($q_wage);
  117.  
  118.                                 }
  119.  
  120.                 }
  121.  
  122.  
  123. }
  124.  
  125. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement