Skip to content

Commit a01ca98

Browse files
authored
Link to rules when starting the game (#186)
1 parent 37ebd4c commit a01ca98

File tree

4 files changed

+91
-56
lines changed

4 files changed

+91
-56
lines changed

src/components/GameSettings.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import { makeStyles } from "@material-ui/core/styles";
99
import firebase from "../firebase";
1010
import { modes } from "../game";
1111
import useStorage from "../hooks/useStorage";
12+
import InternalLink from "./InternalLink";
1213

13-
const useStyles = makeStyles(() => ({
14+
const useStyles = makeStyles({
1415
settings: { display: "flex", justifyContent: "space-evenly" },
15-
}));
16+
modeSelector: { display: "flex", alignItems: "baseline", marginRight: "1em" },
17+
});
1618

1719
const practiceModeTip =
1820
"Practice mode is only available in private games. " +
@@ -37,21 +39,25 @@ function GameSettings({ game, gameId, userId }) {
3739

3840
return (
3941
<div className={classes.settings}>
40-
<div style={{ display: "flex", alignItems: "baseline" }}>
41-
<Typography style={{ marginRight: "0.6em" }}>Mode:</Typography>
42+
<div className={classes.modeSelector}>
43+
<Typography style={{ marginRight: "0.5em" }}>Mode:</Typography>
4244
<Select
4345
value={gameMode}
4446
disabled={userId !== game.host}
4547
onChange={handleChangeMode}
4648
>
47-
{Object.entries(modes).map(([key, { name, description }]) => (
49+
{Object.entries(modes).map(([key, { name }]) => (
4850
<MenuItem key={key} value={key}>
49-
<Tooltip key={key} arrow placement="left" title={description}>
50-
<Typography>{name}</Typography>
51-
</Tooltip>
51+
<Typography>{name}</Typography>
5252
</MenuItem>
5353
))}
5454
</Select>
55+
<InternalLink
56+
to={`/help#rules-${gameMode}`}
57+
style={{ marginLeft: "0.5em" }}
58+
>
59+
(Read the rules)
60+
</InternalLink>
5561
</div>
5662
<Tooltip arrow placement="left" title={practiceModeTip}>
5763
<FormControlLabel

src/components/ScrollToHash.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { useEffect } from "react";
2+
import { useLocation } from "react-router-dom";
3+
4+
function ScrollToHash({ isLoading = false, options }) {
5+
const location = useLocation();
6+
7+
useEffect(() => {
8+
if (isLoading || !location.hash) return;
9+
const id = location.hash.slice(1);
10+
const timer = setTimeout(
11+
() => document.getElementById(id)?.scrollIntoView(options),
12+
0
13+
);
14+
return () => clearTimeout(timer);
15+
}, [isLoading, location.key, location.hash, options]);
16+
17+
return null;
18+
}
19+
20+
export default ScrollToHash;

src/game.js

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ export const modes = {
490490
normal: {
491491
name: "Normal",
492492
color: "purple",
493-
description: "Find 3 cards that form a Set.",
494493
setType: "Set",
495494
traits: 4,
496495
chain: 0,
@@ -499,8 +498,6 @@ export const modes = {
499498
junior: {
500499
name: "Junior",
501500
color: "green",
502-
description:
503-
"A simplified version that only uses cards with solid shading.",
504501
setType: "Set",
505502
traits: 3,
506503
chain: 0,
@@ -509,7 +506,6 @@ export const modes = {
509506
setchain: {
510507
name: "Set-Chain",
511508
color: "teal",
512-
description: "In every Set you have to use 1 card from the previous Set.",
513509
setType: "Set",
514510
traits: 4,
515511
chain: 1,
@@ -518,8 +514,6 @@ export const modes = {
518514
ultraset: {
519515
name: "UltraSet",
520516
color: "pink",
521-
description:
522-
"Find 4 cards such that the first pair and the second pair form a Set with the same additional card.",
523517
setType: "UltraSet",
524518
traits: 4,
525519
chain: 0,
@@ -528,8 +522,6 @@ export const modes = {
528522
ultrachain: {
529523
name: "UltraSet-Chain",
530524
color: "orange",
531-
description:
532-
"In every UltraSet you have to use 2 cards from the previous Set.",
533525
setType: "UltraSet",
534526
traits: 4,
535527
chain: 2,
@@ -538,8 +530,6 @@ export const modes = {
538530
ultra9: {
539531
name: "Ultra9",
540532
color: "deepOrange",
541-
description:
542-
"Same as UltraSet, but only 9 cards are dealt at a time, unless they don't contain any sets.",
543533
setType: "UltraSet",
544534
traits: 4,
545535
chain: 0,
@@ -548,7 +538,6 @@ export const modes = {
548538
megaset: {
549539
name: "MegaSet",
550540
color: "lime",
551-
description: "Each card has 5 traits instead of 4.",
552541
setType: "Set",
553542
traits: 5,
554543
chain: 0,
@@ -557,8 +546,6 @@ export const modes = {
557546
ghostset: {
558547
name: "GhostSet",
559548
color: "lightBlue",
560-
description:
561-
"Find 3 disjoint pairs of cards such that the cards that complete them to Sets themselves form a Set.",
562549
setType: "GhostSet",
563550
traits: 4,
564551
chain: 0,
@@ -567,7 +554,6 @@ export const modes = {
567554
"4set": {
568555
name: "4Set",
569556
color: "amber",
570-
description: "Find 4 cards that form a 4Set.",
571557
setType: "4Set",
572558
traits: 4,
573559
chain: 0,
@@ -576,7 +562,6 @@ export const modes = {
576562
"4setjr": {
577563
name: "4Set Junior",
578564
color: "amber",
579-
description: "Find 4 cards that form a 4Set.",
580565
setType: "4Set",
581566
traits: 3,
582567
chain: 0,
@@ -585,8 +570,6 @@ export const modes = {
585570
"4setjrchain": {
586571
name: "4Set Jr-Chain",
587572
color: "red",
588-
description:
589-
"In every 4Set you have to use 2 cards from the previous 4Set.",
590573
setType: "4Set",
591574
traits: 3,
592575
chain: 2,
@@ -595,7 +578,6 @@ export const modes = {
595578
puzzle: {
596579
name: "Puzzle",
597580
color: "cyan",
598-
description: "Find all Sets on the board before moving to the next board.",
599581
setType: "Set",
600582
traits: 4,
601583
chain: 0,
@@ -605,8 +587,6 @@ export const modes = {
605587
ultra9puzzle: {
606588
name: "Ultra9 Puzzle",
607589
color: "orange",
608-
description:
609-
"Find all UltraSets on the board before moving to the next board.",
610590
setType: "UltraSet",
611591
traits: 4,
612592
chain: 0,
@@ -616,7 +596,6 @@ export const modes = {
616596
"4setjrpuzzle": {
617597
name: "4Set Jr-Puzzle",
618598
color: "indigo",
619-
description: "Find all 4Sets on the board before moving to the next board.",
620599
setType: "4Set",
621600
traits: 3,
622601
chain: 0,
@@ -626,7 +605,6 @@ export const modes = {
626605
shuffle: {
627606
name: "Shuffle",
628607
color: "blue",
629-
description: "Cards are shuffled after each Set.",
630608
setType: "Set",
631609
traits: 4,
632610
chain: 0,
@@ -636,7 +614,6 @@ export const modes = {
636614
memory: {
637615
name: "Memory",
638616
color: "red",
639-
description: "Cards are dealt face down and are turned up 3 at a time.",
640617
setType: "Set",
641618
traits: 4,
642619
chain: 0,

0 commit comments

Comments
 (0)