Skip to content

Commit

Permalink
Merge pull request #16 from will2dye4/alea-core
Browse files Browse the repository at this point in the history
Migrate to alea-core library
  • Loading branch information
will2dye4 authored Mar 12, 2023
2 parents 3f80987 + 5ec155b commit cc3e133
Show file tree
Hide file tree
Showing 55 changed files with 141 additions and 386 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "jeopardye",
"version": "2.1.2",
"version": "2.1.3",
"private": true,
"dependencies": {
"@babel/plugin-syntax-import-assertions": "^7.20.0",
"@chakra-ui/react": "^1.6.3",
"@choc-ui/chakra-autocomplete": "^5.1.4",
"@dyesoft/alea-core": "0.2.5",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@fortawesome/fontawesome-free": "^5.15.3",
Expand Down
4 changes: 2 additions & 2 deletions src/client/actions/action_creators.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getISODateString, StatusCodes, WebsocketEvent } from '@dyesoft/alea-core';
import { connect, disconnect, send } from '@giantmachines/redux-websocket';
import { API_BASE, EventTypes, PLAYER_ID_KEY, StatusCodes, WS_BASE } from '../../constants.mjs';
import { getISODateString, WebsocketEvent } from '../../utils.mjs';
import { API_BASE, EventTypes, PLAYER_ID_KEY, WS_BASE } from '../../constants.mjs';

export const ActionTypes = {
FETCH_ROOM: 'JEOPARDYE::FETCH_ROOM',
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/admin/AdminDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
TabPanel,
TabPanels,
} from '@chakra-ui/react';
import { RoomLinkRequestResolution } from '@dyesoft/alea-core';
import { SELECTED_TAB_STYLES } from '../../../constants.mjs';
import { RoomLinkRequestResolution } from '../../../models/roomLinkRequest.mjs';
import Card from '../common/card/Card';
import Players from './Players';
import RoomLinkRequests from './RoomLinkRequests';
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/admin/RoomLinkRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
Thead,
Tr,
} from '@chakra-ui/react';
import { RoomLinkRequestResolution } from '@dyesoft/alea-core';
import { faCheck, faTimes } from '@fortawesome/free-solid-svg-icons';
import { SORT_ARROW_DESCENDING } from '../../../constants.mjs';
import { RoomLinkRequestResolution } from '../../../models/roomLinkRequest.mjs';
import ActionIcon from '../common/ActionIcon';

function getResolveButtons(props, request) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/common/players/KickPlayerDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SECONDS_PER_MINUTE,
SECONDS_PER_MONTH,
SECONDS_PER_WEEK,
} from '../../../../constants.mjs';
} from '@dyesoft/alea-core';

