Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Punisher{
- // String
- public $name = null;
- //Int
- public $health = null;
- //Bool
- public $god_mode = false;
- //Int
- public $god_mode_timeout = 0;
- //Int
- public $god_mode_start = 0;
- // Array
- public $weapons = array();
- // Int
- public $tangos_down = 0;
- // Int
- private $tangos_down_bonus = 0;
- public function __construct( $name, $weapons ){
- $this->name = $name;
- $this->weapons = $weapons;
- if( is_null( $this->health ) ){
- $this->health = 100;
- }
- }
- public function strike( $target ){
- $tango_down = unset( $target ) ? true : false;
- self::add_tango_down( $tango_down );
- }
- public function get_tangos_down( $bonus = false ){
- return $bonus ? $this->tangos_down_bonus : $this->tangos_down;
- }
- public function die(){
- unset $this;
- echo 'Game Over!';
- }
- private function damage( $hit ){
- if( $this->god_mode ){
- $hit = 0;
- }
- $this->health = 0 <= $this->health - $hit ? $this->die() : $this->health - $hit;
- }
- private function bullet_proof( $start, $timeout ){
- if( ( time() - $start ) < $timeout ){
- $this->god_mode = true;
- }else{
- $this->god_mode = false;
- }
- }
- private function check_tangos_down(){
- if( count( $tangos_down_bonus ) > 50 ){
- $this->god_mode_start = time();
- $this->god_mode_timeout = 60;
- $this->tangos_down_bonus = 0;
- self::bullet_proof( $this->god_mode_start, $this->god_mode_timeout );
- }
- }
- private function add_tango_down( $tango ){
- if( $tango ){
- $this->tangos_down = $this->tangos_down_bonus = $this->tangos_down + 1;
- self::check_tangos_down();
- }
- return $tango;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement