diff --git a/src/interactions/map_campus_house_1/bedroomShelf.interaction.js b/src/interactions/map_campus_house_1/bedroomShelf.interaction.js new file mode 100644 index 0000000..6e6d3a9 --- /dev/null +++ b/src/interactions/map_campus_house_1/bedroomShelf.interaction.js @@ -0,0 +1,19 @@ +import { displayDialogue } from '../../utils'; +import { updateEnergyState } from '../../utils/energyUpdate'; +import { getRandomTip } from '../../utils/randomTip'; + +export const bedroomShelfInteractions = (player, k, map) => { + player.onCollide('bedroom_shelf', () => { + player.isInDialog = true; + + displayDialogue({ + k, + player, + text: ["Here's a tip for learning to code:", getRandomTip()], + onDisplayEnd: () => { + player.isInDialog = false; + }, + }); + updateEnergyState(player.state, player.state.energy + 5); + }); +}; diff --git a/src/interactions/map_campus_house_1/index.js b/src/interactions/map_campus_house_1/index.js index 109ef79..0fe4110 100644 --- a/src/interactions/map_campus_house_1/index.js +++ b/src/interactions/map_campus_house_1/index.js @@ -4,6 +4,7 @@ import { computerInteractions } from './computer.interaction'; import { mageInteractions } from './mage.interaction'; import { bedroomVanityInteractions } from './bedroomVanity.interaction'; import { kitchenFridgeInteractions } from './kitchenFridge.interaction'; +import { bedroomShelfInteractions } from './bedroomShelf.interaction'; const interactions = [ // Add more interactions here @@ -13,6 +14,7 @@ const interactions = [ mageInteractions, bedroomVanityInteractions, kitchenFridgeInteractions, + bedroomShelfInteractions ]; export default interactions; diff --git a/src/utils/randomTip.js b/src/utils/randomTip.js new file mode 100644 index 0000000..6bcdaba --- /dev/null +++ b/src/utils/randomTip.js @@ -0,0 +1,33 @@ + +export const getRandomTip = () => { + + // Feel free to add additional tips to this array. + const tipsForLearningToCode = [ + "Start by understanding the fundamentals like variables, loops, and functions before diving into more complex topics.", + "Practice regularly by building small projects or solving coding challenges to solidify your knowledge.", + "Don't be afraid to make mistakes; debugging is a key part of the learning process and will help you improve.", + "Read and understand other people's code; it can expose you to new techniques and approaches to solving problems.", + "Break down complex problems into smaller, manageable parts to avoid feeling overwhelmed.", + "Use comments in your code to explain your thought process and make it easier to understand later.", + "Leverage online resources like Stack Overflow and documentation when you get stuck, but try to solve problems on your own first.", + "Learn how to effectively use a debugger or console to trace and fix errors in your code.", + "Write clean and readable code by following best practices such as consistent indentation and meaningful variable names.", + "Don't focus too much on memorizing syntax: understanding concepts and knowing where to find answers is more important.", + "Start with one language and get comfortable with it before moving on to others.", + "Use version control systems like Git to keep track of changes and collaborate with others.", + "Focus on learning how to think logically and solve problems rather than just learning syntax.", + "Set small, achievable goals to stay motivated and measure your progress over time.", + "Get comfortable reading official documentation, as it's often the best source of information.", + "Pair programming with a friend or mentor can help you learn faster and gain new perspectives.", + "Write tests for your code to ensure it works as expected and is easy to maintain in the future.", + "Keep your functions and code blocks small and focused on one task to improve readability and reusability.", + "Understand how data structures like arrays, objects, and lists work, as they are fundamental in coding.", + "Always keep learning and stay curious—new frameworks, libraries, and tools are constantly being developed." + ]; + + // Select a random tip from the array + const randomTip = tipsForLearningToCode[Math.floor(Math.random() * tipsForLearningToCode.length)]; + + // Return the random tip + return randomTip; +} \ No newline at end of file