Ejemplo n.º 1
0
 /**
  * @group Helpers
  * @group RoundSimulator
  */
 public function testRoundSimulator()
 {
     $match = \App\Lib\DsManager\Models\Orm\Match::where(['simulated' => false])->whereNotNull('league_round_id')->get()->random(1);
     $this->assertNotEmpty($match);
     $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id);
     $this->assertNotEmpty($result);
     $match = \App\Lib\DsManager\Models\Orm\Match::where(['id' => $match->id, 'simulated' => true])->first();
     $this->assertNotEmpty($match);
     $round = \App\Lib\DsManager\Models\Orm\LeagueRound::find($match->league_round_id);
     $this->assertNotEmpty($round);
     $this->assertTrue($round->simulated);
 }
Ejemplo n.º 2
0
 /**
  * @group Stats
  */
 public function testGetStats()
 {
     $match = \App\Lib\DsManager\Models\Orm\Match::where(['simulated' => false])->whereNotNull('league_round_id')->get()->random(1);
     $this->assertNotEmpty($match);
     $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id);
     $this->assertNotEmpty($result);
     $players = \App\Lib\DsManager\Models\Orm\Player::getBest();
     $this->assertNotEmpty($players);
     $teams = \App\Lib\DsManager\Models\Orm\Team::getBest();
     $this->assertNotEmpty($teams);
 }
Ejemplo n.º 3
0
$api->get('/leagues', function ($request, $response, $args) {
    return Responder::getJsonResponse(League::all(), $response);
});
$api->get('/leagues/{id}', function ($request, $response, $args) {
    return Responder::getJsonResponse(League::with('rounds')->where(['id' => $args['id']])->first(), $response);
});
$api->get('/leagues/{id}/rounds/{roundId}', function ($request, $response, $args) {
    return Responder::getJsonResponse(LeagueRound::complete()->where(['id' => $args['roundId']])->first(), $response);
});
$api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
    return Responder::getJsonResponse(MatchSimulator::simulateRound($args['roundId']), $response);
});
$api->get('/matches', function ($request, $response, $args) {
    return Responder::getJsonResponse(Match::teams()->get(), $response);
});
$api->post('/matches', function ($request, $response, $args) {
    $json = $request->getBody();
    $json = json_decode($json, true);
    return Responder::getJsonResponse(Match::create($json), $response);
});
$api->get('/matches/{id}', function ($request, $response, $args) {
    return Responder::getJsonResponse(Match::complete()->where(['id' => $args['id']])->first(), $response);
});
$api->get('/matches/{id}/result', function ($request, $response, $args) {
    $result = MatchResult::complete()->where(['id' => $args['id']])->first();
    return Responder::getJsonResponse($result, $response);
});
$api->put('/matches/{id}/simulate', function ($request, $response, $args) {
    return Responder::getJsonResponse(MatchSimulator::simulateCompleteResult($args['id']), $response);
});
$api->run();