From 3498275bf06f735460a81abe036ffe6eec3154ca Mon Sep 17 00:00:00 2001 From: Rose Liverman Date: Sat, 26 Sep 2026 21:05:33 -0600 Subject: [PATCH] PQ name gen, level up I got interrupted while doing this days ago and forgot to commit --- ReadMe.md | 8 ++++++++ src/main.lua | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index be4556a..9019c6c 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -50,6 +50,14 @@ special characters: - Anti Juandez, who is made-up - Zargon +I want exploration, generated or discovered areas. And a map. + +- [ ] fishing +- [ ] Sims elements / life sim elements +- [ ] mining +- [ ] construction +- [ ] agriculture + ###### Prefixes Sick modifiers: dead, comatose, crippled, sick, undernourished Young: foetal, baby, preadolescent, teenage, underage diff --git a/src/main.lua b/src/main.lua index ba6dab3..e7ce28e 100644 --- a/src/main.lua +++ b/src/main.lua @@ -19,12 +19,14 @@ local constants = require "data.constants" local classes = require "data.classes" local races = require "data.races" + + local new_character = function(name) local base_stat_roll = function() return 3 + math.random(1, 6) + math.random(1, 6) + math.random(1, 6) end - local random_name = function(length) + local naive_random_name = function(length) local vowels = "aaeeeiioouuy" local consonants = "bcdfghjklmnpqrstvwxyz" local text = "" @@ -41,7 +43,21 @@ local new_character = function(name) return text end - name = name or random_name(math.random(3, 9)) -- name not affected by seed + local progress_quest_random_name = function() + local parts = { + ("br|cr|dr|fr|gr|j|kr|l|m|n|pr||||r|sh|tr|v|wh|x|y|z"):split("|"), + ("a|a|e|e|i|i|o|o|u|u|ae|ie|oo|ou"):split("|"), + ("b|ck|d|g|k|m|n|p|t|v|x|z"):split("|"), + } + local name = "" + for i = 0, 5 do + local part = parts[i % 3 + 1] + name = name .. part[math.random(1, #part)] + end + return name + end + + name = name or progress_quest_random_name() -- name not affected by seed local seed = math.random() math.randomseed(seed) @@ -63,9 +79,39 @@ local new_character = function(name) character.health = math.random(1, 8) + math.floor(character.constitution / 6) character.magic = math.random(1, 8) + math.floor(character.intelligence / 6) + for _, stat_name in ipairs(races[character.race].stats) do + character[stat_name] = character[stat_name] + math.random(1, 3) + end + for _, stat_name in ipairs(classes[character.class].stats) do + character[stat_name] = character[stat_name] + math.random(1, 3) + end + + character.max_encumberance = character.strength + 10 + character.inventory = {} + return character end +local level_up = function(character) + local random_stat_up = function(character) + local core_stats = { + "charisma", "constitution", "dexterity", "intelligence", "strength", "wisdom", + } + local selected_stat = core_stats[math.random(1, #core_stats)] + character[selected_stat] = character[selected_stat] + 1 + end + + character.health = character.health + 1 + math.floor(character.constitution / 3) + math.random(1, 4) + character.magic = character.magic + 1 + math.floor(character.intelligence / 3) + math.random(1, 4) + + random_stat_up(character) + random_stat_up(character) + + character.max_encumberance = character.strength + 10 + + -- TODO this is where a spell could be added, and +end + local test_new_character = function() local character = new_character() local message = "My name is " .. character.name .. ", and I am a " .. character.class .. " " .. character.race .. "!"