Exemplo n.º 1
0
 public function perform($direction = 'backward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     $this->unit->position->rotate(array_search($direction, self::$ROTATION_DIRECTIONS));
     $this->unit->say(sprintf(__("pivots %s"), __($direction)));
 }
Exemplo n.º 2
0
 public function verify_direction($direction)
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     if (array_search($direction, \PHPWarrior\Position::$RELATIVE_DIRECTIONS) === false) {
         throw new \Exception("Unknown direction {$direction}. Should be :forward, :backward, :left or :right.");
     }
 }
Exemplo n.º 3
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     $map = [];
     foreach (range(1, 3) as $amount) {
         $map[] = $this->space($direction, $amount);
     }
     return $map;
 }
Exemplo n.º 4
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     if ($this->unit->position) {
         $this->unit->say(sprintf(__("detonates a bomb %s launching a deadly explosion."), $direction));
         $this->bomb($direction, 1, 0, 8);
         foreach ([[1, 1], [1, -1], [2, 0], [0, 0]] as list($x, $y)) {
             $this->bomb($direction, $x, $y, 4);
         }
     }
 }
Exemplo n.º 5
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     $receiver = $this->unit($direction);
     if ($receiver) {
         $this->unit->say(sprintf(__('binds %1$s and restricts %2$s'), __($direction), $receiver));
         $receiver->bind();
     } else {
         $this->unit->say(sprintf(__("binds %s and restricts nothing"), $direction));
     }
 }
Exemplo n.º 6
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     if ($this->unit->position) {
         $s_direction = __(str_replace(':', '', $direction));
         $this->unit->say(sprintf(__("walks %s"), $s_direction));
         if ($this->space($direction)->is_empty()) {
             call_user_func_array([$this->unit->position, 'move'], $this->offset($direction));
         } else {
             $this->unit->say(sprintf(__("bumps into %s"), $this->space($direction)));
         }
     }
 }
Exemplo n.º 7
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     if ($this->space($direction)->is_captive()) {
         $recipient = $this->unit($direction);
         $this->unit->say(sprintf(__('unbinds %1$s and rescues %2$s'), __($direction), $recipient));
         $recipient->unbind();
         if (is_a($recipient, 'PHPWarrior\\Units\\Captive')) {
             $recipient->position = null;
             $this->unit->earn_points(20);
         }
     } else {
         $this->unit->say(sprintf(__("unbinds %s and rescues nothing"), __($direction)));
     }
 }
Exemplo n.º 8
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     $receiver = $this->unit($direction);
     if ($receiver) {
         $this->unit->say(sprintf(__('attacks %1$s and hits %2$s'), __($direction), $receiver));
         if ($direction === 'backward') {
             $power = ceil($this->unit->attack_power() / 2.0);
         } else {
             $power = $this->unit->attack_power();
         }
         $this->damage($receiver, $power);
     } else {
         $this->unit->say(sprintf(__("attacks %s and hits nothing"), __($direction)));
     }
 }
Exemplo n.º 9
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     $receiver = null;
     foreach ($this->multi_unit($direction, range(1, 3)) as $row) {
         if (!is_null($row)) {
             $receiver = $row;
             break;
         }
     }
     if ($receiver) {
         $this->unit->say(sprintf(__('shoots %1$s and hits %2$s'), __($direction), $receiver));
         $this->damage($receiver, $this->unit->shoot_power());
     } else {
         $this->unit->say(__("shoots and hits nothing"));
     }
 }
Exemplo n.º 10
0
 public function perform($direction = 'forward')
 {
     $direction = \PHPWarrior\Position::normalize_direction($direction);
     $this->verify_direction($direction);
     return $this->space($direction);
 }