From 1fac678a794bd7c7cf616ebde03b9bce046e6cb3 Mon Sep 17 00:00:00 2001 From: Rose Liverman Date: Tue, 22 Sep 2026 19:59:54 -0600 Subject: [PATCH] progress towards character creation --- ReadMe.md | 8 +++--- src/data/classes.lua | 9 ++++-- src/data/races.lua | 9 ++++-- src/main.lua | 65 +++++++++++++++++++++++++++++++++++++++----- 4 files changed, 76 insertions(+), 15 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index b7cff5e..be4556a 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,13 +1,16 @@ # nasa-tawa Strange motion. Idle toy inspired by Progress Quest. +WARNING: Opens a console to LAN which can run *any* code as the user Love2D is +running as! There is no security on this. + ## Brainstroming Name the Race. Motto. Level Class (xp bar) Plot: Description (progress bar) Quest (progress bar) (quest log?) -Stats: strength, constitution, dexterity, intelligence, wisdom, charisma, health/max, magic/max +Stats Equipment list and stats. Spell list and levels. @@ -42,8 +45,6 @@ Equipment is generated based on level, but random, so lots of downgrading. - SpecialItem: InterestingItem of ItemOfs - InterestingItem: ItemAttrib Specials -Only 100 quests are kept in the log. - special characters: - Demi, who does 1 backflip - Anti Juandez, who is made-up @@ -70,7 +71,6 @@ Young, no modifiers, messianic, Big, Special. Quest completion triggers a reward: spell, equipment, stat, item ## Tasks -- [x] Push the modifications to timer to the GitHub library! - [ ] I have to make a stat called consider - [ ] Progress bars should be set within a manager (like timers) so one global draw function draws them all. diff --git a/src/data/classes.lua b/src/data/classes.lua index 80b7644..4486b00 100644 --- a/src/data/classes.lua +++ b/src/data/classes.lua @@ -4,7 +4,10 @@ local utility = require "lib.utility" local classes = utility.load_data("classes.json") -- TODO abstract out since this is shared between classes and races +local class_names = {} for name, data in pairs(classes) do + class_names[#class_names + 1] = name + if type(data.tasks) == "string" then data.tasks = { data.tasks } elseif not data.tasks then @@ -17,7 +20,7 @@ for name, data in pairs(classes) do local time = #task * constants.reading_time_multiplier -- TODO decide on a random amount of extra time to add tasks[index] = {time, time, task} - if #task == 1 then + elseif #task == 1 then local time = #task[1] * constants.reading_time_multiplier -- TODO decide on a random amount of extra time to add tasks[index] = {time, time, task[1]} @@ -29,4 +32,6 @@ for name, data in pairs(classes) do end end -return classes +table.sort(class_names) + +return classes, class_names diff --git a/src/data/races.lua b/src/data/races.lua index 04051f1..458aee5 100644 --- a/src/data/races.lua +++ b/src/data/races.lua @@ -4,7 +4,10 @@ local utility = require "lib.utility" local races = utility.load_data("races.json") -- TODO abstract out since this is shared between classes and races +local race_names = {} for name, data in pairs(races) do + race_names[#race_names + 1] = name + if type(data.tasks) == "string" then data.tasks = { data.tasks } elseif not data.tasks then @@ -17,7 +20,7 @@ for name, data in pairs(races) do local time = #task * constants.reading_time_multiplier -- TODO decide on a random amount of extra time to add tasks[index] = {time, time, task} - if #task == 1 then + elseif #task == 1 then local time = #task[1] * constants.reading_time_multiplier -- TODO decide on a random amount of extra time to add tasks[index] = {time, time, task[1]} @@ -29,4 +32,6 @@ for name, data in pairs(races) do end end -return races +table.sort(race_names) + +return races, race_names diff --git a/src/main.lua b/src/main.lua index 8f7db60..1755c23 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,3 +1,5 @@ +local window_width, window_height = love.graphics.getDimensions() + local log = require "lib.log" local lovebird = require "lib.lovebird" local progress_bar = require "lib.progress_bar" @@ -10,18 +12,67 @@ log{ testing = true, } -local constants = requrie "data.constants" -local classes = require "data.classes" -local races = require "data.races" +local constants = require "data.constants" +local classes, class_names = require "data.classes" +local races, race_names = 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 vowels = "aaeeeiioouuy" + local consonants = "bcdfghjklmnpqrstvwxyz" + local text = "" + for i = 1, length do + local c + if i % 2 == 0 then + c = math.random(1, #vowels) + text = text .. vowels:sub(c, c) + else + c = math.random(1, #consonants) + text = text .. consonants:sub(c, c) + end + end + return text + end + + name = name or random_name(math.random(3, 9)) -- name not affected by seed + + local seed = os.time() + math.randomseed(seed) + + local character = { + seed = seed, + name = name, + race = race_names[math.random(1, #race_names)], + class = class_names[math.random(1, #class_names)], + charisma = base_stat_roll(), + constitution = base_stat_roll(), + dexterity = base_stat_roll(), + intelligence = base_stat_roll(), + strength = base_stat_roll(), + wisdom = base_stat_roll(), + level = 1, + experience = 0, + } + character.health = math.random(1, 8) + math.floor(character.constitution / 6) + character.magic = math.random(1, 8) + math.floor(character.intelligence / 6) + + math.randomseed(os.time()) + return character +end + +-- for i = 1, 100 do +-- print(new_character()) +-- end +-- os.exit(1) -- test progress_bar -local window_width, window_height = love.graphics.getDimensions() local test_bar = progress_bar(0, window_height - constants.progress_bar_height * 2, window_width, constants.progress_bar_height) - local test_message = "This is a test text string of significant length. It exists to test printing over a progress bar." -log("testing", #test_message) test_bar:set_text(test_message) --- test:set_progress(math.random()) local test_timer = timer.every(#test_message * constants.reading_time_multiplier, function() log("testing", "The timer completed.") end) -- TODO consider making timer not need a function; cause I don't here!