Пример #1
0
 public function canMove(Thing $destination)
 {
     if ($destination instanceof Terrain) {
         return $destination->getMovementCost() <= $this->getMovementLeft();
     }
     // If not moving to a terrain, allow movement
     return true;
 }
Пример #2
0
 /**
  * Test parentship from a parent viewpoint
  * AddChild and RemoveChild updates both sides of the relation.
  */
 public function testAddChildRemoveChild()
 {
     $child = new Thing();
     $parent = new Thing();
     $parent->addChild($child);
     $this->assertSame($parent, $child->getParent());
     $this->assertContains($child, $parent->getChildren());
     $parent->removeChild($child);
     $this->assertNull($child->getParent());
     $this->assertNotContains($child, $parent->getChildren());
 }
Пример #3
0
 /**
  * @param Action $action
  * @return $this|void
  * @throws \Exception
  */
 public function registerReference(Thing $thing)
 {
     $thing->setReference($thing->getName() . '_' . ++$this->referenceCounter);
     array_push($this->referenceMap, $thing->getReference());
 }