User prompt
ad age up ten years
User prompt
ai generated choices based on age infinite possible choices but age based and answers are age base
User prompt
now make decisions that makes sense based on age
User prompt
show age at top corner of screen
User prompt
age shower that shows you your age
User prompt
add more possible decisions infinite decisions
User prompt
add a age up one year age up one day age up one week age up 1 month choice
User prompt
add one day age up and if you age up one day decision time add parents inthegame also ... other stuff to do later you can move the character
Code edit (1 edits merged)
Please save this source code
User prompt
Life Clicker: Age Up Adventure
Initial prompt
a game where you start as a newborn baby age up a year when the player wants you too and live a life
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // AgeUpButton class var AgeUpButton = Container.expand(function () { var self = Container.call(this); var btn = self.attachAsset('ageup_btn', { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2('Age Up', { size: 70, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); label.x = 0; label.y = 0; self.addChild(label); // For click feedback self.flash = function () { tween(btn, { tint: 0x80ff80 }, { duration: 100, onFinish: function onFinish() { tween(btn, { tint: 0x43aa8b }, { duration: 200 }); } }); }; return self; }); // Avatar class for displaying the character at different ages var Avatar = Container.expand(function () { var self = Container.call(this); // Default to baby self.stage = 'baby'; self.avatarNode = null; self.setStage = function (stage) { self.stage = stage; if (self.avatarNode) { self.avatarNode.destroy(); } var assetId = 'avatar_' + stage; self.avatarNode = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); }; // Initialize as baby self.setStage('baby'); return self; }); // EventPopup class for showing milestone or choice events var EventPopup = Container.expand(function () { var self = Container.call(this); var bg = self.attachAsset('event_bg', { anchorX: 0.5, anchorY: 0.5 }); self.text = new Text2('', { size: 60, fill: 0x222222, wordWrap: true, wordWrapWidth: 1100 }); self.text.anchor.set(0.5, 0.5); self.text.x = 0; self.text.y = -100; self.addChild(self.text); // Option buttons (max 2 for MVP) self.optionBtns = []; // Show popup with text and options self.show = function (text, options) { self.text.setText(text); // Remove old buttons for (var i = 0; i < self.optionBtns.length; i++) { self.optionBtns[i].destroy(); } self.optionBtns = []; // Create new buttons var btnY = 120; for (var i = 0; i < options.length; i++) { (function (idx) { var opt = options[idx]; var btn = new Container(); var btnBg = btn.attachAsset('ageup_btn', { anchorX: 0.5, anchorY: 0.5, width: 500, height: 100 }); btn.x = 0; btn.y = btnY + idx * 130; var btnLabel = new Text2(opt.text, { size: 48, fill: 0xFFFFFF }); btnLabel.anchor.set(0.5, 0.5); btn.addChild(btnLabel); btn.down = function (x, y, obj) { // Animate feedback tween(btnBg, { tint: 0x80ff80 }, { duration: 100, onFinish: function onFinish() { tween(btnBg, { tint: 0x43aa8b }, { duration: 200 }); } }); // Call option handler if (opt.onSelect) { opt.onSelect(); } }; self.addChild(btn); self.optionBtns.push(btn); })(i); } }; // Hide popup self.hide = function () { for (var i = 0; i < self.optionBtns.length; i++) { self.optionBtns[i].destroy(); } self.optionBtns = []; self.text.setText(''); self.visible = false; }; // Start hidden self.visible = false; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf7f7f7 }); /**** * Game Code ****/ // Life stages and their age ranges // Character avatars for each life stage (baby, child, teen, adult, elder) // Button for "Age Up" // Event popup background var lifeStages = [{ stage: 'baby', min: 0, max: 2 }, { stage: 'child', min: 3, max: 12 }, { stage: 'teen', min: 13, max: 19 }, { stage: 'adult', min: 20, max: 64 }, { stage: 'elder', min: 65, max: 120 }]; // Milestone events per age (MVP: a few per stage) var milestoneEvents = { 0: { text: "Welcome to the world! You are a newborn baby.", options: [{ text: "Continue" }] }, 1: { text: "You take your first steps!", options: [{ text: "Yay!" }] }, 5: { text: "You start school. Do you want to make a new friend?", options: [{ text: "Yes", onSelect: function onSelect() { showEvent("You made a new friend!"); } }, { text: "No", onSelect: function onSelect() { showEvent("You prefer to play alone for now."); } }] }, 13: { text: "You become a teenager. Time for high school!", options: [{ text: "Bring it on!" }] }, 18: { text: "You graduate high school. What will you do?", options: [{ text: "Go to college", onSelect: function onSelect() { showEvent("You start college life!"); } }, { text: "Start working", onSelect: function onSelect() { showEvent("You get your first job!"); } }] }, 30: { text: "You reach adulthood. Do you want to travel?", options: [{ text: "Yes", onSelect: function onSelect() { showEvent("You see the world and gain new experiences!"); } }, { text: "No", onSelect: function onSelect() { showEvent("You focus on your career."); } }] }, 65: { text: "You retire! Time to relax and enjoy your golden years.", options: [{ text: "Celebrate" }] }, 90: { text: "You reflect on a life well lived.", options: [{ text: "The End" }] } }; // Helper to get stage by age function getStageByAge(age) { for (var i = 0; i < lifeStages.length; i++) { if (age >= lifeStages[i].min && age <= lifeStages[i].max) { return lifeStages[i].stage; } } return 'elder'; } // Generate infinite age-based decisions function generateAgeBasedDecisions() { var stage = getStageByAge(age); var decisionTemplates = []; var responseTemplates = []; var activities = []; var emotions = []; var objects = []; var people = []; var places = []; var skills = []; var challenges = []; if (stage === "baby") { activities = ["cuddle", "cry", "sleep", "babble", "giggle", "stare", "reach", "wiggle", "smile", "coo", "suck thumb", "kick legs", "roll over", "grab", "listen"]; objects = ["mobile", "toy", "blanket", "bottle", "rattle", "stuffed animal", "colorful shapes", "music box", "soft fabric", "shiny object"]; people = ["mommy", "daddy", "sibling", "grandparent", "caregiver", "visitor"]; emotions = ["happy", "sleepy", "curious", "content", "fussy", "excited", "calm", "surprised"]; decisionTemplates = ["[activity] with [people]", "[activity] at the [objects]", "Feel [emotions] and [activity]", "Try to [activity]", "[activity] because you're [emotions]"]; responseTemplates = ["You feel [emotions] and [emotions].", "[people] smiles at you lovingly.", "The [objects] captures your attention.", "You discover something wonderful!", "This makes you feel safe and loved.", "You're learning about the world around you."]; } else if (stage === "child") { activities = ["play", "draw", "build", "read", "run", "jump", "sing", "dance", "explore", "help", "learn", "share", "imagine", "create", "discover"]; objects = ["blocks", "crayons", "book", "toy car", "doll", "puzzle", "ball", "bike", "sandbox", "swing", "slide", "art supplies", "games"]; people = ["friends", "parents", "teacher", "siblings", "classmates", "neighbor", "pets"]; places = ["playground", "school", "backyard", "park", "bedroom", "kitchen", "library", "store"]; emotions = ["excited", "proud", "curious", "happy", "silly", "adventurous", "creative", "friendly"]; skills = ["counting", "writing", "riding", "swimming", "climbing", "sharing", "reading"]; decisionTemplates = ["[activity] with [objects] at the [places]", "Help [people] with something", "Practice [skills]", "[activity] and feel [emotions]", "Go to [places] and [activity]", "Share [objects] with [people]", "Learn about [skills] by [activity]"]; responseTemplates = ["You have so much fun [activity]!", "[people] is proud of your [skills].", "You feel [emotions] and accomplished.", "This helps you grow and learn.", "You make new friends while [activity].", "Your imagination runs wild!", "You discover you're good at [skills]."]; } else if (stage === "teen") { activities = ["study", "hang out", "practice", "volunteer", "work", "drive", "party", "compete", "perform", "rebel", "dream", "plan", "date", "experiment"]; objects = ["phone", "car", "guitar", "computer", "books", "sports equipment", "clothes", "music", "video games"]; people = ["friends", "crush", "teammates", "family", "teachers", "boss", "mentor"]; places = ["school", "mall", "concert", "party", "gym", "job", "car", "room", "hangout spot"]; emotions = ["confident", "nervous", "excited", "rebellious", "passionate", "confused", "determined", "social"]; skills = ["driving", "leadership", "sports", "music", "academics", "social skills", "independence"]; challenges = ["peer pressure", "responsibilities", "identity", "relationships", "future planning"]; decisionTemplates = ["[activity] with [people] at [places]", "Deal with [challenges] by [activity]", "Use your [objects] to [activity]", "Feel [emotions] and [activity]", "Practice [skills] through [activity]", "Balance [activity] with responsibilities"]; responseTemplates = ["You feel [emotions] and more mature.", "This helps you understand [challenges] better.", "[people] respects your [skills].", "You're becoming more independent.", "This experience shapes who you're becoming.", "You learn valuable life lessons.", "Your [skills] improves significantly."]; } else if (stage === "adult") { activities = ["work", "travel", "cook", "exercise", "invest", "network", "create", "mentor", "innovate", "lead", "balance", "achieve"]; objects = ["career", "home", "car", "savings", "relationship", "family", "business", "skills", "goals"]; people = ["spouse", "children", "colleagues", "boss", "friends", "parents", "mentees", "clients"]; places = ["office", "home", "gym", "restaurant", "vacation spot", "conference", "neighborhood"]; emotions = ["accomplished", "stressed", "fulfilled", "ambitious", "responsible", "wise", "experienced"]; skills = ["management", "parenting", "financial planning", "communication", "expertise", "leadership"]; challenges = ["work-life balance", "career growth", "family responsibilities", "financial planning", "health"]; decisionTemplates = ["Focus on [skills] at [places]", "Balance [objects] with [people]", "[activity] to improve [challenges]", "Invest time in [objects]", "[activity] with [people] for [objects]", "Handle [challenges] by [activity]"]; responseTemplates = ["You feel [emotions] with your progress.", "This strengthens your [objects].", "[people] appreciates your [skills].", "You're building a meaningful life.", "This decision pays off in the long run.", "You're becoming the person you want to be.", "Your [skills] reaches new heights."]; } else { // elder activities = ["reflect", "share", "mentor", "volunteer", "relax", "remember", "teach", "enjoy", "appreciate", "guide", "celebrate"]; objects = ["wisdom", "memories", "family", "health", "legacy", "stories", "experience", "peace"]; people = ["grandchildren", "family", "friends", "community", "younger generation"]; places = ["home", "park", "family gatherings", "community center", "garden", "favorite spots"]; emotions = ["peaceful", "wise", "grateful", "content", "nostalgic", "proud", "serene"]; skills = ["wisdom sharing", "mentoring", "patience", "appreciation", "reflection"]; challenges = ["health", "loneliness", "changing times", "legacy building"]; decisionTemplates = ["Share [objects] with [people]", "[activity] about [objects]", "Enjoy [places] with [people]", "[activity] and feel [emotions]", "Pass on [skills] to [people]", "Find [emotions] in [activity]"]; responseTemplates = ["You feel [emotions] and fulfilled.", "[people] treasures your [objects].", "This brings you deep satisfaction.", "You're leaving a meaningful [objects].", "Your [skills] touches many lives.", "You find joy in simple moments.", "Life feels [emotions] and complete."]; } // Generate 2-4 unique decisions var numOptions = 2 + Math.floor(Math.random() * 3); var options = []; var usedTexts = {}; for (var i = 0; i < numOptions; i++) { var attempts = 0; var decisionText, responseText; do { // Pick random templates var template = decisionTemplates[Math.floor(Math.random() * decisionTemplates.length)]; var responseTemplate = responseTemplates[Math.floor(Math.random() * responseTemplates.length)]; // Fill in template with random words decisionText = template; responseText = responseTemplate; if (activities.length > 0) { decisionText = decisionText.replace(/\[activity\]/g, activities[Math.floor(Math.random() * activities.length)]); responseText = responseText.replace(/\[activity\]/g, activities[Math.floor(Math.random() * activities.length)]); } if (objects.length > 0) { decisionText = decisionText.replace(/\[objects\]/g, objects[Math.floor(Math.random() * objects.length)]); responseText = responseText.replace(/\[objects\]/g, objects[Math.floor(Math.random() * objects.length)]); } if (people.length > 0) { decisionText = decisionText.replace(/\[people\]/g, people[Math.floor(Math.random() * people.length)]); responseText = responseText.replace(/\[people\]/g, people[Math.floor(Math.random() * people.length)]); } if (places.length > 0) { decisionText = decisionText.replace(/\[places\]/g, places[Math.floor(Math.random() * places.length)]); responseText = responseText.replace(/\[places\]/g, places[Math.floor(Math.random() * places.length)]); } if (emotions.length > 0) { decisionText = decisionText.replace(/\[emotions\]/g, emotions[Math.floor(Math.random() * emotions.length)]); responseText = responseText.replace(/\[emotions\]/g, emotions[Math.floor(Math.random() * emotions.length)]); } if (skills.length > 0) { decisionText = decisionText.replace(/\[skills\]/g, skills[Math.floor(Math.random() * skills.length)]); responseText = responseText.replace(/\[skills\]/g, skills[Math.floor(Math.random() * skills.length)]); } if (challenges.length > 0) { decisionText = decisionText.replace(/\[challenges\]/g, challenges[Math.floor(Math.random() * challenges.length)]); responseText = responseText.replace(/\[challenges\]/g, challenges[Math.floor(Math.random() * challenges.length)]); } // Capitalize first letter decisionText = decisionText.charAt(0).toUpperCase() + decisionText.slice(1); responseText = responseText.charAt(0).toUpperCase() + responseText.slice(1); attempts++; } while (usedTexts[decisionText] && attempts < 10); if (!usedTexts[decisionText]) { usedTexts[decisionText] = true; options.push({ text: decisionText, onSelect: function (response) { return function () { showEvent(response); decisionTime = false; }; }(responseText) }); } } return options; } // Game state var age = 0; var day = 0; var maxAge = 100; var avatar = null; var ageUpBtn = null; var ageText = null; var eventPopup = null; var milestoneShown = {}; // To avoid showing same milestone twice var parents = []; // To store parent avatars var dayText = null; var decisionTime = false; // If true, show decision popup on day age up // Center positions var centerX = 2048 / 2; var centerY = 2732 / 2; // Add parents (simple: two parent avatars, left and right of baby) function addParents() { // Only add once if (parents.length > 0) return; var parent1 = new Avatar(); parent1.setStage('adult'); parent1.x = centerX - 350; parent1.y = centerY - 350; game.addChild(parent1); var parent2 = new Avatar(); parent2.setStage('adult'); parent2.x = centerX + 350; parent2.y = centerY - 350; game.addChild(parent2); parents.push(parent1, parent2); } addParents(); // Add avatar avatar = new Avatar(); avatar.x = centerX; avatar.y = centerY - 350; game.addChild(avatar); // Age text ageText = new Text2('Age: 0y 0m', { size: 120, fill: 0x333333 }); ageText.anchor.set(0.5, 0); ageText.x = centerX; ageText.y = 200; game.addChild(ageText); // Day text dayText = new Text2('Day: 0', { size: 80, fill: 0x666666 }); dayText.anchor.set(0.5, 0); dayText.x = centerX; dayText.y = 320; game.addChild(dayText); // Age Up buttons for year, month, week, day var ageUpBtns = []; var ageUpTypes = [{ label: "Age Up 1 Year", type: "year" }, { label: "Age Up 1 Month", type: "month" }, { label: "Age Up 1 Week", type: "week" }, { label: "Age Up 1 Day", type: "day" }]; var btnSpacing = 220; for (var i = 0; i < ageUpTypes.length; i++) { (function (idx) { var btn = new AgeUpButton(); btn.x = centerX; btn.y = centerY + 400 + idx * btnSpacing; btn.children[1].setText(ageUpTypes[idx].label); // Set label btn.ageType = ageUpTypes[idx].type; btn.down = function (x, y, obj) { btn.flash(); doAgeUp(btn.ageType); }; game.addChild(btn); ageUpBtns.push(btn); })(i); } // Event popup eventPopup = new EventPopup(); eventPopup.x = centerX; eventPopup.y = centerY; game.addChild(eventPopup); // Show event helper function showEvent(text, options) { eventPopup.visible = true; if (!options) { options = [{ text: "OK", onSelect: function onSelect() { eventPopup.hide(); } }]; } eventPopup.show(text, options); } // Show milestone if available function checkMilestone() { if (milestoneEvents[age] && !milestoneShown[age]) { milestoneShown[age] = true; var event = milestoneEvents[age]; // Wrap options to always hide popup after selection var opts = []; for (var i = 0; i < event.options.length; i++) { (function (idx) { var opt = event.options[idx]; opts.push({ text: opt.text, onSelect: function onSelect() { if (opt.onSelect) opt.onSelect(); eventPopup.hide(); } }); })(i); } showEvent(event.text, opts); } } // Age up logic function doAgeUp(type) { if (eventPopup.visible) return; // Don't age up while popup is open if (age >= maxAge) return; // If it's decision time, show a decision popup instead of aging up if (decisionTime) { var options = generateAgeBasedDecisions(); showEvent("It's decision time! What will you do today?", options); return; } var daysToAdd = 1; if (type === "year") daysToAdd = 365;else if (type === "month") daysToAdd = 30;else if (type === "week") daysToAdd = 7;else daysToAdd = 1; for (var i = 0; i < daysToAdd; i++) { if (age >= maxAge) break; day += 1; // Every 7 days, age up by one year if (day % 7 === 0) { age += 1; // Animate avatar "growing" tween(avatar, { scaleX: 1.1, scaleY: 1.1 }, { duration: 120, onFinish: function onFinish() { tween(avatar, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); // Update avatar stage if needed var newStage = getStageByAge(age); if (avatar.stage !== newStage) { avatar.setStage(newStage); } // Show milestone if any checkMilestone(); // End of life if (age === maxAge) { LK.effects.flashScreen(0x000000, 1200); LK.showGameOver(); break; } } // Every 3 days, trigger a decision time if (day % 3 === 0) { decisionTime = true; break; } } // Calculate years and months for display var years = age; var months = Math.floor(day % 365 / 30); ageText.setText('Age: ' + years + 'y ' + months + 'm'); dayText.setText('Day: ' + day); } // Also allow clicking anywhere on avatar to age up one day avatar.down = function (x, y, obj) { doAgeUp("day"); }; // Prevent interaction when popup is open game.down = function (x, y, obj) { if (eventPopup.visible) { // Dismiss popup if click outside options eventPopup.hide(); } }; // Show first milestone at start checkMilestone(); // No need for update loop for MVP // GUI: Show age at top right corner LK.gui.topRight.addChild(ageText); LK.gui.top.addChild(dayText);
===================================================================
--- original.js
+++ change.js
@@ -153,12 +153,12 @@
/****
* Game Code
****/
-// Event popup background
-// Button for "Age Up"
-// Character avatars for each life stage (baby, child, teen, adult, elder)
// Life stages and their age ranges
+// Character avatars for each life stage (baby, child, teen, adult, elder)
+// Button for "Age Up"
+// Event popup background
var lifeStages = [{
stage: 'baby',
min: 0,
max: 2
@@ -262,8 +262,130 @@
}
}
return 'elder';
}
+// Generate infinite age-based decisions
+function generateAgeBasedDecisions() {
+ var stage = getStageByAge(age);
+ var decisionTemplates = [];
+ var responseTemplates = [];
+ var activities = [];
+ var emotions = [];
+ var objects = [];
+ var people = [];
+ var places = [];
+ var skills = [];
+ var challenges = [];
+ if (stage === "baby") {
+ activities = ["cuddle", "cry", "sleep", "babble", "giggle", "stare", "reach", "wiggle", "smile", "coo", "suck thumb", "kick legs", "roll over", "grab", "listen"];
+ objects = ["mobile", "toy", "blanket", "bottle", "rattle", "stuffed animal", "colorful shapes", "music box", "soft fabric", "shiny object"];
+ people = ["mommy", "daddy", "sibling", "grandparent", "caregiver", "visitor"];
+ emotions = ["happy", "sleepy", "curious", "content", "fussy", "excited", "calm", "surprised"];
+ decisionTemplates = ["[activity] with [people]", "[activity] at the [objects]", "Feel [emotions] and [activity]", "Try to [activity]", "[activity] because you're [emotions]"];
+ responseTemplates = ["You feel [emotions] and [emotions].", "[people] smiles at you lovingly.", "The [objects] captures your attention.", "You discover something wonderful!", "This makes you feel safe and loved.", "You're learning about the world around you."];
+ } else if (stage === "child") {
+ activities = ["play", "draw", "build", "read", "run", "jump", "sing", "dance", "explore", "help", "learn", "share", "imagine", "create", "discover"];
+ objects = ["blocks", "crayons", "book", "toy car", "doll", "puzzle", "ball", "bike", "sandbox", "swing", "slide", "art supplies", "games"];
+ people = ["friends", "parents", "teacher", "siblings", "classmates", "neighbor", "pets"];
+ places = ["playground", "school", "backyard", "park", "bedroom", "kitchen", "library", "store"];
+ emotions = ["excited", "proud", "curious", "happy", "silly", "adventurous", "creative", "friendly"];
+ skills = ["counting", "writing", "riding", "swimming", "climbing", "sharing", "reading"];
+ decisionTemplates = ["[activity] with [objects] at the [places]", "Help [people] with something", "Practice [skills]", "[activity] and feel [emotions]", "Go to [places] and [activity]", "Share [objects] with [people]", "Learn about [skills] by [activity]"];
+ responseTemplates = ["You have so much fun [activity]!", "[people] is proud of your [skills].", "You feel [emotions] and accomplished.", "This helps you grow and learn.", "You make new friends while [activity].", "Your imagination runs wild!", "You discover you're good at [skills]."];
+ } else if (stage === "teen") {
+ activities = ["study", "hang out", "practice", "volunteer", "work", "drive", "party", "compete", "perform", "rebel", "dream", "plan", "date", "experiment"];
+ objects = ["phone", "car", "guitar", "computer", "books", "sports equipment", "clothes", "music", "video games"];
+ people = ["friends", "crush", "teammates", "family", "teachers", "boss", "mentor"];
+ places = ["school", "mall", "concert", "party", "gym", "job", "car", "room", "hangout spot"];
+ emotions = ["confident", "nervous", "excited", "rebellious", "passionate", "confused", "determined", "social"];
+ skills = ["driving", "leadership", "sports", "music", "academics", "social skills", "independence"];
+ challenges = ["peer pressure", "responsibilities", "identity", "relationships", "future planning"];
+ decisionTemplates = ["[activity] with [people] at [places]", "Deal with [challenges] by [activity]", "Use your [objects] to [activity]", "Feel [emotions] and [activity]", "Practice [skills] through [activity]", "Balance [activity] with responsibilities"];
+ responseTemplates = ["You feel [emotions] and more mature.", "This helps you understand [challenges] better.", "[people] respects your [skills].", "You're becoming more independent.", "This experience shapes who you're becoming.", "You learn valuable life lessons.", "Your [skills] improves significantly."];
+ } else if (stage === "adult") {
+ activities = ["work", "travel", "cook", "exercise", "invest", "network", "create", "mentor", "innovate", "lead", "balance", "achieve"];
+ objects = ["career", "home", "car", "savings", "relationship", "family", "business", "skills", "goals"];
+ people = ["spouse", "children", "colleagues", "boss", "friends", "parents", "mentees", "clients"];
+ places = ["office", "home", "gym", "restaurant", "vacation spot", "conference", "neighborhood"];
+ emotions = ["accomplished", "stressed", "fulfilled", "ambitious", "responsible", "wise", "experienced"];
+ skills = ["management", "parenting", "financial planning", "communication", "expertise", "leadership"];
+ challenges = ["work-life balance", "career growth", "family responsibilities", "financial planning", "health"];
+ decisionTemplates = ["Focus on [skills] at [places]", "Balance [objects] with [people]", "[activity] to improve [challenges]", "Invest time in [objects]", "[activity] with [people] for [objects]", "Handle [challenges] by [activity]"];
+ responseTemplates = ["You feel [emotions] with your progress.", "This strengthens your [objects].", "[people] appreciates your [skills].", "You're building a meaningful life.", "This decision pays off in the long run.", "You're becoming the person you want to be.", "Your [skills] reaches new heights."];
+ } else {
+ // elder
+ activities = ["reflect", "share", "mentor", "volunteer", "relax", "remember", "teach", "enjoy", "appreciate", "guide", "celebrate"];
+ objects = ["wisdom", "memories", "family", "health", "legacy", "stories", "experience", "peace"];
+ people = ["grandchildren", "family", "friends", "community", "younger generation"];
+ places = ["home", "park", "family gatherings", "community center", "garden", "favorite spots"];
+ emotions = ["peaceful", "wise", "grateful", "content", "nostalgic", "proud", "serene"];
+ skills = ["wisdom sharing", "mentoring", "patience", "appreciation", "reflection"];
+ challenges = ["health", "loneliness", "changing times", "legacy building"];
+ decisionTemplates = ["Share [objects] with [people]", "[activity] about [objects]", "Enjoy [places] with [people]", "[activity] and feel [emotions]", "Pass on [skills] to [people]", "Find [emotions] in [activity]"];
+ responseTemplates = ["You feel [emotions] and fulfilled.", "[people] treasures your [objects].", "This brings you deep satisfaction.", "You're leaving a meaningful [objects].", "Your [skills] touches many lives.", "You find joy in simple moments.", "Life feels [emotions] and complete."];
+ }
+ // Generate 2-4 unique decisions
+ var numOptions = 2 + Math.floor(Math.random() * 3);
+ var options = [];
+ var usedTexts = {};
+ for (var i = 0; i < numOptions; i++) {
+ var attempts = 0;
+ var decisionText, responseText;
+ do {
+ // Pick random templates
+ var template = decisionTemplates[Math.floor(Math.random() * decisionTemplates.length)];
+ var responseTemplate = responseTemplates[Math.floor(Math.random() * responseTemplates.length)];
+ // Fill in template with random words
+ decisionText = template;
+ responseText = responseTemplate;
+ if (activities.length > 0) {
+ decisionText = decisionText.replace(/\[activity\]/g, activities[Math.floor(Math.random() * activities.length)]);
+ responseText = responseText.replace(/\[activity\]/g, activities[Math.floor(Math.random() * activities.length)]);
+ }
+ if (objects.length > 0) {
+ decisionText = decisionText.replace(/\[objects\]/g, objects[Math.floor(Math.random() * objects.length)]);
+ responseText = responseText.replace(/\[objects\]/g, objects[Math.floor(Math.random() * objects.length)]);
+ }
+ if (people.length > 0) {
+ decisionText = decisionText.replace(/\[people\]/g, people[Math.floor(Math.random() * people.length)]);
+ responseText = responseText.replace(/\[people\]/g, people[Math.floor(Math.random() * people.length)]);
+ }
+ if (places.length > 0) {
+ decisionText = decisionText.replace(/\[places\]/g, places[Math.floor(Math.random() * places.length)]);
+ responseText = responseText.replace(/\[places\]/g, places[Math.floor(Math.random() * places.length)]);
+ }
+ if (emotions.length > 0) {
+ decisionText = decisionText.replace(/\[emotions\]/g, emotions[Math.floor(Math.random() * emotions.length)]);
+ responseText = responseText.replace(/\[emotions\]/g, emotions[Math.floor(Math.random() * emotions.length)]);
+ }
+ if (skills.length > 0) {
+ decisionText = decisionText.replace(/\[skills\]/g, skills[Math.floor(Math.random() * skills.length)]);
+ responseText = responseText.replace(/\[skills\]/g, skills[Math.floor(Math.random() * skills.length)]);
+ }
+ if (challenges.length > 0) {
+ decisionText = decisionText.replace(/\[challenges\]/g, challenges[Math.floor(Math.random() * challenges.length)]);
+ responseText = responseText.replace(/\[challenges\]/g, challenges[Math.floor(Math.random() * challenges.length)]);
+ }
+ // Capitalize first letter
+ decisionText = decisionText.charAt(0).toUpperCase() + decisionText.slice(1);
+ responseText = responseText.charAt(0).toUpperCase() + responseText.slice(1);
+ attempts++;
+ } while (usedTexts[decisionText] && attempts < 10);
+ if (!usedTexts[decisionText]) {
+ usedTexts[decisionText] = true;
+ options.push({
+ text: decisionText,
+ onSelect: function (response) {
+ return function () {
+ showEvent(response);
+ decisionTime = false;
+ };
+ }(responseText)
+ });
+ }
+ }
+ return options;
+}
// Game state
var age = 0;
var day = 0;
var maxAge = 100;
@@ -394,244 +516,9 @@
if (eventPopup.visible) return; // Don't age up while popup is open
if (age >= maxAge) return;
// If it's decision time, show a decision popup instead of aging up
if (decisionTime) {
- // Decision pools for each life stage
- var babyDecisions = [{
- text: "Cuddle with parents",
- onSelect: function onSelect() {
- showEvent("You feel loved and safe.");
- decisionTime = false;
- }
- }, {
- text: "Cry for milk",
- onSelect: function onSelect() {
- showEvent("Your parents feed you. Yum!");
- decisionTime = false;
- }
- }, {
- text: "Try to crawl",
- onSelect: function onSelect() {
- showEvent("You wiggle and move a little!");
- decisionTime = false;
- }
- }, {
- text: "Stare at a mobile",
- onSelect: function onSelect() {
- showEvent("The spinning shapes fascinate you.");
- decisionTime = false;
- }
- }, {
- text: "Babble nonsense",
- onSelect: function onSelect() {
- showEvent("Your parents smile at your sounds.");
- decisionTime = false;
- }
- }, {
- text: "Nap time",
- onSelect: function onSelect() {
- showEvent("You have a restful nap.");
- decisionTime = false;
- }
- }, {
- text: "Play with a toy",
- onSelect: function onSelect() {
- showEvent("You discover a new favorite toy!");
- decisionTime = false;
- }
- }, {
- text: "Look at your hands",
- onSelect: function onSelect() {
- showEvent("Hands are amazing!");
- decisionTime = false;
- }
- }, {
- text: "Giggle at something silly",
- onSelect: function onSelect() {
- showEvent("Your laughter fills the room.");
- decisionTime = false;
- }
- }, {
- text: "Try to stand up",
- onSelect: function onSelect() {
- showEvent("You wobble and almost stand!");
- decisionTime = false;
- }
- }];
- var childDecisions = [{
- text: "Draw a picture",
- onSelect: function onSelect() {
- showEvent("You create a colorful masterpiece!");
- decisionTime = false;
- }
- }, {
- text: "Play tag with friends",
- onSelect: function onSelect() {
- showEvent("You run and laugh with your friends.");
- decisionTime = false;
- }
- }, {
- text: "Read a storybook",
- onSelect: function onSelect() {
- showEvent("You get lost in a magical story.");
- decisionTime = false;
- }
- }, {
- text: "Build with blocks",
- onSelect: function onSelect() {
- showEvent("You build a tall tower!");
- decisionTime = false;
- }
- }, {
- text: "Help your parents",
- onSelect: function onSelect() {
- showEvent("You help set the table for dinner.");
- decisionTime = false;
- }
- }, {
- text: "Ride your bike",
- onSelect: function onSelect() {
- showEvent("You zoom around the neighborhood.");
- decisionTime = false;
- }
- }, {
- text: "Go to a birthday party",
- onSelect: function onSelect() {
- showEvent("You eat cake and play games!");
- decisionTime = false;
- }
- }];
- var teenDecisions = [{
- text: "Study for a test",
- onSelect: function onSelect() {
- showEvent("You ace your exam!");
- decisionTime = false;
- }
- }, {
- text: "Hang out with friends",
- onSelect: function onSelect() {
- showEvent("You have a fun time at the mall.");
- decisionTime = false;
- }
- }, {
- text: "Join a sports team",
- onSelect: function onSelect() {
- showEvent("You score the winning goal!");
- decisionTime = false;
- }
- }, {
- text: "Learn to drive",
- onSelect: function onSelect() {
- showEvent("You get your driver's license!");
- decisionTime = false;
- }
- }, {
- text: "Go to a concert",
- onSelect: function onSelect() {
- showEvent("You enjoy your favorite band live.");
- decisionTime = false;
- }
- }, {
- text: "Volunteer for a cause",
- onSelect: function onSelect() {
- showEvent("You help make a difference.");
- decisionTime = false;
- }
- }];
- var adultDecisions = [{
- text: "Go to work",
- onSelect: function onSelect() {
- showEvent("You have a productive day at work.");
- decisionTime = false;
- }
- }, {
- text: "Cook a new recipe",
- onSelect: function onSelect() {
- showEvent("You make a delicious meal!");
- decisionTime = false;
- }
- }, {
- text: "Travel to a new city",
- onSelect: function onSelect() {
- showEvent("You explore exciting places.");
- decisionTime = false;
- }
- }, {
- text: "Spend time with family",
- onSelect: function onSelect() {
- showEvent("You enjoy a cozy evening together.");
- decisionTime = false;
- }
- }, {
- text: "Start a new hobby",
- onSelect: function onSelect() {
- showEvent("You discover a passion for painting.");
- decisionTime = false;
- }
- }, {
- text: "Exercise at the gym",
- onSelect: function onSelect() {
- showEvent("You feel energized and healthy.");
- decisionTime = false;
- }
- }];
- var elderDecisions = [{
- text: "Share a story from your youth",
- onSelect: function onSelect() {
- showEvent("Your family loves your stories.");
- decisionTime = false;
- }
- }, {
- text: "Take a walk in the park",
- onSelect: function onSelect() {
- showEvent("You enjoy the fresh air and sunshine.");
- decisionTime = false;
- }
- }, {
- text: "Bake cookies for grandchildren",
- onSelect: function onSelect() {
- showEvent("The cookies are a big hit!");
- decisionTime = false;
- }
- }, {
- text: "Join a book club",
- onSelect: function onSelect() {
- showEvent("You discuss your favorite novel.");
- decisionTime = false;
- }
- }, {
- text: "Tend to your garden",
- onSelect: function onSelect() {
- showEvent("Your flowers bloom beautifully.");
- decisionTime = false;
- }
- }];
- // Pick decision pool based on current stage
- var stage = getStageByAge(age);
- var decisionPool = [];
- if (stage === "baby") {
- decisionPool = babyDecisions;
- } else if (stage === "child") {
- decisionPool = childDecisions;
- } else if (stage === "teen") {
- decisionPool = teenDecisions;
- } else if (stage === "adult") {
- decisionPool = adultDecisions;
- } else {
- decisionPool = elderDecisions;
- }
- // Pick 2-4 random unique decisions for this event
- var numOptions = 2 + Math.floor(Math.random() * 3); // 2-4 options
- var used = {};
- var options = [];
- for (var i = 0; i < numOptions && i < decisionPool.length; i++) {
- var idx;
- do {
- idx = Math.floor(Math.random() * decisionPool.length);
- } while (used[idx]);
- used[idx] = true;
- options.push(decisionPool[idx]);
- }
+ var options = generateAgeBasedDecisions();
showEvent("It's decision time! What will you do today?", options);
return;
}
var daysToAdd = 1;
@@ -673,83 +560,8 @@
}
// Every 3 days, trigger a decision time
if (day % 3 === 0) {
decisionTime = true;
- // Infinite random decisions pool
- var decisionPool = [{
- text: "Cuddle with parents",
- onSelect: function onSelect() {
- showEvent("You feel loved and safe.");
- decisionTime = false;
- }
- }, {
- text: "Cry for milk",
- onSelect: function onSelect() {
- showEvent("Your parents feed you. Yum!");
- decisionTime = false;
- }
- }, {
- text: "Try to crawl",
- onSelect: function onSelect() {
- showEvent("You wiggle and move a little!");
- decisionTime = false;
- }
- }, {
- text: "Stare at a mobile",
- onSelect: function onSelect() {
- showEvent("The spinning shapes fascinate you.");
- decisionTime = false;
- }
- }, {
- text: "Babble nonsense",
- onSelect: function onSelect() {
- showEvent("Your parents smile at your sounds.");
- decisionTime = false;
- }
- }, {
- text: "Nap time",
- onSelect: function onSelect() {
- showEvent("You have a restful nap.");
- decisionTime = false;
- }
- }, {
- text: "Play with a toy",
- onSelect: function onSelect() {
- showEvent("You discover a new favorite toy!");
- decisionTime = false;
- }
- }, {
- text: "Look at your hands",
- onSelect: function onSelect() {
- showEvent("Hands are amazing!");
- decisionTime = false;
- }
- }, {
- text: "Giggle at something silly",
- onSelect: function onSelect() {
- showEvent("Your laughter fills the room.");
- decisionTime = false;
- }
- }, {
- text: "Try to stand up",
- onSelect: function onSelect() {
- showEvent("You wobble and almost stand!");
- decisionTime = false;
- }
- }];
- // Pick 2-4 random unique decisions for this event
- var numOptions = 2 + Math.floor(Math.random() * 3); // 2-4 options
- var used = {};
- var options = [];
- for (var i = 0; i < numOptions; i++) {
- var idx;
- do {
- idx = Math.floor(Math.random() * decisionPool.length);
- } while (used[idx]);
- used[idx] = true;
- options.push(decisionPool[idx]);
- }
- showEvent("It's decision time! What will you do today?", options);
break;
}
}
// Calculate years and months for display