From 5cf80639ab948d56ccdf9e5d8a8003d095b7284b Mon Sep 17 00:00:00 2001 From: Regalijan Date: Sat, 16 Mar 2024 01:56:58 -0400 Subject: [PATCH] Finally fix stat reduction modal --- components/GameAppealCard.tsx | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/components/GameAppealCard.tsx b/components/GameAppealCard.tsx index c4b6e8e..2e752e5 100644 --- a/components/GameAppealCard.tsx +++ b/components/GameAppealCard.tsx @@ -7,6 +7,7 @@ import { CardHeader, Heading, Input, + ListItem, Modal, ModalBody, ModalContent, @@ -16,8 +17,10 @@ import { Stack, StackDivider, Text, + UnorderedList, useDisclosure, useToast, + VStack, } from "@chakra-ui/react"; import { useState } from "react"; @@ -104,21 +107,35 @@ export default function (props: GameAppealProps & { port?: MessagePort }) { - + How much should this player's stats be reduced by? - { - const value = (e.target as EventTarget & { value: string }) - .value; + + { + const value = (e.target as EventTarget & { value: string }) + .value; - return !value.match(/\D/); - }} - onChange={(e) => setPercentage(parseInt(e.target.value))} - placeholder="Number between 0 and 100" - /> + return ( + Boolean(value.match(/^-?\d{0,3}$/)) || + value === "-" || + !value + ); + }} + onChange={(e) => setPercentage(parseInt(e.target.value))} + placeholder="Reduction factor" + /> +
+ Stat multiplication factors: +
+ + Money: {Math.min(0.1 * percentage, 1)} + Parts: {Math.min(0.6 * percentage, 1)} + Derby Wins: {Math.min(0.6 * percentage, 1)} + +