Skip to content

Commit

Permalink
Merge pull request #1979 from Wotuu/development
Browse files Browse the repository at this point in the history
Release v7.0 - Classic dungeon support, phase 1
  • Loading branch information
Wotuu authored Aug 24, 2023
2 parents 6eba9d0 + 37b4159 commit ff8b7e0
Show file tree
Hide file tree
Showing 408 changed files with 59,644 additions and 1,194 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/CombatLog/OutputResultEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function handle(CombatLogServiceInterface $combatLogService): int

return $this->parseCombatLogRecursively($filePath, function (string $filePath) use ($combatLogService, $force, $dungeonOrRaid) {
if (!str_contains($filePath, '.zip')) {
$this->comment(sprintf('Skipping file %s', $filePath));
$this->comment(sprintf('Skipping file %s (not a .zip file)', $filePath));

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxKillZoneController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private function saveKillZone(DungeonRoute $dungeonroute, array $data, bool $rec
// Bulk insert
KillZoneEnemy::insert($killZoneEnemies);

$killZone->setEnemiesCache(collect($validEnemyIds));
$killZone->setEnemiesAttributeCache(collect($validEnemyIds));
}

// May be null for mass request
Expand Down
9 changes: 5 additions & 4 deletions app/Http/Controllers/NpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ public function store(NpcFormRequest $request, Npc $npc = null)


$existingEnemyForces = 0;
if ($oldId !== null) {

// Now create new enemy forces. Default to 0, but can be set if we just changed the dungeon
if( $oldId === null ) {
$npc->createNpcEnemyForcesForExistingMappingVersions($existingEnemyForces);
} else {
Enemy::where('npc_id', $oldId)->update(['npc_id' => $npc->id]);
NpcEnemyForces::where('npc_id', $oldId)->update(['npc_id' => $npc->id]);

Expand All @@ -120,9 +124,6 @@ public function store(NpcFormRequest $request, Npc $npc = null)
}
}

// Now create new enemy forces. Default to 0, but can be set if we just changed the dungeon
$npc->createNpcEnemyForcesForExistingMappingVersions($existingEnemyForces);

// Broadcast notifications so that any open mapping sessions get these changes immediately
// If no dungeon is set, user selected 'All Dungeons'
$npcAllDungeon = ($npc->dungeon === null);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Requests/EnemyPatrol/EnemyPatrolFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public function rules(): array
{
return [
'id' => 'int',
'mapping_version_id' => ['required', Rule::exists(MappingVersion::class, 'id')],
'floor_id' => ['required', Rule::exists(Floor::class, 'id')],
'mapping_version_id' => ['required', 'int', Rule::exists(MappingVersion::class, 'id')],
'floor_id' => ['required', 'int', Rule::exists(Floor::class, 'id')],
'polyline_id' => ['nullable', Rule::exists(Polyline::class, 'id')],
'teeming' => [Rule::in(array_merge(Enemy::TEEMING_ALL, ['', null]))],
'faction' => [Rule::in(array_merge(array_keys(Faction::ALL), ['any']))],
Expand Down
7 changes: 3 additions & 4 deletions app/Http/Requests/NpcFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Dungeon;
use App\Models\Npc;
use App\Models\NpcClass;
use App\Models\NpcClassification;
use Auth;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
Expand All @@ -28,12 +29,12 @@ public function authorize(): bool
*/
public function rules(): array
{
$rules = [
return [
'id' => 'required',
'name' => 'required',
'dungeon_id' => [Rule::in([-1] + Dungeon::all()->pluck('id')->toArray())],
'npc_class_id' => Rule::in(array_values(NpcClass::ALL)),
'classification_id' => 'required',
'classification_id' => [Rule::in(NpcClassification::ALL), 'required'],
'aggressiveness' => Rule::in(Npc::ALL_AGGRESSIVENESS),
'base_health' => [
'required',
Expand All @@ -48,7 +49,5 @@ public function rules(): array
'bolstering_whitelist_npcs' => 'array',
'spells' => 'array',
];

return $rules;
}
}
122 changes: 122 additions & 0 deletions app/Logic/Structs/IngameXY.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php

namespace App\Logic\Structs;

use App\Models\Floor;

class IngameXY
{
private float $x;

private float $y;

private ?Floor $floor;

private ?LatLng $latLng = null;

/**
* @param float $x
* @param float $y
* @param Floor|null $floor
*/
public function __construct(float $x = 0, float $y = 0, ?Floor $floor = null)
{
$this->x = $x;
$this->y = $y;
$this->floor = $floor;
}

/**
* @return float
*/
public function getX(): float
{
return $this->x;
}

/**
* @param float $x
*
* @return IngameXY
*/
public function setX(float $x): IngameXY
{
$this->x = $x;
return $this;
}

/**
* @return float
*/
public function getY(): float
{
return $this->y;
}

/**
* @param float $y
*
* @return IngameXY
*/
public function setY(float $y): IngameXY
{
$this->y = $y;
return $this;
}

/**
* @return Floor|null
*/
public function getFloor(): ?Floor
{
return $this->floor;
}

/**
* @param Floor|null $floor
*
* @return IngameXY
*/
public function setFloor(?Floor $floor): IngameXY
{
$this->floor = $floor;
return $this;
}

/**
* @return LatLng
*/
public function getLatLng(): ?LatLng
{
return $this->latLng ?? ($this->latLng = $this->calculateLatLng());
}

/**
* @return LatLng|null
*/
private function calculateLatLng(): ?LatLng
{
$result = null;

if ($this->floor !== null) {
$latLng = $this->floor->calculateMapLocationForIngameLocation(
$this->x,
$this->y
);
$result = LatLng::fromArray($latLng, $this->floor);
}

return $result;
}

/**
* @param array $ingameXY
* @param Floor|null $floor
*
* @return IngameXY
*/
public static function fromArray(array $ingameXY, ?Floor $floor): IngameXY
{
return new IngameXY($ingameXY['x'], $ingameXY['y'], $floor);
}
}
123 changes: 123 additions & 0 deletions app/Logic/Structs/LatLng.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

namespace App\Logic\Structs;

use App\Models\Floor;

class LatLng
{
private float $lat;

private float $lng;

private ?Floor $floor;

private ?IngameXY $ingameXY = null;

/**
* @param float $lat
* @param float $lng
* @param Floor|null $floor
*/
public function __construct(float $lat = 0, float $lng = 0, ?Floor $floor = null)
{
$this->lat = $lat;
$this->lng = $lng;
$this->floor = $floor;
}

/**
* @return float
*/
public function getLat(): float
{
return $this->lat;
}

/**
* @param float $lat
*
* @return LatLng
*/
public function setLat(float $lat): LatLng
{
$this->lat = $lat;
return $this;
}

/**
* @return float
*/
public function getLng(): float
{
return $this->lng;
}

/**
* @param float $lng
*
* @return LatLng
*/
public function setLng(float $lng): LatLng
{
$this->lng = $lng;
return $this;
}

/**
* @return Floor|null
*/
public function getFloor(): ?Floor
{
return $this->floor;
}

/**
* @param Floor|null $floor
*
* @return LatLng
*/
public function setFloor(?Floor $floor): LatLng
{
$this->floor = $floor;
return $this;
}

/**
* @return IngameXY|null
*/
public function getIngameXY(): ?IngameXY
{
return $this->ingameXY ?? ($this->ingameXY = $this->calculateIngameCoordinates());
}

/**
* @return void
*/
private function calculateIngameCoordinates(): ?IngameXY
{
$result = null;

if ($this->floor !== null) {
$ingameXY = $this->floor->calculateIngameLocationForMapLocation(
$this->lat,
$this->lng
);

$result = IngameXY::fromArray($ingameXY, $this->floor);
}

return $result;
}

/**
* @param array $latLng
* @param Floor|null $floor
*
* @return LatLng
*/
public static function fromArray(array $latLng, ?Floor $floor): LatLng
{
return new LatLng($latLng['lat'], $latLng['lng'], $floor);
}
}
Loading

0 comments on commit ff8b7e0

Please sign in to comment.