local ____lualib = require("lualib_bundle")
local Map = ____lualib.Map
local Set = ____lualib.Set
local ____exports = {}
local ____playerIndex = require("functions.playerIndex")
local getPlayerIndex = ____playerIndex.getPlayerIndex
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
-- `Map.set` method if you have a map of this type.
-- 
-- For example:
-- 
-- ```ts
-- const v = {
--   run: {
--     playersSpeedBoost: new Map<PlayerIndex, int>(),
--   },
-- };
-- 
-- function incrementSpeedBoost(player: EntityPlayer) {
--   const oldSpeedBoost = mapGetPlayer(v.run.playersSpeedBoost, player);
--   const newSpeedBoost = oldSpeedBoost + 0.1;
--   mapSetPlayer(v.run.playersSpeedBoost, player);
-- }
-- ```
function ____exports.mapSetPlayer(self, map, player, value)
    local playerIndex = getPlayerIndex(nil, player)
    map:set(playerIndex, value)
end
--- Helper function to make using default maps with an index of `PlayerIndex` easier. Use this
-- instead of the `DefaultMap.getAndSetDefault` method if you have a default map of this type.
-- 
-- For example:
-- 
-- ```ts
-- const v = {
--   run: {
--     playersSpeedBoost: new DefaultMap<PlayerIndex, int>(0),
--   },
-- };
-- 
-- function evaluateCacheSpeed(player: EntityPlayer) {
--   player.MoveSpeed = defaultMapGetPlayer(v.run.playersSpeedBoost, player);
-- }
-- ```
-- 
-- @allowEmptyVariadic
function ____exports.defaultMapGetPlayer(self, map, player, ...)
    local playerIndex = getPlayerIndex(nil, player)
    return map:getAndSetDefault(playerIndex, ...)
end
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
-- `Map.set` method if you have a map of this type.
-- 
-- Since `Map` and `DefaultMap` set values in the same way, this function is simply an alias for the
-- `mapSetPlayer` helper function.
function ____exports.defaultMapSetPlayer(self, map, player, value)
    ____exports.mapSetPlayer(nil, map, player, value)
end
--- Helper function to make using maps with an type of `PlayerIndex` easier. Use this instead of the
-- `Map.delete` method if you have a set of this type.
function ____exports.mapDeletePlayer(self, map, player)
    local playerIndex = getPlayerIndex(nil, player)
    return map:delete(playerIndex)
end
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
-- `Map.get` method if you have a map of this type.
-- 
-- For example:
-- 
-- ```ts
-- const v = {
--   run: {
--     playersSpeedBoost: new Map<PlayerIndex, int>(),
--   },
-- };
-- 
-- function incrementSpeedBoost(player: EntityPlayer) {
--   const oldSpeedBoost = mapGetPlayer(v.run.playersSpeedBoost, player);
--   const newSpeedBoost = oldSpeedBoost + 0.1;
--   mapSetPlayer(v.run.playersSpeedBoost, player);
-- }
-- ```
function ____exports.mapGetPlayer(self, map, player)
    local playerIndex = getPlayerIndex(nil, player)
    return map:get(playerIndex)
end
--- Helper function to make using maps with an index of `PlayerIndex` easier. Use this instead of the
-- `Map.has` method if you have a map of this type.
function ____exports.mapHasPlayer(self, map, player)
    local playerIndex = getPlayerIndex(nil, player)
    return map:has(playerIndex)
end
--- Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
-- `Set.add` method if you have a set of this type.
function ____exports.setAddPlayer(self, set, player)
    local playerIndex = getPlayerIndex(nil, player)
    set:add(playerIndex)
end
--- Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
-- `Set.delete` method if you have a set of this type.
function ____exports.setDeletePlayer(self, set, player)
    local playerIndex = getPlayerIndex(nil, player)
    return set:delete(playerIndex)
end
--- Helper function to make using sets with an type of `PlayerIndex` easier. Use this instead of the
-- `Set.has` method if you have a set of this type.
function ____exports.setHasPlayer(self, set, player)
    local playerIndex = getPlayerIndex(nil, player)
    return set:has(playerIndex)
end
return ____exports
