-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83dcbc0
commit 08d7dcf
Showing
34 changed files
with
653 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,7 @@ body { | |
} | ||
|
||
.ghostHand { | ||
z-index: 1; | ||
display: flex; | ||
position: absolute; | ||
bottom: 100px; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { CSSProperties, FC, useEffect, useRef } from "react" | ||
import { CardType } from "../../math/CardType" | ||
import { CardsHand } from "../CardsHand/CardsHand" | ||
|
||
interface GhostPreviewProps { | ||
card: CardType | ||
deck: Array<CardType> | ||
} | ||
|
||
export const GhostPreview: FC<GhostPreviewProps> = ({ card, deck }) => { | ||
const cardRef = useRef<HTMLDivElement | null>(null) | ||
|
||
useEffect(() => { | ||
const mouseMoveHandler = (e: MouseEvent) => { | ||
if (!card) return | ||
if (!cardRef.current) return | ||
const x = e.pageX | ||
const y = e.pageY | ||
const newposX = x - 60 | ||
const newposY = y + 60 | ||
cardRef.current.style.transform = `matrix(1.2, 0, 0, 1.2, ${newposX},${newposY})` | ||
cardRef.current.style.rotate = `0deg` | ||
cardRef.current.style.visibility = `visible` | ||
} | ||
document.addEventListener('mousemove', mouseMoveHandler) | ||
return () => { | ||
document.removeEventListener('mousemove', mouseMoveHandler) | ||
} | ||
}, [card]) | ||
|
||
return ( | ||
<CardsHand | ||
className={['ghostHand']} | ||
keys={deck.map((x) => x.getId().toString())} | ||
styles={deck.map((x) => { | ||
const isSelected = x.getId().toString() === card?.getId().toString() | ||
return isSelected ? { position: 'fixed', top: '0px', left: '0px', rotate: '0deg' } : {} | ||
})} | ||
> | ||
{deck | ||
// .filter((x) => x.getDescription() !== selectedCard?.getDescription()) | ||
.map((x) => { | ||
const isSelected = x.getId().toString() === card?.getId().toString() | ||
const style: CSSProperties = { | ||
// scale: isSelected ? '1.2' : '1', | ||
zIndex: isSelected ? 200 : '', | ||
// visibility: isSelected ? 'visible' : 'hidden', | ||
visibility: 'hidden', | ||
position: isSelected ? 'absolute' : 'relative' | ||
} | ||
return ( | ||
<div | ||
key={x.getId().toString()} | ||
className='card hideCard ghostCard' | ||
style={style} | ||
ref={isSelected ? cardRef : null} | ||
> | ||
{card.getDescription()} | ||
</div> | ||
) | ||
})} | ||
</CardsHand> | ||
) | ||
// return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
interface CardTypeProps { | ||
name: string | ||
} | ||
|
||
interface ICardType { | ||
setCount(count: number): void | ||
getId(): number | ||
getName(): string | ||
getDescription(): string | ||
getCount(): string | ||
} | ||
|
||
export class CardType implements ICardType { | ||
private id: number | ||
private name: string | ||
private count: number | ||
constructor({ name }: CardTypeProps) { | ||
this.name = name | ||
this.count = 0 | ||
this.id = Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) | ||
} | ||
|
||
setCount(count: number) { | ||
this.count = count | ||
} | ||
|
||
getId() { | ||
return this.id | ||
} | ||
|
||
setName(name: string) { | ||
this.name = name | ||
} | ||
|
||
getName() { | ||
return this.name.toString() | ||
} | ||
|
||
getCount() { | ||
return this.count.toString() | ||
} | ||
|
||
getDescription() { | ||
return this.name | ||
} | ||
|
||
getIsInteractive() { | ||
return false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.