const DURATIONS = {
'1 minute': SECONDS_PER_MINUTE,
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/common/players/PlayerList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { List, ListItem } from '@chakra-ui/react';
import { comparePlayerNames } from '../../../../utils.mjs';
import { comparePlayerNames } from '@dyesoft/alea-core';
import Card from '../card/Card';
import CardHeader from '../card/CardHeader';
import PlayerListItem from './PlayerListItem';
Expand Down
5 changes: 3 additions & 2 deletions src/client/components/episode/EpisodeBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ import {
Tr,
} from '@chakra-ui/react';
import { faClipboardQuestion, faCrown, faEyeLowVision, faTriangleExclamation } from '@fortawesome/free-solid-svg-icons';
import { MILLISECONDS_PER_DAY, SORT_ARROW_ASCENDING, SORT_ARROW_DESCENDING } from '../../../constants.mjs';
import { formatDate, formatWeekday, getURLForContestant, range } from '../../../utils.mjs';
import { formatDate, formatWeekday, MILLISECONDS_PER_DAY, range } from '@dyesoft/alea-core';
import { SORT_ARROW_ASCENDING, SORT_ARROW_DESCENDING } from '../../../constants.mjs';
import { getURLForContestant } from '../../../utils.mjs';
import Bold from '../common/Bold';
import Card from '../common/card/Card';
import Icon from '../common/Icon';
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/game/Game.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Box, Text } from '@chakra-ui/react';
import { formatList } from '@dyesoft/alea-core';
import {
CATEGORIES_PER_ROUND,
CLUES_PER_CATEGORY,
Expand All @@ -14,7 +15,6 @@ import {
} from '../../../constants.mjs';
import {
EventContext,
formatList,
getCountdownTimeInMillis,
getUnplayedClues,
getUnrevealedClues,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { SimpleGrid } from '@chakra-ui/react';
import { range } from '@dyesoft/alea-core';
import { CATEGORIES_PER_ROUND } from '../../../../../constants.mjs';
import { range } from '../../../../../utils.mjs';
import CategoryHeading from './CategoryHeading';

function CategoryHeadings(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/game/board/clue/ActiveClue.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Box, Flex, Image, Text } from '@chakra-ui/react';
import { formatDate } from '../../../../../utils.mjs';
import { formatDate } from '@dyesoft/alea-core';
import { getPlayerName } from '../../../../reducers/game_reducer';
import ActiveClueButtons from './ActiveClueButtons';
import ActiveClueLabel from './ActiveClueLabel';
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/game/board/clue/Clue.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { faEyeLowVision } from '@fortawesome/free-solid-svg-icons';
import { Box, Flex } from '@chakra-ui/react';
import { formatDate } from '../../../../../utils.mjs';
import { formatDate } from '@dyesoft/alea-core';
import { isSafari } from '../../../../utils';
import Icon from '../../../common/Icon';

Expand Down
2 changes: 1 addition & 1 deletion src/client/components/game/board/clue/ClueGrid.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { SimpleGrid } from '@chakra-ui/react';
import { range } from '@dyesoft/alea-core';
import { CATEGORIES_PER_ROUND, CLUES_PER_CATEGORY } from '../../../../../constants.mjs';
import { range } from '../../../../../utils.mjs';
import Clue from './Clue';

function ClueGrid(props) {
Expand Down
3 changes: 2 additions & 1 deletion src/client/components/game/episode/EpisodeContestants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
SimpleGrid,
Text,
} from '@chakra-ui/react';
import { formatScore, getURLForContestant } from '../../../../utils.mjs';
import { formatScore } from '@dyesoft/alea-core';
import { getURLForContestant } from '../../../../utils.mjs';
import Bold from '../../common/Bold';

function EpisodeContestants(props) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/game/episode/EpisodeScores.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
SimpleGrid,
Text,
} from '@chakra-ui/react';
import { formatScore } from '../../../../utils.mjs';
import { formatScore } from '@dyesoft/alea-core';
import Bold from '../../common/Bold';

function EpisodeScores(props) {
Expand Down
5 changes: 3 additions & 2 deletions src/client/components/game/history/GameHistoryEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React from 'react';
import moment from 'moment';
import { Box, GridItem, HStack, ListItem, Text } from '@chakra-ui/react';
import { faGavel } from '@fortawesome/free-solid-svg-icons';
import { comparePlayerNames, formatScore } from '@dyesoft/alea-core';
import { Emoji, EventTypes } from '../../../../constants.mjs';
import { comparePlayerNames, formatScore, isDailyDouble } from '../../../../utils.mjs';
import { isDailyDouble } from '../../../../utils.mjs';
import { getPlayerName } from '../../../reducers/game_reducer';
import { formatElementList } from '../../../utils';
import ActionIcon from '../../common/ActionIcon';
Expand Down Expand Up @@ -99,7 +100,7 @@ function getEventDescription(props) {
};
}
break;
case EventTypes.PLAYER_CHANGED_NAME_AND_EMAIL:
case EventTypes.PLAYER_CHANGED_SETTINGS:
if (event.payload.name !== event.payload.prevName) {
eventConfig = {
description: <React.Fragment><PlayerName>{event.payload.prevName}</PlayerName> is now known as <PlayerName>{event.payload.name}</PlayerName>.</React.Fragment>,
Expand Down
4 changes: 2 additions & 2 deletions src/client/components/game/podium/Podium.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
PopoverTrigger,
} from '@chakra-ui/react';
import { faCrown, faUserTie } from '@fortawesome/free-solid-svg-icons';
import { DEFAULT_FONT_STYLE, MAX_PLAYER_NAME_LENGTH } from '../../../../constants.mjs';
import { formatScore } from '../../../../utils.mjs';
import { formatScore, MAX_PLAYER_NAME_LENGTH } from '@dyesoft/alea-core';
import { DEFAULT_FONT_STYLE } from '../../../../constants.mjs';
import Icon from '../../common/Icon';
import PodiumMenu from './PodiumMenu';

Expand Down
2 changes: 1 addition & 1 deletion src/client/components/game/podium/Podiums.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Flex } from '@chakra-ui/react';
import { comparePlayerNames } from '@dyesoft/alea-core';
import { MAX_PLAYERS_PER_GAME } from '../../../../constants.mjs';
import { comparePlayerNames } from '../../../../utils.mjs';
import Podium from './Podium';
import SpectatorsMenu from './SpectatorsMenu';

Expand Down
6 changes: 3 additions & 3 deletions src/client/components/game/summary/RoundScores.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Box, Flex, Divider, GridItem, Heading } from '@chakra-ui/react';
import { faCrown } from '@fortawesome/free-solid-svg-icons';
import { comparePlayerNames, formatScore } from '../../../../utils.mjs';
import { comparePlayerNames, formatScore } from '@dyesoft/alea-core';
import GridRow from '../../common/GridRow';
import Icon from '../../common/Icon';

