Skip to content

Commit

Permalink
Score Log, options menu fix
Browse files Browse the repository at this point in the history
  • Loading branch information
imisaacwu committed Aug 13, 2024
1 parent 7026ae1 commit 874035f
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 48 deletions.
178 changes: 138 additions & 40 deletions src/GameState.ts

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ export const Card = ({
const popupTags = game.state === 'scoring' && debuffed ?
<div id='debuffed-tag' className='tag'>Debuffed</div> :
<>
{enhancement !== undefined && enhancement !== Enhancement.Base &&
<div id='enhancement' className={`tag ${enhancement}`}>{`${Enhancement[enhancement]} Card`}</div>
}
{edition !== undefined &&
<div id='edition' className={`tag ${edition}`}>{Edition[edition]}</div>
}
{enhancement !== undefined && enhancement !== Enhancement.Base &&
<div id='enhancement' className={`tag ${enhancement}`}>{`${Enhancement[enhancement]} Card`}</div>
}
{seal !== undefined &&
<div id='seal' className={`tag ${seal}`}>{`${Seal[seal]} Seal`}</div>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/DeckMenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
margin: 4px;
}

tr {
#suits tr {
display: flex;
flex-direction: row;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/InfoPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Options } from './Options'
export const InfoPanel = () => {
const { state: game } = useContext(GameStateContext)
const [ runMenu, setRunMenu ] = useState(false)
const [ optionsMenu, setOptionsMenu ] = useState(true)
const [ optionsMenu, setOptionsMenu ] = useState(false)

return (
<div id='info'>
Expand Down
4 changes: 4 additions & 0 deletions src/components/Round.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
margin: 0 8px;
}

#score-display:hover {
cursor: pointer;
}

#stake-icon {
width: 24px;
height: 24px;
Expand Down
8 changes: 6 additions & 2 deletions src/components/Round.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { useContext } from 'react'
import { useContext, useState } from 'react'
import stake_icon from '../assets/white_stake.webp'
import { GameStateContext } from '../GameState'
import './Round.css'
import { ScoreLog } from './ScoreLog'

export const Round = () => {
const { state: game } = useContext(GameStateContext)
const [ logMenu, setLogMenu ] = useState(false)

return (
<div id='round-score'>
<div id='round-score-text'>Round<br/>score</div>
<div id='score-display'>
<div id='score-display' onClick={() => setLogMenu(true)}>
<img id='stake-icon' src={stake_icon} />
<div id='score'>{game.stats.score}</div>
</div>
{logMenu && <ScoreLog setMenu={setLogMenu} />}
</div>
)
}
41 changes: 41 additions & 0 deletions src/components/ScoreLog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#score-log-outline {
position: absolute;
z-index: 1;
background-color: var(--light-grey);
border-radius: 8px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

#score-log {
background-color: var(--grey);
border-radius: 8px;
margin: 4px;
width: 512px;
max-height: 640px;
overflow: scroll;
}

#score-log > table {
font-size: 20px;
border-collapse: collapse;
}

#score-log > table > tr {
border-bottom: 1px solid aliceblue;
}

#score-log > table > tr:last-child { border: none }

#score-log > table > #headings {
font-size: 32px;
}

#score-log-back {
text-align: center;
font-size: 32px;
background-color: var(--orange);
border-radius: 8px;
margin: 2px;
}
54 changes: 54 additions & 0 deletions src/components/ScoreLog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { useContext } from "react"
import { GameStateContext } from "../GameState"
import './ScoreLog.css'

type ScoreLogProps = {
setMenu: React.Dispatch<React.SetStateAction<boolean>>
}

export const ScoreLog = (props: ScoreLogProps) => {
const { state: game } = useContext(GameStateContext)

const chipFormat = (chips: number | undefined, mult: number | undefined, mult_type: string | undefined) => {
if(chips !== undefined) {
if(mult !== undefined && mult_type === undefined) { return <td className='blue' style={{fontSize: '24px'}}>{chips}</td>}
return <td className='blue'>{`+${chips}`}</td>
}
return <td />
}

const multFormat = (mult: number | undefined, mult_type: string | undefined) => {
if(mult !== undefined) {
if(mult < 0) { return <td className='red'>{mult}</td> }
if(mult_type === undefined) { return <td className='red' style={{fontSize: '24px'}}>{mult}</td>}
if(mult_type === '+') { return <td className='red'>{`+${mult}`}</td>}
return <td className='red-invert'>{`X${mult}`}</td>
}
return <td />
}

return (
<div id='score-log-outline'>
<div id='score-log'>
<table style={{width: '100%'}}>
<tr id='headings'>
<th style={{width: '60%'}}>Name</th>
<th>Chips</th>
<th>Mult</th>
</tr>
{game.scoreLog.map((entry, i) => (
entry.chips === undefined && entry.mult === undefined ?
<tr key={i} style={{fontSize: '24px', backgroundColor: 'var(--dark-grey)'}}><td colSpan={3}>{entry.name}</td></tr> :
<tr key={i}>
<td>{entry.name}</td>
{chipFormat(entry.chips, entry.mult, entry.mult_type)}
{multFormat(entry.mult, entry.mult_type)}
</tr>
)
)}
</table>
</div>
<div id='score-log-back' onClick={() => props.setMenu(false)}>Back</div>
</div>
)
}
2 changes: 1 addition & 1 deletion src/components/UseConsumable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export const useConsumable = (game: GameState, dispatch: React.Dispatch<GameActi
case 'The Wheel of Fortune':
const WoFJokers = game.jokers.filter(j => j.edition === undefined)
if(WoFJokers.length === 0) { return false }
if(Random.next() < 2.25) {
if(Random.next() < .25) {
const joker = WoFJokers[Math.floor(Random.next() * WoFJokers.length)]
switch(Math.floor(Random.next() * 3)) {
case 0: joker.edition = Edition.Foil; break
Expand Down

0 comments on commit 874035f

Please sign in to comment.