Skip to content

Commit 352eb0e

Browse files
authored
Merge pull request #2520 from RaiderIO/development
Release v11.3.4 - The Stonevault enemy placement - MDT import/export affixes
2 parents ee46b2c + 46a881c commit 352eb0e

File tree

246 files changed

+720
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+720
-176
lines changed

app/Http/Controllers/AdminToolsController.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use App\Models\DungeonRoute\DungeonRoute;
1414
use App\Models\Floor\Floor;
1515
use App\Models\Mapping\MappingVersion;
16+
use App\Models\MDTImport;
1617
use App\Models\Npc\Npc;
1718
use App\Models\Npc\NpcClassification;
1819
use App\Models\Npc\NpcEnemyForces;
@@ -438,6 +439,15 @@ public function mdtviewasdungeonroute(): View
438439
return view('admin.tools.mdt.string', ['asDungeonroute' => true]);
439440
}
440441

442+
public function mdtImportList(): View
443+
{
444+
return view('admin.tools.mdt.list', [
445+
'mdtImports' => MDTImport::whereNotNull('error')
446+
->orderByDesc('created_at')
447+
->paginate(50),
448+
]);
449+
}
450+
441451
/**
442452
* @return never|void
443453
*

app/Http/Controllers/MDTImportController.php

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -34,41 +34,35 @@ public function details(
3434
$validated = $request->validated();
3535
$string = $validated['import_string'];
3636

37-
// try {
38-
$warnings = collect();
39-
$errors = collect();
40-
41-
return $mdtImportStringService
42-
->setEncodedString($string)
43-
->getDetails($warnings, $errors);
44-
// } catch (MDTStringParseException $ex) {
45-
// return abort(StatusCode::INTERNAL_SERVER_ERROR, __('controller.mdtimport.error.mdt_string_parsing_failed'));
46-
// } catch (InvalidMDTStringException $ex) {
47-
// return abort(StatusCode::BAD_REQUEST, __('controller.mdtimport.error.mdt_string_format_not_recognized'));
48-
// } catch (Exception $ex) {
49-
// // Different message based on our deployment settings
50-
// if (config('app.debug')) {
51-
// $message = sprintf(__('controller.mdtimport.error.invalid_mdt_string_exception'), $ex->getMessage());
52-
// } else {
53-
// $message = __('controller.admintools.error.invalid_mdt_string');
54-
// }
55-
//
56-
// // We're not interested if the string was 100% not an MDT string - it will never work then
57-
// if (isValidBase64($string)) {
58-
// report($ex);
59-
// }
60-
//
61-
// Log::error($ex->getMessage());
62-
//
63-
// return abort(StatusCode::BAD_REQUEST, $message);
64-
// } catch (Throwable $error) {
65-
// if ($error->getMessage() === "Class 'Lua' not found") {
66-
// return abort(StatusCode::INTERNAL_SERVER_ERROR, __('controller.mdtimport.error.mdt_importer_not_configured_properly'));
67-
// }
68-
// Log::error($error->getMessage());
69-
//
70-
// throw $error;
71-
// }
37+
try {
38+
$warnings = collect();
39+
$errors = collect();
40+
41+
return $mdtImportStringService
42+
->setEncodedString($string)
43+
->getDetails($warnings, $errors);
44+
} catch (MDTStringParseException $ex) {
45+
return abort(StatusCode::BAD_REQUEST, __('controller.mdtimport.error.mdt_string_parsing_failed'));
46+
} catch (InvalidMDTStringException $ex) {
47+
return abort(StatusCode::BAD_REQUEST, __('controller.mdtimport.error.mdt_string_format_not_recognized'));
48+
} catch (Exception $ex) {
49+
// Different message based on our deployment settings
50+
if (config('app.debug')) {
51+
$message = sprintf(__('controller.mdtimport.error.invalid_mdt_string_exception'), $ex->getMessage());
52+
} else {
53+
$message = __('controller.admintools.error.invalid_mdt_string');
54+
}
55+
56+
return abort(StatusCode::BAD_REQUEST, $message);
57+
} catch (Throwable $error) {
58+
Log::error($error->getMessage());
59+
60+
if ($error->getMessage() === "Class 'Lua' not found") {
61+
return abort(StatusCode::INTERNAL_SERVER_ERROR, __('controller.mdtimport.error.mdt_importer_not_configured_properly'));
62+
}
63+
64+
throw $error;
65+
}
7266
}
7367

7468
/**
@@ -97,14 +91,8 @@ public function import(ImportStringFormRequest $request, MDTImportStringServiceI
9791
$dungeonRoute->team_id = $validated['team_id'] ?? null;
9892
$dungeonRoute->save();
9993
}
100-
101-
// Keep track of the import
102-
MDTImport::create([
103-
'dungeon_route_id' => $dungeonRoute->id,
104-
'import_string' => $string,
105-
]);
10694
} catch (MDTStringParseException) {
107-
return abort(StatusCode::INTERNAL_SERVER_ERROR, __('controller.mdtimport.error.mdt_string_parsing_failed'));
95+
return abort(StatusCode::BAD_REQUEST, __('controller.mdtimport.error.mdt_string_parsing_failed'));
10896
} catch (InvalidMDTStringException) {
10997
return abort(StatusCode::BAD_REQUEST, __('controller.mdtimport.error.mdt_string_format_not_recognized'));
11098
} catch (Exception $ex) {

app/Logic/MDT/Conversion.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use App\Models\Dungeon;
1414
use App\Models\Expansion;
1515
use App\Models\Floor\Floor;
16+
use App\Models\Season;
1617
use App\Service\Season\SeasonService;
1718
use Exception;
1819

@@ -295,18 +296,30 @@ public static function convertLatLngToMDTCoordinate(LatLng $latLng): array
295296
*/
296297
public static function convertWeekToAffixGroup(SeasonService $seasonService, Dungeon $dungeon, int $mdtWeek): ?AffixGroup
297298
{
298-
$season = $dungeon->getActiveSeason($seasonService);
299+
if (!$dungeon->gameVersion->has_seasons) {
300+
return null;
301+
}
302+
303+
$season = $seasonService->getUpcomingSeasonForDungeon($dungeon) ??
304+
$seasonService->getMostRecentSeasonForDungeon($dungeon);
305+
299306
if ($season === null) {
300307
logger()->error(sprintf('Unable to find season for dungeon %s', __($dungeon->name)));
301308

302309
return null;
303310
}
304311

305-
$affixGroup = $season->affixGroups->get(($season->start_affix_group_index + ($mdtWeek - 1)) % $season->affixGroups->count());
312+
// For each season this is different
313+
if ($season->id === Season::SEASON_TWW_S1) {
314+
$affixGroup = $season->affixGroups->get(($season->start_affix_group_index + $mdtWeek) % $season->affixGroups->count());
315+
} else {
316+
$affixGroup = $season->affixGroups->get(($season->start_affix_group_index + ($mdtWeek - 1)) % $season->affixGroups->count());
317+
}
318+
306319
// $affixGroup = $season->affixgroups->get(($season->start_affix_group_index - ($mdtWeek - 1)));
307320
if ($affixGroup === null) {
308321
logger()->error('Unable to find affix group for mdtWeek - returning current affix group instead', [
309-
'$mdtWeek' => $mdtWeek,
322+
'mdtWeek' => $mdtWeek,
310323
]);
311324

312325
$affixGroup = $season->getCurrentAffixGroup();
@@ -317,6 +330,11 @@ public static function convertWeekToAffixGroup(SeasonService $seasonService, Dun
317330

318331
public static function convertAffixGroupToWeek(AffixGroup $affixGroup): int
319332
{
333+
// For each season this is different
334+
if ($affixGroup->season_id === Season::SEASON_TWW_S1) {
335+
return ($affixGroup->id - 2) % $affixGroup->season->affix_group_count;
336+
}
337+
320338
// We need to figure out which week it is in the rotation
321339
return ($affixGroup->id - 1) % $affixGroup->season->affix_group_count;
322340
}

app/Models/DungeonRoute/DungeonRoute.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,8 @@ public function saveFromRequest(
822822
// If it was empty just set Unspecified instead
823823
$this->faction_id = empty($this->faction_id) ? 1 : $this->faction_id;
824824

825-
$activeSeason = $seasonService->getMostRecentSeasonForDungeon($this->dungeon);
825+
$activeSeason = $seasonService->getUpcomingSeasonForDungeon($this->dungeon) ??
826+
$seasonService->getMostRecentSeasonForDungeon($this->dungeon);
826827
// Can still be null if there are no seasons for this dungeon, like in Classic
827828
$this->season_id = $activeSeason->id ?? null;
828829

app/Models/Expansion.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ public function showDiscoverRoutesCardDungeonImage(): bool
209209
return !in_array($this->shortname, [Expansion::EXPANSION_SHADOWLANDS]);
210210
}
211211

212+
public function getWallpaperUrl(): string
213+
{
214+
return url(sprintf('/images/dungeons/%s/wallpaper.jpg', $this->shortname));
215+
}
216+
212217
/**
213218
* Saves an expansion with the data from a Request.
214219
*

app/Models/MDTImport.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
namespace App\Models;
44

55
use App\Models\DungeonRoute\DungeonRoute;
6+
use Carbon\Carbon;
67
use Eloquent;
78
use Illuminate\Database\Eloquent\Model;
89
use Illuminate\Database\Eloquent\Relations\BelongsTo;
910

1011
/**
11-
* @property int $id
12-
* @property int $dungeon_route_id
13-
* @property string $import_string
12+
* @property int $id
13+
* @property int|null $dungeon_route_id
14+
* @property string|null $error
15+
* @property string $import_string
16+
*
17+
* @property DungeonRoute $dungeonRoute
18+
* @property Carbon $created_at
19+
* @property Carbon $updated_at
1420
*
1521
* @mixin Eloquent
1622
*/
@@ -21,13 +27,14 @@ class MDTImport extends Model
2127

2228
protected $fillable = [
2329
'dungeon_route_id',
30+
'error',
2431
'import_string',
2532
];
2633

2734
/**
2835
* Get the dungeon route that this import created.
2936
*/
30-
public function dungeonroute(): BelongsTo
37+
public function dungeonRoute(): BelongsTo
3138
{
3239
return $this->belongsTo(DungeonRoute::class);
3340
}

app/Providers/KeystoneGuruServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ static function (View $view) use ($globalViewVariables) {
462462
$view->with('nextSeason', $regionViewVariables['nextSeason']);
463463
$view->with('selectedSeason', $selectedSeason);
464464
$view->with('currentAffixGroup', $selectedSeason->getCurrentAffixGroup());
465-
$view->with('affixgroups', $selectedSeason->affixGroups);
465+
$view->with('affixGroups', $selectedSeason->affixGroups);
466466
$view->with('dungeons', $selectedSeason->dungeons);
467467
});
468468

app/Service/DungeonRoute/CoverageService.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ public function getForUser(User $user, Season $season): Collection
1717
return DungeonRoute::with(['affixes'])
1818
->selectRaw('dungeon_routes.*, IF(dungeon_routes.enemy_forces < mapping_versions.enemy_forces_required, 0, 1) as has_enemy_forces')
1919
->join('dungeons', 'dungeons.id', 'dungeon_routes.dungeon_id')
20-
->join('dungeon_route_affix_groups', 'dungeon_route_affix_groups.dungeon_route_id', 'dungeon_routes.id')
21-
->join('affix_groups', 'affix_groups.id', 'dungeon_route_affix_groups.affix_group_id')
22-
->join('season_dungeons', 'season_dungeons.dungeon_id', 'dungeons.id')
2320
->join('mapping_versions', 'mapping_versions.id', 'dungeon_routes.mapping_version_id')
2421
->where('dungeon_routes.author_id', $user->id)
25-
->where('affix_groups.season_id', $season->id)
26-
->where('season_dungeons.season_id', $season->id)
22+
->where('dungeon_routes.season_id', $season->id)
2723
->whereNull('expires_at')
2824
->groupBy('dungeon_routes.id')
2925
->get()
@@ -42,5 +38,15 @@ public function getForUser(User $user, Season $season): Collection
4238
// and `season_dungeons`.`season_id` = 9
4339
// and `expires_at` is null
4440
// group by `dungeon_routes`.`id`
41+
42+
43+
// select dungeon_routes.*, IF(mapping_versions.enemy_forces_required > dungeon_routes.enemy_forces, 0, 1) as has_enemy_forces
44+
// from `dungeon_routes`
45+
// inner join `mapping_versions` on `mapping_versions`.`id` = `dungeon_routes`.`mapping_version_id`
46+
// where `dungeon_routes`.`author_id` = 20265
47+
// and `dungeon_routes`.`season_id` = 14
48+
// and `expires_at` is null
49+
// group by `dungeon_routes`.`id`
50+
// ORDER BY `dungeon_routes`.`dungeon_id` ASC
4551
}
4652
}

