Private
Public Access
1
0

chg: usr: change the shareable battle - add avatars to it - even on the og tags #4

This commit is contained in:
2026-04-15 16:44:57 +02:00
parent 573d409606
commit c52939a7a3
7 changed files with 224 additions and 53 deletions

View File

@@ -57,7 +57,7 @@ class ProfileController extends AbstractController
}
#[Route('/profile', name: 'MineSeekerBundle_profile')]
public function index(): Response
public function index(CacheManager $cacheManager): Response
{
/** @var User $user */
$user = $this->getUser();
@@ -124,7 +124,7 @@ class ProfileController extends AbstractController
'bestScore' => $this->repo->findBestScoreForUser($user),
],
'recent' => ($recent = $this->repo->findRecentFinishedForUser($user)),
'gamesData' => array_map(static function (PlayedGame $game) use ($userId): array {
'gamesData' => array_map(function (PlayedGame $game) use ($userId, $cacheManager): array {
$isRed = $game->getRed()?->getId() === $userId;
$resign = $game->getResign();
$myColor = $isRed ? 'red' : 'blue';
@@ -140,6 +140,9 @@ class ProfileController extends AbstractController
elseif ($myPts < $oppPts) $result = 'loss';
}
$redAvatarPath = $game->getRed()?->getAvatarPath();
$blueAvatarPath = $game->getBlue()?->getAvatarPath();
return [
'id' => $game->getId(),
'uuid' => $game->getUuid()?->toRfc4122(),
@@ -147,6 +150,8 @@ class ProfileController extends AbstractController
$game->getRed()?->getUsername() ?? $game->getRedAnon()?->getUserName() ?? 'Guest',
'blueName' =>
$game->getBlue()?->getUsername() ?? $game->getBlueAnon()?->getUserName() ?? 'Guest',
'redAvatar' => $redAvatarPath ? $cacheManager->generateUrl($redAvatarPath, 'avatar_thumb') : null,
'blueAvatar' => $blueAvatarPath ? $cacheManager->generateUrl($blueAvatarPath, 'avatar_thumb') : null,
'redPoints' => $game->getRedPoints(),
'bluePoints' => $game->getBluePoints(),
'redExplodedBomb' => $game->getRedExplodedBomb(),
@@ -190,6 +195,8 @@ class ProfileController extends AbstractController
$redPts = $game->getRedPoints();
$bluePts = $game->getBluePoints();
$resign = $game->getResign();
$redAvatar = $game->getRed()?->getAvatarPath();
$blueAvatar = $game->getBlue()?->getAvatarPath();
if ($resign === 'red') {
$summary = "$redName resigned — $blueName wins";
@@ -208,14 +215,16 @@ class ProfileController extends AbstractController
}
return $this->render('Game/battle_share.html.twig', [
'game' => $game,
'redName' => $redName,
'blueName' => $blueName,
'redPts' => $redPts,
'bluePts' => $bluePts,
'resign' => $resign,
'ogTitle' => "MineSeeker · $summary",
'ogDesc' => "Watch the battle replay: $summary — played on MineSeeker, the multiplayer minesweeper.",
'game' => $game,
'redName' => $redName,
'blueName' => $blueName,
'redPts' => $redPts,
'bluePts' => $bluePts,
'resign' => $resign,
'redAvatar' => $redAvatar,
'blueAvatar' => $blueAvatar,
'ogTitle' => "MineSeeker · $summary",
'ogDesc' => "Watch the battle replay: $summary — played on MineSeeker, the multiplayer minesweeper.",
]);
}