public function testFindPlayableFromInitialChar() { $pc = Player::find($this->char_id); $acc = Account::findByChar($pc); $pc2 = Player::findPlayable($acc->id()); $this->assertEquals($pc->id(), $pc2->id()); }
public function __construct() { $this->self = Player::findPlayable($this->getAccountId()); }
/** * Returns a view spec hash for rendering a template * * @param Array $parts Hash of variables to pass to the view * @return Response */ private function render($parts) { $char = Player::findPlayable($this->getAccountId()); if (!$char) { $char = new Player(); } $myBounty = $char->bounty; // Pulling the bounties. $bounties = query_array("SELECT player_id, uname, bounty, class_name AS class, level, clan_id, clan_name\n FROM players JOIN class ON class_id = _class_id LEFT JOIN clan_player ON player_id = _player_id\n LEFT JOIN clan ON clan_id = _clan_id WHERE bounty > 0 AND active = 1 and health > 0 ORDER BY bounty DESC"); $parts['bounties'] = $bounties; $parts['myBounty'] = $myBounty; $parts['char'] = $char; $parts['display_gold'] = number_format($char->gold); $quickstat = $parts['quickstat']; return new StreamedViewResponse('Doshin Office', 'doshin.tpl', $parts, ['quickstat' => $quickstat]); }
/** * Generates the view spec hash for displaying a template * * @param p_parts Array Name/Value pairings to pass to the view * @return Array */ private function render($p_parts) { $player = Player::findPlayable($this->getAccountId()); $p_parts['gold'] = $player ? $player->gold : 0; $p_parts['item_costs'] = $this->itemForSaleCosts(); $p_parts['authenticated'] = SessionFactory::getSession()->get('authenticated'); return new StreamedViewResponse('Shop', 'shop.tpl', $p_parts, ['quickstat' => 'viewinv']); }
public function testShopCannotBuyInvalidItem() { $pc = Player::findPlayable($this->account->id()); $pc->gold = $pc->gold + 9999; $pc->save(); $request = new Request([], ['quantity' => 4, 'item' => 'zigzigX']); RequestWrapper::inject($request); $shop = new ShopController(); $response = $shop->buy(); $this->assertNotEmpty($response); $reflection = new \ReflectionProperty(get_class($response), 'data'); $reflection->setAccessible(true); $response_data = $reflection->getValue($response); $this->assertFalse($response_data['valid']); }