Advertisement
iEmanuele

IT Punisher

Jun 15th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class Punisher{
  5.  
  6.     // String
  7.     public $name = null;
  8.  
  9.     //Int
  10.     public $health = null;
  11.  
  12.     //Bool
  13.     public $god_mode = false;
  14.  
  15.     //Int
  16.     public $god_mode_timeout = 0;
  17.  
  18.     //Int
  19.     public $god_mode_start = 0;
  20.  
  21.     // Array
  22.     public $weapons = array();
  23.  
  24.     // Int
  25.     public $tangos_down = 0;
  26.  
  27.     // Int
  28.     private $tangos_down_bonus = 0;
  29.  
  30.     public function __construct( $name, $weapons ){
  31.         $this->name = $name;
  32.         $this->weapons = $weapons;
  33.         if( is_null( $this->health ) ){
  34.             $this->health = 100;
  35.         }
  36.     }
  37.  
  38.     public function strike( $target ){
  39.         $tango_down = unset( $target ) ? true : false;
  40.         self::add_tango_down( $tango_down );   
  41.     }
  42.  
  43.     public function get_tangos_down( $bonus = false ){
  44.         return $bonus ? $this->tangos_down_bonus : $this->tangos_down;
  45.     }
  46.  
  47.     public function die(){
  48.         unset $this;
  49.         echo 'Game Over!';
  50.     }
  51.  
  52.     private function damage( $hit ){
  53.         if( $this->god_mode ){
  54.             $hit = 0;
  55.         }
  56.         $this->health = 0 <= $this->health - $hit ? $this->die() : $this->health - $hit;
  57.     }
  58.  
  59.     private function bullet_proof( $start, $timeout ){
  60.         if( ( time() - $start ) < $timeout ){
  61.             $this->god_mode = true;
  62.         }else{
  63.             $this->god_mode = false;
  64.         }
  65.     }
  66.  
  67.     private function check_tangos_down(){
  68.         if( count( $tangos_down_bonus ) > 50 ){
  69.             $this->god_mode_start = time();
  70.             $this->god_mode_timeout = 60;
  71.             $this->tangos_down_bonus = 0;
  72.             self::bullet_proof( $this->god_mode_start, $this->god_mode_timeout );
  73.         }
  74.     }
  75.  
  76.     private function add_tango_down( $tango ){
  77.         if( $tango ){
  78.             $this->tangos_down = $this->tangos_down_bonus = $this->tangos_down + 1;
  79.             self::check_tangos_down();
  80.         }
  81.         return $tango;
  82.     }
  83.  
  84.  
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement