public function testDefaultGridActions() { $grid = new Grid(2, 2); $actions = $grid->getActions(); $this->assertEquals(4, count($actions)); $gameActionGoNorthFound = false; $gameActionGoEastFound = false; $gameActionGoSouthFound = false; $gameActionGoWestFound = false; foreach ($actions as $action) { if ($action instanceof Go\North) { $gameActionGoNorthFound = true; } if ($action instanceof Go\East) { $gameActionGoEastFound = true; } if ($action instanceof Go\South) { $gameActionGoSouthFound = true; } if ($action instanceof Go\West) { $gameActionGoWestFound = true; } } $this->assertTrue($gameActionGoNorthFound); $this->assertTrue($gameActionGoEastFound); $this->assertTrue($gameActionGoSouthFound); $this->assertTrue($gameActionGoWestFound); }
/** * Constructor * Will setup the entire parser and run it automatically * * @param Game\Request $request * @param Game\Response $response * @param Game\Grid $grid * @param Game\Inventory $personalInventory * @return void */ public function __construct(Request $request, Response $response, Grid $grid, Inventory $personalInventory) { $this->response = $response; $this->input = trim($request->getCmd()); $this->parsedInput = $this->input; $this->personalInventory = $personalInventory; $this->grid = $grid; $this->tile = $grid->getTileFromPosition(); }