<commit_before>-- require "libs.cupid"

-- lock down the globals table for performance and error detection
setmetatable(_G, {
  __index = function(_, key)
    return error("no such global '" .. tostring(key) .. "'")
  end,
  __newindex = function(_, key, value)
    return error("creating global '" .. tostring(key) .. "' not allowed")
  end,
})

-- require "shared.controllerbindings"

local sti           = require "libs.sti"

local state         = require "minionmaster.state"

local ui            = require "minionmaster.ui"

local content       = require "minionmaster.content"
local EntityStatics = require "minionmaster.entitystatics"

local Enemy         = require "minionmaster.enemy"
local Minion        = require "minionmaster.minion"
local MinionMaster  = require "minionmaster.minionmaster"

local baseWidth, baseHeight = 1920, 1080

local enemyCount = 10

local zoom = 1
local zoomSpeed = 0.1

local function spawnMinion(master)
    if state.dna > EntityStatics.minion.cost then
        state.dna = state.dna - EntityStatics.minion.cost
        local minion = Minion:new(EntityStatics.minion, master)
        minion:setPosition(master.position.x, master.position.y)
        state.entityManager:add(minion)
    end
end

local function load()
    state.initialize()
    content.load()

    -- spawn the master
    state.master = MinionMaster:new(EntityStatics.master)
    state.master:setPosition(baseWidth/4, baseHeight/4)
    state.entityManager:add(state.master)

    -- spawn initial enemies
    for i=1,enemyCount do
        local enemy = Enemy:new(EntityStatics.enemy, state.master)
        enemy:setPosition(math.random(baseWidth/2),math.random(baseHeight/2))
        state.entityManager:add(enemy)
    end

    ui.load()
end

function love.update(dt)
    state.entityManager:update(dt)
    state.map:update(dt)
    ui.update(dt)
end

function love.draw(dt)
    local width, height = love.graphics.getDimensions()
    width = width / zoom
    height = height / zoom

    local translateX = -state.master.position.x + width / 2
    local translateY = -state.master.position.y + height / 2

    state.map:setDrawRange(translateX, translateY, width, height)
    love.graphics.push()
    love.graphics.scale(zoom, zoom)
    love.graphics.translate(translateX, translateY)
    state.map:draw()
    state.entityManager:draw(dt)
    love.graphics.pop()

    ui.draw()
end

function love.keypressed(key, unicode)
	if key == "escape" then
        -- sends quit event
        love.event.quit()
    end

    if key == "m" then
        spawnMinion(state.master)
    end
end

function love.mousepressed(x, y, button)
    if button == "wd" then
        zoom = zoom - zoomSpeed
    elseif button == "wu" then
        zoom = zoom + zoomSpeed
    end
end

function love.mousereleased(x, y, button)<commit_msg>Allow clicking somewhere to jump to that location (cheat)<commit_after>-- require "libs.cupid"

-- lock down the globals table for performance and error detection
setmetatable(_G, {
  __index = function(_, key)
    return error("no such global '" .. tostring(key) .. "'")
  end,
  __newindex = function(_, key, value)
    return error("creating global '" .. tostring(key) .. "' not allowed")
  end,
})

-- require "shared.controllerbindings"

local sti           = require "libs.sti"

local state         = require "minionmaster.state"

local ui            = require "minionmaster.ui"

local content       = require "minionmaster.content"
local EntityStatics = require "minionmaster.entitystatics"

local Enemy         = require "minionmaster.enemy"
local Minion        = require "minionmaster.minion"
local MinionMaster  = require "minionmaster.minionmaster"

local baseWidth, baseHeight = 1920, 1080

local enemyCount = 10

local zoom = 1
local zoomSpeed = 0.1

local function spawnMinion(master)
    if state.dna > EntityStatics.minion.cost then
        state.dna = state.dna - EntityStatics.minion.cost
        local minion = Minion:new(EntityStatics.minion, master)
        minion:setPosition(master.position.x, master.position.y)
        state.entityManager:add(minion)
    end
end

local function load()
    state.initialize()
    content.load()

    -- spawn the master
    state.master = MinionMaster:new(EntityStatics.master)
    state.master:setPosition(baseWidth/4, baseHeight/4)
    state.entityManager:add(state.master)

    -- spawn initial enemies
    for i=1,enemyCount do
        local enemy = Enemy:new(EntityStatics.enemy, state.master)
        enemy:setPosition(math.random(baseWidth/2),math.random(baseHeight/2))
        state.entityManager:add(enemy)
    end

    ui.load()
end

function love.update(dt)
    state.entityManager:update(dt)
    state.map:update(dt)
    ui.update(dt)
end

function love.draw(dt)
    local width, height = love.graphics.getDimensions()
    width = width / zoom
    height = height / zoom

    local translateX = -state.master.position.x + width / 2
    local translateY = -state.master.position.y + height / 2

    state.translateX = translateX
    state.translateY = translateY

    state.map:setDrawRange(translateX, translateY, width, height)
    love.graphics.push()
    love.graphics.scale(zoom, zoom)
    love.graphics.translate(translateX, translateY)
    state.map:draw()
    state.entityManager:draw(dt)
    love.graphics.pop()

    ui.draw()
end

function love.keypressed(key, unicode)
	if key == "escape" then
        -- sends quit event
        love.event.quit()
    end

    if key == "m" then
        spawnMinion(state.master)
    end
end

function love.mousepressed(x, y, button)
    if button == "wd" then
        zoom = zoom - zoomSpeed
    elseif button == "wu" then
        zoom = zoom + zoomSpeed
    elseif button == "l" then
        state.master.position.x = x - state.translateX
        state.master.position.y = y - state.translateY
    end
end

function love.mousereleased(x, y, button)
{'fraction_non_alphanumeric': 0.10791489361702128, 'fraction_numerical': 0.006808510638297872, 'mean_word_length': 3.0440467997247076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5861830', 'n_tokens_mistral': 1866, 'n_tokens_neox': 1810, 'n_words': 449}