Skip to content
Draft
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
56 changes: 56 additions & 0 deletions app/Domain/CatchEmAll/Achievements/DoubleAgent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Domain\CatchEmAll\Achievements;

use App\Domain\CatchEmAll\Interface\Achievement;
use App\Domain\CatchEmAll\Models\AchievementUpdateContext;

class DoubleAgent implements Achievement
{
public function getId(): string
{
return 'double_agent';
}

public function getTile(): string
{
return 'Double Agent';
}

public function getDescription(): string
{
return 'Playing both sides of the field, are we?';
}

public function getIcon(): string
{
return '';
}

public function getMaxProgress(): int
{
return 1;
}

public function isSecret(): bool
{
return false;
}

public function isOptional(): bool
{
return false;
}

public function isHidden(): bool
{
return false;
}

public function updateAchievementProgress(AchievementUpdateContext $context): int
{
$currentProgress = $context->userOwnedFursuits > 0 ? 1 : -1;

return $currentProgress;
}
}
69 changes: 69 additions & 0 deletions app/Domain/CatchEmAll/Achievements/NightOwl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace App\Domain\CatchEmAll\Achievements;

use App\Domain\CatchEmAll\Interface\Achievement;
use App\Domain\CatchEmAll\Models\AchievementUpdateContext;
use Carbon\Carbon;

class NightOwl implements Achievement
{
public function getId(): string
{
return 'night_owl';
}

public function getTile(): string
{
return 'Night Owl';
}

public function getDescription(): string
{
return 'The hunt never sleeps, and neither do you.';
}

public function getIcon(): string
{
return '🦉';
}

public function getMaxProgress(): int
{
return 1;
}

public function isSecret(): bool
{
return false;
}

public function isOptional(): bool
{
return false;
}

public function isHidden(): bool
{
return false;
}

public function updateAchievementProgress(AchievementUpdateContext $context): int
{
// Only trigger on actual catches, not special codes
if (!$context->hasCatch()) {
return -1; // Ignore this update
}

// Get the catch time in CEST timezone
$catchTime = Carbon::parse($context->userCatch->created_at)->setTimezone('Europe/Berlin');
$hour = $catchTime->hour;

// Check if catch was between 1 AM and 5 AM (1:00 - 4:59)
if ($hour >= 1 && $hour < 5) {
return 1; // Achievement completed
}

return -1; // Not completed yet
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
use App\Domain\CatchEmAll\Achievements\BugBountyHunter;
use App\Domain\CatchEmAll\Achievements\Collector;
use App\Domain\CatchEmAll\Achievements\Curator;
use App\Domain\CatchEmAll\Achievements\DoubleAgent;
use App\Domain\CatchEmAll\Achievements\FirstCatch;
use App\Domain\CatchEmAll\Achievements\FuredexComplete;
use App\Domain\CatchEmAll\Achievements\GottaCatchEmAll;
use App\Domain\CatchEmAll\Achievements\Nice;
use App\Domain\CatchEmAll\Achievements\NightOwl;
use App\Domain\CatchEmAll\Achievements\TheLegendary151;
use App\Domain\CatchEmAll\Enums\SpecialCodeType;
use App\Domain\CatchEmAll\Interface\Achievement;
Expand All @@ -34,6 +36,8 @@ class AchievementRegister
Nice::class,
TheLegendary151::class,
FuredexComplete::class,
DoubleAgent::class,
NightOwl::class,
// Add new achievements here in the format:
// AchievementClassName::class,
];
Expand Down
3 changes: 3 additions & 0 deletions app/Domain/CatchEmAll/Models/AchievementUpdateContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Domain\CatchEmAll\Models;

use App\Domain\CatchEmAll\Enums\SpecialCodeType;
use App\Models\Fursuit\Fursuit;
use App\Models\Event;
use App\Models\EventUser;
use App\Models\User;
Expand Down Expand Up @@ -46,6 +47,7 @@ public static function fromCatch(EventUser $eventUser, ?UserCatch $userCatch = n
->where('event_id', operator: $currentEvent->id)
->distinct('fursuit_id')
->count();
$userOwnedFursuits = Fursuit::where('user_id', $user->id)->count();

return new self(
eventUser: $eventUser,
Expand All @@ -54,6 +56,7 @@ public static function fromCatch(EventUser $eventUser, ?UserCatch $userCatch = n
userTotalCatches: $userTotalCatches,
totalCatchableFursuits: $totalCatchableFursuits,
userUniqueFursuits: $userUniqueFursuits,
userOwnedFursuits: $userOwnedFursuits,
);
}

Expand Down
Loading