mirror of
https://git.rezel.net/LudoTech/traque.git
synced 2026-02-09 02:10:18 +01:00
Améliorations mineures
This commit is contained in:
BIN
traque-back/images/missing_image.jpg
Normal file
BIN
traque-back/images/missing_image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
@@ -61,23 +61,25 @@ export function initPhotoUpload() {
|
||||
//App handler for serving the photo of a team given its secret ID
|
||||
app.get("/photo/my", (req, res) => {
|
||||
let team = game.getTeam(Number(req.query.team));
|
||||
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.id.toString());
|
||||
if (team) {
|
||||
res.set("Content-Type", "image/png")
|
||||
res.set("Access-Control-Allow-Origin", "*");
|
||||
res.sendFile(process.cwd() + "/" + UPLOAD_DIR + "/" + team.id);
|
||||
res.sendFile(fs.existsSync(imagePath) ? imagePath : path.join(process.cwd(), "images", "missing_image.jpg"));
|
||||
} else {
|
||||
res.send(400, "Team not found")
|
||||
res.status(400).send("Team not found")
|
||||
}
|
||||
})
|
||||
//App handler for serving the photo of the team chased by the team given by its secret ID
|
||||
app.get("/photo/enemy", (req, res) => {
|
||||
let team = game.getTeam(Number(req.query.team));
|
||||
const imagePath = path.join(process.cwd(), UPLOAD_DIR, team.chasing.toString());
|
||||
if (team) {
|
||||
res.set("Content-Type", "image/png")
|
||||
res.set("Access-Control-Allow-Origin", "*");
|
||||
res.sendFile(process.cwd() + "/" + UPLOAD_DIR + "/" + team.chasing);
|
||||
res.sendFile(fs.existsSync(imagePath) ? imagePath : path.join(process.cwd(), "images", "missing_image.jpg"));
|
||||
} else {
|
||||
res.send(400, "Team not found")
|
||||
res.status(400).send("Team not found")
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -73,24 +73,26 @@ export function initTeamSocket() {
|
||||
logoutPlayer(socket.id)
|
||||
});
|
||||
|
||||
socket.on("login", (loginTeamId) => {
|
||||
socket.on("login", (loginTeamId, callback) => {
|
||||
if (game.getTeam(loginTeamId) === undefined) {
|
||||
socket.emit("login_response", false);
|
||||
return;
|
||||
callback({ isLoggedIn : false, message: "Login denied"});
|
||||
} else {
|
||||
logoutPlayer(socket.id)
|
||||
teamId = loginTeamId;
|
||||
let team = game.getTeam(loginTeamId);
|
||||
team.sockets.push(socket.id);
|
||||
sendUpdatedTeamInformations(loginTeamId);
|
||||
socket.emit("login_response", true);
|
||||
socket.emit("game_state", game.state)
|
||||
socket.emit("game_settings", game.settings)
|
||||
socket.emit("zone", zone.currentZone)
|
||||
socket.emit("new_zone", {
|
||||
begin: zone.currentStartZone,
|
||||
end: zone.nextZone
|
||||
})
|
||||
callback({ isLoggedIn : true, message: "Logged in"});
|
||||
}
|
||||
logoutPlayer(socket.id)
|
||||
teamId = loginTeamId;
|
||||
let team = game.getTeam(loginTeamId);
|
||||
team.sockets.push(socket.id);
|
||||
sendUpdatedTeamInformations(loginTeamId);
|
||||
socket.emit("login_response", true);
|
||||
socket.emit("game_state", game.state)
|
||||
socket.emit("game_settings", game.settings)
|
||||
socket.emit("zone", zone.currentZone)
|
||||
socket.emit("new_zone", {
|
||||
begin: zone.currentStartZone,
|
||||
end: zone.nextZone
|
||||
})
|
||||
});
|
||||
|
||||
socket.on("logout", () => {
|
||||
|
||||
@@ -41,7 +41,7 @@ export function CircularAreaPicker({ area, setArea, markerPosition, ...props })
|
||||
const location = useLocation(Infinity);
|
||||
const { handleClick, handleMouseMove, center, radius } = useMapCircleDraw(area, setArea);
|
||||
return (
|
||||
<MapContainer {...props} className='min-h-full w-full ' center={[0, 0]} zoom={0} scrollWheelZoom={true}>
|
||||
<MapContainer {...props} className='min-h-full w-full ' center={[48.7143326, 2.20564757]} zoom={14} scrollWheelZoom={true}>
|
||||
<TileLayer
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
@@ -84,7 +84,7 @@ export function ZonePicker({ minZone, setMinZone, maxZone, setMaxZone, editMode,
|
||||
return (
|
||||
<div>
|
||||
<div className='h-96'>
|
||||
<MapContainer {...props} className='min-h-full w-full ' center={[0, 0]} zoom={0} scrollWheelZoom={true}>
|
||||
<MapContainer {...props} className='min-h-full w-full ' center={[48.7143326, 2.20564757]} zoom={14} scrollWheelZoom={true}>
|
||||
<TileLayer
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
|
||||
@@ -4,11 +4,15 @@ import BlueButton from '../util/button'
|
||||
|
||||
export default function TeamAddForm({onAddTeam}) {
|
||||
const [teamName, setTeamName] = React.useState('');
|
||||
|
||||
function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
onAddTeam(teamName);
|
||||
setTeamName("")
|
||||
if (teamName !== "") {
|
||||
onAddTeam(teamName);
|
||||
setTeamName("")
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<form className='flex flex-row m-y-5' onSubmit={handleSubmit}>
|
||||
<div className='w-4/5'>
|
||||
|
||||
@@ -95,7 +95,7 @@ export default function TeamEdit({ selectedTeamId, setSelectedTeamId }) {
|
||||
<CircularAreaPicker area={team.startingArea} setArea={(startingArea) => updateTeam(team.id, { startingArea })} markerPosition={team?.currentLocation} />
|
||||
</div>
|
||||
<div className='w-1/2'>
|
||||
<img className='self-stretch' ref={teamImage} />
|
||||
<img className='self-stretch' ref={teamImage} onError={(e) => {e.target.src = "/images/missing_image.jpg"}} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
BIN
traque-front/public/images/missing_image.jpg
Normal file
BIN
traque-front/public/images/missing_image.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Reference in New Issue
Block a user