Skip to content

Commit

Permalink
Merge pull request #48 from codergautam/2024dev
Browse files Browse the repository at this point in the history
2024dev
  • Loading branch information
codergautam authored Dec 23, 2024
2 parents 09c2f8e + 1d5f448 commit e04d96c
Show file tree
Hide file tree
Showing 30 changed files with 3,704 additions and 3,268 deletions.
6 changes: 5 additions & 1 deletion components/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Circle, Marker, Polyline, Popup, Tooltip, useMapEvents } from "react-le
import { useTranslation } from '@/components/useTranslations';
import 'leaflet/dist/leaflet.css';
import customPins from '../public/customPins.json' with { type: "module" };
import guestNameString from "@/serverUtils/guestNameFromString";
const hintMul = 5000000 / 20000; //5000000 for all countries (20,000 km)

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

setTimeout(() => {
try {

if (extent) {
const bounds = L.latLngBounds([extent[1], extent[0]], [extent[3], extent[2]]);
map.fitBounds(bounds);
} else {
// reset to default
map.setView([30, 0], 2);
}
}catch(e) {}
}, 500);
}, [gameOptions?.extent ? JSON.stringify(gameOptions.extent) : null, map, answerShown]);

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


const name = player.username;
const name = process.env.NEXT_PUBLIC_COOLMATH?guestNameString(player.username):player.username;
const latLong = [player.guess[0], player.guess[1]];

const tIcon = customPins[name]==="polandball" ? polandballIcon : src2Icon;
Expand Down
22 changes: 9 additions & 13 deletions components/gameUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown,
round: prev.round + 1
}
})
} else {
} else if(setSinglePlayerRound) {
// reset to default
setSinglePlayerRound({
round: 1,
Expand All @@ -96,7 +96,7 @@ export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown,
const loadTime = window.gameOpen;
const lastDiscordShown = gameStorage.getItem("shownDiscordModal");
if(lastDiscordShown) return console.log("Discord modal already shown");
if(Date.now() - loadTime > 600000) {
if(Date.now() - loadTime > 600000 && !process.env.NEXT_PUBLIC_COOLMATH) {
setShowDiscordModal(true)
sendEvent('discord_modal_shown')
} else console.log("Not showing discord modal, waiting for "+(600000 - (Date.now() - loadTime))+"ms")
Expand Down Expand Up @@ -454,14 +454,14 @@ export default function GameUI({ inCoolMathGames, miniMapShown, setMiniMapShown,
return (
<div className="gameUI">

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


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

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

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


{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")) && (
{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")) && (
<PlayerList multiplayerState={multiplayerState} playAgain={() => {


backBtnPressed(true)

backBtnPressed(true, "unranked")
}} backBtn={() => {

backBtnPressed()
}} />
)}
Expand Down
Loading

0 comments on commit e04d96c

Please sign in to comment.