<commit_before><?php

namespace Wecamp\FlyingLiqourice\Domain;

use Rhumsaa\Uuid\Uuid;
use Wecamp\FlyingLiqourice\Domain\Game\Coords;
use Wecamp\FlyingLiqourice\Domain\Game\Grid;
use Wecamp\FlyingLiqourice\Domain\Game\FireResult;
use Wecamp\FlyingLiqourice\Domain\Game\GameIsLockedException;

final class GameTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @test
     */
    public function it_should_return_the_status()
    {
        $game   = Game::create();
        $coords = Coords::fromArray(['x' => 1, 'y' => 1]);

        $fireResult = $game->fire($coords);
        $status     = $game->status();

        $this->assertCount(1, $status);
        $this->assertInstanceOf(FireResult::class, $status[0]);
        $this->assertSame($fireResult, $status[0]);
    }

    /**
     * @test
     */
    public function it_sinks_a_ship()
    {
        $gridData = [
            'fields' => [
                [
                    'coords' => [
                        'x' => 0,
                        'y' => 0
                    ],
                    'ship' => [
                        'startPoint' => [
                            'x' => 0,
                            'y' => 0
                        ],
                        'endPoint' => [
                            'x' => 0,
                            'y' => 1
                        ],
                        'hits' => 0
                    ],
                    'shot' => false
                ],
                [
                    'coords' => [
                        'x' => 0,
                        'y' => 1
                    ],
                    'ship' => [
                        'startPoint' => [
                            'x' => 0,
                            'y' => 0
                        ],
                        'endPoint' => [
                            'x' => 0,
                            'y' => 1
                        ],
                        'hits' => 0
                    ],
                    'shot' => false
                ]
            ],
            'ships' => [
                [
                    'startPoint' => [
                        'x' => 0,
                        'y' => 0
                    ],
                    'endPoint' => [
                        'x' => 0,
                        'y' => 1
                    ],
                    'hits' => 0
                ]
            ]
        ];

        $data = [
            'width' => 10,
            'height' => 10,
            'fields' => $gridData
        ];
        $gameData = ['id' => Uuid::uuid4()->toString(), 'locked' => false, 'grid' => $data];
        $game = Game::fromArray($gameData);
        $result = $game->fire(Coords::create(0, 0));

        $this->assertEquals('HIT', (string)$result);

        $result = $game->fire(Coords::create(0, 1));

        $this->assertEquals('SINK', (string)$result);
    }<commit_msg>Fixed unittests and validate the bugfix<commit_after><?php

namespace Wecamp\FlyingLiqourice\Domain;

use Rhumsaa\Uuid\Uuid;
use Wecamp\FlyingLiqourice\Domain\Game\Coords;
use Wecamp\FlyingLiqourice\Domain\Game\Grid;
use Wecamp\FlyingLiqourice\Domain\Game\FireResult;
use Wecamp\FlyingLiqourice\Domain\Game\GameIsLockedException;

final class GameTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @test
     */
    public function it_should_return_the_status()
    {
        $game   = Game::create();
        $coords = Coords::fromArray(['x' => 1, 'y' => 1]);

        $fireResult = $game->fire($coords);
        $status     = $game->status();

        $this->assertCount(1, $status);
        $this->assertInstanceOf(FireResult::class, $status[0]);
        $this->assertSame($fireResult, $status[0]);
    }

    /**
     * @test
     */
    public function it_wins_the_game()
    {
        $gridData = [
            'fields' => [
                [
                    'coords' => [
                        'x' => 0,
                        'y' => 0
                    ],
                    'shot' => false
                ],
                [
                    'coords' => [
                        'x' => 0,
                        'y' => 1
                    ],
                    'shot' => false
                ]
            ],
            'ships' => [
                [
                    'startPoint' => [
                        'x' => 0,
                        'y' => 0
                    ],
                    'endPoint' => [
                        'x' => 0,
                        'y' => 1
                    ],
                    'hits' => 0
                ]
            ]
        ];

        $data = [
            'width' => 10,
            'height' => 10,
            'fields' => $gridData
        ];

        $gameData = ['id' => Uuid::uuid4()->toString(), 'locked' => false, 'grid' => $data, 'fireResults' => []];
        $game = Game::fromArray($gameData);
        $result = $game->fire(Coords::create(0, 0));

        $this->assertEquals('HIT 0.0', (string)$result);

        $result = $game->fire(Coords::create(0, 1));

        $this->assertEquals('WIN 0.1 0.0 0.1', (string)$result);
    }

    /**
     * @test
     */
    public function it_sinks_a_ship()
    {
        $gridData = [
            'fields' => [
                [
                    'coords' => [
                        'x' => 0,
                        'y' => 0
                    ],
                    'shot' => false
                ],
                [
                    'coords' => [
                        'x' => 0,
                        'y' => 1
                    ],
                    'shot' => false
                ],
                [
                    'coords' => [
                        'x' => 1,
                        'y' => 0
                    ],
                    'shot' => false
                ],
                [
                    'coords' => [
                        'x' => 1,
                        'y' => 1
                    ],
                    'shot' => false
                ]
            ],
            'ships' => [
                [
                    'startPoint' => [
                        'x' => 0,
                        'y' => 0
                    ],
                    'endPoint' => [
                        'x' => 0,
                        'y' => 1
                    ],
                    'hits' => 0
                ],
                [
                    'startPoint' => [
                        'x' => 1,
                        'y' => 0
                    ],
                    'endPoint' => [
                        'x' => 1,
                        'y' => 1
                    ],
                    'hits' => 0
                ]
            ]
        ];

        $data = [
            'width' => 10,
            'height' => 10,
            'fields' => $gridData
        ];

        $gameData = ['id' => Uuid::uuid4()->toString(), 'locked' => false, 'grid' => $data, 'fireResults' => []];
        $game = Game::fromArray($gameData);
        $result = $game->fire(Coords::create(0, 0));

        $this->assertEquals('HIT 0.0', (string)$result);

        $result = $game->fire(Coords::create(0, 1));

        $this->assertEquals('SANK 0.1 0.0 0.1', (string)$result);
    }
{'fraction_non_alphanumeric': 0.14830566607216353, 'fraction_numerical': 0.013582110028810537, 'mean_word_length': 0.8188622754491018, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 134, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7526141', 'n_tokens_mistral': 2145, 'n_tokens_neox': 1930, 'n_words': 322}