|
@@ -35,27 +35,56 @@ const GuessPane = () => {
|
|
|
const targetPoint = useTargetPoint();
|
|
|
const roundNum = useCurrentRound();
|
|
|
|
|
|
- const handleSubmitGuess = async () => {
|
|
|
+ const handleSubmitGuess = useCallback(async () => {
|
|
|
setSubmitted(true);
|
|
|
if (!submitted) {
|
|
|
await dispatch.submitGuess(selectedPoint);
|
|
|
}
|
|
|
- };
|
|
|
+ }, [selectedPoint, submitted]);
|
|
|
|
|
|
- const handleGateKeeping = async ({ target }) => {
|
|
|
- const { score } = await checkScore(
|
|
|
- selectedPoint,
|
|
|
- targetPoint,
|
|
|
- scoreMethod,
|
|
|
- roundNum
|
|
|
- );
|
|
|
- if (score < 4000) {
|
|
|
- target.blur();
|
|
|
- setGunGameBlock(true);
|
|
|
- } else {
|
|
|
- await handleSubmitGuess();
|
|
|
+ const handleGateKeeping = useCallback(
|
|
|
+ async ({ target }) => {
|
|
|
+ const { score } = await checkScore(
|
|
|
+ selectedPoint,
|
|
|
+ targetPoint,
|
|
|
+ scoreMethod,
|
|
|
+ roundNum
|
|
|
+ );
|
|
|
+ if (score < 4000) {
|
|
|
+ target.blur();
|
|
|
+ setGunGameBlock(true);
|
|
|
+ } else {
|
|
|
+ await handleSubmitGuess();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [handleSubmitGuess, roundNum, selectedPoint, targetPoint, scoreMethod]
|
|
|
+ );
|
|
|
+
|
|
|
+ const handleGateKeptTimeout = useCallback(async () => {
|
|
|
+ if (selectedPoint) {
|
|
|
+ const { score } = await checkScore(
|
|
|
+ selectedPoint,
|
|
|
+ targetPoint,
|
|
|
+ scoreMethod,
|
|
|
+ roundNum
|
|
|
+ );
|
|
|
+ if (score >= 4000) {
|
|
|
+ await handleSubmitGuess();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setSubmitted(true);
|
|
|
+ if (!submitted) {
|
|
|
+ await dispatch.submitGuess(null);
|
|
|
}
|
|
|
- };
|
|
|
+ }, [
|
|
|
+ handleSubmitGuess,
|
|
|
+ submitted,
|
|
|
+ roundNum,
|
|
|
+ selectedPoint,
|
|
|
+ targetPoint,
|
|
|
+ scoreMethod,
|
|
|
+ ]);
|
|
|
|
|
|
return (
|
|
|
<>
|
|
@@ -72,7 +101,11 @@ const GuessPane = () => {
|
|
|
Submit Guess
|
|
|
</button>
|
|
|
<ClickMarkerMap onMarkerMoved={setSelectedPoint} />
|
|
|
- <RoundTimer onTimeout={handleSubmitGuess} />
|
|
|
+ <RoundTimer
|
|
|
+ onTimeout={
|
|
|
+ gameMode === GUN_GAME ? handleGateKeptTimeout : handleSubmitGuess
|
|
|
+ }
|
|
|
+ />
|
|
|
<div
|
|
|
className={styles.resize}
|
|
|
onClick={toggleBig}
|