Files
Main/Assets/GameAssets/Resources/Lua/Logic/AuctionHouse/AuctionItem.lua

177 lines
5.5 KiB
Lua
Raw Normal View History

2025-01-25 04:38:09 +08:00
------------------------------------------------
--作者: 杨全福
--日期: 2021-02-23
--文件: AuctionItem.lua
--模块: AuctionItem
--描述: 拍卖行道具
------------------------------------------------
local L_ItemCache = List:New()
local AuctionItem = {
--是否锁定锁定的不能被free
IsLocked = false,
--上架人ID
OwnerID = 0,
--物品唯一ID
ID = 0,
--物品配置ID
CfgID = 0,
--物品实例
ItemInst = nil,
--所属公会
OwnerGuild = 0,
--当前价格
CurPrice = 0,
--当前出价人ID
CurPriceOwner = 0,
--自身是否是出价最高的
IsSelfPriceOwner = false,
--参与过竞价的玩家列表
JionPlayerList = nil,
--自身是否参与了竞价
IsSefJion = false,
--最低竞价
MinPrice = 0,
--竞拍增加值类型0价格1万分比
SinglePriceType = 0,
--每次竞价增加值
SinglePrice = 0,
--一口价
MaxPrice = 0,
--是否有开始CD
HaveStartCD = false,
--物品配置
ItemCfg = nil,
--装备配置
EquipCfg = nil,
--拍卖总时间
AuctionAllTime = 0,
--剩余时间
ServerRemainTime = 0,
--同步的时间
SyncTime = 0,
--是否有密码
HasMiMa = false,
--使用的货币配置
UseCoinCfg = nil,
--使用的拍卖类型0固定价格1自定义价格
UsePriceType = 0,
}
function AuctionItem.Get()
local _m = nil
local _haveCount = #L_ItemCache
if _haveCount > 0 then
_m = L_ItemCache[_haveCount]
L_ItemCache:RemoveAt(_haveCount)
else
_m = Utils.DeepCopy(AuctionItem)
end
return _m
end
function AuctionItem.Free(item, force)
if item.IsLocked and not force then
return
end
item.ItemInst = nil
item.ID = 0
item.CfgID = 0
item.OwnerID = 0
item.ServerRemainTime = 0
item.SyncTime = 0
item.CurPrice = 0
item.CurPriceOwner = 0
item.ItemCfg = nil
item.EquipCfg = nil
item.HasMiMa = false
L_ItemCache:Add(item)
end
--刷新数据
function AuctionItem:RefreshData(msgInfo)
local _lpId = GameCenter.GameSceneSystem:GetLocalPlayerID()
self.ItemInst = LuaItemBase.CreateItemBaseByMsg(msgInfo.item)
self.CfgID = self.ItemInst.CfgID
self.OwnerGuild = msgInfo.guildId
self.ID = msgInfo.id
self.OwnerID = msgInfo.ownId
self.ServerRemainTime = msgInfo.time
self.SyncTime = Time.GetRealtimeSinceStartup()
self.CurPrice = msgInfo.price
self.CurPriceOwner = msgInfo.roleId
self.IsSelfPriceOwner = (self.CurPriceOwner == _lpId)
self.HasMiMa = msgInfo.isPassword
self.JionPlayerList = {}
if self.CurPriceOwner > 0 then
self.JionPlayerList[self.CurPriceOwner] = true
end
if msgInfo.roleIds ~= nil then
for i = 1, #msgInfo.roleIds do
self.JionPlayerList[msgInfo.roleIds[i]] = true
end
end
local _itemCount = self.ItemInst.Count
self.IsSefJion = self.JionPlayerList[_lpId] or false
if self.ItemInst.Type == ItemType.Equip or self.ItemInst.Type == ItemType.HolyEquip or self.ItemInst.Type == ItemType.UnrealEquip then
self.EquipCfg = DataConfig.DataEquip[self.CfgID]
if self.EquipCfg ~= nil then
self.MinPrice = self.EquipCfg.AuctionMinPrice * _itemCount
self.SinglePrice = self.EquipCfg.AuctionSinglePrice * _itemCount
self.SinglePriceType = self.EquipCfg.AuctionSingleType
self.MaxPrice = self.EquipCfg.AuctionMaxPrice * _itemCount
--有交易密码时不会有开始cd
self.HaveStartCD = self.EquipCfg.AuctionCountdown ~= 0 and not self.HasMiMa
if self.OwnerGuild > 0 then
--仙盟拍卖
self.AuctionAllTime = self.EquipCfg.AuctionGuildAllTime
else
--世界拍卖
self.AuctionAllTime = self.EquipCfg.AuctionAllTime
end
self.UseCoinCfg = DataConfig.DataItem[self.EquipCfg.AuctionUseCoin]
self.UsePriceType = self.EquipCfg.AuctionPriceType
end
else
self.ItemCfg = DataConfig.DataItem[self.CfgID]
if self.ItemCfg ~= nil then
self.MinPrice = self.ItemCfg.AuctionMinPrice * _itemCount
self.SinglePrice = self.ItemCfg.AuctionSinglePrice * _itemCount
self.SinglePriceType = self.ItemCfg.AuctionSingleType
self.MaxPrice = self.ItemCfg.AuctionMaxPrice * _itemCount
--有交易密码时不会有开始cd
self.HaveStartCD = self.ItemCfg.AuctionCountdown ~= 0 and not self.HasMiMa
if self.OwnerGuild > 0 then
--仙盟拍卖
self.AuctionAllTime = self.ItemCfg.AuctionGuildAllTime
else
--世界拍卖
self.AuctionAllTime = self.ItemCfg.AuctionAllTime
end
self.UseCoinCfg = DataConfig.DataItem[self.ItemCfg.AuctionUseCoin]
self.UsePriceType = self.ItemCfg.AuctionPriceType
end
end
if self.CurPrice <= 0 then
self.CurPrice = self.MinPrice
end
end
--刷新假数据
function AuctionItem:RefreshTempData(msgInfo)
--时间设置为最大
self.ServerRemainTime = self.AuctionAllTime
self.SyncTime = Time.GetRealtimeSinceStartup()
--价格设置为最后一次竞价的价格
self.CurPrice = self.MaxPrice - self.SinglePrice
CurPriceOwner = 1
end
--剩余时间
function AuctionItem:GetRemainTime()
return self.ServerRemainTime - (Time.GetRealtimeSinceStartup() - self.SyncTime)
end
return AuctionItem