Skip to content

Commit e04d96c

Browse files
authored
Merge pull request #48 from codergautam/2024dev
2024dev
2 parents 09c2f8e + 1d5f448 commit e04d96c

30 files changed

+3704
-3268
lines changed

components/Map.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Circle, Marker, Polyline, Popup, Tooltip, useMapEvents } from "react-le
44
import { useTranslation } from '@/components/useTranslations';
55
import 'leaflet/dist/leaflet.css';
66
import customPins from '../public/customPins.json' with { type: "module" };
7+
import guestNameString from "@/serverUtils/guestNameFromString";
78
const hintMul = 5000000 / 20000; //5000000 for all countries (20,000 km)
89

910
// Dynamic import of react-leaflet components
@@ -59,13 +60,16 @@ function MapPlugin({ pinPoint, setPinPoint, answerShown, dest, gameOptions, ws,
5960
if (!map || answerShown) return;
6061

6162
setTimeout(() => {
63+
try {
64+
6265
if (extent) {
6366
const bounds = L.latLngBounds([extent[1], extent[0]], [extent[3], extent[2]]);
6467
map.fitBounds(bounds);
6568
} else {
6669
// reset to default
6770
map.setView([30, 0], 2);
6871
}
72+
}catch(e) {}
6973
}, 500);
7074
}, [gameOptions?.extent ? JSON.stringify(gameOptions.extent) : null, map, answerShown]);
7175

@@ -179,7 +183,7 @@ const MapComponent = ({ shown, options, ws, session, pinPoint, setPinPoint, answ
179183
if(!player.guess) return null;
180184

181185

182-
const name = player.username;
186+
const name = process.env.NEXT_PUBLIC_COOLMATH?guestNameString(player.username):player.username;
183187
const latLong = [player.guess[0], player.guess[1]];
184188

185189
const tIcon = customPins[name]==="polandball" ? polandballIcon : src2Icon;

components/gameUI.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown,
7676
round: prev.round + 1
7777
}
7878
})
79-
} else {
79+
} else if(setSinglePlayerRound) {
8080
// reset to default
8181
setSinglePlayerRound({
8282
round: 1,
@@ -96,7 +96,7 @@ export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown,
9696
const loadTime = window.gameOpen;
9797
const lastDiscordShown = gameStorage.getItem("shownDiscordModal");
9898
if(lastDiscordShown) return console.log("Discord modal already shown");
99-
if(Date.now() - loadTime > 600000) {
99+
if(Date.now() - loadTime > 600000 && !process.env.NEXT_PUBLIC_COOLMATH) {
100100
setShowDiscordModal(true)
101101
sendEvent('discord_modal_shown')
102102
} else console.log("Not showing discord modal, waiting for "+(600000 - (Date.now() - loadTime))+"ms")
@@ -454,14 +454,14 @@ export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown,
454454
return (
455455
<div className="gameUI">
456456

457-
{ !onboarding && !inCrazyGames && !inCoolMathGames && (!session?.token?.supporter) && (
457+
{ !onboarding && !inCrazyGames && !inCoolMathGames && (!session?.token?.supporter) && (width >700) && (
458458
<div className={`topAdFixed ${(multiplayerTimerShown || onboardingTimerShown || singlePlayerRound)?'moreDown':''}`}>
459-
<Ad inCrazyGames={inCrazyGames} showAdvertisementText={false} screenH={height} types={[[728,90]]} centerOnOverflow={600} screenW={Math.max(400, width-450)} vertThresh={0.3} />
459+
<Ad inCrazyGames={inCrazyGames} showAdvertisementText={false} screenH={height} types={[[320,50]]} centerOnOverflow={600} screenW={Math.max(400, width-450)} vertThresh={0.3} />
460460
</div>
461461
)}
462462

463463

464-
{ multiplayerState?.gameData?.public && (
464+
{ multiplayerState?.gameData?.duel && (
465465
<div className={`hbparent ${isStartingDuel ? 'hb-parent' : ''}`}>
466466
<div className={`${isStartingDuel ? 'hb-bars' : ''}`}>
467467
<div style={{zIndex: 1001, position: "fixed", top: 0, left: 0, pointerEvents: 'none'}}
@@ -627,7 +627,7 @@ button1Press={() =>{
627627
}
628628
}} />
629629
)}
630-
<span className={`timer duel ${!multiplayerTimerShown ? '' : 'shown'} ${multiplayerState?.gameData?.public ? 'duel' : ''}`}>
630+
<span className={`timer duel ${!multiplayerTimerShown ? '' : 'shown'} ${multiplayerState?.gameData?.duel ? 'duel' : ''}`}>
631631

632632
{/* Round #{multiplayerState?.gameData?.curRound} / {multiplayerState?.gameData?.rounds} - {timeToNextMultiplayerEvt}s */}
633633
{text("roundTimer", {r:multiplayerState?.gameData?.curRound, mr: multiplayerState?.gameData?.rounds, t: timeToNextMultiplayerEvt})}
@@ -651,21 +651,17 @@ button1Press={() =>{
651651
)
652652
}
653653

654-
{multiplayerState && multiplayerState.inGame && !multiplayerState?.gameData?.public && multiplayerState?.gameData?.state === 'getready' && multiplayerState?.gameData?.curRound === 1 && (
654+
{multiplayerState && multiplayerState.inGame && !multiplayerState?.gameData?.duel && multiplayerState?.gameData?.state === 'getready' && multiplayerState?.gameData?.curRound === 1 && (
655655
<BannerText text={
656656
text("gameStartingIn", {t:timeToNextMultiplayerEvt})
657657
} shown={true} />
658658
)}
659659

660660

661-
{multiplayerState && multiplayerState.inGame && !multiplayerState?.gameData?.public && ((multiplayerState?.gameData?.state === 'getready' && timeToNextMultiplayerEvt < 5 && multiplayerState?.gameData?.curRound !== 1 && multiplayerState?.gameData?.curRound <= multiplayerState?.gameData?.rounds)||(multiplayerState?.gameData?.state === "end")) && (
661+
{multiplayerState && multiplayerState.inGame && !multiplayerState?.gameData?.duel && ((multiplayerState?.gameData?.state === 'getready' && timeToNextMultiplayerEvt < 5 && multiplayerState?.gameData?.curRound !== 1 && multiplayerState?.gameData?.curRound <= multiplayerState?.gameData?.rounds)||(multiplayerState?.gameData?.state === "end")) && (
662662
<PlayerList multiplayerState={multiplayerState} playAgain={() => {
663-
664-
665-
backBtnPressed(true)
666-
663+
backBtnPressed(true, "unranked")
667664
}} backBtn={() => {
668-
669665
backBtnPressed()
670666
}} />
671667
)}

0 commit comments

Comments
 (0)