Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions frontend/components/BettingChips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const CHIP_OPTIONS = [
{ value: 50, color: '#10B981', bg: 'bg-emerald-500 hover:bg-emerald-400 border-emerald-400' },
{ value: 100, color: '#EAB308', bg: 'bg-yellow-500 hover:bg-yellow-400 border-yellow-400' },
{ value: 500, color: '#F97316', bg: 'bg-orange-500 hover:bg-orange-400 border-orange-400' },
{ value: -1, color: '#DC2626', isMax: true, bg: 'bg-red-600 hover:bg-red-500 border-red-500' },
];

export default function ChipControls({
Expand All @@ -33,13 +34,22 @@ export default function ChipControls({

return (
<div className="flex flex-wrap gap-2 justify-center mb-5">
{CHIP_OPTIONS.map(({ value, color, bg }) => {
{CHIP_OPTIONS.map(({ value, color, isMax, bg }) => {
const isCurrent = selectedChip?.value === value;

let betValue: number;
if (isMax) {
betValue = userBalance;
}
else {
betValue = value;
}

const canAfford = userBalance >= value;

return (
<button
key={value}
key={isMax ? 'MAX' : value}
data-cy={`chip-${value}`}
disabled={!canAfford}
className={`chip-button mr-2 transition duration-200 ${
Expand All @@ -48,13 +58,15 @@ export default function ChipControls({
!isSelected && canAfford ? (isDarkMode ? 'glow-pulse-dark' : 'glow-pulse-light') : ''
} ${
!canAfford ? (isDarkMode ? 'bg-gray-900' : 'bg-gray-400') + ' cursor-not-allowed opacity-50' : bg
}`}
} ${
isMax ? 'text-[1.70rem]' : 'text-[2rem]'}
`}
onClick={() => {
handleChipSelect(value, color);
handleChipSelect(betValue, color, isMax);
setIsSelected(true);
}}
>
{value}
{isMax ? 'MAX' : value}
</button>
);
})}
Expand Down
1 change: 0 additions & 1 deletion frontend/css/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
justify-content: center;
border-width: 0.125rem;
transition: background-color 0.2s;
font-size: 2rem;
cursor: pointer;
user-select: none;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/hooks/useBetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
};

// User selecting chips in game
const handleChipSelect = (value: number, color: string) => {
const handleChipSelect = (value: number, color: string, isMax?: boolean) => {

Check failure on line 56 in frontend/hooks/useBetting.ts

View workflow job for this annotation

GitHub Actions / Frontend (Lint + Build)

'isMax' is defined but never used
if (userBalance >= value) {
setSelectedChip({ value, color });
}
Expand Down
1 change: 1 addition & 0 deletions frontend/types/chips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
export interface Chip {
value: number;
color: string;
isMax?: boolean;
}

// Define Bet
Expand Down
26 changes: 17 additions & 9 deletions frontend/utils/chipFormatting.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
// Decides what color the betting chip should be based on amount
// Decides what color the bet chip should be based on amount
const updateChipColor = (bet: number) => {
if (bet >= 500) {
return "#F97316"; // orange-500
} else if (bet >= 100) {
}
else if (bet >= 100) {
return "#EAB308"; // yellow-500
} else if (bet >= 50) {
}
else if (bet >= 50) {
return "#10B981"; // emerald-500
} else if (bet >= 20) {
}
else if (bet >= 20) {
return "#06B6D4"; // cyan-500
} else if (bet >= 10) {
}
else if (bet >= 10) {
return "#EC4899"; // pink-500
} else if (bet >= 5) {
}
else if (bet >= 5) {
return "#A855F7"; // purple-500
} else if (bet >= 2) {
}
else if (bet >= 2) {
return "#3B82F6"; // blue-500
} else if (bet >= 1) {
}
else if (bet >= 1) {
return "#6366F1"; // indigo-500
} else {
}
else {
return "#6B7280"; // gray-500
}
};
Expand Down
Loading