Skip to content

Commit

Permalink
Add reusable getRandomTip function, create bedroom_shelf interaction (#…
Browse files Browse the repository at this point in the history
…144)

Part of #130
  • Loading branch information
r4pt0s authored Oct 12, 2024
2 parents 636149b + f3d537c commit 93df694
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/interactions/map_campus_house_1/bedroomShelf.interaction.js
Original file line number Diff line number Diff line change
@@ -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);
});
};
2 changes: 2 additions & 0 deletions src/interactions/map_campus_house_1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,6 +14,7 @@ const interactions = [
mageInteractions,
bedroomVanityInteractions,
kitchenFridgeInteractions,
bedroomShelfInteractions
];

export default interactions;
33 changes: 33 additions & 0 deletions src/utils/randomTip.js
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 93df694

Please sign in to comment.