Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 4th, 2012  |  syntax: None  |  size: 7.50 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. // (c) f33lix 12. Nov 2009
  3.  
  4. class battle_enginge {
  5.        
  6.         // Angreifer
  7.         protected $atk_name;
  8.         protected $atk_hp;
  9.         protected $atk_recoverrate;
  10.         protected $atk_str;
  11.         protected $atk_critrate;
  12.         protected $atk_crit = false;
  13.         protected $atk_dmg;
  14.         protected $atk_waffe;
  15.         protected $atk_add_dmg_waffe;
  16.        
  17.         // Verteidiger
  18.         protected $def_name;
  19.         protected $def_hp;
  20.         protected $def_recoverrate;
  21.         protected $def_str;
  22.         protected $def_critrate;
  23.         protected $def_crit = false;
  24.         protected $def_dmg;
  25.         protected $def_waffe;
  26.         protected $def_add_dmg_waffe;
  27.        
  28.         // Neutral
  29.         protected $mindmgmultiplikator = 19.9;
  30.         protected $maxdmgmultiplikator = 25.9;
  31.         protected $runden = 10; // Maximale Anzahl an Kampfrunden
  32.        
  33.        
  34.         public function calc_dmg_attacker($a_str, $a_critrate, $a_waffe) {     
  35.                 $criticalhit = false;
  36.                        
  37.                 $this->atk_str = $a_str;
  38.                 $this->atk_critrate = $a_critrate;
  39.                 $calc_critrate = rand($this->atk_critrate, 10);
  40.                 if ($calc_critrate == 10) {
  41.                         $criticalhit = true;
  42.                         $this->atk_crit = true;
  43.                 } else {
  44.                         $this->atk_crit = false;
  45.                 }
  46.                 $add = rand($this->mindmgmultiplikator, $this->maxdmgmultiplikator);
  47.                 $this->atk_dmg = $this->atk_str * $add;
  48.                 ($criticalhit == true) ? $add = 2 : $add = 1;
  49.                 $this->atk_dmg = $this->atk_dmg * $add + $a_waffe;
  50.         }
  51.        
  52.         public function calc_dmg_defender($d_str, $d_critrate, $d_waffe) {     
  53.                 $criticalhit = false;
  54.                
  55.                 $this->def_str = $d_str;
  56.                 $this->def_critrate = $d_critrate;
  57.                 $calc_critrate = rand($this->def_critrate, 10);
  58.                 if ($calc_critrate == 10) {
  59.                         $criticalhit = true;
  60.                         $this->def_crit = true;
  61.                 } else {
  62.                         $this->def_crit = false;
  63.                 }
  64.                 $add = rand($this->mindmgmultiplikator, $this->maxdmgmultiplikator);
  65.                 $this->def_dmg = $this->def_str * $add;
  66.                 ($criticalhit == true) ? $add = 2 : $add = 1;
  67.                 $this->def_dmg = $this->def_dmg * $add  + $b_waffe;
  68.         }
  69.        
  70.         public function force($a_name, $a_hp, $a_str, $a_critrate, $a_regrate, $a_waffe, $d_name, $d_hp, $d_str, $d_critrate, $d_regrate, $d_waffe) {
  71.                
  72.                
  73.                
  74.                 $atkmaxhp = $a_hp * 10;
  75.                 $defmaxhp = $d_hp * 10;
  76.                
  77.                 $this->atk_hp = $a_hp;
  78.                 $this->atk_recoverrate = $a_regrate;
  79.                 $this->atk_waffe = $a_waffe;
  80.                
  81.                 $this->def_hp = $d_hp;
  82.                 $this->def_recoverrate = $d_regrate;
  83.                 $this->def_waffe = $d_waffe;
  84.                
  85.                 switch ($a_waffe) {
  86.                         case 0: $this->atk_waffe = "Keine";$this->atk_add_dmg_waffe = 0; break;
  87.                         case 1: $this->atk_waffe = "Messer";$this->atk_add_dmg_waffe = 2; break;
  88.                         case 2: $this->atk_waffe = "Dolch";$this->atk_add_dmg_waffe = 4; break;
  89.                         case 666: $this->atk_waffe = "Awesome Stick";$this->atk_add_dmg_waffe = 312341234155; break;
  90.                 }
  91.                 switch ($b_waffe) {
  92.                         case 0: $this->def_waffe = "Keine";$this->def_add_dmg_waffe = 0; break;
  93.                         case 1: $this->def_waffe = "Messer";$this->def_add_dmg_waffe = 2; break;
  94.                         case 2: $this->def_waffe = "Dolch";$this->def_add_dmg_waffe = 4; break;
  95.                 }
  96.                        
  97.                 echo "<span style=\"margin-left:50px;\">\nStarte Kampf zwischen <b style=\"color:red;\">".$a_name."</b> (Angreifer) und <b style=\"color:green;\">".$d_name."</b> (Verteidiger)\n</span>\n<br>\n<br>\n";
  98.                 $aprozcrit = $a_critrate * 10;
  99.                 $dprozcrit = $d_critrate * 10;
  100.                 echo "<b style=\"color:red;\">".$a_name."</b>: Stärke: <b>".$a_str."</b> +(".$this->atk_add_dmg_waffe.") - Kritische Trefferrate: <b>".$aprozcrit."%</b> - Regnerationsrate: <b>".$a_regrate."%</b> - Waffe: <b>".$this->atk_waffe."</b><br>\n";
  101.                 echo "<b style=\"color:green;\">".$d_name."</b>: Stärke: <b>".$d_str."</b> +(".$this->def_add_dmg_waffe.") - Kritische Trefferrate: <b>".$dprozcrit."%</b> - Regnerationsrate: <b>".$d_regrate."%</b> - Waffe: <b>".$this->def_waffe."<br><br>\n";
  102.                 for ($i = 0; $i < $this->runden; $i++) {
  103.                         if ($this->atk_hp > 0 && $this->def_hp > 0) {
  104.                         $runde = $i + 1;
  105.                                 echo "<u>Kampfwelle ".$runde."</u>:\n<br><br>\n";
  106.                                 echo "<span style=\"margin-left:50px;\">\n";
  107.                                 $this->calc_dmg_attacker($a_str, $a_critrate, $this->atk_add_dmg_waffe);
  108.                                 if ($this->def_crit == true) {
  109.                                         $iscrit = " - <b style=\"font-weight:normal;color:blue\">Kritischer Treffer</b>\n";
  110.                                 } else {
  111.                                         $iscrit = "";
  112.                                 }
  113.                                 echo "<b style=\"color:red;\">".$a_name."</b> fügt <b style=\"color:green;\">".$d_name."</b> ".$this->atk_dmg." Schaden zu. ".$iscrit."<br>\n";
  114.                                 echo "</span>\n";
  115.                                 $this->def_hp = $this->def_hp - $this->atk_dmg;
  116.                                 if ($this->def_hp > 0) {
  117.                                         $this->calc_dmg_defender($d_str, $d_critrate,  $this->def_add_dmg_waffe);
  118.                                         if ($this->def_crit == true) {
  119.                                                 $iscrit = " - <b style=\"font-weight:normal;color:blue\">Kritischer Treffer</b>\n";
  120.                                         } else {
  121.                                                 $iscrit = "";
  122.                                         }
  123.                                         echo "<span style=\"margin-left:50px;\">\n";
  124.                                         echo "<b style=\"color:green;\">".$d_name."</b> fügt <b style=\"color:red;\">".$a_name."</b> ".$this->def_dmg." Schaden zu. ".$iscrit."<br>\n";
  125.                                         echo "</span>\n";
  126.                                         $this->atk_hp = $this->atk_hp - $this->def_dmg;
  127.                                 } else {
  128.                                         echo "<br>\n<span style=\"margin-left:100px;border:1px solid #9f9f9f;padding:2px;\">\nDer Angreifer <b style=\"color:red;\">".$a_name."</b> hat die Schlacht gewonnen!\n</span>\n<br>\n";
  129.                                 }
  130.                                 if ($this->atk_hp <= 0) {
  131.                                         echo "<br><span style=\"margin-left:100px;border:1px solid #9f9f9f;padding:2px;\">\nDer Verteidiger <b style=\"color:green;\">".$d_name."</b> hat die Schlacht gewonnen!\n</span>\n<br>\n";
  132.                                 }
  133.                                 if ($this->atk_hp > 0 && $this->def_hp > 0) {
  134.                                        
  135.                                         $newhpdef = explode(".", $this->def_hp);
  136.                                         $newhpatk = explode(".", $this->atk_hp);
  137.                                        
  138.                                         echo "<br><span style=\"margin-left:100px;\">";
  139.                                         echo "<b style=\"color:green;\">".$d_name."</b> besitzt noch ".$newhpdef[0]." HP";
  140.                                         echo "</span>";
  141.                                         echo "<br><span style=\"margin-left:100px;\">";
  142.                                         echo "<b style=\"color:red;\">".$a_name."</b> besitzt noch ".$newhpatk[0]." HP<br>";
  143.                                         echo "</span>";
  144.                                        
  145.                                         // Regeneriere HP
  146.                                         if ($this->def_hp <= $defmaxhp) {
  147.                                                 $this->def_hp = $this->def_hp / 100 * (100 + $this->def_recoverrate);
  148.                                                 $newhpdef = explode(".", $this->def_hp);
  149.                                                 echo "<br><span style=\"margin-left:100px;\">";
  150.                                                 echo "<i style=\"color:#6f6f6f;\"><b style=\"color:#7AB274;\">".$d_name."</b> Regeneriert ".$this->def_recoverrate."% HP und besitzt nun <b style=\"color:#7f7f7f;\">".$newhpdef[0]."</b> HP</i>";
  151.                                                 echo "</span>";
  152.                                         } else {
  153.                                                 echo "<br><span style=\"margin-left:100px;\"><b style=\"color:#7AB274;\">".$d_name."</b> Können nicht mehr HP regeneriert werden</span>";
  154.                                         }
  155.                                         if ($this->atk_hp <= $atkmaxhp) {
  156.                                                 $this->atk_hp = $this->atk_hp / 100 * (100 + $this->atk_recoverrate);  
  157.                                                 $newhpatk = explode(".", $this->atk_hp);
  158.                                                 echo "<br><span style=\"margin-left:100px;\">";
  159.                                                 echo "<i style=\"color:#6f6f6f;\"><b style=\"color:#FFA7A7;\">".$a_name."</b> Regeneriert ".$this->atk_recoverrate."% HP und besitzt nun <b style=\"color:#7f7f7f;\">".$newhpatk[0]."</b> HP</i>";
  160.                                                 echo "</span>";
  161.                                         } else {
  162.                                                 echo "<br><span style=\"margin-left:100px;\"><b style=\"color:#FFA7A7;\">".$a_name."</b> Können nicht mehr HP regeneriert werden</span>";
  163.                                         }
  164.                                 }
  165.                                 echo "<hr style=\"margin-left:10px;width: 300px;border:none;background-color:black;height:1px;\"><br>";
  166.                         }
  167.                 }
  168.                 if ($this->atk_hp > 0 && $this->def_hp > 0) {
  169.                         echo "<br><span style=\"margin-left:100px;border:1px solid #9f9f9f;padding:2px;\">Der Kampf endete Unentschieden!</span><br>";
  170.                 }
  171.         }
  172.        
  173. }
  174.  
  175. ?>
  176. <html>
  177. <head>
  178. <style>
  179. body {font:11px arial;}
  180. </style>
  181. </head>
  182. <body>
  183. <?php
  184.         $battle = new battle_enginge;
  185.         $battle->force("Felix", 10634563400, 10, 0, 10, 666, "Lunatic", 1000523523452, 10, 0, 10, 0);
  186. ?>
  187. </body>
  188. </html>