|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import BackToDashBoardLink from "@/components/back-to-dashboard-link"; |
| 4 | +import Quiz from "@/components/tutorial-quiz"; |
| 5 | + |
| 6 | +import { Cinzel } from "next/font/google"; |
| 7 | +import { conditionalsQuiz } from "@/data/quizzes/04-conditionals"; |
| 8 | + |
| 9 | +const cinzel = Cinzel({ |
| 10 | + subsets: ["latin"], |
| 11 | + weight: ["400", "700"], |
| 12 | +}); |
| 13 | + |
| 14 | +// body text (Times New Roman = more readable) |
| 15 | +const bodyFontClass = "font-serif text-amber-950"; |
| 16 | +// titles (Cinzel font) |
| 17 | +const cinzelTitleClass = cinzel.className; |
| 18 | + |
| 19 | +export default function TutorialConditionals() { |
| 20 | + return ( |
| 21 | + // Background of scroll |
| 22 | + <div |
| 23 | + className="min-h-screen p-4 md:p-12" |
| 24 | + style={{ |
| 25 | + backgroundImage: "url('/geminiblurred.png')", |
| 26 | + backgroundSize: "cover", |
| 27 | + backgroundPosition: "center", |
| 28 | + backgroundColor: "#fef3c7", |
| 29 | + }} |
| 30 | + > |
| 31 | + <div className="inline-block p-4" style={{ zIndex: 10 }}> |
| 32 | + <BackToDashBoardLink /> |
| 33 | + </div> |
| 34 | + |
| 35 | + {/* "scroll" */} |
| 36 | + <article |
| 37 | + className={`max-w-4xl mx-auto bg-amber-100 p-8 md:p-12 shadow-2xl shadow-amber-950/70 space-y-8 |
| 38 | + ${bodyFontClass} border border-amber-800 transform rotate-[-0.5deg] |
| 39 | + rounded-t-[4rem] rounded-b-lg`} |
| 40 | + > |
| 41 | + {/* title */} |
| 42 | + <h1 |
| 43 | + className={`text-4xl md:text-5xl font-bold ${cinzelTitleClass} |
| 44 | + border-b-4 border-amber-900 pb-4 mb-8 text-center uppercase`} |
| 45 | + > |
| 46 | + Quest: The Forking Path – Choosing Fate with If and Else |
| 47 | + </h1> |
| 48 | + |
| 49 | + <p className="text-xl italic text-amber-900"> |
| 50 | + Every adventure has moments of choice: fight or flee, open the chest or walk away. |
| 51 | + In code, those decisions are made with <strong>conditionals</strong>—the <strong>if</strong> |
| 52 | + and <strong>else</strong> spells that tell your program which path to follow. |
| 53 | + </p> |
| 54 | + |
| 55 | + <p className="text-lg"> |
| 56 | + This quest teaches your code the power to decide, not just blindly follow one script. |
| 57 | + </p> |
| 58 | + |
| 59 | + <hr className="my-8 border-amber-900/50" /> |
| 60 | + |
| 61 | + {/* section */} |
| 62 | + <section className="space-y-4"> |
| 63 | + <h2 className={`text-3xl font-semibold ${cinzelTitleClass}`}> |
| 64 | + What Are Conditionals? |
| 65 | + </h2> |
| 66 | + <p className="text-lg"> |
| 67 | + A conditional is a question about the world that leads to different outcomes. It looks like: |
| 68 | + </p> |
| 69 | + <p className="text-lg font-mono bg-amber-200 px-2 py-1 rounded border border-amber-800"> |
| 70 | + "If this condition is true, do A; otherwise, do B." |
| 71 | + </p> |
| 72 | + <p className="text-lg"> |
| 73 | + The condition is usually a comparison—like checking if <strong>health ≤ 0</strong> |
| 74 | + or if <strong>gold > 100</strong>. True or false determines which branch of the story runs. |
| 75 | + </p> |
| 76 | + </section> |
| 77 | + |
| 78 | + <hr className="my-8 border-amber-900/50" /> |
| 79 | + |
| 80 | + {/* section */} |
| 81 | + <section className="space-y-4"> |
| 82 | + <h2 className={`text-3xl font-semibold ${cinzelTitleClass}`}> |
| 83 | + Why These Choices Matter |
| 84 | + </h2> |
| 85 | + <ul className="list-disc list-inside space-y-3 text-lg pl-4"> |
| 86 | + <li> |
| 87 | + <strong className="font-semibold text-amber-950">Logic:</strong> Real programs rarely do the same thing every time. They react. |
| 88 | + </li> |
| 89 | + <li> |
| 90 | + <strong className="font-semibold text-amber-950">Safety:</strong> You can prevent bad actions, e.g., "Only open the gate if the password is correct." |
| 91 | + </li> |
| 92 | + <li> |
| 93 | + <strong className="font-semibold text-amber-950">Complexity:</strong> By chaining conditions, you can describe rich behavior without writing separate programs. |
| 94 | + </li> |
| 95 | + </ul> |
| 96 | + <p className="text-lg"> |
| 97 | + Conditionals are the difference between a straight hallway and a branching dungeon. |
| 98 | + </p> |
| 99 | + </section> |
| 100 | + |
| 101 | + <hr className="my-8 border-amber-900/50" /> |
| 102 | + |
| 103 | + {/* section */} |
| 104 | + <section className="space-y-4"> |
| 105 | + <h2 className={`text-3xl font-semibold ${cinzelTitleClass}`}> |
| 106 | + Visualizing the Incantation (Conceptual Example) |
| 107 | + </h2> |
| 108 | + |
| 109 | + <pre className="bg-amber-200 p-6 rounded-md font-mono text-sm text-amber-950 border-2 border-amber-800/50 overflow-x-auto shadow-inner shadow-amber-900/30"> |
| 110 | + <code>{`// Check the hero's health |
| 111 | +if health <= 0 then |
| 112 | + Display: "You have fallen in battle..." |
| 113 | +else |
| 114 | + Display: "You still stand! Prepare your next move." |
| 115 | +end`}</code> |
| 116 | + </pre> |
| 117 | + |
| 118 | + <p className="text-lg"> |
| 119 | + The program examines a condition and chooses which message to reveal, like a dungeon master reacting to the dice. |
| 120 | + </p> |
| 121 | + </section> |
| 122 | + |
| 123 | + <hr className="my-8 border-amber-900/50" /> |
| 124 | + |
| 125 | + {/* Quiz */} |
| 126 | + <Quiz quizData={conditionalsQuiz}></Quiz> |
| 127 | + </article> |
| 128 | + </div> |
| 129 | + ); |
| 130 | +} |
0 commit comments