2024-09-01 20:49:41 +00:00
|
|
|
---@class XHomeFurnitureData
|
2023-07-14 19:35:33 +00:00
|
|
|
XHomeFurnitureData = XClass(nil, "XHomeFurnitureData")
|
|
|
|
|
|
|
|
function XHomeFurnitureData:Ctor(data)
|
|
|
|
self.Id = data.Id or 0
|
|
|
|
self.PlayerId = 0
|
|
|
|
self.ConfigId = data.ConfigId or 0
|
|
|
|
self.X = data.X
|
|
|
|
self.Y = data.Y
|
|
|
|
self.Angle = data.Angle
|
|
|
|
self.DormitoryId = data.DormitoryId or 0
|
|
|
|
self.Addition = data.Addition
|
|
|
|
self.AttrList = data.AttrList
|
|
|
|
self.IsLocked = data.IsLocked
|
2024-09-01 20:49:41 +00:00
|
|
|
self.BaseAttrList = data.BaseAttrList or {0, 0, 0} --基础属性分配
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetInstanceID()
|
|
|
|
return self.Id
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:SetConfigId(cfgId)
|
|
|
|
self.ConfigId = cfgId
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetConfigId()
|
|
|
|
return self.ConfigId
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:SetUsedDormitoryId(dormitoryId)
|
|
|
|
self.DormitoryId = dormitoryId
|
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
function XHomeFurnitureData:GetDormitoryId()
|
|
|
|
return self.DormitoryId
|
|
|
|
end
|
|
|
|
|
2023-07-14 19:35:33 +00:00
|
|
|
function XHomeFurnitureData:CheckIsUsed()
|
|
|
|
return self.DormitoryId > 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetScore()
|
|
|
|
local score = 0
|
|
|
|
if self.Addition > 0 then
|
|
|
|
score = score + XFurnitureConfigs.GetAdditionalAddScore(self.Addition)
|
|
|
|
end
|
|
|
|
|
|
|
|
for _, attr in ipairs(self.AttrList) do
|
|
|
|
score = score + attr
|
|
|
|
end
|
|
|
|
return score
|
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
function XHomeFurnitureData:GetAttrScore(attrType, attrScore)
|
2023-07-14 19:35:33 +00:00
|
|
|
local score = attrScore or 0
|
|
|
|
if self.Addition <= 0 then
|
|
|
|
return score
|
|
|
|
end
|
|
|
|
|
2024-09-01 20:49:41 +00:00
|
|
|
local additionConfig = XFurnitureConfigs.GetAdditionAttrConfigById(self.Addition)
|
2023-07-14 19:35:33 +00:00
|
|
|
if additionConfig == nil then
|
|
|
|
return score
|
|
|
|
end
|
|
|
|
|
|
|
|
if additionConfig.AddType == XFurnitureConfigs.FurnitureAdditionType.AttrTotal then
|
|
|
|
score = additionConfig.AddValue[attrType] + score
|
|
|
|
elseif additionConfig.AddType == XFurnitureConfigs.FurnitureAdditionType.AttrTotalPercent then
|
|
|
|
score = math.floor(additionConfig.AddValue[attrType] * score / 100) + score
|
|
|
|
end
|
|
|
|
|
|
|
|
return score
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetRedScore()
|
2024-09-01 20:49:41 +00:00
|
|
|
return self:GetAttrScore(XFurnitureConfigs.AttrType.AttrA, self.AttrList[XFurnitureConfigs.AttrType.AttrA])
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetYellowScore()
|
2024-09-01 20:49:41 +00:00
|
|
|
return self:GetAttrScore(XFurnitureConfigs.AttrType.AttrB, self.AttrList[XFurnitureConfigs.AttrType.AttrB])
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetBlueScore()
|
2024-09-01 20:49:41 +00:00
|
|
|
return self:GetAttrScore(XFurnitureConfigs.AttrType.AttrC, self.AttrList[XFurnitureConfigs.AttrType.AttrC])
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetFurnitureTotalAttrLevel()
|
|
|
|
if not XTool.IsNumberValid(self.ConfigId) then
|
|
|
|
return XFurnitureConfigs.FurnitureAttrLevelId.LevelC
|
|
|
|
end
|
|
|
|
local template = XFurnitureConfigs.GetFurnitureTemplateById(self.ConfigId)
|
|
|
|
local level, _, _ = XFurnitureConfigs.GetFurnitureTotalAttrLevel(template.TypeId, self:GetScore())
|
|
|
|
return level
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetIsLocked()
|
|
|
|
return self.IsLocked
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:SetIsLocked(isLocked)
|
|
|
|
self.IsLocked = isLocked
|
2024-09-01 20:49:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetSuitId()
|
|
|
|
if not XTool.IsNumberValid(self.ConfigId) then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
local template = XFurnitureConfigs.GetFurnitureTemplateById(self.ConfigId)
|
|
|
|
return template.SuitId
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetTypeId()
|
|
|
|
if not XTool.IsNumberValid(self.ConfigId) then
|
|
|
|
return 0
|
|
|
|
end
|
|
|
|
local template = XFurnitureConfigs.GetFurnitureTemplateById(self.ConfigId)
|
|
|
|
return template.TypeId
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:CheckIsBaseFurniture()
|
|
|
|
return self:GetSuitId() == XFurnitureConfigs.BASE_SUIT_ID
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetBaseAttrList()
|
|
|
|
return self.BaseAttrList
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetBaseAttr()
|
|
|
|
return table.unpack(self.BaseAttrList)
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetFurnitureName()
|
|
|
|
if not XTool.IsNumberValid(self.ConfigId) then
|
|
|
|
return ""
|
|
|
|
end
|
|
|
|
local template = XFurnitureConfigs.GetFurnitureTemplateById(self.ConfigId)
|
|
|
|
return template.Name
|
|
|
|
end
|
|
|
|
|
|
|
|
function XHomeFurnitureData:GetAttrTotal()
|
|
|
|
local total = 0
|
|
|
|
for _, attr in pairs(self.AttrList) do
|
|
|
|
total = total + attr
|
|
|
|
end
|
|
|
|
return total
|
2023-07-14 19:35:33 +00:00
|
|
|
end
|