Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reusable getRandomTip function, create bedroom_shelf interaction #144

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}