Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide future event achievement selection #3085

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions app/Support/Shortcode/Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

namespace App\Support\Shortcode;

use App\Models\Achievement;
use App\Models\System;
use App\Models\Ticket;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Thunder\Shortcode\Event\FilterShortcodesEvent;
Expand Down Expand Up @@ -340,6 +343,16 @@ private function embedAchievement(int $id): string
return '';
}

if ($data['ConsoleID'] === System::Events) {
$achievement = Achievement::find($id);
if ($achievement->eventData?->source_achievement_id
&& $achievement->eventData->active_from > Carbon::now()) {
$data['Title'] = $data['AchievementTitle'] = 'Upcoming Challenge';
$data['Description'] = '?????';
$data['BadgeName'] = '00000';
}
}

return achievementAvatar($data, iconSize: 24);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@
$imgClass = $isUnlockedOnHardcore ? 'goldimagebig' : 'badgeimg';
$imgClass .= ' w-[54px] h-[54px] sm:w-16 sm:h-16';

$renderedAchievementAvatar = achievementAvatar(
$achievement,
label: false,
icon: $achBadgeName,
iconSize: 64,
iconClass: $imgClass,
tooltip: false
);

$unlockDate = '';
if (isset($achievement['DateEarned'])) {
$unlockDate = Carbon::parse($achievement['DateEarned'])->format('F j Y, g:ia');
Expand All @@ -53,8 +44,23 @@
if ($activeUntil > Carbon::now()) {
$isActive = true;
}
} elseif ($achievement['SourceAchievementId']) {
// future event has been picked. don't show it until it's active
$achBadgeName = '00000';
$achievement['Title'] = 'Upcoming Challenge';
$achievement['Description'] = '?????';
$achievement['SourceGameId'] = null;
}
}

$renderedAchievementAvatar = achievementAvatar(
$achievement,
label: false,
icon: $achBadgeName,
iconSize: 64,
iconClass: $imgClass,
tooltip: false
);
?>

<li class="flex gap-x-3 odd:bg-[rgba(50,50,50,0.4)] light:odd:bg-neutral-200 px-2 py-3 md:py-1 w-full {{ $isUnlocked ? 'unlocked-row' : '' }} {{ $achievement['type'] === 'missable' ? 'missable-row' : '' }} {{ $isActive ? 'active-row' : '' }}">
Expand Down
14 changes: 12 additions & 2 deletions resources/views/pages-legacy/achievementInfo.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use App\Platform\Enums\AchievementType;
use App\Platform\Services\TriggerDecoderService;
use App\Support\Shortcode\Shortcode;
use Carbon\Carbon;
use Illuminate\Support\Facades\Blade;

authenticateFromCookie($user, $permissions, $userDetails);
Expand Down Expand Up @@ -132,9 +133,18 @@
$eventAchievement = EventAchievement::where('achievement_id', '=', $achievementID)
->with('sourceAchievement')->first();

// update the ID of the dataOut so the link goes to the source achievement
if ($eventAchievement?->sourceAchievement) {
$dataOut['ID'] = $eventAchievement->sourceAchievement->ID;
if ($eventAchievement->active_from > Carbon::now()) {
// future event has been picked. don't show it until it's active
$eventAchievement = null;
$badgeName = $dataOut['BadgeName'] = '00000';
$achievementTitleRaw = $achievementTitle = $dataOut['Title'] = 'Upcoming Challenge';
$achievementDescriptionRaw = $dataOut['Description'] = '?????';
$dataOut['SourceGameId'] = null;
} else {
// update the ID of the dataOut so the link goes to the source achievement
$dataOut['ID'] = $eventAchievement->sourceAchievement->ID;
}
}
}

Expand Down