feat(combat): water traversal costs 3 and ends the turn
This commit is contained in:
@@ -249,6 +249,59 @@ final class PostMatchActionTest extends TestCase
|
||||
self::assertSame(409, $response->status);
|
||||
}
|
||||
|
||||
public function testMoveIntoWaterEndsTurn(): void
|
||||
{
|
||||
// Build a match where alpha-1 is on dry ground next to a water tile;
|
||||
// alpha-2 and alpha-3 are parked out of the way so the move path is
|
||||
// clear, and the move target (0,1) becomes a water tile whose cost (3)
|
||||
// matches alpha-1's speed budget.
|
||||
$match = $this->freshMatch();
|
||||
$matchArray = ScenarioSerializer::matchToArray($match);
|
||||
$matchArray['units'][0]['position'] = ['x' => 0, 'y' => 0];
|
||||
$matchArray['units'][0]['speed'] = 3;
|
||||
$matchArray['units'][1]['position'] = ['x' => 0, 'y' => 3]; // alpha-2 clear of alpha-1's path
|
||||
$matchArray['units'][2]['position'] = ['x' => 0, 'y' => 2]; // alpha-3 clear of alpha-1's path
|
||||
$matchArray['units'][3]['position'] = ['x' => 7, 'y' => 7]; // bravo-1 stays put
|
||||
$matchArray['units'][4]['position'] = ['x' => 6, 'y' => 7]; // bravo-2
|
||||
$matchArray['units'][5]['position'] = ['x' => 5, 'y' => 7]; // bravo-3
|
||||
$matchArray['battlefield']['terrain'] = ['0:1' => 'water'];
|
||||
$match = ScenarioSerializer::matchFromArray($matchArray);
|
||||
|
||||
$token = $this->tokenFor($match);
|
||||
[$csrf, $cookie] = CsrfToken::issue(self::SECRET);
|
||||
|
||||
$response = (new PostMatchMove(self::SECRET))->handle(
|
||||
$this->buildRequest(
|
||||
match: $match,
|
||||
csrf: $csrf,
|
||||
turnToken: $token,
|
||||
cookies: ['__csrf' => $cookie, '__csrf_token' => $token],
|
||||
body: [
|
||||
'matchId' => self::MATCH_ID,
|
||||
'match' => ScenarioSerializer::matchToArray($match),
|
||||
'unitId' => 'alpha-1',
|
||||
'x' => 0,
|
||||
'y' => 1,
|
||||
],
|
||||
),
|
||||
[],
|
||||
);
|
||||
|
||||
self::assertSame(200, $response->status);
|
||||
|
||||
$body = json_decode($response->body, true);
|
||||
$moved = null;
|
||||
foreach ($body['match']['units'] as $u) {
|
||||
if ($u['id'] === 'alpha-1') {
|
||||
$moved = $u;
|
||||
}
|
||||
}
|
||||
self::assertNotNull($moved);
|
||||
self::assertSame(['x' => 0, 'y' => 1], $moved['position']);
|
||||
self::assertSame(0, $moved['actionsRemaining'], 'wading ends the turn');
|
||||
self::assertTrue($moved['wadedThisTurn'], 'wade flag is set after water entry');
|
||||
}
|
||||
|
||||
public function testEndTurnHappyPathSwitchesTheActiveTeamAndIncrementsTheRoundAfterBothSides(): void
|
||||
{
|
||||
$match = $this->freshMatch();
|
||||
|
||||
Reference in New Issue
Block a user