Spells/Reagents

* always check all reagent fields, they are not set first to last
This commit is contained in:
Sarjuuk
2024-05-05 14:31:15 +02:00
parent 92c51237c6
commit 6b25288e2b
20 changed files with 49 additions and 43 deletions

View File

@@ -461,17 +461,20 @@ abstract class BaseType
trait listviewHelper
{
public function hasSetFields($fields)
public function hasSetFields(?string ...$fields) : int
{
if (!is_array($fields))
return 0x0;
$result = 0x0;
foreach ($this->iterate() as $__)
{
foreach ($fields as $k => $str)
{
if (!$str)
{
unset($fields[$k]);
continue;
}
if ($this->getField($str))
{
$result |= 1 << $k;
@@ -489,11 +492,8 @@ trait listviewHelper
return $result;
}
public function hasDiffFields($fields)
public function hasDiffFields(?string ...$fields) : int
{
if (!is_array($fields))
return 0x0;
$base = [];
$result = 0x0;
@@ -504,6 +504,12 @@ trait listviewHelper
{
foreach ($fields as $k => $str)
{
if (!$str)
{
unset($fields[$k]);
continue;
}
if ($base[$str] != $this->getField($str))
{
$result |= 1 << $k;

View File

@@ -574,7 +574,7 @@ class Loot
if (!empty($result))
$tabsFinal[16][4][] = '$Listview.extraCols.percent';
if ($srcObj->hasSetFields(['reagent1']))
if ($srcObj->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8'))
$tabsFinal[16][6][] = 'reagents';
foreach ($srcObj->iterate() as $_)

View File

@@ -98,7 +98,7 @@ class AchievementsPage extends GenericPage
$this->extendGlobalData($acvList->getJSGlobals());
// if we are have different cats display field
if ($acvList->hasDiffFields(['category']))
if ($acvList->hasDiffFields('category'))
$tabData['visibleCols'] = ['category'];
if (!empty($this->filter['fi']['extraCols']))

View File

@@ -104,7 +104,7 @@ class ArenaTeamsPage extends GenericPage
{
$teams->initializeLocalEntries();
$dFields = $teams->hasDiffFields(['faction', 'type']);
$dFields = $teams->hasDiffFields('faction', 'type');
if (!($dFields & 0x1))
$tabData['hiddenCols'][] = 'faction';

View File

@@ -162,7 +162,7 @@ class ClassPage extends GenericPage
$this->extendGlobalData($items->getJSGlobals());
$hiddenCols = null;
if ($items->hasDiffFields(['requiredRace']))
if ($items->hasDiffFields('requiredRace'))
$hiddenCols = ['side'];
$this->lvTabs[] = [ItemList::$brickFile, array(

View File

@@ -180,7 +180,7 @@ class CurrencyPage extends GenericPage
'id' => 'created-by',
);
if ($createdBy->hasSetFields(['reagent1']))
if ($createdBy->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8'))
$tabData['visibleCols'] = ['reagents'];
$this->lvTabs[] = [SpellList::$brickFile, $tabData];

View File

@@ -81,7 +81,7 @@ class EnchantmentsPage extends GenericPage
if (array_filter(array_column($tabData['data'], 'spells')))
$tabData['visibleCols'] = ['trigger'];
if (!$ench->hasSetFields(['skillLine']))
if (!$ench->hasSetFields('skillLine'))
$tabData['hiddenCols'] = ['skill'];
if ($this->filterObj->error)

View File

@@ -97,7 +97,7 @@ class GuildsPage extends GenericPage
{
$guilds->initializeLocalEntries();
$dFields = $guilds->hasDiffFields(['faction', 'type']);
$dFields = $guilds->hasDiffFields('faction', 'type');
if (!($dFields & 0x1))
$tabData['hiddenCols'][] = 'faction';

View File

@@ -571,7 +571,7 @@ class ItemPage extends genericPage
$this->extendGlobalData($contains->getJSGlobals(GLOBALINFO_SELF));
$hCols = ['side'];
if (!$contains->hasSetFields(['slot']))
if (!$contains->hasSetFields('slot'))
$hCols[] = 'slot';
$this->lvTabs[] = [ItemList::$brickFile, array(
@@ -618,7 +618,7 @@ class ItemPage extends genericPage
'visibleCols' => ['category']
);
if (!$criteriaOf->hasSetFields(['reward_loc0']))
if (!$criteriaOf->hasSetFields('reward_loc0'))
$tabData['hiddenCols'] = ['rewards'];
$this->lvTabs[] = [AchievementList::$brickFile, $tabData];
@@ -927,7 +927,7 @@ class ItemPage extends genericPage
$this->extendGlobalData($taughtSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
$visCols = ['level', 'schools'];
if ($taughtSpells->hasSetFields(['reagent1']))
if ($taughtSpells->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8'))
$visCols[] = 'reagents';
$this->lvTabs[] = [SpellList::$brickFile, array(

View File

@@ -370,7 +370,7 @@ class ItemsPage extends GenericPage
}
if (!empty($this->filterObj->getSetWeights()))
if ($items->hasSetFields(['armor']))
if ($items->hasSetFields('armor'))
$tabData['visibleCols'][] = 'armor';
// create note if search limit was exceeded; overwriting 'note' is intentional

View File

@@ -229,7 +229,7 @@ class ItemsetPage extends GenericPage
'name' => '$LANG.tab_seealso'
);
if (!$relSets->hasDiffFields(['classMask']))
if (!$relSets->hasDiffFields('classMask'))
$tabData['hiddenCols'] = ['classes'];
$this->lvTabs[] = [ItemsetList::$brickFile, $tabData];

View File

@@ -639,7 +639,7 @@ class NpcPage extends GenericPage
{
$colAddIn = null;
$extraCols = ["\$Listview.funcBox.createSimpleCol('stack', 'stack', '10%', 'stack')", '$Listview.extraCols.cost'];
if ($soldItems->hasSetFields(['condition']))
if ($soldItems->hasSetFields('condition'))
$extraCols[] = '$Listview.extraCols.condition';
$lvData = $soldItems->getListviewData(ITEMINFO_VENDOR, [Type::NPC => [$this->typeId]]);

View File

@@ -59,7 +59,7 @@ class ObjectsPage extends GenericPage
if (!$objects->error)
{
$tabData['data'] = array_values($objects->getListviewData());
if ($objects->hasSetFields(['reqSkill']))
if ($objects->hasSetFields('reqSkill'))
$tabData['visibleCols'] = ['skill'];
// create note if search limit was exceeded

View File

@@ -48,7 +48,7 @@ class PetsPage extends GenericPage
'computeDataFunc' => '$_'
);
if (!$pets->hasDiffFields(['type']))
if (!$pets->hasDiffFields('type'))
$data['hiddenCols'] = ['type'];
};
$this->lvTabs[] = [PetList::$brickFile, $data, 'petFoodCol'];

View File

@@ -140,7 +140,7 @@ class ProfilesPage extends GenericPage
// init roster-listview
// $_GET['roster'] = 1|2|3|4 originally supplemented this somehow .. 2,3,4 arenateam-size (4 => 5-man), 1 guild
if ($this->roster == 1 && !$profiles->hasDiffFields(['guild']) && $profiles->getField('guild'))
if ($this->roster == 1 && !$profiles->hasDiffFields('guild') && $profiles->getField('guild'))
{
$tabData['roster'] = $this->roster;
$tabData['visibleCols'][] = 'guildrank';
@@ -148,7 +148,7 @@ class ProfilesPage extends GenericPage
$this->roster = Lang::profiler('guildRoster', [$profiles->getField('guildname')]);
}
else if ($this->roster && !$profiles->hasDiffFields(['arenateam']) && $profiles->getField('arenateam'))
else if ($this->roster && !$profiles->hasDiffFields('arenateam') && $profiles->getField('arenateam'))
{
$tabData['roster'] = $this->roster;
$tabData['visibleCols'][] = 'rating';

View File

@@ -647,7 +647,7 @@ class SearchPage extends GenericPage
}
$vis = ['level', 'schools'];
if ($abilities->hasSetFields(['reagent1']))
if ($abilities->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8'))
$vis[] = 'reagents';
$vis[] = $multiClass > 1 ? 'classes' : 'singleclass';
@@ -700,7 +700,7 @@ class SearchPage extends GenericPage
$this->extendGlobalData($talents->getJSGlobals());
$vis = ['level', 'singleclass', 'schools'];
if ($talents->hasSetFields(['reagent1']))
if ($talents->hasSetFields('reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8'))
$vis[] = 'reagents';
$osInfo = [Type::SPELL, ' (Talent)', $talents->getMatches(), [], []];
@@ -1353,7 +1353,7 @@ class SearchPage extends GenericPage
if (array_filter(array_column($result['data'], 'spells')))
$result['visibleCols'] = ['trigger'];
if (!$enchantment->hasSetFields(['skillLine']))
if (!$enchantment->hasSetFields('skillLine'))
$result['hiddenCols'] = ['skill'];
if ($enchantment->getMatches() > $this->maxResults)

View File

@@ -374,7 +374,7 @@ class SpellPage extends GenericPage
'visibleCols' => ['level'],
);
if (!$abilities->hasSetFields(['skillLines']))
if (!$abilities->hasSetFields('skillLines'))
$tabData['hiddenCols'] = ['skill'];
$this->lvTabs[] = [SpellList::$brickFile, $tabData];
@@ -432,7 +432,7 @@ class SpellPage extends GenericPage
}
$modifiesData += $modSpells->getListviewData();
if ($modSpells->hasSetFields(['skillLines']))
if ($modSpells->hasSetFields('skillLines'))
$hideSkillCol = false;
$this->extendGlobalData($modSpells->getJSGlobals(GLOBALINFO_SELF | GLOBALINFO_RELATED));
@@ -500,7 +500,7 @@ class SpellPage extends GenericPage
'visibleCols' => ['level'],
);
if (!$modsSpell->hasSetFields(['skillLines']))
if (!$modsSpell->hasSetFields('skillLines'))
$tabData['hiddenCols'] = ['skill'];
$this->lvTabs[] = [SpellList::$brickFile, $tabData];
@@ -562,7 +562,7 @@ class SpellPage extends GenericPage
'visibleCols' => ['level'],
);
if (!$saSpells->hasSetFields(['skillLines']))
if (!$saSpells->hasSetFields('skillLines'))
$tabData['hiddenCols'] = ['skill'];
if (isset($saE))
@@ -812,7 +812,7 @@ class SpellPage extends GenericPage
foreach ($data as $k => $d)
$data[$k]['stackRule'] = $groups[$k];
if (!$stacks->hasSetFields(['skillLines']))
if (!$stacks->hasSetFields('skillLines'))
$sH = ['skill'];
$tabData = array(
@@ -1100,7 +1100,7 @@ class SpellPage extends GenericPage
'visibleCols' => $vis,
);
if (!$teaches->hasSetFields(['skillLines']))
if (!$teaches->hasSetFields('skillLines'))
$tabData['hiddenCols'] = ['skill'];
$this->lvTabs[] = [SpellList::$brickFile, $tabData];

View File

@@ -446,15 +446,15 @@ class SpellsPage extends GenericPage
$tabData['_errors'] = 1;
$mask = $spells->hasSetFields(['reagent1', 'skillLines', 'trainingCost', 'reqClassMask']);
if ($mask & 0x1)
$visibleCols[] = 'reagents';
if (!($mask & 0x2) && $this->category && !in_array($this->category[0], [9, 11]))
$mask = $spells->hasSetFields('skillLines', 'trainingCost', 'reqClassMask', null, 'reagent1', 'reagent2', 'reagent3', 'reagent4', 'reagent5', 'reagent6', 'reagent7', 'reagent8');
if (!($mask & 0x1) && $this->category && !in_array($this->category[0], [9, 11]))
$hiddenCols[] = 'skill';
if ($mask & 0x4)
if ($mask & 0x2)
$visibleCols[] = 'trainingcost';
if (($mask & 0x8) && !in_array('singleclass', $visibleCols))
if (($mask & 0x4) && !in_array('singleclass', $visibleCols))
$visibleCols[] = 'classes';
if ($mask & 0xFF0)
$visibleCols[] = 'reagents';
if ($visibleCols)

View File

@@ -42,7 +42,7 @@ class TitlesPage extends GenericPage
{
$tabData['data'] = array_values($titles->getListviewData());
if ($titles->hasDiffFields(['category']))
if ($titles->hasDiffFields('category'))
$tabData['visibleCols'] = ['category'];
if (!$titles->hasAnySource())

View File

@@ -73,7 +73,7 @@ class ZonesPage extends GenericPage
$zones = new ZoneList($conditions);
if (!$zones->hasSetFields(['type']))
if (!$zones->hasSetFields('type'))
$hiddenCols[] = 'instancetype';
$tabData = ['data' => array_values($zones->getListviewData())];