mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 02:10:18 +01:00
Corrections zones
This commit is contained in:
@@ -117,7 +117,7 @@ export default {
|
|||||||
if (team.currentLocation == null || !zoneManager.isRunning) {
|
if (team.currentLocation == null || !zoneManager.isRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!zoneManager.isInCircle({ lat: team.currentLocation[0], lng: team.currentLocation[1] })) {
|
if (!zoneManager.isInZone({ lat: team.currentLocation[0], lng: team.currentLocation[1] })) {
|
||||||
//The team was not previously out of the zone
|
//The team was not previously out of the zone
|
||||||
if (!this.outOfBoundsSince[team.id]) {
|
if (!this.outOfBoundsSince[team.id]) {
|
||||||
this.outOfBoundsSince[team.id] = Date.now();
|
this.outOfBoundsSince[team.id] = Date.now();
|
||||||
|
|||||||
@@ -183,9 +183,12 @@ export default {
|
|||||||
|
|
||||||
goNextZone() {
|
goNextZone() {
|
||||||
this.currentZone.id++;
|
this.currentZone.id++;
|
||||||
if (this.currentZone.id >= this.zones.length) return;
|
if (this.currentZone.id >= this.zones.length - 1) {
|
||||||
this.currentZone.timeoutId = setTimeout(() => this.goNextZone(), this.getCurrentZone().duration * 60 * 1000);
|
this.currentZone.endDate = Date.now();
|
||||||
this.currentZone.endDate = Date.now() + this.getCurrentZone().duration * 60 * 1000;
|
} else {
|
||||||
|
this.currentZone.timeoutId = setTimeout(() => this.goNextZone(), this.getCurrentZone().duration * 60 * 1000);
|
||||||
|
this.currentZone.endDate = Date.now() + this.getCurrentZone().duration * 60 * 1000;
|
||||||
|
}
|
||||||
this.zoneBroadcast();
|
this.zoneBroadcast();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -54,15 +54,15 @@ export default function LiveMap() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='min-h-full w-full'>
|
<div className='min-h-full w-full'>
|
||||||
{gameState == GameState.PLAYING && timeLeftNextZone && <p>{`Next zone in : ${formatTime(timeLeftNextZone)}`}</p>}
|
{gameState == GameState.PLAYING && <p>{`Next zone in : ${formatTime(timeLeftNextZone)}`}</p>}
|
||||||
<MapContainer className='min-h-full w-full' center={location} zoom={DEFAULT_ZOOM} scrollWheelZoom={true}>
|
<MapContainer className='min-h-full w-full' center={location} zoom={DEFAULT_ZOOM} scrollWheelZoom={true}>
|
||||||
<TileLayer
|
<TileLayer
|
||||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||||
/>
|
/>
|
||||||
<MapPan center={location} zoom={DEFAULT_ZOOM} />
|
<MapPan center={location} zoom={DEFAULT_ZOOM} />
|
||||||
{gameState == GameState.PLAYING && zoneExtremities.begin && <Polygon positions={zoneExtremities.begin.points} pathOptions={{ color: 'blue', fillColor: 'blue', fillOpacity: '0.2', weight: 3 }} />}
|
{gameState == GameState.PLAYING && zoneExtremities.begin && <Polygon positions={zoneExtremities.begin.points} pathOptions={{ color: 'red', fillColor: 'red', fillOpacity: '0.1', weight: 3 }} />}
|
||||||
{gameState == GameState.PLAYING && zoneExtremities.end && <Polygon positions={zoneExtremities.end.points} pathOptions={{ color: 'red', fillColor: 'red', fillOpacity: '0', weight: 3 }} />}
|
{gameState == GameState.PLAYING && zoneExtremities.end && <Polygon positions={zoneExtremities.end.points} pathOptions={{ color: 'green', fillColor: 'green', fillOpacity: '0.1', weight: 3 }} />}
|
||||||
{teams.map((team) => team.currentLocation && !team.captured &&
|
{teams.map((team) => team.currentLocation && !team.captured &&
|
||||||
<Marker key={team.id} position={team.currentLocation} icon={positionIcon}>
|
<Marker key={team.id} position={team.currentLocation} icon={positionIcon}>
|
||||||
<Tooltip permanent direction="top" offset={[0, -5]} className="custom-tooltip">{team.name}</Tooltip>
|
<Tooltip permanent direction="top" offset={[0, -5]} className="custom-tooltip">{team.name}</Tooltip>
|
||||||
|
|||||||
@@ -19,25 +19,26 @@ export function AdminProvider({ children }) {
|
|||||||
const [gameState, setGameState] = useState(GameState.SETUP);
|
const [gameState, setGameState] = useState(GameState.SETUP);
|
||||||
const [startDate, setStartDate] = useState(null);
|
const [startDate, setStartDate] = useState(null);
|
||||||
|
|
||||||
useSocketListener(adminSocket, "game_state", (data) => {setGameState(data.state); setStartDate(data.startDate)});
|
|
||||||
// Send a request to get the teams when the user logs in
|
// Send a request to get the teams when the user logs in
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
adminSocket.emit("get_teams");
|
adminSocket.emit("get_teams");
|
||||||
}, [loggedIn]);
|
}, [loggedIn]);
|
||||||
|
|
||||||
function setCurrent_zone(data) {
|
function setCurrentZone(data) {
|
||||||
setZoneExtremities({begin: data.begin, end: data.end});
|
setZoneExtremities({begin: data.begin, end: data.end});
|
||||||
setNextZoneDate(data.endDate);
|
setNextZoneDate(data.endDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind listeners to update the team list and the game status on socket message
|
useSocketListener(adminSocket, "game_state", (data) => {setGameState(data.state); setStartDate(data.startDate)});
|
||||||
useSocketListener(adminSocket, "teams", setTeams);
|
useSocketListener(adminSocket, "teams", setTeams);
|
||||||
useSocketListener(adminSocket, "zone_settings", setZoneSettings);
|
useSocketListener(adminSocket, "zone_settings", setZoneSettings);
|
||||||
useSocketListener(adminSocket, "game_settings", setGameSettings);
|
useSocketListener(adminSocket, "game_settings", setGameSettings);
|
||||||
useSocketListener(adminSocket, "penalty_settings", setPenaltySettings);
|
useSocketListener(adminSocket, "penalty_settings", setPenaltySettings);
|
||||||
useSocketListener(adminSocket, "current_zone", setCurrent_zone);
|
useSocketListener(adminSocket, "current_zone", setCurrentZone);
|
||||||
|
|
||||||
const value = useMemo(() => ({ zoneExtremities, teams, zoneSettings, penaltySettings, gameSettings, gameState, nextZoneDate, startDate }), [zoneSettings, teams, gameState, zoneExtremities, penaltySettings, gameSettings, nextZoneDate, startDate]);
|
const value = useMemo(() => (
|
||||||
|
{ zoneExtremities, teams, zoneSettings, penaltySettings, gameSettings, gameState, nextZoneDate, startDate }
|
||||||
|
), [zoneSettings, teams, gameState, zoneExtremities, penaltySettings, gameSettings, nextZoneDate, startDate]);
|
||||||
return (
|
return (
|
||||||
<adminContext.Provider value={value}>
|
<adminContext.Provider value={value}>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user