29 lines
720 B
Lua
29 lines
720 B
Lua
local ServerFormationData = class("ServerFormationData", ServerBaseData)
|
|
|
|
function ServerFormationData:init(data)
|
|
if data then
|
|
self.data.formations = data.formations or {}
|
|
else
|
|
self.data.formations = {}
|
|
end
|
|
end
|
|
|
|
function ServerFormationData:getFormation(formationType)
|
|
local formation = self.data.formations[formationType]
|
|
if formation == nil then
|
|
formation = {}
|
|
self.data.formations[formationType] = formation
|
|
end
|
|
return formation
|
|
end
|
|
|
|
function ServerFormationData:upHeroToFormation(formationType, matchType, heroId)
|
|
local formation = self:getFormation(formationType)
|
|
if formation[matchType] == heroId then
|
|
return false
|
|
end
|
|
formation[matchType] = heroId
|
|
return true
|
|
end
|
|
|
|
return ServerFormationData |