function game_load()
    print("Game state loaded: game")
    turnType = "player"
    outputText = ""
    oToutputMode = "red"
    bunkerHealth = 500
    playerHealth = 100
    defenseAmount = 0 -- increment + 10?
    foodAmount = 20 -- increment + 10???
    constructionProgress = 0
    constructionRequired = 25
    turnInitialized = false
    totalTurnsPlayed = 0
    peopleAmount = 1
    actionsAvailable = 3
    resourceTextureArray["defensebutton"] = love.graphics.newImage("assets/defensebutton.png")
    resourceTextureArray["foodbutton"] = love.graphics.newImage("assets/foodbutton.png")
    resourceTextureArray["healbutton"] = love.graphics.newImage("assets/healbutton.png")
    resourceTextureArray["repairbutton"] = love.graphics.newImage("assets/repairbutton.png")
    resourceTextureArray["endturn"] = love.graphics.newImage("assets/endturn.png")
    resourceTextureArray["constructbutton"] = love.graphics.newImage("assets/construct.png")
    resourceTextureArray["addtobunker"] = love.graphics.newImage("assets/addtobunker.png")
    resourceTextureArray["missileattack"] = love.graphics.newImage("assets/missileattack.png")
    resourceTextureArray["poisonfood"] = love.graphics.newImage("assets/poisonfood.png")
    tempDataArray["pgraphic"] = {
        x = 0,
        y = 395,
        width = 75,
        height = 150
    }
    tempDataArray["buttons"] = {
        width = 290,
        height = 85
    }
    tempDataArray["defensebutton"] = {
        x = 0,
        y = 550
    }
    tempDataArray["repairbutton"] = {
        x = 0,
        y = 635
    }
    tempDataArray["foodbutton"] = {
        x = 990,
        y = 550
    }
    tempDataArray["healbutton"] = {
        x = 990,
        y = 635
    }
    tempDataArray["pendturn"] = {
        x = 495,
        y = 0
    }
    tempDataArray["constructbutton"] = {
        x = 495,
        y = 592
    }
    tempDataArray["addtobunker"] = {
        x = 0,
        y = 101
    }
    tempDataArray["missileattack"] = {
        x = 990,
        y = 101
    }
    tempDataArray["poisonfood"] = {
        x = 495,
        y = 101
    }
    screenLoaded = true
end
function game_update()
    if turnType == "player" then
        playerturn_update()
    elseif turnType == "godmode" then
        omnipotentturn_update()
    end
