Added achievement data
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Achievements\Checkers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\UserFlight;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class AircraftChecker extends BaseChecker
|
||||
{
|
||||
private const array BOEING_FAMILIES = [
|
||||
'707' => ['B701', 'B703', 'B720'],
|
||||
'717' => ['B712', 'B717'],
|
||||
'727' => ['B721', 'B722', 'B727'],
|
||||
'737' => ['B731', 'B732', 'B733', 'B734', 'B735', 'B736', 'B737', 'B738', 'B739', 'B37M', 'B38M', 'B39M'],
|
||||
'747' => ['B741', 'B742', 'B743', 'B744', 'B748', 'B74D', 'B74R', 'B74S'],
|
||||
'757' => ['B752', 'B753', 'B757'],
|
||||
'767' => ['B762', 'B763', 'B764', 'B767'],
|
||||
'777' => ['B772', 'B773', 'B77L', 'B77W', 'B778', 'B779'],
|
||||
'787' => ['B788', 'B789', 'B78X'],
|
||||
];
|
||||
|
||||
private const array AIRBUS_FAMILIES = [
|
||||
'A300' => ['A30B', 'A300', 'A306'],
|
||||
'A310' => ['A310', 'A312', 'A313'],
|
||||
'A318' => ['A318'],
|
||||
'A319' => ['A319', 'A31X'],
|
||||
'A320' => ['A320', 'A20N'],
|
||||
'A321' => ['A321', 'A21N'],
|
||||
'A330' => ['A330', 'A332', 'A333', 'A338', 'A339'],
|
||||
'A340' => ['A340', 'A342', 'A343', 'A345', 'A346'],
|
||||
'A350' => ['A350', 'A358', 'A359', 'A35K'],
|
||||
'A380' => ['A380', 'A388'],
|
||||
];
|
||||
|
||||
private const array DOUBLE_DECKER_DESIGNATORS = [
|
||||
// A380
|
||||
'A380', 'A388',
|
||||
// 747 variants
|
||||
'B741', 'B742', 'B743', 'B744', 'B748', 'B74D', 'B74R', 'B74S',
|
||||
];
|
||||
|
||||
public function check(): void
|
||||
{
|
||||
/**
|
||||
* @var $flights Collection<int, UserFlight>
|
||||
*/
|
||||
$flights = $this->flights();
|
||||
|
||||
|
||||
$flightsWithAircraft = $flights->filter(fn($f) => $f->aircraft !== null);
|
||||
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => in_array($f->aircraft->aircraft_description, ['LandPlane', 'SeaPlane'])
|
||||
),
|
||||
'aircraft.fly_on_a_plane'
|
||||
);
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => $f->aircraft->aircraft_description === 'Helicopter'
|
||||
),
|
||||
'aircraft.fly_on_a_helicopter'
|
||||
);
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => $f->aircraft->engine_type === 'Jet'
|
||||
),
|
||||
'aircraft.fly_on_a_jet'
|
||||
);
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => $f->aircraft->engine_type === 'Turboprop/Turboshaft' || $f->aircraft->engine_type === 'Piston'
|
||||
),
|
||||
'aircraft.fly_on_a_prop'
|
||||
);
|
||||
|
||||
// --- Engine count achievements ---
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(fn(UserFlight $f) => $f->aircraft->engine_count === 1 && $f->aircraft->aircraft_description !== 'Helicopter'),
|
||||
'aircraft.single_engine'
|
||||
);
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(fn(UserFlight $f) => $f->aircraft->engine_count === 2 && $f->aircraft->aircraft_description !== 'Helicopter'),
|
||||
'aircraft.twin_engine'
|
||||
);
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(fn(UserFlight $f) => $f->aircraft->engine_count === 3 && $f->aircraft->aircraft_description !== 'Helicopter'),
|
||||
'aircraft.tri_engine'
|
||||
);
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(fn(UserFlight $f) => $f->aircraft->engine_count === 4 && $f->aircraft->aircraft_description !== 'Helicopter'),
|
||||
'aircraft.quad_engine'
|
||||
);
|
||||
|
||||
// --- Double decker ---
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => in_array($f->aircraft->designator, self::DOUBLE_DECKER_DESIGNATORS)
|
||||
),
|
||||
'aircraft.double_decker'
|
||||
);
|
||||
|
||||
// --- Smaller manufacturer (scheduled service only) ---
|
||||
|
||||
$this->awardIf(
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => $f->airline && $f->flight_number && !in_array(strtolower($f->aircraft->manufacturer_code), ['boeing', 'airbus'])
|
||||
),
|
||||
'aircraft.smaller_manufacturer'
|
||||
);
|
||||
|
||||
// --- Boeing 7x7 families ---
|
||||
|
||||
$flownBoeingFamilies = collect(self::BOEING_FAMILIES)
|
||||
->filter(fn($designators) =>
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => in_array($f->aircraft->designator, $designators)
|
||||
)
|
||||
)
|
||||
->count();
|
||||
|
||||
$this->awardProgress($flownBoeingFamilies, 'aircraft.all_boeing_7x7');
|
||||
|
||||
// --- Airbus A3xx families ---
|
||||
|
||||
$flownAirbusFamilie = collect(self::AIRBUS_FAMILIES)
|
||||
->filter(fn($designators) =>
|
||||
$flightsWithAircraft->contains(
|
||||
fn(UserFlight $f) => in_array($f->aircraft->designator, $designators)
|
||||
)
|
||||
)
|
||||
->count();
|
||||
|
||||
$this->awardProgress($flownAirbusFamilie, 'aircraft.all_airbus_a3xx');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user