$this->travelTo(CarbonImmutable::parse('2026-10-29 12:00:00'))); function mapAround(Village $village): array { return app(ShowMap::class)(owner($village), $village->world_id, $village->x, $village->y, 41, 41); } function relationOn(array $map, Village $village): ?string { return collect($map['villages'])->firstWhere('id', $village->id)['relation'] ?? null; } it('colours villages by what their owner is to the viewer', function () { $me = startVillage(); $mate = startVillage(); $ally = startVillage(); $foe = startVillage(); $stranger = startVillage(); $barbarian = app(VillageFactory::class)->create($me->world, null, 'Barbarian village', $me->x + 2, $me->y + 2, ['headquarters' => 1]); foreach ([[$me, 'AAA'], [$ally, 'BBB'], [$foe, 'CCC']] as [$v, $tag]) { app(Tribes::class)->found(owner($v), $v->world_id, "Tribe $tag", $tag); } app(Tribes::class)->invite(owner($me), $me->world_id, $mate->player->name); app(Tribes::class)->join(owner($mate), $mate->world_id, Tribe::where('tag', 'AAA')->value('id')); app(Tribes::class)->propose(owner($me), $me->world_id, 'BBB', 'ally'); app(Tribes::class)->accept(owner($ally), $ally->world_id, Tribe::where('tag', 'AAA')->value('id')); app(Tribes::class)->enemy(owner($foe), $foe->world_id, 'AAA'); $map = mapAround($me); expect(relationOn($map, $me))->toBe('own') ->and(relationOn($map, $mate))->toBe('tribe') ->and(relationOn($map, $ally))->toBe('ally') ->and(relationOn($map, $foe))->toBe('enemy') ->and(relationOn($map, $stranger))->toBe('none') ->and(relationOn($map, $barbarian))->toBe('barbarian') ->and(collect($map['villages'])->firstWhere('id', $ally->id)['player']['tribe']['tag'])->toBe('BBB'); }); it('shows own groups with units and spotted incoming ones by size only', function () { $me = startVillage(); $other = startVillage(); $barbarian = app(VillageFactory::class)->create($me->world, null, 'Barbarian village', $me->x + 3, $me->y, ['headquarters' => 1]); $me->buildings()->create(['type' => 'rally_point', 'level' => 1]); $me->troops()->create(['home_village_id' => $me->id, 'unit' => 'spear', 'count' => 60]); app(SendTroops::class)(owner($me), $me->id, 'attack', $barbarian->x, $barbarian->y, ['spear' => 60], null, null); $mine = mapAround($me)['movements']; expect($mine)->toHaveCount(1) ->and($mine[0])->toMatchArray(['type' => 'attack', 'own' => true, 'raid' => false, 'size' => 'small', 'units' => ['spear' => 60]]) ->and($mine[0]['from']['id'])->toBe($me->id) ->and($mine[0]['to']['id'])->toBe($barbarian->id) ->and(mapAround($other)['movements'])->toBe([]); });