ro-table/Asstes/Resources/Script/Util/EnchantEquipUtil.txt
2025-06-04 05:02:57 +08:00

269 lines
8.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

EnchantEquipTypeRateMap = {
[170] = "SpearRate", -- 170对应的是“Spears”的增强率可能是某种矛类武器的强化
[180] = "SwordRate", -- 180对应的是“Sword”的增强率代表剑类武器的强化
[190] = "StaffRate", -- 190对应的是“Staff”的增强率代表法杖类武器的强化
[200] = "KatarRate", -- 200对应的是“Katar”的增强率Katar是短剑类武器的名字
[210] = "BowRate", -- 210对应的是“Bow”的增强率代表弓类武器的强化
[220] = "MaceRate", -- 220对应的是“Mace”的增强率代表锤类武器的强化
[230] = "AxeRate", -- 230对应的是“Axe”的增强率代表斧类武器的强化
[240] = "BookRate", -- 240对应的是“Book”的增强率代表书类物品的强化
[250] = "KnifeRate", -- 250对应的是“Knife”的增强率代表刀类武器的强化
[260] = "InstrumentRate",-- 260对应的是“Instrument”的增强率代表乐器类物品的强化
[270] = "LashRate", -- 270对应的是“Lash”的增强率可能是鞭子类武器的强化
[280] = "PotionRate", -- 280对应的是“Potion”的增强率可能是药水类物品的强化
[290] = "GloveRate", -- 290对应的是“Glove”的增强率代表手套类物品的强化
[500] = "ArmorRate", -- 500对应的是“Armor”的增强率代表盔甲类物品的强化
[510] = "ShieldRate", -- 510对应的是“Shield”的增强率代表盾牌类物品的强化
[520] = "RobeRate", -- 520对应的是“Robe”的增强率代表长袍类物品的强化
[530] = "ShoeRate", -- 530对应的是“Shoe”的增强率代表鞋类物品的强化
[540] = "AccessoryRate", -- 540对应的是“Accessory”的增强率代表饰品类物品的强化
[511] = "OrbRate", -- 511对应的是“Orb”的增强率代表宝珠类物品的强化
[512] = "EikonRate", -- 512对应的是“Eikon”的增强率可能是指某种饰品或符文的强化
[513] = "BracerRate", -- 513对应的是“Bracer”的增强率代表护腕类物品的强化
[514] = "BraceletRate", -- 514对应的是“Bracelet”的增强率代表手链类物品的强化
[515] = "TrolleyRate", -- 515对应的是“Trolley”的增强率可能是与交通工具相关的物品的强化
[800] = "HeadRate", -- 800对应的是“Head”的增强率代表头部装备类物品的强化
[810] = "WingRate", -- 810对应的是“Wing”的增强率代表翅膀类物品的强化
[830] = "FaceRate", -- 830对应的是“Face”的增强率代表面部装备类物品的强化
[840] = "TailRate", -- 840对应的是“Tail”的增强率代表尾部装备类物品的强化
[850] = "MouthRate", -- 850对应的是“Mouth”的增强率代表口部装备类物品的强化
}
EnchantMenuType = {
Default = 0,
SixBaseAttri = 1,
BaseAttri = 2,
DefAttri = 3,
CombineAttri = 4,
}
Enchant1rdAttri = {
"Str","Agi","Vit","Int","Dex","Luk",
}
Enchant2rdAttri = {
"Hp","Sp",
"MaxHp","MaxHpPer",
"MaxSp","MaxSpPer",
"Atk","AtkPer",
"MAtk","MAtkPer",
"Def","DefPer",
"MDef","MDefPer",
"Hit","Cri","Flee","AtkSpd",
"CriRes", "CriDamPer",
"CriDefPer", "HealEncPer",
"BeHealEncPer", "DamIncrease",
"DamReduc", "DamRebound",
"MDamRebound", "Vampiric",
"EquipASPD",
}
Enchant3rdAttri = {
"SilenceDef",
"FreezeDef",
"StoneDef",
"StunDef",
"BlindDef",
"PoisonDef",
"SlowDef",
"ChaosDef",
"CurseDef",
}
-------------------------------------------------------------------------
EnchantData = class("EnchantData");
function EnchantData:ctor()
self.datas = {};
end
-- return with canGet
function EnchantData:Get(itemType)
local rateKey = itemType and EnchantEquipTypeRateMap[itemType]
if(not rateKey)then
return self.datas[1], false;
end
for i=#self.datas,1,-1 do
if(EnchantData.CanGet(self.datas[i], itemType))then
return self.datas[i], true;
end
end
-- 預設返回第一條
return self.datas[1], false;
end
function EnchantData:Add( equipEnchant_config )
table.insert(self.datas, equipEnchant_config);
end
function EnchantData.CanGet( data, itemType )
local rateKey = itemType and EnchantEquipTypeRateMap[itemType]
if(not rateKey)then
return false;
end
local cantEnchantMap = data.CantEnchant;
if(cantEnchantMap[rateKey] ~= 1)then
return true;
end
return false;
end
-------------------------------------------------------------------------
EnchantEquipUtil = class("EnchantEquipUtil");
EnchantEquipUtil.Instance = nil
function EnchantEquipUtil:ctor()
self:Init();
EnchantEquipUtil.Instance = self;
end
function EnchantEquipUtil:Init()
self.dataMap = {};
self.combineEffectMap = {};
for typeKey, enchantType in pairs(EnchantType)do
self.dataMap[enchantType] = {};
self.combineEffectMap[enchantType] = {};
end
self.costMap = {};
for key,data in pairs(Table_EquipEnchant)do
local enchantData = self.dataMap[data.EnchantType][data.AttrType];
if(enchantData == nil)then
enchantData = EnchantData.new();
self.dataMap[data.EnchantType][data.AttrType] = enchantData;
end
enchantData:Add(data);
local key,value = next(data.AttrType2);
if(key and value and data.ComBineAttr~="")then
table.insert(self.combineEffectMap[data.EnchantType], data);
end
if(not self.costMap[data.EnchantType])then
self.costMap[data.EnchantType] = {};
self.costMap[data.EnchantType].ItemCost = data.ItemCost;
self.costMap[data.EnchantType].ZenyCost = data.ZenyCost;
end
end
self.priceRateMap = {};
local priceConfig = Table_EquipEnchantPrice or {};
for _,data in pairs(priceConfig)do
if(data.AttrType)then
self.priceRateMap[data.AttrType] = data;
end
end
end
function EnchantEquipUtil:GetEnchantDatasByEnchantType(enchantType)
return self.dataMap[enchantType];
end
function EnchantEquipUtil:GetEnchantData(enchantType, attri, itemType)
if(not attri or not enchantType)then
errorLog(string.format("GetEnchantData Parama Error (%s %s)", tostring(enchantType), tostring(attri)));
return;
end
local edatas = self.dataMap[enchantType];
if(edatas == nil)then
return;
end
local enchantData = edatas[ attri ];
if(enchantData == nil)then
return;
end
return enchantData:Get(itemType);
end
function EnchantEquipUtil:GetAttriPropVO(attriType)
local pro = RolePropsContainer.config[attriType];
if(nil == pro)then
errorLog(string.format("NO This Attri %s", tostring(attriType)));
end
return pro;
end
function EnchantEquipUtil:GetMenuType(attriType)
for pos,type in pairs(Enchant1rdAttri)do
if(attriType == type)then
return EnchantMenuType.SixBaseAttri, pos;
end
end
for pos,type in pairs(Enchant2rdAttri)do
if(attriType == type)then
return EnchantMenuType.BaseAttri, pos;
end
end
for pos,type in pairs(Enchant3rdAttri)do
if(attriType == type)then
return EnchantMenuType.DefAttri, pos;
end
end
errorLog(string.format("(%s) Not Config In EnchantEquipUtil'TopConfig", attriType));
return EnchantMenuType.Default, 1;
end
function EnchantEquipUtil:GetEnchantCost(enchantType)
return self.costMap[enchantType];
end
function EnchantEquipUtil:GetCombineEffects(enchantType)
return self.combineEffectMap[enchantType];
end
function EnchantEquipUtil:GetCombineEffect(uniqueId)
for _,data in pairs(Table_EquipEnchant) do
if(data.UniqID == uniqueId)then
return data;
end
end
return nil;
end
function EnchantEquipUtil:GetPriceRate(attriType, itemType)
if(attriType)then
local data = self.priceRateMap[attriType];
if(data)then
local key = EnchantEquipTypeRateMap[itemType];
if(data[key])then
return data[key]
end
end
end
return 0;
end
function EnchantEquipUtil:CanGetCombineEffect(data, itemType)
local canGet1 = EnchantData.CanGet( data, itemType )
if(not canGet1)then
return;
end
local attri2 = data.AttrType2[1];
if(attri2 == nil)then
return canGet1;
end
local rateKey = itemType and EnchantEquipTypeRateMap[itemType]
if(not rateKey or data.NoShowEquip[rateKey] == 1)then
return false;
end
local enchantType = data.EnchantType;
local data2, canGet2 = self:GetEnchantData(enchantType, attri2, itemType)
if(data2 == nil)then
return false;
end
return canGet2;
end