/** * Add point to shoot * @param PointInterface $shot * @return self */ public function shoot(PointInterface $shot) { $event = new \Event\Model\Battlefield\ShootEvent('beforeShoot', $this, $shot); $this->dispatch($event); if ($shot instanceof CheatPointInterface) { return $this; } if (!$this->isPointValid($shot)) { throw new Exception\HumanReadableException("Invlid point"); } $this->shots->addPoint($shot); return $this; }
/** * Get all point used by palcer. * * Placer with points [0.0] : [0.2] * have points [0.0], [0.1], [0.2] * @return \Model\Battlefield\Point\PointCollection */ public function getPoints() { $startX = $this->getStartPoint()->getX(); $startY = $this->getStartPoint()->getY(); $endX = $this->getEndPoint()->getX(); $endY = $this->getEndPoint()->getY(); /* * Horizontal placement */ $return = new Point\PointCollection(); if ($startY == $endY) { for ($i = $startX; $i <= $endX; $i++) { $return->addPoint(new Point\Point($i, $startY)); } } else { for ($i = $startY; $i <= $endY; $i++) { $return->addPoint(new Point\Point($startX, $i)); } } return $return; }