-- 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("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("playercards/RandomWeaknessGenerator")
end)
__bundle_register("playercards/RandomWeaknessGenerator", function(require, _LOADED, __bundle_register, __bundle_modules)
local allCardsBagGuid = "15bb07"

function onLoad(saved_data)
  createDrawButton()
end

function createDrawButton()
    self.createButton({
        label="Draw Random\nWeakness", click_function="buttonClick_draw", function_owner=self,
        position={0,0.1,2.1}, rotation={0,0,0}, height=600, width=1800,
        font_size=250, color={0,0,0}, font_color={1,1,1}
    })
end

-- Draw a random weakness and spawn it below the object
function buttonClick_draw()
  local allCardsBag = getObjectFromGUID(allCardsBagGuid)
  local weaknessId = allCardsBag.call("getRandomWeaknessId")
  if (weaknessId == nil) then
    broadcastToAll("All basic weaknesses are in play!", {0.9, 0.2, 0.2})
    return
  end
  local card = allCardsBag.call("getCardById", { id = weaknessId })
  spawnObjectData({
    data = card.data,
    position = self.positionToWorld({0, 1, 5.5}),
    rotation = self.getRotation()})
end
end)
return __bundle_require("__root")