You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
983 B
50 lines
983 B
<?php
|
|
|
|
namespace Coffee;
|
|
|
|
/**
|
|
* Class Tile
|
|
*
|
|
* @package Coffee
|
|
*/
|
|
class Tile extends Position {
|
|
|
|
/**
|
|
* Representation on the map, that element exists on the given tile
|
|
*/
|
|
const REPRESENTS_ELEMENT = 1;
|
|
/**
|
|
* Representation on the map, that element does not exist on the given tile
|
|
*/
|
|
const REPRESENTS_VOID = 0;
|
|
/**
|
|
* @var bool
|
|
*/
|
|
private $containsElement = false;
|
|
|
|
/**
|
|
* Tile constructor.
|
|
*
|
|
* @param $row
|
|
* @param $column
|
|
* @param $tileRepresentation
|
|
* @throws \Exception
|
|
*/
|
|
public function __construct($row, $column, $tileRepresentation) {
|
|
if ($tileRepresentation != self::REPRESENTS_ELEMENT && $tileRepresentation != self::REPRESENTS_VOID) {
|
|
throw new \Exception('The map contains invalid representations');
|
|
}
|
|
|
|
parent::__construct($row, $column);
|
|
|
|
$this->containsElement = $tileRepresentation;
|
|
}
|
|
|
|
/**
|
|
* @return boolean
|
|
*/
|
|
public function representsElement() {
|
|
return $this->containsElement == self::REPRESENTS_ELEMENT;
|
|
}
|
|
|
|
} |