Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Finally fix stat reduction modal
  • Loading branch information
regalijan committed Mar 16, 2024
1 parent 9d3b210 commit 5cf8063
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions components/GameAppealCard.tsx
Expand Up @@ -7,6 +7,7 @@ import {
CardHeader,
Heading,
Input,
ListItem,
Modal,
ModalBody,
ModalContent,
Expand All @@ -16,8 +17,10 @@ import {
Stack,
StackDivider,
Text,
UnorderedList,
useDisclosure,
useToast,
VStack,
} from "@chakra-ui/react";
import { useState } from "react";

Expand Down Expand Up @@ -104,21 +107,35 @@ export default function (props: GameAppealProps & { port?: MessagePort }) {
<ModalOverlay />
<ModalContent>
<ModalHeader>
<Heading>
<Heading size="sm">
How much should this player's stats be reduced by?
</Heading>
</ModalHeader>
<ModalBody>
<Input
onBeforeInput={(e) => {
const value = (e.target as EventTarget & { value: string })
.value;
<VStack spacing={4}>
<Input
onBeforeInput={(e) => {
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"
/>
<br />
<Text>Stat multiplication factors:</Text>
<br />
<UnorderedList>
<ListItem>Money: {Math.min(0.1 * percentage, 1)}</ListItem>
<ListItem>Parts: {Math.min(0.6 * percentage, 1)}</ListItem>
<ListItem>Derby Wins: {Math.min(0.6 * percentage, 1)}</ListItem>
</UnorderedList>
</VStack>
</ModalBody>
<ModalFooter>
<Button colorScheme="red" onClick={onClose}>
Expand Down

0 comments on commit 5cf8063

Please sign in to comment.