Skip to content

Commit a19aa12

Browse files
Merge pull request #92 from codexsit/reveal-pc-number
feat: added PC number rotation
2 parents ed604f8 + 8251f8e commit a19aa12

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed

src/pages/Bug2Bot/index.jsx

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ export default function Bug2Bot() {
6262
minutes: 0,
6363
seconds: 0,
6464
});
65+
const [currentIndex, setCurrentIndex] = useState(0);
66+
const [spanContents, setSpanContents] = useState([
67+
"unlock",
68+
"team",
69+
"15",
70+
"race",
71+
]);
6572

6673
const updateCountdown = () => {
6774
const now = new Date();
@@ -89,6 +96,35 @@ export default function Bug2Bot() {
8996
return () => clearInterval(interval);
9097
}, []);
9198

99+
useEffect(() => {
100+
const PCs = ["4", "8", "17", "28"];
101+
const revealElements = document.querySelectorAll(".reveal");
102+
103+
const updateIndex = () => {
104+
const now = new Date();
105+
const minutes = now.getMinutes();
106+
const hours = now.getHours();
107+
const totalMinutes = hours * 60 + minutes;
108+
const newIndex = Math.floor(totalMinutes / 15) % PCs.length;
109+
setCurrentIndex(newIndex);
110+
};
111+
112+
revealElements.forEach((element, i) => {
113+
element.addEventListener("click", (event) => {
114+
event.preventDefault();
115+
updateIndex();
116+
if (i === currentIndex) {
117+
setSpanContents((prevContents) => {
118+
const newContents = [...prevContents];
119+
newContents[i] = btoa(PCs[i]);
120+
return newContents;
121+
});
122+
alert(`PC Number: ${btoa(PCs[i])}`);
123+
}
124+
});
125+
});
126+
}, [currentIndex]);
127+
92128
const gradientFontSize = 100;
93129
return (
94130
<PageTransition>
@@ -155,9 +191,13 @@ export default function Bug2Bot() {
155191
<div className="font-orbitron text-xl">
156192
Unleash your tech prowess in this ultimate challenge where
157193
coding precision meets hands-on ingenuity. Teams will tackle
158-
gripping puzzles to unlock a path toward an innovative and
159-
competitive build. Navigate through tasks designed to test
160-
your creativity, strategy, and teamwork!
194+
gripping puzzles to{" "}
195+
<span className="reveal font-orbitron">
196+
{spanContents[0]}
197+
</span>{" "}
198+
a path toward an innovative and competitive build. Navigate
199+
through tasks designed to test your creativity, strategy, and
200+
teamwork!
161201
</div>
162202
</div>
163203
{/* Col 2 */}
@@ -189,7 +229,11 @@ export default function Bug2Bot() {
189229
</div>
190230
<ol className="list-decimal list-inside space-y-1 sm:space-y-2">
191231
<li className="font-orbitron text-base sm:text-xl">
192-
Form a team of 3 - 4.
232+
Form a{" "}
233+
<span className="reveal font-orbitron">
234+
{spanContents[1]}
235+
</span>{" "}
236+
of 3 - 4.
193237
</li>
194238
<li className="font-orbitron text-base sm:text-xl">
195239
Find Qr, scan it.
@@ -223,7 +267,11 @@ export default function Bug2Bot() {
223267
Assemble the RC car and race!!
224268
</li>
225269
<li className="font-orbitron text-xl">
226-
Total Time - 15 Minutes.
270+
Total Time -{" "}
271+
<span className="reveal font-orbitron">
272+
{spanContents[2]}
273+
</span>{" "}
274+
Minutes.
227275
</li>
228276
</ol>
229277
</div>
@@ -239,7 +287,11 @@ export default function Bug2Bot() {
239287
</div>
240288
<ol className="list-decimal list-inside">
241289
<li className="font-orbitron text-xl">
242-
Navigate through the race track.
290+
Navigate through the{" "}
291+
<span className="reveal font-orbitron">
292+
{spanContents[3]}
293+
</span>{" "}
294+
track.
243295
</li>
244296
<li className="font-orbitron text-xl">
245297
Outsmart the traps.

0 commit comments

Comments
 (0)