Small edits

This commit is contained in:
snen 2021-09-30 22:07:34 -04:00
parent 07aeb03a60
commit 1d69cbaabe
4 changed files with 19 additions and 14 deletions

View File

@ -19,7 +19,7 @@ export default function Game(props: GameProps): JSX.Element {
team,
board,
player,
deck,
deckSize,
enemyLife,
enemyDeckSize,
enemyHandSize,
@ -79,18 +79,24 @@ export default function Game(props: GameProps): JSX.Element {
</div>
<div className="player-info">
<p>Life: {player.life}</p>
<p>Deck: {deck.cards.length}</p>
<p>Deck: {deckSize}</p>
</div>
</div>
<div className="game-board">
<div className="hand">
{Array(enemyHandSize).fill(null).map(() => (
<CardToken cardKey={null} isSelected={false} disabled />
{Array(enemyHandSize).fill(null).map((_, i) => (
<CardToken
key={`enemy-hand-${i}`}
cardKey={null}
isSelected={false}
disabled
/>
))}
</div>
<div className="fighter-area enemy">
{enemyBoard.map((card, index) => (
<BoardSlot
key={`enemy-${index}`}
card={card ?? null}
onSelect={() => selectCard({target: 'opponent', type: 'board', index})}
isSelected={
@ -105,6 +111,7 @@ export default function Game(props: GameProps): JSX.Element {
<div className="fighter-area ally">
{allyBoard.map((card, index) => (
<BoardSlot
key={`ally-${index}`}
card={card ?? null}
onSelect={() => selectCard({target: 'ally', type: 'board', index})}
isSelected={
@ -121,6 +128,7 @@ export default function Game(props: GameProps): JSX.Element {
<div className="draw-choices">
{drawChoices.map((card, index) => (
<CardToken
key={`draw-choices-${index}`}
cardKey={card.type === -1 ? null : card.type}
onSelect={() => selectCard({target: 'ally', type: 'draws', index})}
isSelected={
@ -148,6 +156,7 @@ export default function Game(props: GameProps): JSX.Element {
<div className="hand">
{player.hand.map((card, index) => (
<CardToken
key={`hand-${index}`}
cardKey={card.type === -1 ? null : card.type}
onSelect={() => selectCard({target: 'ally', type: 'hand', index})}
isSelected={

View File

@ -84,19 +84,17 @@ const initialState: GameClientState = {
},
player: {
name: '',
id: 0,
id: -1,
hand: [],
life: 0,
life: -1,
ready: false,
},
deck: {
cards: []
},
deckSize: 0,
team: 1,
enemyLife: 0,
enemyDeckSize: 0,
enemyHandSize: 0,
currentTurn: 1,
currentTurn: 0,
canDraw: false,
hasDrawn: false,
gameStatus: 0,

View File

@ -56,9 +56,7 @@ interface GameStatusMap {
export interface GameState {
board: Board
player: Player
deck: {
cards: Card[]
}
deckSize: number
team: Team
enemyLife: number
enemyDeckSize: number

View File

@ -164,7 +164,7 @@ export default function useServerSocket(
state: {
board: result.board,
player: result.player,
deck: result.deck,
deckSize: result.deck_size,
enemyLife: result.enemy_life,
enemyDeckSize: result.enemy_deck_size,
enemyHandSize: result.enemy_hand_size,