Exemplo n.º 1
0
 public function testIsFormationCompleted()
 {
     $team = Mockery::mock("Offside\\Repo\\TeamRepository");
     $team->shouldReceive("countPlayerAtPosition")->times(4)->andReturn(1, 4, 3, 3);
     $formationStructure = new \Offside\Formation\Formation433();
     $formation = new \Offside\Formation\Formation($formationStructure, $team);
     $this->assertEquals(true, $formation->isFormationCompleted());
 }
Exemplo n.º 2
0
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        Model::unguard();
        //Create a user
        $user_first = User::create(['name' => 'Burim Shala', 'email' => '*****@*****.**', 'password' => Hash::make('123456')]);
        $user_second = User::create(['name' => 'Arian Selimaj', 'email' => '*****@*****.**', 'password' => Hash::make('123456')]);
        $user_firstid = $user_first->id;
        $user_secondtid = $user_second->id;
        //Create a team, and attach to use
        $team_first = Team::create(['name' => 'Real Madrid', 'user_id' => $user_firstid, 'colors' => ["#e3e3e3", "#121212"]]);
        $team_second = Team::create(['name' => 'Barcelona', 'user_id' => $user_secondtid, 'colors' => ["#e3e3e3", "#121212"]]);
        $team_third = Team::create(['name' => 'Real Madrid Cloned', 'user_id' => $user_firstid, 'colors' => ["#e3e3e3", "#121212"]]);
        $team_fourth = Team::create(['name' => 'Barcelona Cloned', 'user_id' => $user_secondtid, 'colors' => ["#e3e3e3", "#121212"]]);
        //Create some players
        $players = json_decode('[
{
"id": 4,
"name": "Ronaldo",
"price": 3000,
"attack": 92,
"stamina": 85,
"defense": 22,
"goal_conversion": 85,
"assist_conversion": 75,
"creativity": 69,
"position": "attack",
"quality": "legendary",
"created_at": "2015-04-07 18:48:32",
"updated_at": "2015-04-07 18:48:32"
},
{
"id": 5,
"name": "Benzema",
"price": 1500,
"attack": 85,
"stamina": 79,
"defense": 20,
"goal_conversion": 75,
"assist_conversion": 70,
"creativity": 55,
"position": "attack",
"quality": "experienced",
"created_at": "2015-04-07 18:49:04",
"updated_at": "2015-04-07 18:49:04"
},
{
"id": 6,
"name": "Bale",
"price": 1500,
"attack": 88,
"stamina": 79,
"defense": 19,
"goal_conversion": 79,
"assist_conversion": 70,
"creativity": 65,
"position": "attack",
"quality": "experienced",
"created_at": "2015-04-07 18:49:41",
"updated_at": "2015-04-07 18:49:41"
},
{
"id": 7,
"name": "Kroos",
"price": 1000,
"attack": 65,
"stamina": 71,
"defense": 44,
"goal_conversion": 25,
"assist_conversion": 59,
"creativity": 72,
"position": "midfield",
"quality": "experienced",
"created_at": "2015-04-07 18:50:42",
"updated_at": "2015-04-07 18:50:42"
},
{
"id": 8,
"name": "Modric",
"price": 1500,
"attack": 72,
"stamina": 75,
"defense": 39,
"goal_conversion": 45,
"assist_conversion": 82,
"creativity": 83,
"position": "midfield",
"quality": "experienced",
"created_at": "2015-04-07 18:51:30",
"updated_at": "2015-04-07 18:51:30"
},
{
"id": 9,
"name": "Khedira",
"price": 1000,
"attack": 49,
"stamina": 82,
"defense": 62,
"goal_conversion": 22,
"assist_conversion": 49,
"creativity": 22,
"position": "midfield",
"quality": "experienced",
"created_at": "2015-04-07 18:52:15",
"updated_at": "2015-04-07 18:52:15"
},
{
"id": 10,
"name": "Pepe",
"price": 1200,
"attack": 12,
"stamina": 85,
"defense": 85,
"goal_conversion": 10,
"assist_conversion": 10,
"creativity": 10,
"position": "defense",
"quality": "experienced",
"created_at": "2015-04-07 18:53:23",
"updated_at": "2015-04-07 18:53:23"
},
{
"id": 11,
"name": "Ramos",
"price": 1200,
"attack": 39,
"stamina": 85,
"defense": 85,
"goal_conversion": 20,
"assist_conversion": 10,
"creativity": 10,
"position": "defense",
"quality": "experienced",
"created_at": "2015-04-07 18:53:47",
"updated_at": "2015-04-07 18:53:47"
},
{
"id": 12,
"name": "Marcelo",
"price": 800,
"attack": 55,
"stamina": 76,
"defense": 0,
"goal_conversion": 22,
"assist_conversion": 25,
"creativity": 10,
"position": "defense",
"quality": "average",
"created_at": "2015-04-07 18:54:25",
"updated_at": "2015-04-07 18:54:25"
},
{
"id": 13,
"name": "Carvajal",
"price": 800,
"attack": 22,
"stamina": 70,
"defense": 0,
"goal_conversion": 15,
"assist_conversion": 15,
"creativity": 15,
"position": "defense",
"quality": "average",
"created_at": "2015-04-07 18:55:06",
"updated_at": "2015-04-07 18:55:06"
},
{
"id": 14,
"name": "Casillas",
"price": 800,
"attack": 0,
"stamina": 65,
"defense": 84,
"goal_conversion": 0,
"assist_conversion": 0,
"creativity": 0,
"position": "goalkeeper",
"quality": "experienced",
"created_at": "2015-04-07 18:55:50",
"updated_at": "2015-04-07 18:55:50"
},
{
"id": 15,
"name": "Ter Stegen",
"price": 800,
"attack": 0,
"stamina": 72,
"defense": 80,
"goal_conversion": 0,
"assist_conversion": 0,
"creativity": 0,
"position": "goalkeeper",
"quality": "average",
"created_at": "2015-04-07 18:56:22",
"updated_at": "2015-04-07 18:56:22"
},
{
"id": 16,
"name": "Messi",
"price": 3000,
"attack": 93,
"stamina": 79,
"defense": 25,
"goal_conversion": 85,
"assist_conversion": 85,
"creativity": 85,
"position": "attack",
"quality": "legendary",
"created_at": "2015-04-07 18:57:01",
"updated_at": "2015-04-07 18:57:01"
},
{
"id": 17,
"name": "Suarez",
"price": 1500,
"attack": 87,
"stamina": 75,
"defense": 20,
"goal_conversion": 80,
"assist_conversion": 75,
"creativity": 59,
"position": "attack",
"quality": "experienced",
"created_at": "2015-04-07 18:57:39",
"updated_at": "2015-04-07 18:57:39"
},
{
"id": 18,
"name": "Neymar",
"price": 1500,
"attack": 83,
"stamina": 63,
"defense": 19,
"goal_conversion": 78,
"assist_conversion": 83,
"creativity": 80,
"position": "attack",
"quality": "experienced",
"created_at": "2015-04-07 18:58:15",
"updated_at": "2015-04-07 18:58:15"
},
{
"id": 19,
"name": "Iniesta",
"price": 1500,
"attack": 69,
"stamina": 62,
"defense": 35,
"goal_conversion": 69,
"assist_conversion": 73,
"creativity": 82,
"position": "midfield",
"quality": "experienced",
"created_at": "2015-04-07 19:03:04",
"updated_at": "2015-04-07 19:03:04"
},
{
"id": 20,
"name": "Busquets",
"price": 1000,
"attack": 32,
"stamina": 79,
"defense": 66,
"goal_conversion": 10,
"assist_conversion": 25,
"creativity": 22,
"position": "midfield",
"quality": "experienced",
"created_at": "2015-04-07 19:04:14",
"updated_at": "2015-04-07 19:04:14"
},
{
"id": 21,
"name": "Rakitic",
"price": 1000,
"attack": 68,
"stamina": 65,
"defense": 42,
"goal_conversion": 62,
"assist_conversion": 73,
"creativity": 75,
"position": "midfield",
"quality": "average",
"created_at": "2015-04-07 19:05:20",
"updated_at": "2015-04-07 19:05:20"
},
{
"id": 22,
"name": "Pique",
"price": 1000,
"attack": 0,
"stamina": 79,
"defense": 82,
"goal_conversion": 0,
"assist_conversion": 0,
"creativity": 0,
"position": "defense",
"quality": "experienced",
"created_at": "2015-04-07 19:05:50",
"updated_at": "2015-04-07 19:05:50"
},
{
"id": 23,
"name": "Mathieu",
"price": 800,
"attack": 10,
"stamina": 75,
"defense": 75,
"goal_conversion": 10,
"assist_conversion": 0,
"creativity": 0,
"position": "defense",
"quality": "average",
"created_at": "2015-04-07 19:07:06",
"updated_at": "2015-04-07 19:07:06"
},
{
"id": 24,
"name": "Alves",
"price": 800,
"attack": 59,
"stamina": 75,
"defense": 75,
"goal_conversion": 20,
"assist_conversion": 35,
"creativity": 12,
"position": "defense",
"quality": "average",
"created_at": "2015-04-07 19:07:57",
"updated_at": "2015-04-07 19:07:57"
},
{
"id": 25,
"name": "Alba",
"price": 700,
"attack": 29,
"stamina": 72,
"defense": 75,
"goal_conversion": 10,
"assist_conversion": 0,
"creativity": 0,
"position": "defense",
"quality": "average",
"created_at": "2015-04-07 19:08:25",
"updated_at": "2015-04-07 19:08:25"
}
]', true);
        //Insert players to databse
        foreach ($players as $key => $player) {
            $cur_player = Player::create(["name" => $player["name"], "price" => $player["price"], "attack" => $player["attack"], "defense" => $player["defense"], "stamina" => $player["stamina"], "goal_conversion" => $player["goal_conversion"], "assist_conversion" => $player["assist_conversion"], "creativity" => $player["creativity"], "position" => $player["position"], "quality" => $player["quality"]]);
        }
        $players = Player::all();
        foreach ($players as $key => $player) {
            $cur_team = $key <= 10 ? $team_first : $team_second;
            $cur_team->players()->attach($player->id, ['position' => 'none']);
        }
        foreach ($players as $key => $player) {
            $cur_team = $key <= 10 ? $team_third : $team_fourth;
            $cur_team->players()->attach($player->id, ['position' => 'none']);
        }
        $league = League::create(['name' => 'local_league']);
        $league->teams()->attach([$team_first->id, $team_second->id, $team_third->id, $team_fourth->id]);
        //Spread players on positions
        $formation = new \Offside\Formation\Formation(new \Offside\Formation\Formation532(), new \Offside\Repo\TeamRepository($team_first));
        $formation->spreadPlayersOnPositions();
        $formation = new \Offside\Formation\Formation(new \Offside\Formation\Formation433(), new \Offside\Repo\TeamRepository($team_second));
        $formation->spreadPlayersOnPositions();
        $formation = new \Offside\Formation\Formation(new \Offside\Formation\Formation433(), new \Offside\Repo\TeamRepository($team_third));
        $formation->spreadPlayersOnPositions();
        $formation = new \Offside\Formation\Formation(new \Offside\Formation\Formation433(), new \Offside\Repo\TeamRepository($team_fourth));
        $formation->spreadPlayersOnPositions();
        $league = new \Offside\Repo\LeagueRepository($league);
        $matchGenerator = new \Offside\League\InstantMatchGenerator($league);
        $matchGenerator->generateMatches();
        //$matchGenerator = new \Offside\
        //Attach players to the team
        //$team->players()->attach([$player_1->id,$player_2->id]);
        //$this->call('UserTableSeeder');
    }