public function canMove(Thing $destination) { if ($destination instanceof Terrain) { return $destination->getMovementCost() <= $this->getMovementLeft(); } // If not moving to a terrain, allow movement return true; }
/** * 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()); }
/** * @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()); }