Core/Conditions

* rewritten and moved to its own class, should be easier to expand in the future
 * add missing sources and types from TrinityCore
 * implement conditions on Areatrigger and Loot containers
 * implement reverse lookups (e.g. a spell is a conditional for something else)
 * general beautification pass .. should be more legible in general

NOTE:
 * texts have been changed, so the existing translation for esES ist gone
 * selecting and describing condition targets is still wonky
This commit is contained in:
Sarjuuk
2024-04-01 21:33:09 +02:00
parent 84555afae3
commit bc7d561da2
26 changed files with 2158 additions and 1272 deletions

View File

@@ -230,7 +230,7 @@ class ObjectPage extends GenericPage
$relBoss = null;
if ($ll = DB::Aowow()->selectRow('SELECT * FROM ?_loot_link WHERE objectId = ?d ORDER BY priority DESC LIMIT 1', $this->typeId))
if ($ll = DB::Aowow()->selectRow('SELECT * FROM ?_loot_link WHERE `objectId` = ?d ORDER BY `priority` DESC LIMIT 1', $this->typeId))
{
// group encounter
if ($ll['encounterId'])
@@ -386,7 +386,6 @@ class ObjectPage extends GenericPage
}
// tab: contains
$reqQuest = [];
if ($_ = $this->subject->getField('lootId'))
{
$goLoot = new Loot();
@@ -397,24 +396,18 @@ class ObjectPage extends GenericPage
$hiddenCols = ['source', 'side', 'slot', 'reqlevel'];
$this->extendGlobalData($goLoot->jsGlobals);
$lootResult = $goLoot->getResult();
foreach ($goLoot->iterate() as &$lv)
foreach ($hiddenCols as $k => $str)
{
if (!empty($hiddenCols))
foreach ($hiddenCols as $k => $str)
if (!empty($lv[$str]))
unset($hiddenCols[$k]);
if (!$lv['quest'])
continue;
$extraCols[] = '$Listview.extraCols.condition';
$reqQuest[$lv['id']] = 0;
$lv['condition'][0][$this->typeId][] = [[CND_QUESTTAKEN, &$reqQuest[$lv['id']]]];
if ($k == 1 && array_filter(array_column($lootResult, $str), function ($x) { return $x != SIDE_BOTH; }))
unset($hiddenCols[$k]);
else if ($k != 1 && array_column($lootResult, $str))
unset($hiddenCols[$k]);
}
$tabData = array(
'data' => array_values($goLoot->getResult()),
'data' => array_values($lootResult),
'id' => 'contains',
'name' => '$LANG.tab_contains',
'sort' => ['-percent', 'name'],
@@ -422,36 +415,12 @@ class ObjectPage extends GenericPage
);
if ($hiddenCols)
$tabData['hiddenCols'] = $hiddenCols;
$tabData['hiddenCols'] = array_values($hiddenCols);
$this->lvTabs[] = [ItemList::$brickFile, $tabData];
}
}
if ($reqIds = array_keys($reqQuest)) // apply quest-conditions as back-reference
{
$conditions = array(
'OR',
['reqSourceItemId1', $reqIds], ['reqSourceItemId2', $reqIds],
['reqSourceItemId3', $reqIds], ['reqSourceItemId4', $reqIds],
['reqItemId1', $reqIds], ['reqItemId2', $reqIds], ['reqItemId3', $reqIds],
['reqItemId4', $reqIds], ['reqItemId5', $reqIds], ['reqItemId6', $reqIds]
);
$reqQuests = new QuestList($conditions);
$this->extendGlobalData($reqQuests->getJSGlobals());
foreach ($reqQuests->iterate() as $qId => $__)
{
if (empty($reqQuests->requires[$qId][Type::ITEM]))
continue;
foreach ($reqIds as $rId)
if (in_array($rId, $reqQuests->requires[$qId][Type::ITEM]))
$reqQuest[$rId] = $reqQuests->id;
}
}
// tab: Spell Focus for
if ($sfId = $this->subject->getField('spellFocusId'))
{