-- Bundled by luabundle {"version":"1.6.0"} local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire) local loadingPlaceholder = {[{}] = true} local register local modules = {} local require local loaded = {} register = function(name, body) if not modules[name] then modules[name] = body end end require = function(name) local loadedModule = loaded[name] if loadedModule then if loadedModule == loadingPlaceholder then return nil end else if not modules[name] then if not superRequire then local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name) error('Tried to require ' .. identifier .. ', but no such module has been registered') else return superRequire(name) end end loaded[name] = loadingPlaceholder loadedModule = modules[name](require, loaded, register, modules) loaded[name] = loadedModule end return loadedModule end return require, loaded, register, modules end)(nil) __bundle_register("core/OptionPanelApi", function(require, _LOADED, __bundle_register, __bundle_modules) do local OptionPanelApi = {} -- loads saved options ---@param options Table New options table OptionPanelApi.loadSettings = function(options) return Global.call("loadSettings", options) end -- returns option panel table OptionPanelApi.getOptions = function() return Global.getTable("optionPanel") end return OptionPanelApi end end) __bundle_register("core/VictoryDisplayApi", function(require, _LOADED, __bundle_register, __bundle_modules) do local VictoryDisplayApi = {} local VD_GUID = "6ccd6d" -- triggers an update of the Victory count ---@param delay Number Delay in seconds after which the update call is executed VictoryDisplayApi.update = function(delay) getObjectFromGUID(VD_GUID).call("startUpdate", delay) end -- moves a card to the victory display (in the first empty spot) ---@param object Object Object that should be checked and potentially moved VictoryDisplayApi.placeCard = function(object) if object ~= nil and object.tag == "Card" then getObjectFromGUID(VD_GUID).call("placeCard", object) end end return VictoryDisplayApi end end) __bundle_register("playermat/PlaymatApi", function(require, _LOADED, __bundle_register, __bundle_modules) do local PlaymatApi = { } local internal = { } local MAT_IDS = { White = "8b081b", Orange = "bd0ff4", Green = "383d8b", Red = "0840d5" } local CLUE_COUNTER_GUIDS = { White = "37be78", Orange = "1769ed", Green = "032300", Red = "d86b7c" } local CLUE_CLICKER_GUIDS = { White = "db85d6", Orange = "3f22e5", Green = "891403", Red = "4111de" } -- Returns the color of the by position requested playermat as string ---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat PlaymatApi.getMatColorByPosition = function(startPos) if startPos.x < -42 then if startPos.z > 0 then return "White" else return "Orange" end else if startPos.z > 0 then return "Green" else return "Red" end end end -- Returns the color of the player's hand that is seated next to the playermat ---@param matColor String Color of the playermat PlaymatApi.getPlayerColor = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.getVar("playerColor") end -- Returns the color of the playermat that owns the playercolor's hand ---@param handColor String Color of the playermat PlaymatApi.getMatColor = function(handColor) local matColors = {"White", "Orange", "Green", "Red"} for i, mat in ipairs(internal.getMatForColor("All")) do local color = mat.getVar("playerColor") if color == handColor then return matColors[i] end end return "NOT_FOUND" end -- Returns the result of a cast in the specificed playermat's area ---@param matColor String Color of the playermat PlaymatApi.searchPlaymat = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.call("searchAroundSelf") end -- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat ---@param matColor String Color of the playermat PlaymatApi.isDES = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.getVar("isDES") end -- Returns the draw deck of the requested playmat ---@param matColor String Color of the playermat PlaymatApi.getDrawDeck = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) mat.call("getDrawDiscardDecks") return mat.getVar("drawDeck") end -- Returns the position of the discard pile of the requested playmat ---@param matColor String Color of the playermat PlaymatApi.getDiscardPosition = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.call("returnGlobalDiscardPosition") end -- Transforms a local position into a global position ---@param localPos Table Local position to be transformed ---@param matColor String Color of the playermat PlaymatApi.transformLocalPosition = function(localPos, matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.positionToWorld(localPos) end -- Returns the rotation of the requested playmat ---@param matColor String Color of the playermat PlaymatApi.returnRotation = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.getRotation() end -- Triggers the Upkeep for the requested playmat ---@param matColor String Color of the playermat ---@param playerColor String Color of the calling player (for messages) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.call("doUpkeepFromHotkey", playerColor) end -- Returns the active investigator id ---@param matColor String Color of the playermat PlaymatApi.returnInvestigatorId = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.getVar("activeInvestigatorId") end -- Sets the requested playermat's snap points to limit snapping to matching card types or not. If -- matchTypes is true, the main card slot snap points will only snap assets, while the -- investigator area point will only snap Investigators. If matchTypes is false, snap points will -- be reset to snap all cards. ---@param matchCardTypes Boolean. Whether snap points should only snap for the matching card -- types. ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will apply the setting to all four mats. PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("setLimitSnapsByType", matchCardTypes) end end -- Sets the requested playermat's draw 1 button to visible ---@param isDrawButtonVisible Boolean. Whether the draw 1 button should be visible or not ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will apply the setting to all four mats. PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("showDrawButton", isDrawButtonVisible) end end -- Shows or hides the clickable clue counter for the requested playermat ---@param showCounter Boolean. Whether the clickable counter should be present or not ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will apply the setting to all four mats. PlaymatApi.clickableClues = function(showCounter, matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("clickableClues", showCounter) end end -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playermat ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will apply the setting to all four mats. PlaymatApi.removeClues = function(matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("removeClues") end end -- Reports the clue count for the requested playermat ---@param useClickableCounters Boolean Controls which type of counter is getting checked PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 for _, mat in ipairs(internal.getMatForColor(matColor)) do count = count + tonumber(mat.call("getClueCount", useClickableCounters)) end return count end -- Adds the specified amount of resources to the requested playermat's resource counter PlaymatApi.gainResources = function(amount, matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("gainResources", amount) end end -- Returns the resource counter amount for the requested playermat PlaymatApi.getResourceCount = function(matColor) local mat = getObjectFromGUID(MAT_IDS[matColor]) return mat.call("getResourceCount") end -- Discard a non-hidden card from the corresponding player's hand PlaymatApi.doDiscardOne = function(matColor) for _, mat in ipairs(internal.getMatForColor(matColor)) do mat.call("doDiscardOne") end end PlaymatApi.syncAllCustomizableCards = function() for _, mat in ipairs(internal.getMatForColor("All")) do mat.call("syncAllCustomizableCards") end end PlaymatApi.updateClueClicker = function(playerColor, val) return getObjectFromGUID(CLUE_CLICKER_GUIDS[playerColor]).call("updateVal", val) end -- Convenience function to look up a mat's object by color, or get all mats. ---@param matColor String for one of the active player colors - White, Orange, Green, Red. Also -- accepts "All" as a special value which will return all four mats. ---@return: Array of playermat objects. If a single mat is requested, will return a single-element -- array to simplify processing by consumers. internal.getMatForColor = function(matColor) local targetMatGuid = MAT_IDS[matColor] if targetMatGuid != nil then return { getObjectFromGUID(targetMatGuid) } end if matColor == "All" then return { getObjectFromGUID(MAT_IDS.White), getObjectFromGUID(MAT_IDS.Orange), getObjectFromGUID(MAT_IDS.Green), getObjectFromGUID(MAT_IDS.Red), } end end return PlaymatApi end end) __bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules) require("core/GameKeyHandler") end) __bundle_register("core/GameKeyHandler", function(require, _LOADED, __bundle_register, __bundle_modules) local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local optionPanelApi = require("core/OptionPanelApi") local playmatApi = require("playermat/PlaymatApi") local victoryDisplayApi = require("core/VictoryDisplayApi") function onLoad() addHotkey("Add Doom to Agenda", addDoomToAgenda) addHotkey("Bless/Curse Status", showBlessCurseStatus) addHotkey("Move card to Victory Display", moveCardToVictoryDisplay) addHotkey("Take clue from location", takeClueFromLocation) addHotkey("Upkeep", triggerUpkeep) addHotkey("Upkeep (Multi-handed)", triggerUpkeepMultihanded) addHotkey("Wendy's Menu", addWendysMenu) end -- triggers the "Upkeep" function of the calling player's playmat function triggerUpkeep(playerColor) if playerColor == "Black" then broadcastToColor("Triggering 'Upkeep (Multihanded)' instead", playerColor, "Yellow") triggerUpkeepMultihanded(playerColor) return end local matColor = playmatApi.getMatColor(playerColor) playmatApi.doUpkeepFromHotkey(matColor, playerColor) end -- triggers the "Upkeep" function of the calling player's playmat AND -- for all playmats that don't have a seated player, but a investigator card function triggerUpkeepMultihanded(playerColor) if playerColor ~= "Black" then triggerUpkeep(playerColor) end local colors = Player.getAvailableColors() for _, handColor in ipairs(colors) do local matColor = playmatApi.getMatColor(handColor) if playmatApi.returnInvestigatorId(matColor) ~= "00000" and Player[handColor].seated == false then playmatApi.doUpkeepFromHotkey(matColor, playerColor) end end end -- adds 1 doom to the agenda function addDoomToAgenda() getObjectFromGUID("85c4c6").call("addVal", 1) end -- moves the hovered card to the victory display function moveCardToVictoryDisplay(_, hoveredObject) victoryDisplayApi.placeCard(hoveredObject) end -- takes a clue from a location, player needs to hover the clue directly or the location function takeClueFromLocation(playerColor, hoveredObject) local cardName, clue if hoveredObject == nil then broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow") return elseif hoveredObject.tag == "Card" then cardName = hoveredObject.getName() for _, v in ipairs(searchOnObj(hoveredObject)) do local obj = v.hit_object if obj.memo == "clueDoom" and obj.is_face_down == false then clue = obj break end end if clue == nil then broadcastToColor("This card does not have any clues on it.", playerColor, "Yellow") return end elseif hoveredObject.memo == "clueDoom" then if hoveredObject.is_face_down then broadcastToColor("This is a doom token and not a clue.", playerColor, "Yellow") return end clue = hoveredObject local search = Physics.cast({ direction = { 0, -1, 0 }, max_distance = 0.1, type = 3, size = { 0.1, 0.1, 0.1 }, origin = clue.getPosition() }) for _, v in ipairs(search) do local obj = v.hit_object if obj.tag == "Card" then cardName = obj.getName() break end end else broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow") return end local clickableClues = optionPanelApi.getOptions()["useClueClickers"] local playerName = Player[playerColor].steam_name local matColor = playmatApi.getMatColor(playerColor) local pos = nil if clickableClues then pos = {x = 0.49, y = 2.66, z = 0.00} playmatApi.updateClueClicker(playerColor, playmatApi.getClueCount(clickableClues, playerColor) + 1) else pos = playmatApi.transformLocalPosition({x = -1.12, y = 0.05, z = 0.7}, matColor) end local rot = playmatApi.returnRotation(matColor) -- check if found clue is a stack or single token if clue.getQuantity() > 1 then clue.takeObject({position = pos, rotation = rot}) else clue.setPositionSmooth(pos) clue.setRotation(rot) end if cardName then broadcastToAll(playerName .. " took one clue from " .. cardName .. ".", playerColor) else broadcastToAll(playerName .. " took one clue.", "Green") end victoryDisplayApi.update() end -- broadcasts the bless/curse status to the calling player function showBlessCurseStatus(playerColor) blessCurseManagerApi.broadcastStatus(playerColor) end -- adds Wendy's menu to the hovered card function addWendysMenu(playerColor, hoveredObject) blessCurseManagerApi.addWendysMenu(playerColor, hoveredObject) end -- searches on an object (by using its bounds) ---@param obj Object Object to search on function searchOnObj(obj) return Physics.cast({ direction = { 0, 1, 0 }, max_distance = 0.5, type = 3, size = obj.getBounds().size, origin = obj.getPosition() }) end end) __bundle_register("chaosbag/BlessCurseManagerApi", function(require, _LOADED, __bundle_register, __bundle_modules) do local BlessCurseManagerApi = {} local MANAGER_GUID = "5933fb" -- removes all taken tokens and resets the counts BlessCurseManagerApi.removeTakenTokensAndReset = function() local BlessCurseManager = getObjectFromGUID(MANAGER_GUID) Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Bless") end, 0.05) Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Curse") end, 0.10) Wait.time(function() BlessCurseManager.call("doReset", "White") end, 0.15) end -- updates the internal count (called by cards that seal bless/curse tokens) BlessCurseManagerApi.sealedToken = function(type, guid) getObjectFromGUID(MANAGER_GUID).call("sealedToken", { type = type, guid = guid }) end -- updates the internal count (called by cards that seal bless/curse tokens) BlessCurseManagerApi.releasedToken = function(type, guid) getObjectFromGUID(MANAGER_GUID).call("releasedToken", { type = type, guid = guid }) end -- broadcasts the current status for bless/curse tokens ---@param playerColor String Color of the player to show the broadcast to BlessCurseManagerApi.broadcastStatus = function(playerColor) getObjectFromGUID(MANAGER_GUID).call("broadcastStatus", playerColor) end -- removes all bless / curse tokens from the chaos bag and play ---@param playerColor String Color of the player to show the broadcast to BlessCurseManagerApi.removeAll = function(playerColor) getObjectFromGUID(MANAGER_GUID).call("doRemove", playerColor) end -- adds Wendy's menu to the hovered card (allows sealing of tokens) ---@param color String Color of the player to show the broadcast to BlessCurseManagerApi.addWendysMenu = function(playerColor, hoveredObject) getObjectFromGUID(MANAGER_GUID).call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) end return BlessCurseManagerApi end end) return __bundle_require("__root")