add life for constant values

This commit is contained in:
Vikeo
2023-08-27 16:33:47 +02:00
parent ad4eb6ef76
commit 85a26b6687
4 changed files with 8 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import { css } from 'styled-components';
import { Player, Rotation } from '../../Types/Player'; import { Player, Rotation } from '../../Types/Player';
import { useRef, useState } from 'react'; import { useRef, useState } from 'react';
import { OutlinedText } from '../Misc/OutlinedText'; import { OutlinedText } from '../Misc/OutlinedText';
import { decrementTimeoutMs } from '../../Data/constants';
const CommanderDamageContainer = styled.div<{ const CommanderDamageContainer = styled.div<{
rotation: number; rotation: number;
@@ -169,7 +170,7 @@ export const CommanderDamage = ({
timeoutRef.current = setTimeout(() => { timeoutRef.current = setTimeout(() => {
setTimeoutFinished(true); setTimeoutFinished(true);
handleCommanderDamageChange(opponentIndex, -1, isPartner); handleCommanderDamageChange(opponentIndex, -1, isPartner);
}, 500); }, decrementTimeoutMs);
}; };
const handleUpInput = ({ opponentIndex, isPartner }: InputProps) => { const handleUpInput = ({ opponentIndex, isPartner }: InputProps) => {

View File

@@ -1,6 +1,7 @@
import { ReactNode, useRef, useState } from 'react'; import { ReactNode, useRef, useState } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { css } from 'styled-components'; import { css } from 'styled-components';
import { decrementTimeoutMs } from '../../Data/constants';
import { CounterType, Rotation } from '../../Types/Player'; import { CounterType, Rotation } from '../../Types/Player';
import { OutlinedText } from '../Misc/OutlinedText'; import { OutlinedText } from '../Misc/OutlinedText';
@@ -96,7 +97,7 @@ const ExtraCounter = ({
timeoutRef.current = setTimeout(() => { timeoutRef.current = setTimeout(() => {
setTimeoutFinished(true); setTimeoutFinished(true);
handleCountChange(-1); handleCountChange(-1);
}, 500); }, decrementTimeoutMs);
}; };
const handleUpInput = () => { const handleUpInput = () => {

View File

@@ -1,6 +1,7 @@
import { useRef, useState } from 'react'; import { useRef, useState } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { css } from 'styled-components'; import { css } from 'styled-components';
import { lifeLongPressMultiplier } from '../../Data/constants';
import { Rotation } from '../../Types/Player'; import { Rotation } from '../../Types/Player';
@@ -82,8 +83,6 @@ const LifeCounterButton = ({
const [timeoutFinished, setTimeoutFinished] = useState(false); const [timeoutFinished, setTimeoutFinished] = useState(false);
const [hasPressedDown, setHasPressedDown] = useState(false); const [hasPressedDown, setHasPressedDown] = useState(false);
const longPressMultiplier = 10;
const handleLifeChange = (increment: number) => { const handleLifeChange = (increment: number) => {
setLifeTotal(lifeTotal + increment); setLifeTotal(lifeTotal + increment);
}; };
@@ -92,7 +91,7 @@ const LifeCounterButton = ({
setTimeoutFinished(false); setTimeoutFinished(false);
setHasPressedDown(true); setHasPressedDown(true);
timeoutRef.current = setTimeout(() => { timeoutRef.current = setTimeout(() => {
handleLifeChange(increment * longPressMultiplier); handleLifeChange(increment * lifeLongPressMultiplier);
setTimeoutFinished(true); setTimeoutFinished(true);
}, 500); }, 500);
}; };

2
src/Data/constants.ts Normal file
View File

@@ -0,0 +1,2 @@
export const decrementTimeoutMs = 300;
export const lifeLongPressMultiplier = 10;