Skip to content

Commit

Permalink
round fixes for new treatments
Browse files Browse the repository at this point in the history
  • Loading branch information
emrergin committed Feb 22, 2024
1 parent 305c1d2 commit 69d5460
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 37 deletions.
11 changes: 9 additions & 2 deletions src/components/Round2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ function Round2({
pointFunction((p: number) => p + pointsForCurrentRound);

if (currentRound < numberOfRounds - 1) {
const newBall =
Math.random() < arrayOfBags[currentRound] / 100 ? "blue" : "red";
setCurrentColor(newBall);

setSubPhase("drawing");
roundData.current = {
...roundData.current,
Expand All @@ -104,13 +108,16 @@ function Round2({
return (
<div>
<>
<BagHolder2 aBlue={10} showBalls={subPhase === "drawing"} />
<BagHolder2
aBlue={arrayOfBags[currentRound]}
showBalls={subPhase === "drawing"}
/>
<Drawing2
numberofBlues={10}
nextFunction={(d) => endDrawing(d)}
fullView={subPhase === "drawing"}
key={currentRound}
result={subPhase === "result"}
isBlue={currentColor === "blue"}
/>
{subPhase === "input" && (
<Slider
Expand Down
22 changes: 5 additions & 17 deletions src/components/experimentComponents/Drawing2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import autoAnimate from "@formkit/auto-animate";
import { QuestionMarkCircled } from "./QuestionBall";

interface drawingProps {
numberofBlues: number;
nextFunction: (d: Drawing2T) => void;
fullView?: boolean;
result?: boolean;
isBlue: boolean;
}

function Drawing2({
numberofBlues,
nextFunction,
isBlue,
fullView = true,
result = false,
}: drawingProps) {
Expand All @@ -39,15 +39,9 @@ function Drawing2({
parent.current && autoAnimate(parent.current);
}, [parent]);

const draws = useRef(
Array.from({ length: 1 }, () => Math.floor(Math.random() * 100)).map(
(num) => (num < numberofBlues ? "blue" : "red"),
),
);

function nextSubPhase() {
nextFunction({
is_blue: draws.current[0] === "blue",
is_blue: isBlue,
});
}

Expand All @@ -68,16 +62,10 @@ function Drawing2({
}}
ref={parent}
>
{draws.current
{[""]
.slice(0, numberOfShownBalls + 1)
.map((a, i) =>
!result ? (
<QuestionMarkCircled key={i} />
) : a === "blue" ? (
"🔵"
) : (
"🔴"
),
!result ? <QuestionMarkCircled key={i} /> : isBlue ? "🔵" : "🔴",
)
.map((e, i) => (
<span key={i} style={{ fontSize: "4rem" }}>
Expand Down
18 changes: 0 additions & 18 deletions src/pages/2/index.tsx

This file was deleted.

0 comments on commit 69d5460

Please sign in to comment.