Skip to content

Commit 94e680a

Browse files
committed
remove squares
1 parent 112ced7 commit 94e680a

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

components/LeafletMap.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,42 @@ export default function LeafletMap({ onCountryClick, highlightCountry, gameState
7070

7171
const loadCountryBoundaries = async (map, L) => {
7272
try {
73-
// For now, we'll create basic country polygons for major countries
74-
// In a real implementation, you'd load actual GeoJSON data
75-
const countryBounds = getSimplifiedCountryBounds();
73+
// Load actual world countries GeoJSON from a public source
74+
const response = await fetch('https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/world.geojson');
75+
const worldData = await response.json();
76+
77+
// Filter to only include our game countries
78+
const gameCountries = [
79+
'United States of America', 'Canada', 'Mexico', 'Brazil', 'Argentina',
80+
'Russia', 'China', 'India', 'Australia', 'Egypt',
81+
'South Africa', 'Nigeria', 'Germany', 'France', 'Spain',
82+
'United Kingdom', 'Italy', 'Turkey', 'Saudi Arabia', 'Iran',
83+
'Kazakhstan', 'Mongolia', 'Japan', 'Indonesia', 'Thailand'
84+
];
85+
86+
// Map display names to GeoJSON names
87+
const countryNameMap = {
88+
'United States': 'United States of America',
89+
'United Kingdom': 'United Kingdom',
90+
'Russia': 'Russia',
91+
'South Africa': 'South Africa'
92+
};
93+
94+
const filteredFeatures = worldData.features.filter(feature => {
95+
const countryName = feature.properties.NAME;
96+
return gameCountries.includes(countryName);
97+
});
98+
99+
const countryBounds = {
100+
type: "FeatureCollection",
101+
features: filteredFeatures.map(feature => ({
102+
...feature,
103+
properties: {
104+
...feature.properties,
105+
name: Object.keys(countryNameMap).find(key => countryNameMap[key] === feature.properties.NAME) || feature.properties.NAME
106+
}
107+
}))
108+
};
76109

77110
const geoJsonLayer = L.geoJSON(countryBounds, {
78111
style: {

components/MapGuessrGame.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ export default function MapGuessrGame() {
1313
const [round, setRound] = useState(1);
1414
const [gameState, setGameState] = useState('playing'); // playing, correct, wrong, finished
1515
const [feedback, setFeedback] = useState('');
16+
const [gameStats, setGameStats] = useState({
17+
totalAnswers: 0,
18+
correctAnswers: 0,
19+
wrongAnswers: 0,
20+
roundDetails: [],
21+
startTime: null,
22+
endTime: null,
23+
averageTimePerRound: 0
24+
});
25+
const [roundStartTime, setRoundStartTime] = useState(null);
1626

1727
// Basic list of easy-to-click major countries
1828
const countries = [
@@ -26,11 +36,26 @@ export default function MapGuessrGame() {
2636
const maxRounds = 10;
2737

2838
useEffect(() => {
39+
// Initialize game stats with start time
40+
setGameStats(prev => ({
41+
...prev,
42+
startTime: new Date()
43+
}));
2944
startNewRound();
3045
}, []);
3146

3247
const startNewRound = () => {
3348
if (round > maxRounds) {
49+
// Finalize game stats
50+
const endTime = new Date();
51+
setGameStats(prev => {
52+
const totalTime = endTime - prev.startTime;
53+
return {
54+
...prev,
55+
endTime,
56+
averageTimePerRound: prev.totalAnswers > 0 ? totalTime / prev.totalAnswers : 0
57+
};
58+
});
3459
setGameState('finished');
3560
return;
3661
}
@@ -39,6 +64,7 @@ export default function MapGuessrGame() {
3964
setCurrentCountry(randomCountry);
4065
setGameState('playing');
4166
setFeedback('');
67+
setRoundStartTime(new Date());
4268
};
4369

4470
const handleCountryClick = (clickedCountry) => {

0 commit comments

Comments
 (0)