Expand All @@ -27,10 +27,10 @@ function RoundScores(props) {
return (
<React.Fragment key={player.playerID}>
<GridRow cols={3}>
<GridItem mr={3} mt={2} pt={pt} color="jeopardyeBlue.500" d="flex" alignItems="center" justifySelf="right">
<GridItem mr={3} mt={2} pt={pt} color="jeopardyeBlue.500" display="flex" alignItems="center" justifySelf="right">
{(j === 0 ? <Heading size={fontSize}>{placeText}</Heading> : <br />)}
</GridItem>
<GridItem colSpan={2} textAlign="left" ml={8} mt={2} pt={pt} d="flex" alignItems="center">
<GridItem colSpan={2} textAlign="left" ml={8} mt={2} pt={pt} display="flex" alignItems="center">
<Heading size={fontSize}>{player.name} ({formatScore(player.score)})</Heading>
{gameOver && place === '1st' && (
<Heading color="jeopardyeYellow.500" size={getFontSize(i + 2)} ml={3}>
Expand Down
3 changes: 2 additions & 1 deletion src/client/components/game/summary/RoundSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
VStack,
} from '@chakra-ui/react';
import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons';
import { EventContext, formatList, getNextRound } from '../../../../utils.mjs';
import { formatList } from '@dyesoft/alea-core';
import { EventContext, getNextRound } from '../../../../utils.mjs';
import { getPlayerName } from '../../../reducers/game_reducer';
import Bold from '../../common/Bold';
import Card from '../../common/card/Card';
Expand Down
7 changes: 3 additions & 4 deletions src/client/components/home/CreateRoomDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
ModalContent,
ModalOverlay,
} from '@chakra-ui/react';
import { MAX_PASSWORD_LENGTH, ROOM_CODE_LENGTH, StatusCodes } from '../../../constants.mjs';
import { validateRoomCode } from '../../../models/room.mjs';
import { MAX_PASSWORD_LENGTH, ROOM_CODE_LENGTH, StatusCodes, validateRoomCode } from '@dyesoft/alea-core';
import { ActionTypes } from '../../actions/action_creators';
import Card from '../common/card/Card';
import GridRow from '../common/GridRow';
Expand Down Expand Up @@ -110,7 +109,7 @@ class CreateRoomDialog extends React.Component {
<FormLabel fontSize="lg" fontWeight="bold" mb={0}>Room Code</FormLabel>
<FormHelperText fontStyle="italic" mt={0}>{ROOM_CODE_LENGTH} letters (leave blank for random)</FormHelperText>
</GridItem>
<GridItem colSpan={2} d="flex" alignItems="center">
<GridItem colSpan={2} display="flex" alignItems="center">
<Input bg="white" focusBorderColor="jeopardyeBlue.500" size="lg" ml={2} w="75%" value={this.state.roomCode}
onChange={this.handleRoomCodeChanged} onKeyUp={this.handleKeyUp} autoFocus={true} aria-label="room-code" />
</GridItem>
Expand All @@ -122,7 +121,7 @@ class CreateRoomDialog extends React.Component {
<FormLabel fontSize="lg" fontWeight="bold" mb={0}>Password</FormLabel>
<FormHelperText fontStyle="italic" mt={0}>optional</FormHelperText>
</GridItem>
<GridItem colSpan={2} d="flex" alignItems="center">
<GridItem colSpan={2} display="flex" alignItems="center">
<Input bg="white" focusBorderColor="jeopardyeBlue.500" size="lg" ml={2} w="75%" value={this.state.password}
onChange={this.handlePasswordChanged} onKeyUp={this.handleKeyUp} type="password" aria-label="room-password" />
</GridItem>
Expand Down
11 changes: 5 additions & 6 deletions src/client/components/home/RequestLinkDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
ModalOverlay,
Text,
} from '@chakra-ui/react';
import { MAX_EMAIL_LENGTH, MAX_ROOM_REQUEST_NAME_LENGTH } from '../../../constants.mjs';
import { validateEmail } from '../../../utils.mjs';
import { MAX_EMAIL_LENGTH, MAX_ROOM_REQUEST_NAME_LENGTH, validateEmail } from '@dyesoft/alea-core';
import Card from '../common/card/Card';
import GridRow from '../common/GridRow';

Expand Down Expand Up @@ -84,21 +83,21 @@ class RequestLinkDialog extends React.Component {
</Text>
<FormControl id="name" isInvalid={this.state.nameInvalid}>
<GridRow cols={3} my={2}>
<GridItem my={1} d="flex" alignItems="center">
<GridItem my={1} display="flex" alignItems="center">
<FormLabel fontSize="lg" fontWeight="bold">Your Name</FormLabel>
</GridItem>
<GridItem colSpan={2} d="flex" alignItems="center">
<GridItem colSpan={2} display="flex" alignItems="center">
<Input bg="white" focusBorderColor="jeopardyeBlue.500" size="lg" ml={2} w="75%" value={this.state.name}
onChange={this.handleNameChanged} onKeyUp={this.handleKeyUp} autoFocus={true} aria-label="name" />
</GridItem>
</GridRow>
</FormControl>
<FormControl id="email" isInvalid={this.state.emailInvalid}>
<GridRow cols={3} my={2}>
<GridItem my={1} d="flex" alignItems="center">
<GridItem my={1} display="flex" alignItems="center">
<FormLabel fontSize="lg" fontWeight="bold" mb={0}>Email Address</FormLabel>
</GridItem>
<GridItem colSpan={2} d="flex" alignItems="center">
<GridItem colSpan={2} display="flex" alignItems="center">
<Input bg="white" focusBorderColor="jeopardyeBlue.500" size="lg" ml={2} w="75%" value={this.state.email}
onChange={this.handleEmailChanged} onKeyUp={this.handleKeyUp} type="email" aria-label="email" />
</GridItem>
Expand Down
9 changes: 5 additions & 4 deletions src/client/components/home/RoomCodeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
ModalContent,
ModalOverlay,
} from '@chakra-ui/react';
import { EventTypes, MAX_PASSWORD_LENGTH, ROOM_CODE_LENGTH, StatusCodes } from '../../../constants.mjs';
import { MAX_PASSWORD_LENGTH, ROOM_CODE_LENGTH, StatusCodes } from '@dyesoft/alea-core';
import { EventTypes } from '../../../constants.mjs';
import Card from '../common/card/Card';
import GridRow from '../common/GridRow';

Expand Down Expand Up @@ -106,10 +107,10 @@ class RoomCodeDialog extends React.Component {
<Heading mb={5} textAlign="center">Join a Room</Heading>
<FormControl id="room-code" isInvalid={this.state.roomCodeInvalid}>
<GridRow cols={3} my={2}>
<GridItem my={1} d="flex" alignItems="center">
<GridItem my={1} display="flex" alignItems="center">
<FormLabel fontSize="lg" fontWeight="bold">Room Code</FormLabel>
</GridItem>
<GridItem colSpan={2} d="flex" alignItems="center">
<GridItem colSpan={2} display="flex" alignItems="center">
<Input bg="white" focusBorderColor="jeopardyeBlue.500" size="lg" ml={2} w="75%" value={this.state.roomCode}
onChange={this.handleRoomCodeChanged} onKeyUp={this.handleKeyUp} autoFocus={true} aria-label="room-code" />
</GridItem>
Expand All @@ -121,7 +122,7 @@ class RoomCodeDialog extends React.Component {
<FormLabel fontSize="lg" fontWeight="bold" mb={0}>Password</FormLabel>
<FormHelperText fontStyle="italic" mt={0}>if provided</FormHelperText>
</GridItem>
<GridItem colSpan={2} d="flex" alignItems="center">
<GridItem colSpan={2} display="flex" alignItems="center">
<Input bg="white" focusBorderColor="jeopardyeBlue.500" size="lg" ml={2} w="75%" value={this.state.password}
onChange={this.handlePasswordChanged} onKeyUp={this.handleKeyUp} type="password" aria-label="room-password" />
</GridItem>
Expand Down
12 changes: 7 additions & 5 deletions src/client/components/lobby/history/RoomHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ import {
} from '@chakra-ui/react';
import { faCrown, faInfoCircle, faUserTie } from '@fortawesome/free-solid-svg-icons';
import {
comparePlayerNames,
formatDate,
formatScore,
getCurrentPlaces,
MILLISECONDS_PER_HOUR,
MILLISECONDS_PER_MINUTE,
SORT_ARROW_ASCENDING,
SORT_ARROW_DESCENDING,
} from '../../../../constants.mjs';
import {comparePlayerNames, formatDate, formatScore, getCurrentPlaces} from '../../../../utils.mjs';
} from '@dyesoft/alea-core';
import { SORT_ARROW_ASCENDING, SORT_ARROW_DESCENDING } from '../../../../constants.mjs';
import { formatEpisodeTitle } from '../../../utils';
import Bold from '../../common/Bold';
import Card from '../../common/card/Card';
import GridRow from '../../common/GridRow';
import Icon from '../../common/Icon';
import GridRow from "../../common/GridRow";

function scrollToTop() {
const closeButton = document.getElementById('room-history-close-button');
Expand Down
3 changes: 2 additions & 1 deletion src/client/components/lobby/settings/ByDateGameSettings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import { Button, Flex, Radio, RadioGroup, Select, Stack, Text } from '@chakra-ui/react';
import { MILLISECONDS_PER_DAY } from '@dyesoft/alea-core';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import { EARLIEST_EPISODE_DATE, GameDateSelectionModes, MILLISECONDS_PER_DAY } from '../../../../constants.mjs';
import { EARLIEST_EPISODE_DATE, GameDateSelectionModes } from '../../../../constants.mjs';
import { isValidEpisodeDate } from '../../../../utils.mjs';
import GameSetting from './GameSetting';

Expand Down
2 changes: 1 addition & 1 deletion src/client/components/lobby/settings/GameSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TabPanels,
Tabs,
} from '@chakra-ui/react';
import { parseISODateString } from '@dyesoft/alea-core';
import {
CATEGORIES_PER_ROUND,
DEFAULT_GAME_SETTINGS_MODE,
Expand All @@ -21,7 +22,6 @@ import {
SELECTED_TAB_STYLES,
} from '../../../../constants.mjs';
import { GameSettings as Settings } from '../../../../models/game.mjs';
import { parseISODateString } from '../../../../utils.mjs';
import { getPlayerName } from '../../../reducers/game_reducer';
import Card from '../../common/card/Card';
import ByCategoryGameSettings from './ByCategoryGameSettings';
Expand Down
2 changes: 1 addition & 1 deletion src/client/components/lobby/settings/RandomGameSettings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Badge } from '@chakra-ui/react';
import { range } from '@dyesoft/alea-core';
import { DailyDoubleSettings, MAX_NUM_ROUNDS } from '../../../../constants.mjs';
import { range } from '../../../../utils.mjs';
import RadioToggleGroup from '../../common/form/RadioToggleGroup';
import ToggleSwitch from '../../common/form/ToggleSwitch';
import GameSetting from './GameSetting';
Expand Down
4 changes: 2 additions & 2 deletions src/client/components/player/PlayerEmailDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
Input,
Text,
} from '@chakra-ui/react';
import { PLACEHOLDER_PLAYER_EMAIL, StatusCodes } from '../../../constants.mjs';
import { validateEmail } from '../../../utils.mjs';
import { StatusCodes, validateEmail } from '@dyesoft/alea-core';
import { PLACEHOLDER_PLAYER_EMAIL } from '../../../constants.mjs';
import { ActionTypes } from '../../actions/action_creators';
import GridRow from '../common/GridRow';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Box, GridItem, SimpleGrid, Text } from '@chakra-ui/react';
import { range } from '../../../../utils.mjs';
import { range } from '@dyesoft/alea-core';
import { ALL_FONT_STYLES } from '../../../../constants.mjs';
import GridRow from '../../common/GridRow';

Expand Down
Loading

0 comments on commit cc3e133

Please sign in to comment.