# RPG: Life Simulator – Initial Leveling System def start_game(): print(“— WELCOME TO RPG: LIFE —“) print(“Answer the following questions to determine your starting stats.\n”) # Initializing base stats stats = {“Intellect”: 10, “Charisma”: 10, “Fitness”: 10} # Questionnaire questions = [ { “q”: “It’s a Friday night. Where are you?”, “options”: { “1”: (“In the library or coding a project.”, “Intellect”), “2”: (“At a party or meeting new people.”, “Charisma”), “3”: (“At the gym or out for a run.”, “Fitness”) } }, { “q”: “A stranger is struggling with a heavy box. You…”, “options”: { “1”: (“Calculate the most efficient way to move it.”, “Intellect”), “2”: (“Offer a friendly smile and strike up a conversation while helping.”, “Charisma”), “3”: (“Lift the box easily and carry it for them.”, “Fitness”) } }, { “q”: “What is your preferred ‘weapon’ in a conflict?”, “options”: { “1”: (“Logic and facts.”, “Intellect”), “2”: (“Persuasion and charm.”, “Charisma”), “3”: (“Intimidation and physical presence.”, “Fitness”) } } ] for item in questions: print(item[“q”]) for key, value in item[“options”].items(): print(f”{key}. {value[0]}”) choice = input(“Select 1, 2, or 3: “) while choice not in item[“options”]: choice = input(“Invalid choice. Please select 1, 2, or 3: “) # Apply stat bonus stat_to_boost = item[“options”][choice][1] stats[stat_to_boost] += 5 print(f”— {stat_to_boost} increased! —\n”) display_results(stats) def display_results(stats): print(“— CHARACTER INITIALIZED —“) for stat, value in stats.items(): print(f”{stat}: {value}”) # Determine Class/Archetype based on highest stat top_stat = max(stats, key=stats.get) archetypes = { “Intellect”: “The Strategist”, “Charisma”: “The Influencer”, “Fitness”: “The Athlete” } print(f”\nYour starting archetype is: **{archetypes[top_stat]}**”) print(“Good luck in the game of life.”) if __name__ == “__main__”: start_game()
function calculateScores() { const pName = document.getElementById(‘pName’).value || “Unnamed Hero”; const pAge = document.getElementById(‘pAge’).value; // Helper function to average the 5 questions per category const getAvg = (ids) => { let sum = ids.reduce((acc, id) => acc + parseInt(document.getElementById(id).value), 0); return Math.round(sum / 5); }; const stats = { STR: getAvg([‘str_q1’, ‘str_q2’, ‘str_q3’, ‘str_q4’, ‘str_q5’]), INT: getAvg([‘int_q1’, ‘int_q2’, ‘int_q3’, ‘int_q4’, ‘int_q5’]), CHA: getAvg([‘cha_q1’, ‘cha_q2’, ‘cha_q3’, ‘cha_q4’, ‘cha_q5’]), SPI: getAvg([‘spi_q1’, ‘spi_q2’, ‘spi_q3’, ‘spi_q4’, ‘spi_q5’]), GRT: getAvg([‘grt_q1’, ‘grt_q2’, ‘grt_q3’, ‘grt_q4’, ‘grt_q5’]) }; // Determine Class Based on Highest Stat const highestStat = Object.keys(stats).reduce((a, b) => stats[a] > stats[b] ? a : b); const classes = { STR: “The Juggernaut”, INT: “The Architect”, CHA: “The Envoy”, SPI: “The Mystic”, GRT: “The Ironclad” }; const initialClass = stats[highestStat] < 3 ? "The Awakened" : classes[highestStat]; // SAVE DATA: This allows other parts of your site (like the Quest Log) to see these stats localStorage.setItem('playerStats', JSON.stringify({ name: pName, age: pAge, class: initialClass, levels: stats, lastUpdated: new Date().toLocaleDateString() })); displayResults(pName, pAge, initialClass, stats); } function displayResults(name, age, className, stats) { const summaryHtml = `

${name} LVL ${age}

${className}
`; // Create progress bars for each stat (Level 1-10) let breakdownHtml = ‘

Attribute Matrix

‘; for (const [stat, lvl] of Object.entries(stats)) { const percent = lvl * 10; // Convert 1-10 to 10%-100% breakdownHtml += `
${stat}
LVL ${lvl}
`; } document.getElementById(‘player-summary’).innerHTML = summaryHtml; document.getElementById(‘attribute-breakdown’).innerHTML = breakdownHtml; }

Leave a Comment

Your email address will not be published. Required fields are marked *