local k=require("\112\108\046\099\108\097\115\115")local V=require("\112\108\046\116\097\098\108\101\120")local E=require("\105\110\118\111\107\097\116\105\111\110\046\099\111\110\115\116\046\110\101\116\095\116\097\098\108\101")local D=k()V.update(D,E)function D._init(V,k)V.name=k end function D.Set(E,k,V)return CustomNetTables:SetTableValue(E.name,k,V)end function D.Get(E,k,V)local D=CustomNetTables:GetTableValue(E.name,k)if D==nil then return V end return D end return D
--- NetTable class.
-- @classmod invokation.dota2.NetTable
local class = require("pl.class")
local tablex = require("pl.tablex")

local NET_TABLE = require("invokation.const.net_table")

local M = class()

tablex.update(M, NET_TABLE)

--- Constructor.
-- @tparam string name Net table name
function M:_init(name)
  self.name = name
end

--- Sets a net table value.
-- @tparam string key Key
-- @param value Value
-- @treturn bool Setting success
function M:Set(key, value)
  return CustomNetTables:SetTableValue(self.name, key, value)
end

--- Gets a net table value.
-- @tparam string key Key
-- @param[opt=nil] defaultValue Default value in case the net table value is `nil`
-- @return Value of `key` if it exists, `defaultValue` otherwise
function M:Get(key, defaultValue)
  local value = CustomNetTables:GetTableValue(self.name, key)

  if value == nil then
    return defaultValue
  end

  return value
end

return M
