Skip to content

Commit

Permalink
Randomized Turtle Dialogue
Browse files Browse the repository at this point in the history
Modified Turtle.tsx and LessonSide.tsx in orde
r to make the turtle's dialogue box display a randomized statement wit
h every new exercise.
  • Loading branch information
johannemoresco committed Apr 25, 2024
1 parent 74eb4f5 commit e49cf8e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
7 changes: 6 additions & 1 deletion src/components/shared/LessonSide/LessonSide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@ interface lessonSideProps {
maxLevel: number;
}

function getRandomNumber(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1)) + min;
}

function LessonSide({
levelNum,
updateLevel,
maxLevel,
}: lessonSideProps): JSX.Element {
const lesson_info = LessonSideContent[levelNum] || [];
const randomTurtleMessage = getRandomNumber(1, 7)
// console.log("max:" + maxLevel);
return (
<section id="lesson-side-container">
Expand All @@ -33,7 +38,7 @@ function LessonSide({
<LessonText text_array={lesson_info} />
</div>
<div>
<Turtle turtleID="your-genius" />
<Turtle turtleID={randomTurtleMessage} />

{/* passed from parent component */}
<LevelSelector
Expand Down
18 changes: 9 additions & 9 deletions src/components/shared/LessonSide/Turtle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ import encouragingTurtleSkills from '../../../assets/LessonSide/EncouragingTurtl
import encouragingTurtleSuccess from '../../../assets/LessonSide/EncouragingTurtleSuccess.svg';

interface TurtleProps {
turtleID: string;
turtleID: number;
}

interface TurtleData {
[key: string]: [fig: string, altText: string];
[key: number]: [fig: string, altText: string];
}

const turtleIDs: TurtleData = {
'full-points': [
1: [
encouragingTurtleFullPoints,
'Turtle saying Full points for you!',
],
'you-can-do-it': [encouragingTurtle, 'Turtle saying You can do it!'],
'numerous-skills': [
2: [encouragingTurtle, 'Turtle saying You can do it!'],
3: [
encouragingTurtleSkills,
'Turtle saying Your skills are numerous!',
],
'your-genius': [
4: [
encouragingTurtleGenius,
"Turtle saying There's no end to your genius!",
],
'nice-going': [encouragingTurtleNiceGoing, 'Turtle saying Nice going!'],
'drawn-to-work': [
5: [encouragingTurtleNiceGoing, 'Turtle saying Nice going!'],
6: [
encouragingTurtleWork,
"Turtle saying I'm drawn to your work!",
],
'large-success': [
7: [
encouragingTurtleSuccess,
'Turtle saying A large degree of success!',
],
Expand Down

0 comments on commit e49cf8e

Please sign in to comment.