diff --git a/src/dct/systems/tickets.lua b/src/dct/systems/tickets.lua index aeceec3f..d6b39823 100644 --- a/src/dct/systems/tickets.lua +++ b/src/dct/systems/tickets.lua @@ -11,6 +11,8 @@ local Command = require("dct.libs.Command") local Check = require("dct.templates.checkers.Check") local UPDATE_TIME = 120 +local coa_list = {"red", "blue", "neutral"} + local difficulty = { ["EASY"] = { ["player_cost"] = 1.0, @@ -168,7 +170,7 @@ function CheckGoals:check(data) local checkside = CheckSide() - for _, side in pairs({"red", "blue", "neutral"}) do + for _, side in pairs(coa_list) do ok, key, msg = checkside:check(data[side]) if not ok then @@ -200,12 +202,9 @@ function Tickets:__init(theater) end end -function Tickets:_unmarshalpost(data) - for _, tbl in ipairs({"tickets"}) do - self[tbl] = {} - for k, v in pairs(data[tbl]) do - self[tbl][tonumber(k)] = v - end +function Tickets:unmarshal(data) + for k, v in pairs(data.tickets) do + utils.mergetables(self.tickets[tonumber(k)], v) end if self.timeout then @@ -214,9 +213,22 @@ function Tickets:_unmarshalpost(data) end end +local include_list = { + ["start"] = true, + ["tickets"] = true, +} + function Tickets:marshal() local data = Marshallable.marshal(self) + for _, coa in pairs(coalition.side) do + for key, _ in pairs(data.tickets[coa]) do + if include_list[key] == nil then + data.tickets[coa][key] = nil + end + end + end + if self.timeout then data.timeleft = self.timer:remain() end @@ -238,7 +250,7 @@ function Tickets:readconfig() self.timer = Timer(goals.time, timer.getAbsTime) self.timeout = true end - for _, val in ipairs({"red", "blue", "neutral"}) do + for _, val in ipairs(coa_list) do local s = coalition.side[string.upper(val)] self.tickets[s] = goals[val] self.tickets[s].name = val