Mostly improvements from Linda
This commit is contained in:
1 parent
714d3464bd
commit
e36bec6b36
17 files changed
+197
-73
No files matched your search
@@ -11,6 +11,7 @@ import RiddleCompleteBanner from "../RiddleCompleteBanner";
|
||||
import { getPlayers } from "@/utils/players";
|
||||
import VoiceOver from "../VoiceOver";
|
||||
import RiddleHintPage from "../RiddleHintPage";
|
||||
import { Player } from "@/types/player";
|
||||
|
||||
export default function Riddle_2({
|
||||
page,
|
||||
@@ -26,6 +27,22 @@ export default function Riddle_2({
|
||||
|
||||
const [ playerIndex, setPlayerIndex ] = useState(0);
|
||||
const players = useMemo(() => getPlayers(), [playersStr]);
|
||||
const playerOrder = useMemo(() => {
|
||||
if (!players || players.length === 0) return [];
|
||||
|
||||
const indices = Array.from({ length: players.length - 1 }, (_, i) => i + 1);
|
||||
|
||||
for (let i = indices.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[indices[i], indices[j]] = [indices[j], indices[i]];
|
||||
}
|
||||
|
||||
indices.push(0);
|
||||
|
||||
return indices;
|
||||
}, [players]);
|
||||
|
||||
const currentPlayer: Player = players[playerOrder[playerIndex]];
|
||||
|
||||
const pages = [
|
||||
(
|
||||
@@ -50,8 +67,8 @@ export default function Riddle_2({
|
||||
<div key={1}>
|
||||
<div className={styles["content"]}>
|
||||
<div className="center-flex">
|
||||
<p style={{fontWeight: "bold", fontSize: "3rem", marginTop: "2rem", marginBottom: "0"}}>Zieh mal {players[playerIndex].name},</p>
|
||||
<p style={{textAlign: "center"}}>zieh nun am Schwert und finde heraus, ob du Excaliburs {players[playerIndex].gender === "female" ? "Erbin" : "Erbe"} bist!</p>
|
||||
<p style={{fontWeight: "bold", fontSize: "3rem", marginTop: "2rem", marginBottom: "0"}}>{currentPlayer.name},</p>
|
||||
<p style={{textAlign: "center"}}>zieh nun am Schwert und finde heraus, ob du Excaliburs {currentPlayer.gender === "female" ? "Erbin" : "Erbe"} bist!</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className={styles["buttons"]}>
|
||||
@@ -63,7 +80,7 @@ export default function Riddle_2({
|
||||
setPlayerIndex(playerIndex+1);
|
||||
}
|
||||
}} disabled={false}>WEITER</OldButton>
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={() => setPage(0)}>ZURÜCK</OldButton> : null}
|
||||
{playerIndex < 1 ? <OldButton red={true} onAction={() => setPage(0)} className={styles["backButton"]}>ZURÜCK</OldButton> : null}
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user