
local common_descs = {
    "Enjoys {long |short |}walks on the beach",
    "Finds teaching {boring|tedious} but enjoys the {pay|hours|benefits}",
    "Likes {cats|dogs|ducks|fish} a bit too much",
    "Owns {5|6|7|8} {cats|dogs}",
    "Addicted to {micro-transactions|lootboxes|cake|chocolate}",
    "Spends weekends trolling {social media|forums|blogs}",
    "Likes to comment on {videos|news posts}",
    "Enjoys {weekends|nights} alone",
    "Enjoys {horse|bear} riding",
}
function add_common(tbl)
    for _, v in ipairs(common_descs) do
        table.insert(tbl, v)
    end
    return tbl
end
local descs = {
    -- Male
    add_common({
        "{Table football|Pong} king 2016-2017"
    }),
    -- Female
    add_common({
        "{Table football|Pong} queen 2016-2017"
    })
}

local special = {
    -- Male
    {
        {
            first_name = "Scetch",
            surname = "Nodus",
            description = "Cheats in video games"
        },
        {
            first_name = "Cld",
            surname = "Fire",
            description = "Works on open source projects in his spare time"
        },
        {
            first_name = "Unnamed",
            surname = "Dude",
            description = "Ex-enterprise programmer"
        },
        {
            first_name = "Xor",
            surname = "Boole",
            description = "Enjoys maths too much"
        },
        {
            first_name = "Ferris",
            surname = "Rusty"
        },
        {
            first_name = "Tony",
            surname = "Collins"
        },
        {
            first_name = "Ryan",
            surname = "Collins"
        }
    },
    -- Female
    {
        {
            first_name = "Leanne",
            surname = "Collins",
            skill = 1.0,
            control = 1.0
        },
        {
            first_name = "Jane",
            surname = "Collins",
            skill = 1.0,
            control = 1.0
        }
    }
}

function generate(player)
    -- TODO: Notes
    --   player will be some proxy/object that contains
    --   information about the current player this is
    --   being generated for. The script _should_ use
    --   this to generate better staff for better unis

    local variant = math.random(0, 1)

    local desc = descs[1 + variant][math.random(#descs[1 + variant])]
    local desc = desc:gsub("{(.-)}", function(selections)
        local parts = selections:split("|")
        return parts[math.random(#parts)]
    end)


    local control = 0.2 + (math.random(0, 1000) / 1000) * 0.8
    local skill = 0.2 + (math.random(0, 1000) / 1000) * 0.8

    local first_name = nil
    local surname = nil
    if math.random(35000) == 1 then
        local s = special[variant + 1]
        local unit = s[math.random(#s)]
        first_name = unit.first_name
        surname = unit.surname
        if unit.description ~= nil then
            desc = unit.description
        end
        if unit.control ~= nil then
            control = unit.control
        end
        if unit.skill ~= nil then
            skill = unit.skill
        end
    end

    local price_weight = 1.0 + control * control + skill

    local base_price = math.random(5000 * price_weight, 12000 * price_weight)
    -- 2% ish every 3 days
    local price = base_price * math.pow(1.02, math.floor(player.day / 3))


    return {
        first_name = first_name,
        surname = surname,
        description = desc,
        stats = {
            control = control,
            skill = skill,
        },
        price = price,
        variant = variant,
    }
end