LeaderboardModel = class(function(o)
	o.scores = {}
end)
function LeaderboardModel:addScore(board, value)
	-- if the board doesn't yet exist, or the new value is higher, then record and submit
	if not self.scores[board] or self.scores[board].value < value then
		self.scores[board] = {
			['value']=value,
			['dirty']=true
		}
	end
	if scf:isSteamConnected() then
		self:reportScores()
	end
end
function LeaderboardModel:reportScores()
	if gk and gk:isConnected() then
		for k,v in pairs(self.scores) do
			if v.dirty and not v.reporting then
				v.reporting = true
				v.dirty = false
				gk:reportScore(k, v.value, function(retVal)
					v.reporting = false
					if retVal then
						v.dirty = true
					end
				end)				
			end
		end
	elseif SteamLeaderboards then
		-- attempt to report through steam
		for k,v in pairs(self.scores) do
			if v.dirty and not v.reporting then
				v.reporting = true
				v.dirty = false
				-- get a new object to report each score, due to the way things are
				local sl = SteamLeaderboards();
				sl:reportScore(k, v.value, function(retVal)
					print("FAILED SCORE UPLODADDD")
					v.reporting = false
					-- if the reporting failed, then store that and attempt to report later
					if not retVal then
						v.dirty = true
					end
				end)
			end
		end
	end
end
function LeaderboardModel:saveTo(data)
	data.scores = self.scores
	return data
end

function LeaderboardModel:loadFrom(data)
	if data.scores then
		self.scores = data.scores
	end
end
