Core/Items: implement some helper methods for easier readability

Port From (https://github.com/TrinityCore/TrinityCore/commit/9124fd1f1fafea19b118eb69c6a35f94376fc7e8)
This commit is contained in:
hondacrx
2022-01-06 10:57:06 -05:00
parent 8f8cd4a7d4
commit 6e0becd106
23 changed files with 105 additions and 100 deletions
+5 -5
View File
@@ -35,7 +35,7 @@ namespace Game.Loots
conditions = li.conditions;
ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(itemid);
freeforall = proto != null && proto.GetFlags().HasAnyFlag(ItemFlags.MultiDrop);
freeforall = proto != null && proto.HasFlag(ItemFlags.MultiDrop);
follow_loot_rules = proto != null && proto.FlagsCu.HasAnyFlag(ItemFlagsCustom.FollowLootRules);
needs_quest = li.needs_quest;
@@ -54,10 +54,10 @@ namespace Game.Loots
return false;
// not show loot for not own team
if (pProto.GetFlags2().HasAnyFlag(ItemFlags2.FactionHorde) && player.GetTeam() != Team.Horde)
if (pProto.HasFlag(ItemFlags2.FactionHorde) && player.GetTeam() != Team.Horde)
return false;
if (pProto.GetFlags2().HasAnyFlag(ItemFlags2.FactionAlliance) && player.GetTeam() != Team.Alliance)
if (pProto.HasFlag(ItemFlags2.FactionAlliance) && player.GetTeam() != Team.Alliance)
return false;
// Master looter can see certain items even if the character can't loot them
@@ -71,7 +71,7 @@ namespace Game.Loots
}
// Don't allow loot for players without profession or those who already know the recipe
if (pProto.GetFlags().HasFlag(ItemFlags.HideUnusableRecipe))
if (pProto.HasFlag(ItemFlags.HideUnusableRecipe))
{
if (!player.HasSkill((SkillType)pProto.GetRequiredSkill()))
return false;
@@ -231,7 +231,7 @@ namespace Game.Loots
// non-conditional one-player only items are counted here,
// free for all items are counted in FillFFALoot(),
// non-ffa conditionals are counted in FillNonQuestNonFFAConditionalLoot()
if (!item.needs_quest && item.conditions.Empty() && !proto.GetFlags().HasAnyFlag(ItemFlags.MultiDrop))
if (!item.needs_quest && item.conditions.Empty() && !proto.HasFlag(ItemFlags.MultiDrop))
++unlootedCount;
}
}
+3 -3
View File
@@ -203,7 +203,7 @@ namespace Game.Loots
// remove real entries and check existence loot
var its = Global.ObjectMgr.GetItemTemplates();
foreach (var pair in its)
if (lootIdSet.Contains(pair.Value.GetId()) && pair.Value.GetFlags().HasAnyFlag(ItemFlags.HasLoot))
if (lootIdSet.Contains(pair.Value.GetId()) && pair.Value.HasFlag(ItemFlags.HasLoot))
lootIdSet.Remove(pair.Value.GetId());
// output error for any still listed (not referenced from appropriate table) ids
@@ -228,7 +228,7 @@ namespace Game.Loots
var its = Global.ObjectMgr.GetItemTemplates();
foreach (var pair in its)
{
if (!pair.Value.GetFlags().HasAnyFlag(ItemFlags.IsMillable))
if (!pair.Value.HasFlag(ItemFlags.IsMillable))
continue;
if (lootIdSet.Contains(pair.Value.GetId()))
@@ -293,7 +293,7 @@ namespace Game.Loots
var its = Global.ObjectMgr.GetItemTemplates();
foreach (var pair in its)
{
if (!pair.Value.GetFlags().HasAnyFlag(ItemFlags.IsProspectable))
if (!pair.Value.HasFlag(ItemFlags.IsProspectable))
continue;
if (lootIdSet.Contains(pair.Value.GetId()))