26 lines
910 B
PHP
26 lines
910 B
PHP
<?php
|
|
|
|
use App\Models\GameEvent;
|
|
use App\Models\Player;
|
|
use App\Models\User;
|
|
use App\Models\Village;
|
|
use App\Models\World;
|
|
|
|
it('wipes a world back to empty and keeps the user accounts', function () {
|
|
config(['game.world.map.barbarians.per_join' => 2]);
|
|
$village = startVillage();
|
|
$world = World::find($village->world_id);
|
|
$users = User::count();
|
|
$user = owner($village);
|
|
|
|
$this->artisan('game:reset-world', ['slug' => 'w1', '--force' => true])->assertSuccessful();
|
|
|
|
expect(Village::where('world_id', $world->id)->count())->toBe(0)
|
|
->and(Player::where('world_id', $world->id)->count())->toBe(0)
|
|
->and(GameEvent::where('world_id', $world->id)->count())->toBe(0)
|
|
->and(User::count())->toBe($users);
|
|
// Joining again starts a fresh village at the centre.
|
|
$again = startVillage($user);
|
|
expect(hypot($again->x, $again->y))->toBeLessThanOrEqual(5);
|
|
});
|