end
function game_handleMouseInput(inx, iny, inbutton, typehit)
    if turnType == "player" then
        if inbutton == "l" and actionsAvailable > 0 and checkButton(inx, iny, tempDataArray["defensebutton"].x, tempDataArray["defensebutton"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        then
            actionsAvailable = actionsAvailable - 1
            defenseAmount = defenseAmount + 10
            oToutputMode = "blue"
            outputText = "+10 Defense!"
        elseif inbutton == "l" and bunkerHealth < 500 and actionsAvailable > 0 and checkButton(inx, iny, tempDataArray["repairbutton"].x, tempDataArray["repairbutton"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        then
            actionsAvailable = actionsAvailable - 1
            bunkerHealth = bunkerHealth + 15
            oToutputMode = "blue"
            outputText = "Bunker repaired +15!"
        elseif inbutton == "l" and checkButton(inx, iny, tempDataArray["foodbutton"].x, tempDataArray["foodbutton"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        and actionsAvailable > 0 then
            actionsAvailable = actionsAvailable - 1
            math.randomseed( os.time() )
            randchancefood = math.random(1, 10)
            if randchancefood < 7 then
                foodAmount = foodAmount + 2
                oToutputMode = "green"
                outputText = "Successfully gathered food! +2 food!"
            else
                foodAmount = foodAmount + 1
                playerHealth = playerHealth - 10
                oToutputMode = "red"
                outputText = "You were attacked while attemping to get food! +1 food, -10 health!"
            end
        elseif inbutton == "l" and checkButton(inx, iny, tempDataArray["healbutton"].x, tempDataArray["healbutton"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        and actionsAvailable > 0 and playerHealth < 100 then
            actionsAvailable = actionsAvailable - 1
            math.randomseed( os.time() )
            randchanceheal = math.random(1, 10)
            if randchanceheal < 8 then
                playerHealth = playerHealth + 15
                oToutputMode = "green"
                outputText = "Player successfully healed! +15 health!"
            else
                playerHealth = playerHealth + 5
                oToutputMode = "red"
                outputText = "Player was poorly bandaged. +5 health!"
            end
            if playerHealth >= 100 then
                playerHealth = 100
            end
        elseif inbutton == "l" and checkButton(inx, iny, tempDataArray["constructbutton"].x, tempDataArray["constructbutton"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        and actionsAvailable > 0 then
            actionsAvailable = actionsAvailable - 1
            constructionProgress = constructionProgress + 1
            oToutputMode = "green"
            outputText = "Constructed project +1! You need " .. constructionRequired - constructionProgress .. " more!"
            if constructionProgress >= constructionRequired then
                outputText = "You won! You built a rocket and escaped the clutches of whatever being controls this bare planet..."
            end
        elseif inbutton == "l" and checkButton(inx, iny, tempDataArray["pendturn"].x, tempDataArray["pendturn"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        and actionsAvailable == 0 then
            finishTurn()
        elseif inbutton == "l" and checkButton(inx, iny, tempDataArray["pendturn"].x, tempDataArray["pendturn"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        and actionsAvailable > 0 then
            oToutputMode = "red"
            outputText = "You still have actions to play!"
        elseif actionsAvailable == 0 then
            oToutputMode = "red"
            outputText = "No actions available!"
        end
    elseif turnType == "godmode" then
        if inbutton == "l" and checkButton(inx, iny, tempDataArray["addtobunker"].x, tempDataArray["addtobunker"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        then
            oToutputMode = "red"
            outputText = "A person was added to your bunker! Double productivity, but even more food consumption!"
            peopleAmount = peopleAmount + 1
            finishTurn()
        elseif inbutton == "l" and checkButton(inx, iny, tempDataArray["poisonfood"].x, tempDataArray["poisonfood"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        then
            oToutputMode = "red"
            outputText = "Your food has been mysteriously poisoned :( You have no choice but to throw it out... -" .. foodAmount .. " Food!"
            foodAmount = 0
            finishTurn()
        elseif inbutton == "l" and checkButton(inx, iny, tempDataArray["missileattack"].x, tempDataArray["missileattack"].y, tempDataArray["buttons"].width, tempDataArray["buttons"].height)
        then
            if bunkerHealth > 0 then
                damageTaken = 25 - defenseAmount
                if damageTaken < 0 then
                    damageTaken = 0
                end
                oToutputMode = "red"
                outputText = "You've been hit by missiles! Your bunker takes " .. damageTaken .. " damage!"
                bunkerHealth = bunkerHealth - damageTaken
            else
                damageTaken = 50 - defenseAmount
                oToutputMode = "red"
                outputText = "With your bunker in ruins, you have no choice but to hide as a missile attack hits! -" .. damageTaken .. " health!"
                playerHealth = playerHealth - damageTaken
            end
            finishTurn()
        end
    end
end
function finishTurn()
    if turnType == "player" then
        --consume food
        foodAmount = foodAmount - peopleAmount * 5
        if foodAmount <= 0 then
            playerHealth = playerHealth - 20
            foodAmount = 0
        end
        actionsAvailable = 3 * peopleAmount + totalTurnsPlayed
        outputText = ""
        turnType = "godmode"
        turnInitialized = false
    elseif turnType == "godmode" then
        turnType = "player"
        defenseAmount = 0
        turnInitialized = false
        totalTurnsPlayed = totalTurnsPlayed + 1
        actionsAvailable = 3 * peopleAmount + totalTurnsPlayed
        if bunkerHealth < 0 then
            bunkerHealth = 0
        end
    end
end
function game_draw()
    love.graphics.setBackgroundColor(255,255,255,0)
    if turnType == "player" then
        playerturn_draw()
    elseif turnType == "godmode" then
        omnipotentturn_draw()
    end
end