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

1829 multiple routes at once #2216

Open
wants to merge 14 commits into
base: development
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion app/Console/Commands/Dungeon/CreateMissingFloors.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use App\Models\Floor;
use Illuminate\Console\Command;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;

class CreateMissingFloors extends Command
{
Expand Down
8 changes: 4 additions & 4 deletions app/Events/LiveSession/InviteEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(LiveSession $liveSession, User $user, Collection $in
public function broadcastOn(): array
{
return [
new PresenceChannel(sprintf('%s-route-edit.%s', config('app.type'), $this->_context->dungeonroute->getRouteKey())),
new PresenceChannel(sprintf('%s-route-edit.%s', config('app.type'), $this->_context->dungeonRoute->getRouteKey())),
];
}

Expand All @@ -56,9 +56,9 @@ public function broadcastWith(): array
// Cannot use ContextModelEvent as model is already deleted and serialization will fail
'invitees' => $this->invitees,
'url' => route('dungeonroute.livesession.view', [
'dungeon' => $this->_context->dungeonroute->dungeon,
'title' => Str::slug($this->_context->dungeonroute->title),
'dungeonroute' => $this->_context->dungeonroute,
'dungeon' => $this->_context->dungeonRoute->dungeon,
'title' => Str::slug($this->_context->dungeonRoute->title),
'dungeonroute' => $this->_context->dungeonRoute,
'livesession' => $this->_context,
]),
]);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AdminToolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function dungeonroutesubmit(Request $request)
$dungeonRoute = DungeonRoute::with([
'faction', 'specializations', 'classes', 'races', 'affixes',
'brushlines', 'paths', 'author', 'killZones', 'pridefulEnemies', 'publishedstate',
'ratings', 'favorites', 'enemyraidmarkers', 'mapicons', 'mdtImport', 'team',
'ratings', 'favorites', 'enemyRaidMarkers', 'mapicons', 'mdtImport', 'team',
])->where('public_key', $request->get('public_key'))->firstOrFail();

