mirror of
https://github.com/Vikeo/LifeTrinket.git
synced 2025-11-12 22:26:20 +00:00
add life for constant values
This commit is contained in:
@@ -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) => {
|
||||||
|
|||||||
@@ -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 = () => {
|
||||||
|
|||||||
@@ -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
2
src/Data/constants.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export const decrementTimeoutMs = 300;
|
||||||
|
export const lifeLongPressMultiplier = 10;
|
||||||
Reference in New Issue
Block a user