Compare commits
6 Commits
7e8fe9eb79
...
rtc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa938f7258 | ||
| 59aa904c5a | |||
|
|
06a87381d5 | ||
| 5444e25249 | |||
|
|
c4f4b09f18 | ||
|
|
25493671c5 |
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useParams } from 'next/navigation';
|
import { useParams } from 'next/navigation';
|
||||||
import { socket } from '@/socket';
|
import useSocket from '@/hooks/useSocket';
|
||||||
|
import useRTC from '@/hooks/useRTC';
|
||||||
import { Eye } from 'lucide-react';
|
import { Eye } from 'lucide-react';
|
||||||
|
|
||||||
import Card from '@/components/Card';
|
import Card from '@/components/Card';
|
||||||
@@ -10,16 +11,18 @@ import CopyButton from '@/components/CopyButton';
|
|||||||
import Notes from '@/components/Notes';
|
import Notes from '@/components/Notes';
|
||||||
import NotFound from '@/components/NotFound';
|
import NotFound from '@/components/NotFound';
|
||||||
import Settings from '@/components/Settings';
|
import Settings from '@/components/Settings';
|
||||||
|
import CardSelect from '@/components/CardSelect';
|
||||||
|
|
||||||
import { cardMap, layout } from '@/constants/tarokka';
|
import { cardMap, layout } from '@/constants/tarokka';
|
||||||
|
|
||||||
import type { GameUpdate, ClientUpdate } from '@/types';
|
import type { Deck, GameUpdate } from '@/types';
|
||||||
|
|
||||||
export default function GamePage() {
|
export default function GamePage() {
|
||||||
const { gameID: gameIDParam } = useParams();
|
const { gameID: gameIDParam } = useParams();
|
||||||
|
|
||||||
const [gameID, setGameID] = useState('');
|
const [gameID, setGameID] = useState('');
|
||||||
const [noGame, setNoGame] = useState(false);
|
const [noGame, setNoGame] = useState(false);
|
||||||
|
const [selectCard, setSelectCard] = useState(-1);
|
||||||
const [gameData, setGameData] = useState<GameUpdate>({
|
const [gameData, setGameData] = useState<GameUpdate>({
|
||||||
dmID: '',
|
dmID: '',
|
||||||
spectatorID: '',
|
spectatorID: '',
|
||||||
@@ -35,6 +38,11 @@ export default function GamePage() {
|
|||||||
|
|
||||||
const { dmID, cards, settings } = gameData;
|
const { dmID, cards, settings } = gameData;
|
||||||
const isDM = !!dmID;
|
const isDM = !!dmID;
|
||||||
|
const selectDeck: Deck | null = selectCard >= 0 ? cards[selectCard].deck : null;
|
||||||
|
|
||||||
|
const socket = useSocket({ gameID, setGameData, setNoGame });
|
||||||
|
const rtc = useRTC(socket);
|
||||||
|
console.log('useRTC:', rtc);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (gameIDParam) {
|
if (gameIDParam) {
|
||||||
@@ -42,44 +50,10 @@ export default function GamePage() {
|
|||||||
}
|
}
|
||||||
}, [gameIDParam]);
|
}, [gameIDParam]);
|
||||||
|
|
||||||
useEffect(() => {
|
const select = (cardIndex: number, cardID: string) => {
|
||||||
if (gameID) {
|
setSelectCard(-1);
|
||||||
socket.emit('join', gameID);
|
|
||||||
|
|
||||||
socket.on('init', (data: GameUpdate) => {
|
socket.select(cardIndex, cardID);
|
||||||
setGameData(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('game-update', (data: GameUpdate) => {
|
|
||||||
setGameData(data);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('join-error', (error) => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
setNoGame(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
socket.on('flip-error', (error) => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
socket.removeAllListeners();
|
|
||||||
};
|
|
||||||
}, [gameID]);
|
|
||||||
|
|
||||||
const flipCard = (cardIndex: number) => {
|
|
||||||
const flip: ClientUpdate = {
|
|
||||||
gameID,
|
|
||||||
cardIndex,
|
|
||||||
};
|
|
||||||
|
|
||||||
socket.emit('flip-card', flip);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSettings = (gameData: GameUpdate) => {
|
|
||||||
socket.emit('settings', { gameID, gameData });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// map our five Tarokka cards to their proper locations in a 3x3 grid
|
// map our five Tarokka cards to their proper locations in a 3x3 grid
|
||||||
@@ -101,7 +75,7 @@ export default function GamePage() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isDM && <Settings gameData={gameData} changeAction={handleSettings} />}
|
{isDM && <Settings gameData={gameData} changeAction={socket.handleSettings} />}
|
||||||
<div className="grid grid-cols-3 grid-rows-3 gap-8 w-fit mx-auto">
|
<div className="grid grid-cols-3 grid-rows-3 gap-8 w-fit mx-auto">
|
||||||
{Array.from({ length: 9 })
|
{Array.from({ length: 9 })
|
||||||
.map(arrangeCards)
|
.map(arrangeCards)
|
||||||
@@ -113,13 +87,22 @@ export default function GamePage() {
|
|||||||
card={card}
|
card={card}
|
||||||
position={layout[cardMap[index]]}
|
position={layout[cardMap[index]]}
|
||||||
settings={settings}
|
settings={settings}
|
||||||
flipAction={() => flipCard(cardMap[index])}
|
flipAction={() => socket.flipCard(cardMap[index])}
|
||||||
|
redrawAction={() => socket.redraw(cardMap[index])}
|
||||||
|
selectAction={() => setSelectCard(cardMap[index])}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<Notes gameData={gameData} show={cards.every(({ flipped }) => flipped)} />
|
<Notes gameData={gameData} show={cards.every(({ flipped }) => flipped)} />
|
||||||
|
<CardSelect
|
||||||
|
show={selectDeck}
|
||||||
|
hand={cards}
|
||||||
|
settings={settings}
|
||||||
|
closeAction={() => setSelectCard(-1)}
|
||||||
|
selectAction={(cardID) => select(selectCard, cardID)}
|
||||||
|
/>
|
||||||
</main>
|
</main>
|
||||||
) : null;
|
) : null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,3 +40,21 @@ body {
|
|||||||
.rotate-y-180 {
|
.rotate-y-180 {
|
||||||
transform: rotateY(180deg);
|
transform: rotateY(180deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.see-through {
|
||||||
|
mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 1) 75%);
|
||||||
|
mask-size: cover;
|
||||||
|
mask-repeat: no-repeat;
|
||||||
|
-webkit-mask-image: radial-gradient(circle at center, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 1) 75%);
|
||||||
|
-webkit-mask-size: cover;
|
||||||
|
-webkit-mask-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-hide {
|
||||||
|
scrollbar-width: none;
|
||||||
|
-ms-overflow-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollbar-hide::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|||||||
10
app/page.tsx
10
app/page.tsx
@@ -16,13 +16,19 @@ export default function Home() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="min-h-screen flex items-center justify-center bg-[url('/img/table3.png')] bg-cover bg-center">
|
<main className="min-h-screen flex justify-center items-center text-yellow-400 bg-[url('/img/table3.png')] bg-cover bg-center">
|
||||||
|
<div className="flex flex-col items-center gap-8 text-center">
|
||||||
|
<h1 className="text-5xl font-bold text-center text-primary">Tarokka</h1>
|
||||||
|
<p className="text-l text-center w-[350px] m-auto">
|
||||||
|
Online Tarokka readings for <em>Dungeons & Dragons: Curse of Strahd</em>.
|
||||||
|
</p>
|
||||||
<button
|
<button
|
||||||
onClick={handleCreateGame}
|
onClick={handleCreateGame}
|
||||||
className="bg-slate-800 hover:bg-slate-700 text-yellow-400 border border-yellow-500/25 hover:drop-shadow-[0_0_3px_rgba(255,215,0,0.5)] hover:text-yellow-300 text-lg px-6 py-3 rounded-lg shadow transition-all duration-250 cursor-pointer"
|
className="bg-slate-800 hover:bg-slate-700 border border-yellow-500/25 hover:drop-shadow-[0_0_3px_rgba(255,215,0,0.5)] hover:text-yellow-300 text-lg px-6 py-3 rounded-lg shadow transition-all duration-250 cursor-pointer"
|
||||||
>
|
>
|
||||||
Create New Game
|
Create New Game
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { useState } from 'react';
|
||||||
|
import TiltCard from '@/components/TiltCard';
|
||||||
import ToolTip from '@/components/ToolTip';
|
import ToolTip from '@/components/ToolTip';
|
||||||
|
import StackTheDeck from '@/components/StackTheDeck';
|
||||||
import tarokkaCards from '@/constants/tarokkaCards';
|
import tarokkaCards from '@/constants/tarokkaCards';
|
||||||
import getCardInfo from '@/tools/getCardInfo';
|
import getCardInfo from '@/tools/getCardInfo';
|
||||||
import getURL from '@/tools/getURL';
|
import getURL from '@/tools/getURL';
|
||||||
@@ -15,9 +18,21 @@ type CardProps = {
|
|||||||
position: Layout;
|
position: Layout;
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
flipAction: () => void;
|
flipAction: () => void;
|
||||||
|
redrawAction: () => void;
|
||||||
|
selectAction: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Card({ dm, card, position, settings, flipAction }: CardProps) {
|
export default function Card({
|
||||||
|
dm,
|
||||||
|
card,
|
||||||
|
position,
|
||||||
|
settings,
|
||||||
|
flipAction,
|
||||||
|
redrawAction,
|
||||||
|
selectAction,
|
||||||
|
}: CardProps) {
|
||||||
|
const [tooltip, setTooltip] = useState<React.ReactNode>(null);
|
||||||
|
|
||||||
const { aria, flipped } = card;
|
const { aria, flipped } = card;
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
@@ -42,22 +57,39 @@ export default function Card({ dm, card, position, settings, flipAction }: CardP
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToolTip content={getTooltip()}>
|
<ToolTip content={tooltip || getTooltip()}>
|
||||||
<div
|
<TiltCard
|
||||||
className={`relative h-[21vh] w-[15vh] perspective transition-transform duration-200 hover:scale-150 z-0 hover:z-10 ${dm ? 'cursor-pointer' : ''} `}
|
className={`h-[21vh] w-[15vh] relative perspective transition-transform duration-200 z-0 hover:z-10 hover:scale-150 ${dm ? 'cursor-pointer' : ''} `}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`transition-transform duration-500 transform-style-preserve-3d ${flipped ? 'rotate-y-180' : ''}`}
|
className={`absolute inset-0 transition-transform duration-500 transform-style-preserve-3d ${flipped ? 'rotate-y-180' : ''}`}
|
||||||
>
|
>
|
||||||
<div className="absolute group inset-0 backface-hidden">
|
<div className="absolute inset-0 group backface-hidden">
|
||||||
|
{dm && (
|
||||||
|
<>
|
||||||
|
<img src={getURL(card, settings)} alt={aria} className="absolute rounded-lg" />
|
||||||
|
<img
|
||||||
|
src={getURL(cardBack as TarokkaGameCard, settings)}
|
||||||
|
alt=""
|
||||||
|
className={`absolute rounded-lg see-through`}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<img
|
<img
|
||||||
src={getURL(cardBack as TarokkaGameCard, settings)}
|
src={getURL(cardBack as TarokkaGameCard, settings)}
|
||||||
alt="Card Back"
|
alt="Card Back"
|
||||||
className={`rounded-lg ${settings.cardStyle === 'grayscale' ? 'border border-yellow-500/25 hover:drop-shadow-[0_0_3px_#ffd700/50]' : ''}`}
|
className={`absolute rounded-lg ${dm ? 'transition duration-500 group-hover:opacity-0' : ''} ${settings.cardStyle === 'grayscale' ? 'border border-yellow-500/25 group-hover:drop-shadow-[0_0_3px_#ffd700/50]' : ''}`}
|
||||||
/>
|
/>
|
||||||
|
{dm && !flipped && (
|
||||||
|
<StackTheDeck
|
||||||
|
onRedraw={redrawAction}
|
||||||
|
onSelect={() => selectAction()}
|
||||||
|
onHover={setTooltip}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute group inset-0 backface-hidden rotate-y-180">
|
<div className="absolute inset-0 backface-hidden rotate-y-180">
|
||||||
<img
|
<img
|
||||||
src={getURL(card, settings)}
|
src={getURL(card, settings)}
|
||||||
alt={aria}
|
alt={aria}
|
||||||
@@ -65,7 +97,7 @@ export default function Card({ dm, card, position, settings, flipAction }: CardP
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</TiltCard>
|
||||||
</ToolTip>
|
</ToolTip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
73
components/CardSelect.tsx
Normal file
73
components/CardSelect.tsx
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import { CircleX } from 'lucide-react';
|
||||||
|
import TarokkaDeck from '@/lib/TarokkaDeck';
|
||||||
|
import getURL from '@/tools/getURL';
|
||||||
|
|
||||||
|
import { Deck, Settings, TarokkaGameCard } from '@/types';
|
||||||
|
|
||||||
|
const tarokkaDeck = new TarokkaDeck();
|
||||||
|
|
||||||
|
type CardSelectProps = {
|
||||||
|
closeAction: () => void;
|
||||||
|
selectAction: (cardID: string) => void;
|
||||||
|
hand: TarokkaGameCard[];
|
||||||
|
settings: Settings;
|
||||||
|
show: Deck | null;
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function CardSelect({
|
||||||
|
closeAction,
|
||||||
|
selectAction,
|
||||||
|
hand,
|
||||||
|
settings,
|
||||||
|
show,
|
||||||
|
className = '',
|
||||||
|
}: CardSelectProps) {
|
||||||
|
const handIDs = hand.map(({ id }) => id);
|
||||||
|
|
||||||
|
const handleClose = (event: React.MouseEvent<HTMLElement>) => {
|
||||||
|
if (event.target === event.currentTarget) {
|
||||||
|
closeAction();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!show) return null;
|
||||||
|
|
||||||
|
const cards = show === 'high' ? tarokkaDeck.getHigh() : tarokkaDeck.getLow();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
onClick={handleClose}
|
||||||
|
className={`fixed inset-0 flex justify-center items-center p-4 bg-black/20 backdrop-blur-sm z-40 ${className}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className={`fixed top-4 right-4 p-2 transition-all duration-250 text-yellow-400 hover:text-yellow-300 hover:drop-shadow-[0_0_3px_#ffd700] cursor-pointer`}
|
||||||
|
onClick={closeAction}
|
||||||
|
>
|
||||||
|
<CircleX className="w-6 h-6" />
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
onClick={handleClose}
|
||||||
|
className={`flex flex-wrap justify-center items-center gap-3 h-dvh w-2/3 overflow-scroll scrollbar-hide p-4`}
|
||||||
|
>
|
||||||
|
{cards
|
||||||
|
.filter(({ id }) => !handIDs.includes(id))
|
||||||
|
.map((card) => (
|
||||||
|
<div
|
||||||
|
key={card.id}
|
||||||
|
className={`relative h-[21vh] w-[15vh] perspective transition-transform duration-200 hover:scale-150 z-0 hover:z-10`}
|
||||||
|
onClick={() => selectAction(card.id)}
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
src={getURL(card, settings)}
|
||||||
|
alt={card.aria}
|
||||||
|
className="rounded-lg border border-yellow-500/25 hover:drop-shadow-[0_0_3px_#ffd700/50]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ export default function Scrim({ children, clickAction, show = true, className =
|
|||||||
clickAction(event);
|
clickAction(event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!show) return null;
|
if (!show) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
48
components/StackTheDeck.tsx
Normal file
48
components/StackTheDeck.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { GalleryHorizontalEnd, RefreshCw } from 'lucide-react';
|
||||||
|
|
||||||
|
interface StackTheDeckProps {
|
||||||
|
onRedraw: () => void;
|
||||||
|
onSelect: () => void;
|
||||||
|
onHover: (state: React.ReactNode) => void;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function StackTheDeck({
|
||||||
|
onRedraw,
|
||||||
|
onSelect,
|
||||||
|
onHover,
|
||||||
|
className = '',
|
||||||
|
}: StackTheDeckProps) {
|
||||||
|
const curryHandleClick = (action: () => void) => (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
action();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`absolute top-0 right-0 flex flex-col items-center justify-center bg-black/50 rounded-tr-lg rounded-bl-lg ${className}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
onMouseEnter={() => onHover(<p className="text-yellow-400">Redraw</p>)}
|
||||||
|
onMouseLeave={() => onHover(null)}
|
||||||
|
onTouchStart={() => onHover(<p className="text-yellow-400">Redraw</p>)}
|
||||||
|
onTouchEnd={() => onHover(null)}
|
||||||
|
className={`p-1 transition-all duration-250 text-yellow-400 hover:text-yellow-300 hover:drop-shadow-[0_0_3px_#ffd700] cursor-pointer`}
|
||||||
|
onClick={curryHandleClick(onRedraw)}
|
||||||
|
>
|
||||||
|
<RefreshCw className="w-3 h-3" />
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
onMouseEnter={() => onHover(<p className="text-yellow-400">Select</p>)}
|
||||||
|
onMouseLeave={() => onHover(null)}
|
||||||
|
onTouchStart={() => onHover(<p className="text-yellow-400">Select</p>)}
|
||||||
|
onTouchEnd={() => onHover(null)}
|
||||||
|
className={`p-1 transition-all duration-250 text-yellow-400 hover:text-yellow-300 hover:drop-shadow-[0_0_3px_#ffd700] cursor-pointer`}
|
||||||
|
onClick={curryHandleClick(onSelect)}
|
||||||
|
>
|
||||||
|
<GalleryHorizontalEnd className="w-3 h-3" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
48
components/TiltCard.tsx
Normal file
48
components/TiltCard.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { useRef } from 'react';
|
||||||
|
|
||||||
|
export default function TiltCard({
|
||||||
|
children,
|
||||||
|
className = '',
|
||||||
|
onClick = () => {},
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
className?: string;
|
||||||
|
onClick: (event: React.MouseEvent) => void;
|
||||||
|
}) {
|
||||||
|
const cardRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
const handleMouseMove = (e: React.MouseEvent) => {
|
||||||
|
const card = cardRef.current;
|
||||||
|
if (!card) return;
|
||||||
|
|
||||||
|
const rect = card.getBoundingClientRect();
|
||||||
|
const x = e.clientX - rect.left;
|
||||||
|
const y = e.clientY - rect.top;
|
||||||
|
const centerX = rect.width / 2;
|
||||||
|
const centerY = rect.height / 2;
|
||||||
|
|
||||||
|
const rotateX = ((y - centerY) / centerY) * -20;
|
||||||
|
const rotateY = ((x - centerX) / centerX) * 20;
|
||||||
|
|
||||||
|
card.style.transform = `rotateX(${rotateX}deg) rotateY(${rotateY}deg)`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseLeave = () => {
|
||||||
|
const card = cardRef.current;
|
||||||
|
if (!card) return;
|
||||||
|
card.style.transform = `rotateX(0deg) rotateY(0deg)`;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`${className}`}
|
||||||
|
onMouseMove={handleMouseMove}
|
||||||
|
onMouseLeave={handleMouseLeave}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
<div ref={cardRef} className={`h-full w-full transition-transform duration-0`}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -15,8 +15,8 @@ type TooltipProps = {
|
|||||||
export default function Tooltip({
|
export default function Tooltip({
|
||||||
children,
|
children,
|
||||||
content,
|
content,
|
||||||
delay = 500,
|
delay = 250,
|
||||||
mobileDelay = 500,
|
mobileDelay = 250,
|
||||||
offsetX = 20,
|
offsetX = 20,
|
||||||
offsetY = 20,
|
offsetY = 20,
|
||||||
edgeBuffer = 10,
|
edgeBuffer = 10,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'back',
|
id: 'back',
|
||||||
name: 'Card Back',
|
name: 'Card Back',
|
||||||
card: 'Back of card',
|
card: 'Back of card',
|
||||||
|
deck: 'back',
|
||||||
suit: null,
|
suit: null,
|
||||||
aria: 'Back of card',
|
aria: 'Back of card',
|
||||||
description: 'Back of card',
|
description: 'Back of card',
|
||||||
@@ -15,6 +16,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'swashbuckler',
|
id: 'swashbuckler',
|
||||||
name: 'Swashbuckler',
|
name: 'Swashbuckler',
|
||||||
card: 'One of Coins',
|
card: 'One of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 01 Swashbuckler',
|
aria: 'Coins 01 Swashbuckler',
|
||||||
description: 'Those who like money yet give it up freely; likable rogues and rapscallions',
|
description: 'Those who like money yet give it up freely; likable rogues and rapscallions',
|
||||||
@@ -31,6 +33,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'philanthropist',
|
id: 'philanthropist',
|
||||||
name: 'Philanthropist',
|
name: 'Philanthropist',
|
||||||
card: 'Two of Coins',
|
card: 'Two of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 02 Philanthropist',
|
aria: 'Coins 02 Philanthropist',
|
||||||
description:
|
description:
|
||||||
@@ -48,6 +51,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'trader',
|
id: 'trader',
|
||||||
name: 'Trader',
|
name: 'Trader',
|
||||||
card: 'Three of Coins',
|
card: 'Three of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 03 Trader',
|
aria: 'Coins 03 Trader',
|
||||||
description: 'Commerce; smuggling and black markets; fair and equitable trades',
|
description: 'Commerce; smuggling and black markets; fair and equitable trades',
|
||||||
@@ -64,6 +68,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'merchant',
|
id: 'merchant',
|
||||||
name: 'Merchant',
|
name: 'Merchant',
|
||||||
card: 'Four of Coins',
|
card: 'Four of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 04 Merchant',
|
aria: 'Coins 04 Merchant',
|
||||||
description:
|
description:
|
||||||
@@ -80,6 +85,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'guild-member',
|
id: 'guild-member',
|
||||||
name: 'Guild Member',
|
name: 'Guild Member',
|
||||||
card: 'Five of Coins',
|
card: 'Five of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 05 Guild Member',
|
aria: 'Coins 05 Guild Member',
|
||||||
description: "Like-minded individuals joined together in a common goal; pride in one's work",
|
description: "Like-minded individuals joined together in a common goal; pride in one's work",
|
||||||
@@ -95,6 +101,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'beggar',
|
id: 'beggar',
|
||||||
name: 'Beggar',
|
name: 'Beggar',
|
||||||
card: 'Six of Coins',
|
card: 'Six of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 06 Beggar',
|
aria: 'Coins 06 Beggar',
|
||||||
description: 'Sudden change in economic status or fortune',
|
description: 'Sudden change in economic status or fortune',
|
||||||
@@ -111,6 +118,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'thief',
|
id: 'thief',
|
||||||
name: 'Thief',
|
name: 'Thief',
|
||||||
card: 'Seven of Coins',
|
card: 'Seven of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 07 Thief',
|
aria: 'Coins 07 Thief',
|
||||||
description:
|
description:
|
||||||
@@ -128,6 +136,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'tax-collector',
|
id: 'tax-collector',
|
||||||
name: 'Tax Collector',
|
name: 'Tax Collector',
|
||||||
card: 'Eight of Coins',
|
card: 'Eight of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 08 Tax Collector',
|
aria: 'Coins 08 Tax Collector',
|
||||||
description: 'Corruption; honesty in an otherwise corrupt government or organization',
|
description: 'Corruption; honesty in an otherwise corrupt government or organization',
|
||||||
@@ -145,6 +154,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'miser',
|
id: 'miser',
|
||||||
name: 'Miser',
|
name: 'Miser',
|
||||||
card: 'Nine of Coins',
|
card: 'Nine of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 09 Miser',
|
aria: 'Coins 09 Miser',
|
||||||
description:
|
description:
|
||||||
@@ -161,6 +171,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'rogue',
|
id: 'rogue',
|
||||||
name: 'Rogue',
|
name: 'Rogue',
|
||||||
card: 'Master of Coins',
|
card: 'Master of Coins',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Coins',
|
suit: 'Coins',
|
||||||
aria: 'Coins 10 Rogue',
|
aria: 'Coins 10 Rogue',
|
||||||
description:
|
description:
|
||||||
@@ -177,6 +188,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'monk',
|
id: 'monk',
|
||||||
name: 'Monk',
|
name: 'Monk',
|
||||||
card: 'One of Glyphs',
|
card: 'One of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 01 Monk',
|
aria: 'Glyphs 01 Monk',
|
||||||
description:
|
description:
|
||||||
@@ -194,6 +206,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'missionary',
|
id: 'missionary',
|
||||||
name: 'Missionary',
|
name: 'Missionary',
|
||||||
card: 'Two of Glyphs',
|
card: 'Two of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 02 Missionary',
|
aria: 'Glyphs 02 Missionary',
|
||||||
description:
|
description:
|
||||||
@@ -212,6 +225,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'healer',
|
id: 'healer',
|
||||||
name: 'Healer',
|
name: 'Healer',
|
||||||
card: 'Three of Glyphs',
|
card: 'Three of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 03 Healer',
|
aria: 'Glyphs 03 Healer',
|
||||||
description:
|
description:
|
||||||
@@ -229,6 +243,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'shepherd',
|
id: 'shepherd',
|
||||||
name: 'Shepherd',
|
name: 'Shepherd',
|
||||||
card: 'Four of Glyphs',
|
card: 'Four of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 04 Shepherd',
|
aria: 'Glyphs 04 Shepherd',
|
||||||
description:
|
description:
|
||||||
@@ -246,6 +261,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'druid',
|
id: 'druid',
|
||||||
name: 'Druid',
|
name: 'Druid',
|
||||||
card: 'Five of Glyphs',
|
card: 'Five of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 05 Druid',
|
aria: 'Glyphs 05 Druid',
|
||||||
description:
|
description:
|
||||||
@@ -264,6 +280,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'anarchist',
|
id: 'anarchist',
|
||||||
name: 'Anarchist',
|
name: 'Anarchist',
|
||||||
card: 'Six of Glyphs',
|
card: 'Six of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 06 Anarchist',
|
aria: 'Glyphs 06 Anarchist',
|
||||||
description: 'A fundamental change brought on by one whose beliefs are being put to the test',
|
description: 'A fundamental change brought on by one whose beliefs are being put to the test',
|
||||||
@@ -280,6 +297,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'charlatan',
|
id: 'charlatan',
|
||||||
name: 'Charlatan',
|
name: 'Charlatan',
|
||||||
card: 'Seven of Glyphs',
|
card: 'Seven of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 07 Charlatan',
|
aria: 'Glyphs 07 Charlatan',
|
||||||
description: 'Liars; those who profess to believe one thing but actually believe another',
|
description: 'Liars; those who profess to believe one thing but actually believe another',
|
||||||
@@ -295,6 +313,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'bishop',
|
id: 'bishop',
|
||||||
name: 'Bishop',
|
name: 'Bishop',
|
||||||
card: 'Eight of Glyphs',
|
card: 'Eight of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 08 Bishop',
|
aria: 'Glyphs 08 Bishop',
|
||||||
description: 'Strict adherence to a code or a belief; those who plot, plan, and scheme',
|
description: 'Strict adherence to a code or a belief; those who plot, plan, and scheme',
|
||||||
@@ -311,6 +330,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'traitor',
|
id: 'traitor',
|
||||||
name: 'Traitor',
|
name: 'Traitor',
|
||||||
card: 'Nine of Glyphs',
|
card: 'Nine of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 09 Traitor',
|
aria: 'Glyphs 09 Traitor',
|
||||||
description: 'Betrayal by someone close and trusted; a weakening or loss of faith',
|
description: 'Betrayal by someone close and trusted; a weakening or loss of faith',
|
||||||
@@ -328,6 +348,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'priest',
|
id: 'priest',
|
||||||
name: 'Priest',
|
name: 'Priest',
|
||||||
card: 'Master of Glyphs',
|
card: 'Master of Glyphs',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Glyphs',
|
suit: 'Glyphs',
|
||||||
aria: 'Glyphs 10 Priest',
|
aria: 'Glyphs 10 Priest',
|
||||||
description: 'Enlightenment; those who follow a deity, a system of values, or a higher purpose',
|
description: 'Enlightenment; those who follow a deity, a system of values, or a higher purpose',
|
||||||
@@ -344,6 +365,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'transmuter',
|
id: 'transmuter',
|
||||||
name: 'Transmuter',
|
name: 'Transmuter',
|
||||||
card: 'One of Stars',
|
card: 'One of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 01 Transmuter',
|
aria: 'Stars 01 Transmuter',
|
||||||
description:
|
description:
|
||||||
@@ -360,6 +382,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'diviner',
|
id: 'diviner',
|
||||||
name: 'Diviner',
|
name: 'Diviner',
|
||||||
card: 'Two of Stars',
|
card: 'Two of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 02 Diviner',
|
aria: 'Stars 02 Diviner',
|
||||||
description:
|
description:
|
||||||
@@ -377,6 +400,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'enchanter',
|
id: 'enchanter',
|
||||||
name: 'Enchanter',
|
name: 'Enchanter',
|
||||||
card: 'Three of Stars',
|
card: 'Three of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 03 Enchanter',
|
aria: 'Stars 03 Enchanter',
|
||||||
description: 'Inner turmoil that comes from confusion, fear of failure, or false information',
|
description: 'Inner turmoil that comes from confusion, fear of failure, or false information',
|
||||||
@@ -394,6 +418,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'abjurer',
|
id: 'abjurer',
|
||||||
name: 'Abjurer',
|
name: 'Abjurer',
|
||||||
card: 'Four of Stars',
|
card: 'Four of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 04 Abjurer',
|
aria: 'Stars 04 Abjurer',
|
||||||
description:
|
description:
|
||||||
@@ -411,6 +436,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'elementalist',
|
id: 'elementalist',
|
||||||
name: 'Elementalist',
|
name: 'Elementalist',
|
||||||
card: 'Five of Stars',
|
card: 'Five of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 05 Elementalist',
|
aria: 'Stars 05 Elementalist',
|
||||||
description:
|
description:
|
||||||
@@ -429,6 +455,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'evoker',
|
id: 'evoker',
|
||||||
name: 'Evoker',
|
name: 'Evoker',
|
||||||
card: 'Six of Stars',
|
card: 'Six of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 06 Evoker',
|
aria: 'Stars 06 Evoker',
|
||||||
description:
|
description:
|
||||||
@@ -446,6 +473,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'illusionist',
|
id: 'illusionist',
|
||||||
name: 'Illusionist',
|
name: 'Illusionist',
|
||||||
card: 'Seven of Stars',
|
card: 'Seven of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 07 Illusionist',
|
aria: 'Stars 07 Illusionist',
|
||||||
description:
|
description:
|
||||||
@@ -463,6 +491,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'necromancer',
|
id: 'necromancer',
|
||||||
name: 'Necromancer',
|
name: 'Necromancer',
|
||||||
card: 'Eight of Stars',
|
card: 'Eight of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 08 Necromancer',
|
aria: 'Stars 08 Necromancer',
|
||||||
description: 'Unnatural events and unhealthy obsessions; those who follow a destructive path',
|
description: 'Unnatural events and unhealthy obsessions; those who follow a destructive path',
|
||||||
@@ -478,6 +507,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'conjurer',
|
id: 'conjurer',
|
||||||
name: 'Conjurer',
|
name: 'Conjurer',
|
||||||
card: 'Nine of Stars',
|
card: 'Nine of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 09 Conjurer',
|
aria: 'Stars 09 Conjurer',
|
||||||
description:
|
description:
|
||||||
@@ -495,6 +525,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'wizard',
|
id: 'wizard',
|
||||||
name: 'Wizard',
|
name: 'Wizard',
|
||||||
card: 'Master of Stars',
|
card: 'Master of Stars',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Stars',
|
suit: 'Stars',
|
||||||
aria: 'Stars 10 Wizard',
|
aria: 'Stars 10 Wizard',
|
||||||
description:
|
description:
|
||||||
@@ -512,6 +543,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'avenger',
|
id: 'avenger',
|
||||||
name: 'Avenger',
|
name: 'Avenger',
|
||||||
card: 'One of Swords',
|
card: 'One of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 01 Avenger',
|
aria: 'Swords 01 Avenger',
|
||||||
description:
|
description:
|
||||||
@@ -529,6 +561,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'paladin',
|
id: 'paladin',
|
||||||
name: 'Paladin',
|
name: 'Paladin',
|
||||||
card: 'Two of Swords',
|
card: 'Two of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 02 Paladin',
|
aria: 'Swords 02 Paladin',
|
||||||
description: 'Just and noble warriors; those who live by a code of honor and integrity',
|
description: 'Just and noble warriors; those who live by a code of honor and integrity',
|
||||||
@@ -545,6 +578,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'soldier',
|
id: 'soldier',
|
||||||
name: 'Soldier',
|
name: 'Soldier',
|
||||||
card: 'Three of Swords',
|
card: 'Three of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 03 Soldier',
|
aria: 'Swords 03 Soldier',
|
||||||
description: 'War and sacrifice; the stamina to endure great hardship',
|
description: 'War and sacrifice; the stamina to endure great hardship',
|
||||||
@@ -561,6 +595,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'mercenary',
|
id: 'mercenary',
|
||||||
name: 'Mercenary',
|
name: 'Mercenary',
|
||||||
card: 'Four of Swords',
|
card: 'Four of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 04 Mercenary',
|
aria: 'Swords 04 Mercenary',
|
||||||
description: 'Inner strength and fortitude; those who fight for power or wealth',
|
description: 'Inner strength and fortitude; those who fight for power or wealth',
|
||||||
@@ -576,6 +611,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'myrmidon',
|
id: 'myrmidon',
|
||||||
name: 'Myrmidon',
|
name: 'Myrmidon',
|
||||||
card: 'Five of Swords',
|
card: 'Five of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 05 Myrmidon',
|
aria: 'Swords 05 Myrmidon',
|
||||||
description:
|
description:
|
||||||
@@ -594,6 +630,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'berserker',
|
id: 'berserker',
|
||||||
name: 'Berserker',
|
name: 'Berserker',
|
||||||
card: 'Six of Swords',
|
card: 'Six of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 06 Berserker',
|
aria: 'Swords 06 Berserker',
|
||||||
description: 'The brutal and barbaric side of warfare; bloodlust; those with a bestial nature',
|
description: 'The brutal and barbaric side of warfare; bloodlust; those with a bestial nature',
|
||||||
@@ -611,6 +648,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'hooded-one',
|
id: 'hooded-one',
|
||||||
name: 'Hooded One',
|
name: 'Hooded One',
|
||||||
card: 'Seven of Swords',
|
card: 'Seven of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 07 Hooded One',
|
aria: 'Swords 07 Hooded One',
|
||||||
description: 'Bigotry, intolerance, and xenophobia; a mysterious presence or newcomer',
|
description: 'Bigotry, intolerance, and xenophobia; a mysterious presence or newcomer',
|
||||||
@@ -628,6 +666,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'dictator',
|
id: 'dictator',
|
||||||
name: 'Dictator',
|
name: 'Dictator',
|
||||||
card: 'Eight of Swords',
|
card: 'Eight of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 08 Dictator',
|
aria: 'Swords 08 Dictator',
|
||||||
description:
|
description:
|
||||||
@@ -644,6 +683,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'torturer',
|
id: 'torturer',
|
||||||
name: 'Torturer',
|
name: 'Torturer',
|
||||||
card: 'Nine of Swords',
|
card: 'Nine of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 09 Torturer',
|
aria: 'Swords 09 Torturer',
|
||||||
description:
|
description:
|
||||||
@@ -662,6 +702,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'warrior',
|
id: 'warrior',
|
||||||
name: 'Warrior',
|
name: 'Warrior',
|
||||||
card: 'Master of Swords',
|
card: 'Master of Swords',
|
||||||
|
deck: 'common',
|
||||||
suit: 'Swords',
|
suit: 'Swords',
|
||||||
aria: 'Swords 10 Warrior',
|
aria: 'Swords 10 Warrior',
|
||||||
description:
|
description:
|
||||||
@@ -679,6 +720,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'artifact',
|
id: 'artifact',
|
||||||
name: 'Artifact',
|
name: 'Artifact',
|
||||||
card: 'The Artifact',
|
card: 'The Artifact',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Artifact',
|
aria: 'High Deck Artifact',
|
||||||
description:
|
description:
|
||||||
@@ -703,6 +745,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'beast',
|
id: 'beast',
|
||||||
name: 'Beast',
|
name: 'Beast',
|
||||||
card: 'The Beast',
|
card: 'The Beast',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Beast',
|
aria: 'High Deck Beast',
|
||||||
description:
|
description:
|
||||||
@@ -728,6 +771,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'broken-one',
|
id: 'broken-one',
|
||||||
name: 'Broken One',
|
name: 'Broken One',
|
||||||
card: 'The Broken One',
|
card: 'The Broken One',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Broken One',
|
aria: 'High Deck Broken One',
|
||||||
description:
|
description:
|
||||||
@@ -759,6 +803,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'darklord',
|
id: 'darklord',
|
||||||
name: 'Darklord',
|
name: 'Darklord',
|
||||||
card: 'The Darklord',
|
card: 'The Darklord',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Darklord',
|
aria: 'High Deck Darklord',
|
||||||
description:
|
description:
|
||||||
@@ -782,6 +827,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'donjon',
|
id: 'donjon',
|
||||||
name: 'Donjon',
|
name: 'Donjon',
|
||||||
card: 'The Donjon',
|
card: 'The Donjon',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Donjon',
|
aria: 'High Deck Donjon',
|
||||||
description:
|
description:
|
||||||
@@ -814,6 +860,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'executioner',
|
id: 'executioner',
|
||||||
name: 'Executioner',
|
name: 'Executioner',
|
||||||
card: 'The Executioner',
|
card: 'The Executioner',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Executioner',
|
aria: 'High Deck Executioner',
|
||||||
description:
|
description:
|
||||||
@@ -840,6 +887,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'ghost',
|
id: 'ghost',
|
||||||
name: 'Ghost',
|
name: 'Ghost',
|
||||||
card: 'The Ghost',
|
card: 'The Ghost',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Ghost',
|
aria: 'High Deck Ghost',
|
||||||
description:
|
description:
|
||||||
@@ -873,6 +921,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'horseman',
|
id: 'horseman',
|
||||||
name: 'Horseman',
|
name: 'Horseman',
|
||||||
card: 'The Horseman',
|
card: 'The Horseman',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Horseman',
|
aria: 'High Deck Horseman',
|
||||||
description:
|
description:
|
||||||
@@ -905,6 +954,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'innocent',
|
id: 'innocent',
|
||||||
name: 'Innocent',
|
name: 'Innocent',
|
||||||
card: 'The Innocent',
|
card: 'The Innocent',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Innocent',
|
aria: 'High Deck Innocent',
|
||||||
description:
|
description:
|
||||||
@@ -937,6 +987,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'marionette',
|
id: 'marionette',
|
||||||
name: 'Marionette',
|
name: 'Marionette',
|
||||||
card: 'The Marionette',
|
card: 'The Marionette',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Marionette',
|
aria: 'High Deck Marionette',
|
||||||
description:
|
description:
|
||||||
@@ -968,6 +1019,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'mists',
|
id: 'mists',
|
||||||
name: 'Mists',
|
name: 'Mists',
|
||||||
card: 'The Mists',
|
card: 'The Mists',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Mists',
|
aria: 'High Deck Mists',
|
||||||
description:
|
description:
|
||||||
@@ -994,6 +1046,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'raven',
|
id: 'raven',
|
||||||
name: 'Raven',
|
name: 'Raven',
|
||||||
card: 'The Raven',
|
card: 'The Raven',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Raven',
|
aria: 'High Deck Raven',
|
||||||
description:
|
description:
|
||||||
@@ -1020,6 +1073,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'seer',
|
id: 'seer',
|
||||||
name: 'Seer',
|
name: 'Seer',
|
||||||
card: 'The Seer',
|
card: 'The Seer',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Seer',
|
aria: 'High Deck Seer',
|
||||||
description:
|
description:
|
||||||
@@ -1046,6 +1100,7 @@ const tarokkaCards: TarokkaCard[] = [
|
|||||||
id: 'tempter',
|
id: 'tempter',
|
||||||
name: 'Tempter',
|
name: 'Tempter',
|
||||||
card: 'The Tempter',
|
card: 'The Tempter',
|
||||||
|
deck: 'high',
|
||||||
suit: 'High Deck',
|
suit: 'High Deck',
|
||||||
aria: 'High Deck Tempter',
|
aria: 'High Deck Tempter',
|
||||||
description:
|
description:
|
||||||
|
|||||||
95
hooks/useChatGPT.ts
Normal file
95
hooks/useChatGPT.ts
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { io, Socket } from 'socket.io-client';
|
||||||
|
|
||||||
|
interface CursorPosition {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PeerMouseHook {
|
||||||
|
cursors: Record<string, CursorPosition>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function usePeerMouse(roomId: string): PeerMouseHook {
|
||||||
|
const [cursors, setCursors] = useState<Record<string, CursorPosition>>({});
|
||||||
|
const socketRef = useRef<Socket | null>(null);
|
||||||
|
const peers = useRef<Record<string, RTCPeerConnection>>({});
|
||||||
|
const channels = useRef<Record<string, RTCDataChannel>>({});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const socket = io();
|
||||||
|
socketRef.current = socket;
|
||||||
|
|
||||||
|
socket.emit('join-room', roomId);
|
||||||
|
|
||||||
|
socket.on('new-peer', async (peerId: string) => {
|
||||||
|
const pc = createPeer(peerId, true);
|
||||||
|
const offer = await pc.createOffer();
|
||||||
|
await pc.setLocalDescription(offer);
|
||||||
|
socket.emit('signal', { to: peerId, data: { description: pc.localDescription } });
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('signal', async ({ from, data }) => {
|
||||||
|
const pc = peers.current[from] || createPeer(from, false);
|
||||||
|
|
||||||
|
if (data.description) {
|
||||||
|
await pc.setRemoteDescription(data.description);
|
||||||
|
|
||||||
|
if (data.description.type === 'offer') {
|
||||||
|
const answer = await pc.createAnswer();
|
||||||
|
await pc.setLocalDescription(answer);
|
||||||
|
socket.emit('signal', { to: from, data: { description: pc.localDescription } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.candidate) {
|
||||||
|
await pc.addIceCandidate(data.candidate);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function createPeer(peerId: string, isInitiator: boolean): RTCPeerConnection {
|
||||||
|
const pc = new RTCPeerConnection();
|
||||||
|
|
||||||
|
if (isInitiator) {
|
||||||
|
const channel = pc.createDataChannel('mouse');
|
||||||
|
setupChannel(peerId, channel);
|
||||||
|
} else {
|
||||||
|
pc.ondatachannel = (e) => setupChannel(peerId, e.channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
pc.onicecandidate = (e) => {
|
||||||
|
if (e.candidate) {
|
||||||
|
socket.emit('signal', { to: peerId, data: { candidate: e.candidate } });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
peers.current[peerId] = pc;
|
||||||
|
return pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupChannel(peerId: string, channel: RTCDataChannel) {
|
||||||
|
channels.current[peerId] = channel;
|
||||||
|
channel.onmessage = (e) => {
|
||||||
|
const pos = JSON.parse(e.data);
|
||||||
|
setCursors((prev) => ({ ...prev, [peerId]: pos }));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleMouseMove(e: MouseEvent) {
|
||||||
|
const pos = JSON.stringify({ x: e.clientX, y: e.clientY });
|
||||||
|
Object.values(channels.current).forEach((ch) => {
|
||||||
|
if (ch.readyState === 'open') ch.send(pos);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('mousemove', handleMouseMove);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener('mousemove', handleMouseMove);
|
||||||
|
socket.disconnect();
|
||||||
|
Object.values(peers.current).forEach((pc) => pc.close());
|
||||||
|
};
|
||||||
|
}, [roomId]);
|
||||||
|
|
||||||
|
return { cursors };
|
||||||
|
}
|
||||||
54
hooks/useRTC.ts
Normal file
54
hooks/useRTC.ts
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import RTCPeer from '@/lib/RTCPeer';
|
||||||
|
|
||||||
|
import type { UseSocket } from '@/hooks/useSocket';
|
||||||
|
|
||||||
|
import type {} from '@/types';
|
||||||
|
|
||||||
|
// interface UseSocketProps {
|
||||||
|
// gameID: string;
|
||||||
|
// setGameData: (gameUpdate: GameUpdate) => void;
|
||||||
|
// setNoGame: (noGame: boolean) => void;
|
||||||
|
// }
|
||||||
|
|
||||||
|
const channelName = 'tilt';
|
||||||
|
|
||||||
|
export default function useRTC({
|
||||||
|
ready,
|
||||||
|
registerAnsweredReceiver,
|
||||||
|
registerOfferredReceiver,
|
||||||
|
rtcAnswer: sendAnswer,
|
||||||
|
rtcOffer: sendOffer,
|
||||||
|
}: UseSocket) {
|
||||||
|
const [peers, setPeers] = useState<RTCPeer[]>([]);
|
||||||
|
|
||||||
|
const answerHandler = (answer: RTCSessionDescriptionInit) => {
|
||||||
|
console.log('[useRTC] answer received', answer);
|
||||||
|
console.log('[useRTC] peers:', peers.length);
|
||||||
|
const peer = peers[0];
|
||||||
|
console.log('peer:', peer);
|
||||||
|
peer.onAnswer(answer);
|
||||||
|
};
|
||||||
|
|
||||||
|
const offerHandler = (offer: RTCSessionDescriptionInit) => {
|
||||||
|
console.log('[useRTC] offer received', offer);
|
||||||
|
setPeers((peers) => {
|
||||||
|
peers.push(new RTCPeer({ channelName, offer, sendAnswer, sendOffer }));
|
||||||
|
return peers;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (ready) {
|
||||||
|
console.log('-=-= SETTING THINGS UP =-=-');
|
||||||
|
registerAnsweredReceiver(answerHandler);
|
||||||
|
registerOfferredReceiver(offerHandler);
|
||||||
|
|
||||||
|
setPeers([new RTCPeer({ channelName, sendAnswer, sendOffer })]);
|
||||||
|
}
|
||||||
|
}, [ready]);
|
||||||
|
|
||||||
|
return {
|
||||||
|
count: peers.length,
|
||||||
|
};
|
||||||
|
}
|
||||||
123
hooks/useSocket.ts
Normal file
123
hooks/useSocket.ts
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { socket } from '@/socket';
|
||||||
|
|
||||||
|
import type { GameUpdate } from '@/types';
|
||||||
|
|
||||||
|
export interface UseSocketProps {
|
||||||
|
gameID: string;
|
||||||
|
setGameData: (gameUpdate: GameUpdate) => void;
|
||||||
|
setNoGame: (noGame: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UseSocket {
|
||||||
|
ready: boolean;
|
||||||
|
flipCard: (cardIndex: number) => void;
|
||||||
|
handleSettings: (cardData: GameUpdate) => void;
|
||||||
|
redraw: (cardIndex: number) => void;
|
||||||
|
rtcAnswer: (answer: RTCSessionDescriptionInit) => void;
|
||||||
|
registerAnsweredReceiver: (receiver: (answer: RTCSessionDescriptionInit) => void) => void;
|
||||||
|
rtcOffer: (offer: RTCSessionDescriptionInit) => void;
|
||||||
|
registerOfferredReceiver: (receiver: (offer: RTCSessionDescriptionInit) => void) => void;
|
||||||
|
select: (cardIndex: number, cardID: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function useSocket({ gameID, setGameData, setNoGame }: UseSocketProps): UseSocket {
|
||||||
|
const [ready, setReady] = useState(false);
|
||||||
|
const answerRef = useRef<(answer: RTCSessionDescriptionInit) => void>(null);
|
||||||
|
const offerRef = useRef<(offer: RTCSessionDescriptionInit) => void>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (gameID) {
|
||||||
|
socket.emit('join', gameID);
|
||||||
|
|
||||||
|
socket.on('init', (data: GameUpdate) => {
|
||||||
|
setReady(true);
|
||||||
|
setGameData(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('game-update', (data: GameUpdate) => {
|
||||||
|
setGameData(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('join-error', (error) => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
setNoGame(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('flip-error', (error) => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('rtc-answered', (answered: RTCSessionDescriptionInit) => {
|
||||||
|
if (answerRef.current) answerRef.current(answered);
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('rtc-offered', (offered: RTCSessionDescriptionInit) => {
|
||||||
|
if (offerRef.current) {
|
||||||
|
offerRef.current(offered);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
socket.removeAllListeners();
|
||||||
|
};
|
||||||
|
}, [gameID]);
|
||||||
|
|
||||||
|
const flipCard = (cardIndex: number) => {
|
||||||
|
console.log('flip-card', {
|
||||||
|
gameID,
|
||||||
|
cardIndex,
|
||||||
|
});
|
||||||
|
socket.emit('flip-card', {
|
||||||
|
gameID,
|
||||||
|
cardIndex,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSettings = (gameData: GameUpdate) => {
|
||||||
|
socket.emit('settings', {
|
||||||
|
gameID,
|
||||||
|
gameData,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const redraw = (cardIndex: number) => {
|
||||||
|
socket.emit('redraw', {
|
||||||
|
gameID,
|
||||||
|
cardIndex,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const rtcAnswer = (answer: RTCSessionDescriptionInit) => {
|
||||||
|
console.log('rtc-answer', { gameID, answer });
|
||||||
|
socket.emit('rtc-answer', { gameID, answer });
|
||||||
|
};
|
||||||
|
|
||||||
|
const rtcOffer = (offer: RTCSessionDescriptionInit) => {
|
||||||
|
console.log('rtc-offer', { gameID, offer });
|
||||||
|
socket.emit('rtc-offer', { gameID, offer });
|
||||||
|
};
|
||||||
|
|
||||||
|
const select = (cardIndex: number, cardID: string) => {
|
||||||
|
socket.emit('select', {
|
||||||
|
gameID,
|
||||||
|
cardIndex,
|
||||||
|
cardID,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
ready,
|
||||||
|
flipCard,
|
||||||
|
handleSettings,
|
||||||
|
redraw,
|
||||||
|
rtcAnswer,
|
||||||
|
registerAnsweredReceiver: (receiver: (obj: RTCSessionDescriptionInit) => void[]) =>
|
||||||
|
(answerRef.current = receiver),
|
||||||
|
rtcOffer,
|
||||||
|
registerOfferredReceiver: (receiver: (obj: RTCSessionDescriptionInit) => void[]) =>
|
||||||
|
(offerRef.current = receiver),
|
||||||
|
select,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -130,6 +130,33 @@ export default class GameStore {
|
|||||||
return this.gameUpdate(game);
|
return this.gameUpdate(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redraw(gameID: string, cardIndex: number): GameUpdate {
|
||||||
|
const game = this.getGame(gameID);
|
||||||
|
const card = game.cards[cardIndex];
|
||||||
|
|
||||||
|
if (!card) throw new Error(`Card ${cardIndex} not found`);
|
||||||
|
|
||||||
|
game.cards[cardIndex] =
|
||||||
|
card.suit === 'High Deck' ? deck.drawHigh(game.cards) : deck.drawLow(game.cards);
|
||||||
|
game.lastUpdated = Date.now();
|
||||||
|
|
||||||
|
return this.gameUpdate(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
select(gameID: string, cardIndex: number, cardID: string): GameUpdate {
|
||||||
|
const game = this.getGame(gameID);
|
||||||
|
const card = game.cards[cardIndex];
|
||||||
|
const replacement = deck.select(cardID);
|
||||||
|
|
||||||
|
if (!card) throw new Error(`Card ${cardIndex} not found`);
|
||||||
|
if (!replacement) throw new Error(`Card ${cardID} not found`);
|
||||||
|
|
||||||
|
game.cards[cardIndex] = replacement;
|
||||||
|
game.lastUpdated = Date.now();
|
||||||
|
|
||||||
|
return this.gameUpdate(game);
|
||||||
|
}
|
||||||
|
|
||||||
updateSettings(gameID: string, settings: Settings) {
|
updateSettings(gameID: string, settings: Settings) {
|
||||||
const game = this.getGame(gameID);
|
const game = this.getGame(gameID);
|
||||||
|
|
||||||
|
|||||||
131
lib/RTCPeer.ts
Normal file
131
lib/RTCPeer.ts
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
const servers = {
|
||||||
|
iceServers: [
|
||||||
|
{ url: 'stun:stun01.sipphone.com' },
|
||||||
|
{ url: 'stun:stun.ekiga.net' },
|
||||||
|
{ url: 'stun:stun.fwdnet.net' },
|
||||||
|
{ url: 'stun:stun.ideasip.com' },
|
||||||
|
{ url: 'stun:stun.iptel.org' },
|
||||||
|
{ url: 'stun:stun.rixtelecom.se' },
|
||||||
|
{ url: 'stun:stun.schlund.de' },
|
||||||
|
{ url: 'stun:stun.l.google.com:19302' },
|
||||||
|
{ url: 'stun:stun1.l.google.com:19302' },
|
||||||
|
{ url: 'stun:stun2.l.google.com:19302' },
|
||||||
|
{ url: 'stun:stun3.l.google.com:19302' },
|
||||||
|
{ url: 'stun:stun4.l.google.com:19302' },
|
||||||
|
{ url: 'stun:stunserver.org' },
|
||||||
|
{ url: 'stun:stun.softjoys.com' },
|
||||||
|
{ url: 'stun:stun.voiparound.com' },
|
||||||
|
{ url: 'stun:stun.voipbuster.com' },
|
||||||
|
{ url: 'stun:stun.voipstunt.com' },
|
||||||
|
{ url: 'stun:stun.voxgratia.org' },
|
||||||
|
{ url: 'stun:stun.xten.com' },
|
||||||
|
|
||||||
|
// {
|
||||||
|
// url: 'turn:numb.viagenie.ca',
|
||||||
|
// credential: 'muazkh',
|
||||||
|
// username: 'webrtc@live.com',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// url: 'turn:192.158.29.39:3478?transport=udp',
|
||||||
|
// credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
||||||
|
// username: '28224511:1379330808',
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// url: 'turn:192.158.29.39:3478?transport=tcp',
|
||||||
|
// credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=',
|
||||||
|
// username: '28224511:1379330808',
|
||||||
|
// },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const pcConstraints = {
|
||||||
|
optional: [{ DtlsSrtpKeyAgreement: true }],
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface RTCPeerProps {
|
||||||
|
channelName: string;
|
||||||
|
offer?: RTCSessionDescriptionInit;
|
||||||
|
sendAnswer: (offer: RTCSessionDescriptionInit) => void;
|
||||||
|
sendOffer: (offer: RTCSessionDescriptionInit) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class RTCPeer {
|
||||||
|
channelName: string;
|
||||||
|
peerConnection: RTCPeerConnection;
|
||||||
|
channel: RTCDataChannel;
|
||||||
|
|
||||||
|
sendAnswer: (offer: RTCSessionDescriptionInit) => void;
|
||||||
|
sendOffer: (offer: RTCSessionDescriptionInit) => void;
|
||||||
|
|
||||||
|
constructor({ channelName, offer, sendAnswer, sendOffer }: RTCPeerProps) {
|
||||||
|
this.sendOffer = sendOffer;
|
||||||
|
this.sendAnswer = sendAnswer;
|
||||||
|
this.channelName = channelName;
|
||||||
|
|
||||||
|
this.peerConnection = new RTCPeerConnection(); //(servers, pcConstraints);
|
||||||
|
this.peerConnection.onicecandidate = offer
|
||||||
|
? this.#handleIceCandidateAnswer
|
||||||
|
: this.#handleIceCandidateOffer;
|
||||||
|
|
||||||
|
this.#createDataChannel();
|
||||||
|
|
||||||
|
if (offer) {
|
||||||
|
console.log('answer');
|
||||||
|
this.peerConnection.setRemoteDescription(offer);
|
||||||
|
this.peerConnection.createAnswer().then((answer) => {
|
||||||
|
this.peerConnection.setLocalDescription(answer);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('call');
|
||||||
|
this.peerConnection.createOffer().then((offer) => {
|
||||||
|
this.peerConnection.setLocalDescription(offer);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onAnswer = (answer: RTCSessionDescriptionInit) => {
|
||||||
|
this.peerConnection.setRemoteDescription(answer);
|
||||||
|
};
|
||||||
|
|
||||||
|
#handleIceCandidateAnswer = (event: RTCPeerConnectionIceEvent) => {
|
||||||
|
if (!event.candidate) {
|
||||||
|
const answer = this.peerConnection.localDescription;
|
||||||
|
|
||||||
|
console.log('send-answer', { answer });
|
||||||
|
if (answer) {
|
||||||
|
this.sendAnswer(answer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#handleIceCandidateOffer = (event: RTCPeerConnectionIceEvent) => {
|
||||||
|
if (!event.candidate) {
|
||||||
|
const offer = this.peerConnection.localDescription;
|
||||||
|
|
||||||
|
if (offer) {
|
||||||
|
console.log('send-offer', { offer });
|
||||||
|
this.sendOffer(offer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#createDataChannel = () => {
|
||||||
|
try {
|
||||||
|
this.channel = this.peerConnection.createDataChannel(this.channelName);
|
||||||
|
|
||||||
|
this.channel.onopen = () => {
|
||||||
|
console.log('Receive Channel[onopen]:', this.channel.readyState);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.channel.onmessage = (event: MessageEvent) => {
|
||||||
|
console.log('Receive Channel[onmessage]:', event.data);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.channel.onclose = () => {
|
||||||
|
console.log('Receive Channel[onclose]:', this.channel.readyState);
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[RTCPeer|#createDataChannel] ERROR', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -8,8 +8,8 @@ export default class TarokkaDeck {
|
|||||||
private backs: TarokkaCard[] = [];
|
private backs: TarokkaCard[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.highDeck = cards.filter((card) => !card.back && card.suit === 'High Deck');
|
this.highDeck = cards.filter((card) => card.deck === 'high');
|
||||||
this.commonDeck = cards.filter((card) => !card.back && card.suit !== 'High Deck');
|
this.commonDeck = cards.filter((card) => card.deck === 'common');
|
||||||
this.backs = cards.filter((card) => card.back);
|
this.backs = cards.filter((card) => card.back);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +19,49 @@ export default class TarokkaDeck {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getLow(): TarokkaGameCard[] {
|
||||||
|
return this.commonDeck.map((card) => ({ ...card, flipped: false }));
|
||||||
|
}
|
||||||
|
|
||||||
|
getHigh(): TarokkaGameCard[] {
|
||||||
|
return this.highDeck.map((card) => ({ ...card, flipped: false }));
|
||||||
|
}
|
||||||
|
|
||||||
|
drawLow(exclude: TarokkaGameCard[] = []): TarokkaGameCard {
|
||||||
|
const excludeIDs = exclude.map(({ id }) => id);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...getRandomItems(
|
||||||
|
this.commonDeck.filter(({ id }) => !excludeIDs.includes(id)),
|
||||||
|
1,
|
||||||
|
)[0],
|
||||||
|
flipped: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
drawHigh(exclude: TarokkaGameCard[] = []): TarokkaGameCard {
|
||||||
|
const excludeIDs = exclude.map(({ id }) => id);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...getRandomItems(
|
||||||
|
this.highDeck.filter(({ id }) => !excludeIDs.includes(id)),
|
||||||
|
1,
|
||||||
|
)[0],
|
||||||
|
flipped: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
select(id: string): TarokkaGameCard | null {
|
||||||
|
const card = cards.find((card) => card.id === id);
|
||||||
|
|
||||||
|
if (!card) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...card,
|
||||||
|
flipped: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
getBack(): TarokkaCard {
|
getBack(): TarokkaCard {
|
||||||
return this.backs[0];
|
return this.backs[0];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"dev": "nodemon",
|
"dev": "nodemon",
|
||||||
"build": "next build && tsc --project tsconfig.server.json",
|
"build": "next build && tsc --project tsconfig.server.json",
|
||||||
"start": "cross-env NODE_ENV=production TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/server.js",
|
"start": "cross-env NODE_ENV=production TS_NODE_BASEURL=./build node -r tsconfig-paths/register build/server.js",
|
||||||
"deploy": "docker buildx build --platform linux/amd64 -t 192.168.0.2:5000/tarokka --push ."
|
"release": "docker buildx build --platform linux/amd64 -t 192.168.0.2:5000/tarokka --push ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
|
|||||||
56
server.ts
56
server.ts
@@ -79,6 +79,36 @@ app.prepare().then(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('redraw', ({ gameID, cardIndex }: ClientUpdate) => {
|
||||||
|
try {
|
||||||
|
//console.log(Date.now(), 'Redraw', { gameID, cardIndex });
|
||||||
|
|
||||||
|
const gameUpdate = gameStore.redraw(gameID, cardIndex);
|
||||||
|
|
||||||
|
broadcast('game-update', gameUpdate);
|
||||||
|
} catch (e) {
|
||||||
|
const error = e instanceof Error ? e.message : e;
|
||||||
|
|
||||||
|
console.error(Date.now(), 'Error[redraw]', error);
|
||||||
|
socket.emit('redraw-error', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('select', ({ gameID, cardIndex, cardID = '' }: ClientUpdate) => {
|
||||||
|
try {
|
||||||
|
//console.log(Date.now(), 'select', { gameID, cardIndex });
|
||||||
|
|
||||||
|
const gameUpdate = gameStore.select(gameID, cardIndex, cardID);
|
||||||
|
|
||||||
|
broadcast('game-update', gameUpdate);
|
||||||
|
} catch (e) {
|
||||||
|
const error = e instanceof Error ? e.message : e;
|
||||||
|
|
||||||
|
console.error(Date.now(), 'Error[select]', error);
|
||||||
|
socket.emit('select-error', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('settings', ({ gameID, gameData }: { gameID: string; gameData: GameUpdate }) => {
|
socket.on('settings', ({ gameID, gameData }: { gameID: string; gameData: GameUpdate }) => {
|
||||||
try {
|
try {
|
||||||
const gameUpdate = gameStore.updateSettings(gameID, gameData.settings);
|
const gameUpdate = gameStore.updateSettings(gameID, gameData.settings);
|
||||||
@@ -89,6 +119,32 @@ app.prepare().then(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('rtc-answer', ({ gameID, answer }: { gameID: string; answer: any }) => {
|
||||||
|
try {
|
||||||
|
const gameState = gameStore.getGame(gameID);
|
||||||
|
console.log('[rtc-answer]', gameID);
|
||||||
|
|
||||||
|
io.to(gameState.dmID).emit('rtc-answered', answer);
|
||||||
|
io.to(gameState.spectatorID).emit('rtc-answered', answer);
|
||||||
|
} catch (e) {
|
||||||
|
const error = e instanceof Error ? e.message : e;
|
||||||
|
console.error(Date.now(), 'Error[rtc-answer]', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on('rtc-offer', ({ gameID, offer }: { gameID: string; offer: any }) => {
|
||||||
|
try {
|
||||||
|
const gameState = gameStore.getGame(gameID);
|
||||||
|
console.log('[rtc-offer]', gameID);
|
||||||
|
|
||||||
|
io.to(gameState.dmID).emit('rtc-offered', offer);
|
||||||
|
io.to(gameState.spectatorID).emit('rtc-offered', offer);
|
||||||
|
} catch (e) {
|
||||||
|
const error = e instanceof Error ? e.message : e;
|
||||||
|
console.error(Date.now(), 'Error[rtc-offer]', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', () => {
|
||||||
try {
|
try {
|
||||||
const game = gameStore.playerExit(socket.id);
|
const game = gameStore.playerExit(socket.id);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function getTooltip(
|
|||||||
|
|
||||||
let text: string[] = [];
|
let text: string[] = [];
|
||||||
|
|
||||||
if (flipped) {
|
if (dm || flipped) {
|
||||||
if (dm || settings.positionFront) text.push(position.text);
|
if (dm || settings.positionFront) text.push(position.text);
|
||||||
|
|
||||||
if (dm) text.push(`${cardName}: ${description}`);
|
if (dm) text.push(`${cardName}: ${description}`);
|
||||||
@@ -33,11 +33,9 @@ export default function getTooltip(
|
|||||||
|
|
||||||
// Low deck: Tome, Ravenkind, or Sunsword
|
// Low deck: Tome, Ravenkind, or Sunsword
|
||||||
if (isLowCard(card)) {
|
if (isLowCard(card)) {
|
||||||
if (dm) text.push(card.prophecy.dmText);
|
|
||||||
if (dm || settings.prophecy) text.push(card.prophecy.playerText);
|
if (dm || settings.prophecy) text.push(card.prophecy.playerText);
|
||||||
|
if (dm) text.push(card.prophecy.dmText);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (dm || settings.positionBack) text.push(position.text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { cardStyles, standardMap } from '@/constants/tarokka';
|
import { cardStyles, standardMap } from '@/constants/tarokka';
|
||||||
import { Settings, TarokkaGameCard } from '@/types';
|
import { Settings, TarokkaCard, TarokkaGameCard } from '@/types';
|
||||||
|
|
||||||
export default function getURL(card: TarokkaGameCard, settings: Settings) {
|
export default function getURL(card: TarokkaCard | TarokkaGameCard, settings: Settings) {
|
||||||
const styleConfig = cardStyles[settings.cardStyle];
|
const styleConfig = cardStyles[settings.cardStyle];
|
||||||
const fileBase = settings.cardStyle === 'standard' ? standardMap[card.id] : card.id;
|
const fileBase = settings.cardStyle === 'standard' ? standardMap[card.id] : card.id;
|
||||||
return `${styleConfig.baseURL}${fileBase}${card.extension || styleConfig.extension}`;
|
return `${styleConfig.baseURL}${fileBase}${card.extension || styleConfig.extension}`;
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
export type CardStyle = 'standard' | 'color' | 'grayscale';
|
export type CardStyle = 'standard' | 'color' | 'grayscale';
|
||||||
|
|
||||||
|
// all = both + back
|
||||||
|
export type Deck = 'high' | 'common' | 'both' | 'back' | 'all';
|
||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
positionBack: boolean;
|
positionBack: boolean;
|
||||||
positionFront: boolean;
|
positionFront: boolean;
|
||||||
@@ -28,6 +31,7 @@ export interface TarokkaBase {
|
|||||||
description: string;
|
description: string;
|
||||||
aria: string;
|
aria: string;
|
||||||
back: boolean;
|
back: boolean;
|
||||||
|
deck: Deck;
|
||||||
suit: 'Coins' | 'Glyphs' | 'High Deck' | 'Stars' | 'Swords' | null;
|
suit: 'Coins' | 'Glyphs' | 'High Deck' | 'Stars' | 'Swords' | null;
|
||||||
extension?: string;
|
extension?: string;
|
||||||
}
|
}
|
||||||
@@ -90,6 +94,7 @@ export interface GameUpdate {
|
|||||||
export interface ClientUpdate {
|
export interface ClientUpdate {
|
||||||
gameID: string;
|
gameID: string;
|
||||||
cardIndex: number;
|
cardIndex: number;
|
||||||
|
cardID?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Layout {
|
export interface Layout {
|
||||||
|
|||||||
Reference in New Issue
Block a user