return view('admin.tools.dungeonroute.viewcontents', [
Expand Down
46 changes: 45 additions & 1 deletion app/Http/Controllers/Ajax/APIDungeonRouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -801,11 +801,55 @@ public function refreshThumbnail(Request $request, ThumbnailServiceInterface $th
/**
* @param APIDungeonRouteDataFormRequest $request
* @return Collection
* @throws \Exception
*/
public function getDungeonRoutesData(APIDungeonRouteDataFormRequest $request): Collection
{
$publicKeys = $request->validated()['public_keys'];

return $this->getDungeonRoutesProperties($publicKeys);
/** @var Collection|DungeonRoute[] $dungeonRoutes */
$dungeonRoutes = DungeonRoute::with([
'affixes',
'killZones',
'mapicons',
'paths',
'brushlines',
'pridefulEnemies',
'enemyRaidMarkers',
])->whereIn('public_key', $publicKeys)->get();

// Validate the routes match enough so we can compare them
$dungeonId = null;
$mappingVersionId = null;
$seasonalIndex = null;
$seasonalAffix = null;

foreach ($dungeonRoutes as $dungeonRoute) {
if ($dungeonId === null) {
$dungeonId = $dungeonRoute->dungeon_id;
$mappingVersionId = $dungeonRoute->mapping_version_id;
$seasonalIndex = $dungeonRoute->seasonal_index;
$seasonalAffix = $dungeonRoute->getSeasonalAffix();
continue;
}

if ($dungeonId !== $dungeonRoute->dungeon_id) {
throw new Exception('Dungeon IDs do not match between routes');
}

if ($mappingVersionId !== $dungeonRoute->mapping_version_id) {
throw new Exception('Mapping versions do not match between routes');
}

if ($seasonalIndex !== $dungeonRoute->seasonal_index) {
throw new Exception('Seasonal index do not match between routes');
}

if ($seasonalAffix !== $dungeonRoute->getSeasonalAffix()) {
throw new Exception('Seasonal affixes do not match between routes');
}
}

return $this->getDungeonRoutesProperties($dungeonRoutes);
}
}
20 changes: 10 additions & 10 deletions app/Http/Controllers/Ajax/APIOverpulledEnemyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ function store(

/**
* @param OverpulledEnemyServiceInterface $overpulledEnemyService
* @param OverpulledEnemyFormRequest $request
* @param DungeonRoute $dungeonroute
* @param LiveSession $livesession
* @param OverpulledEnemyFormRequest $request
* @param DungeonRoute $dungeonRoute
* @param LiveSession $liveSession
* @return array|ResponseFactory|Response
* @throws AuthorizationException
*/
function delete(
OverpulledEnemyServiceInterface $overpulledEnemyService,
OverpulledEnemyFormRequest $request,
DungeonRoute $dungeonroute,
LiveSession $livesession)
DungeonRoute $dungeonRoute,
LiveSession $liveSession)
{
$this->authorize('view', $dungeonroute);
$this->authorize('view', $livesession);
$this->authorize('view', $dungeonRoute);
$this->authorize('view', $liveSession);

$result = response()->noContent();

Expand All @@ -94,17 +94,17 @@ function delete(
try {
foreach ($enemies as $enemy) {
/** @var OverpulledEnemy $overpulledEnemy */
$overpulledEnemy = OverpulledEnemy::where('live_session_id', $livesession->id)
$overpulledEnemy = OverpulledEnemy::where('live_session_id', $liveSession->id)
->where('npc_id', $enemy->npc_id)
->where('mdt_id', $enemy->mdt_id)
->first();

if ($overpulledEnemy && $overpulledEnemy->delete() && Auth::check()) {
broadcast(new OverpulledEnemyDeletedEvent($livesession, Auth::getUser(), $overpulledEnemy));
broadcast(new OverpulledEnemyDeletedEvent($liveSession, Auth::getUser(), $overpulledEnemy));
}

// Optionally don't calculate the return value
$result = $validated['no_result'] === true ? $result : $overpulledEnemyService->getRouteCorrection($livesession)->toArray();
$result = $validated['no_result'] === true ? $result : $overpulledEnemyService->getRouteCorrection($liveSession)->toArray();
}
} catch (Exception $ex) {
$result = response('Not found', Http::NOT_FOUND);
Expand Down
37 changes: 37 additions & 0 deletions app/Http/Controllers/DungeonRouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use App\Http\Requests\DungeonRoute\MigrateToSeasonalTypeRequest;
use App\Jobs\RefreshEnemyForces;
use App\Logic\MapContext\MapContextDungeonRoute;
use App\Logic\MapContext\MapContextDungeonRouteCompare;
use App\Models\Dungeon;
use App\Models\DungeonRoute;
use App\Models\Floor;
Expand Down Expand Up @@ -531,4 +532,40 @@ public function upgrade(Request $request, Dungeon $dungeon, DungeonRoute $dungeo
'title' => $dungeonroute->getTitleSlug(),
]);
}

/**
* @param Request $request
* @param Dungeon $dungeon
* @param DungeonRoute $dungeonRouteA
* @param DungeonRoute $dungeonRouteB
* @return Application|Factory|View
* @throws InvalidArgumentException
*/
public function compare(Request $request, Dungeon $dungeon, DungeonRoute $dungeonRouteA, DungeonRoute $dungeonRouteB)
{
if ($dungeon->id !== $dungeonRouteA->dungeon_id) {
throw new Exception('Route A does not have the same dungeon!');
}

if ($dungeon->id !== $dungeonRouteB->dungeon_id) {
throw new Exception('Route B does not have the same dungeon!');
}

if ($dungeonRouteA->mapping_version_id !== $dungeonRouteB->mapping_version_id) {
throw new Exception('Route A and route B do not have the same mapping version!');
}

/** @var Floor $defaultFloor */
$defaultFloor = $dungeon->floors()->where('default', true)->first();

$dungeonRoutes = collect([$dungeonRouteA, $dungeonRouteB]);

return view('dungeonroute.compare', [
'dungeon' => $dungeon,
'dungeonRoutes' => $dungeonRoutes,
'floor' => $defaultFloor,
'mappingVersion' => $dungeonRouteA->mappingVersion,
'mapContext' => (new MapContextDungeonRouteCompare($dungeonRoutes, $dungeonRouteA->mappingVersion, $defaultFloor))->getProperties(),
]);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/LiveSessionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function viewfloor(Request $request, Dungeon $dungeon, DungeonRoute $dung
}

// It's broken - get rid of it
if ($livesession->dungeonroute === null) {
if ($livesession->dungeonRoute === null) {
logger()->debug('Live session is attached to a deleted dungeon route - deleting live session', [
'live_session_id' => $livesession->id,
'live_session_public_key' => $livesession->public_key,
Expand Down
25 changes: 15 additions & 10 deletions app/Logic/CombatLog/CombatEvents/Prefixes/Prefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ abstract class Prefix implements HasParameters
{
use ValidatesParameterCount;

public const PREFIX_SWING = 'SWING';
public const PREFIX_RANGE = 'RANGE';
public const PREFIX_SPELL_PERIODIC = 'SPELL_PERIODIC';
public const PREFIX_SPELL_BUILDING = 'SPELL_BUILDING';
public const PREFIX_SPELL = 'SPELL';
// Bit of a special one, SWING_DAMAGE_LANDED_SUPPORT is actually a spell and not a swing.
// We have to include the full name here so it doesn't collide with anything else
public const PREFIX_SWING_DAMAGE_LANDED_SUPPORT = 'SWING_DAMAGE_LANDED_SUPPORT';
public const PREFIX_SWING = 'SWING';
public const PREFIX_RANGE = 'RANGE';
public const PREFIX_SPELL_PERIODIC = 'SPELL_PERIODIC';
public const PREFIX_SPELL_BUILDING = 'SPELL_BUILDING';
public const PREFIX_SPELL = 'SPELL';

public const PREFIX_ALL = [
self::PREFIX_SWING_DAMAGE_LANDED_SUPPORT,
self::PREFIX_SWING,
self::PREFIX_RANGE,
self::PREFIX_SPELL_PERIODIC,
Expand All @@ -26,11 +30,12 @@ abstract class Prefix implements HasParameters
];

private const PREFIX_CLASS_MAPPING = [
self::PREFIX_SWING => Swing::class,
self::PREFIX_RANGE => Range::class,
self::PREFIX_SPELL => Spell::class,
self::PREFIX_SPELL_PERIODIC => SpellPeriodic::class,
self::PREFIX_SPELL_BUILDING => SpellBuilding::class,
self::PREFIX_SWING_DAMAGE_LANDED_SUPPORT => SwingDamageLandedSupport::class,
self::PREFIX_SWING => Swing::class,
self::PREFIX_RANGE => Range::class,
self::PREFIX_SPELL => Spell::class,
self::PREFIX_SPELL_PERIODIC => SpellPeriodic::class,
self::PREFIX_SPELL_BUILDING => SpellBuilding::class,
];

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Prefixes;

class SwingDamageLandedSupport extends Range
{
}
9 changes: 3 additions & 6 deletions app/Logic/CombatLog/CombatEvents/Suffixes/Damage.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function isCrushing(): bool
return $this->crushing;
}


/**
* @param array $parameters
* @return HasParameters
Expand All @@ -120,18 +119,16 @@ public function setParameters(array $parameters): HasParameters
$this->rawAmount = $parameters[1];
$this->overKill = $parameters[2];
$this->school = $parameters[3];
$this->resisted = $parameters[4];
$this->blocked = $parameters[5];
$this->absorbed = $parameters[6];
$this->resisted = $parameters[4] === 'nil' ? 0 : $parameters[4];
$this->blocked = $parameters[5] === 'nil' ? 0 : $parameters[5];
$this->absorbed = $parameters[6] === 'nil' ? 0 : $parameters[6];
$this->critical = $parameters[7] !== 'nil';
$this->glancing = $parameters[8] !== 'nil';
$this->crushing = $parameters[9] !== 'nil';


return $this;
}


/**
* @return int
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Suffixes;

class DamageLandedSupport extends DamageSupport
{

}
41 changes: 41 additions & 0 deletions app/Logic/CombatLog/CombatEvents/Suffixes/DamageSupport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Suffixes;

use App\Logic\CombatLog\CombatEvents\Interfaces\HasParameters;
use App\Logic\CombatLog\Guid\Guid;

class DamageSupport extends Damage
{
private Guid $supportGuid;

/**
* @return Guid|null
*/
public function getSupportGuid(): ?Guid
{
return $this->supportGuid;
}

/**
* @param array $parameters
* @return HasParameters
*/
public function setParameters(array $parameters): HasParameters
{
parent::setParameters($parameters);

$this->supportGuid = Guid::createFromGuidString($parameters[10]);

return $this;
}


/**
* @return int
*/
public function getParameterCount(): int
{
return 11;
}
}
41 changes: 41 additions & 0 deletions app/Logic/CombatLog/CombatEvents/Suffixes/HealSupport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Suffixes;

use App\Logic\CombatLog\CombatEvents\Interfaces\HasParameters;
use App\Logic\CombatLog\Guid\Guid;

class HealSupport extends Heal
{
private Guid $supportGuid;

/**
* @return Guid|null
*/
public function getSupportGuid(): ?Guid
{
return $this->supportGuid;
}

/**
* @param array $parameters
* @return HasParameters
*/
public function setParameters(array $parameters): HasParameters
{
parent::setParameters($parameters);

$this->supportGuid = Guid::createFromGuidString($parameters[5]);

return $this;
}


/**
* @return int
*/
public function getParameterCount(): int
{
return 6;
}
}
Loading