app/Service/MDT/MDTExportStringService.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ private function extractPulls(MappingVersion $mappingVersion, Collection $warnin
203203
NpcClassification::ALL[NpcClassification::NPC_CLASSIFICATION_BOSS],
204204
NpcClassification::ALL[NpcClassification::NPC_CLASSIFICATION_FINAL_BOSS]]
205205
)) {
206-
$warnings->push(new ImportWarning(sprintf(__('logic.mdt.io.export_string.category.pull'), $pullIndex),
207-
sprintf(__('logic.mdt.io.export_string.unable_to_find_mdt_enemy_for_kg_enemy'), $enemy->npc->name, $enemy->id, $enemy->getMdtNpcId()),
208-
['details' => __('logic.mdt.io.export_string.unable_to_find_mdt_enemy_for_kg_enemy_details')]
206+
$warnings->push(new ImportWarning(sprintf(__('services.mdt.io.export_string.category.pull'), $pullIndex),
207+
sprintf(__('services.mdt.io.export_string.unable_to_find_mdt_enemy_for_kg_enemy'), $enemy->npc->name, $enemy->id, $enemy->getMdtNpcId()),
208+
['details' => __('services.mdt.io.export_string.unable_to_find_mdt_enemy_for_kg_enemy_details')]
209209
));
210210
}
211211

@@ -224,8 +224,8 @@ private function extractPulls(MappingVersion $mappingVersion, Collection $warnin
224224

225225
// Do not add an empty pull if the killed enemy in our killzone was removed because it didn't exist in MDT, and that caused the pull to be empty
226226
if ($killZoneEnemies->count() !== 0 && $enemiesAdded === 0) {
227-
$warnings->push(new ImportWarning(sprintf(__('logic.mdt.io.export_string.category.pull'), $pullIndex),
228-
__('logic.mdt.io.export_string.unable_to_find_mdt_enemy_for_kg_caused_empty_pull'),
227+
$warnings->push(new ImportWarning(sprintf(__('services.mdt.io.export_string.category.pull'), $pullIndex),
228+
__('services.mdt.io.export_string.unable_to_find_mdt_enemy_for_kg_caused_empty_pull'),
229229
));
230230

231231
continue;
@@ -289,9 +289,9 @@ public function getEncodedString(Collection $warnings): string
289289
// If stripping ascii characters worked in changing the title somehow
290290
if ($asciiTitle !== $this->dungeonRoute->title) {
291291
$warnings->push(
292-
new ImportWarning(__('logic.mdt.io.export_string.category.title'),
293-
__('logic.mdt.io.export_string.route_title_contains_non_ascii_char_bug'),
294-
['details' => sprintf(__('logic.mdt.io.export_string.route_title_contains_non_ascii_char_bug_details'), $this->dungeonRoute->title, $asciiTitle)]
292+
new ImportWarning(__('services.mdt.io.export_string.category.title'),
293+
__('services.mdt.io.export_string.route_title_contains_non_ascii_char_bug'),
294+
['details' => sprintf(__('services.mdt.io.export_string.route_title_contains_non_ascii_char_bug_details'), $this->dungeonRoute->title, $asciiTitle)]
295295
)
296296
);
297297
$this->dungeonRoute->title = $asciiTitle;
@@ -304,9 +304,9 @@ public function getEncodedString(Collection $warnings): string
304304
$asciiComment = preg_replace('/[[:^print:]]/', '', $mapicon->comment ?? '');
305305
if ($asciiComment !== $mapicon->comment) {
306306
$warnings->push(
307-
new ImportWarning(__('logic.mdt.io.export_string.category.map_icon'),
308-
__('logic.mdt.io.export_string.map_icon_contains_non_ascii_char_bug'),
309-
['details' => sprintf(__('logic.mdt.io.export_string.map_icon_contains_non_ascii_char_bug_details'), $asciiComment, $mapicon->comment)]
307+
new ImportWarning(__('services.mdt.io.export_string.category.map_icon'),
308+
__('services.mdt.io.export_string.map_icon_contains_non_ascii_char_bug'),
309+
['details' => sprintf(__('services.mdt.io.export_string.map_icon_contains_non_ascii_char_bug_details'), $asciiComment, $mapicon->comment)]
310310
)
311311
);
312312
$mapicon->comment = $asciiComment;

0 commit comments

Comments
 (0)