fix invite double channel when add friend fix invite, history power up time limited wall
This commit is contained in:
parent
2f777480a0
commit
9098c29287
6
.env
6
.env
@ -12,9 +12,15 @@
|
|||||||
|
|
||||||
#URL
|
#URL
|
||||||
NGINX_ENVSUBST_TEMPLATE_SUFFIX=".conf"
|
NGINX_ENVSUBST_TEMPLATE_SUFFIX=".conf"
|
||||||
|
|
||||||
|
# BASE_URL=http://localhost
|
||||||
|
# SOCKET_URL=localhost:8080
|
||||||
BASE_URL=localhost:8080
|
BASE_URL=localhost:8080
|
||||||
REACT_APP_BASE_URL=localhost:8080
|
REACT_APP_BASE_URL=localhost:8080
|
||||||
REDIRECT_URI=http://localhost:8080/api/auth/login
|
REDIRECT_URI=http://localhost:8080/api/auth/login
|
||||||
|
#postgres var
|
||||||
|
# POSTGRES_HOST=127.0.0.1
|
||||||
|
# DB_TYPE=postgres
|
||||||
POSTGRES_HOST=postgresql
|
POSTGRES_HOST=postgresql
|
||||||
POSTGRES_USER=postgres
|
POSTGRES_USER=postgres
|
||||||
POSTGRES_PASSWORD=postgres
|
POSTGRES_PASSWORD=postgres
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/06/17 01:00:00 by apommier #+# #+# */
|
/* Created: 2023/06/17 01:00:00 by apommier #+# #+# */
|
||||||
/* Updated: 2023/06/24 20:00:09 by apommier ### ########.fr */
|
/* Updated: 2023/06/25 00:10:18 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -96,6 +96,12 @@ export class AppController {
|
|||||||
const user = await this.userService.findOne(req.user.username)
|
const user = await this.userService.findOne(req.user.username)
|
||||||
if (!user)
|
if (!user)
|
||||||
return (0);
|
return (0);
|
||||||
|
if (user.friends.find(item => item === data.username))
|
||||||
|
{
|
||||||
|
user.friendRequest = user.friendRequest.filter((item) => item !== data.username);
|
||||||
|
this.userService.save(user);
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
//create personnal conv for user
|
//create personnal conv for user
|
||||||
//await this.userService.addFriend(user, data.username);
|
//await this.userService.addFriend(user, data.username);
|
||||||
|
|
||||||
@ -115,13 +121,13 @@ export class AppController {
|
|||||||
messages: null,
|
messages: null,
|
||||||
group: false,
|
group: false,
|
||||||
private: false,
|
private: false,
|
||||||
|
|
||||||
};
|
};
|
||||||
conv.members.push(req.user.username);
|
conv.members.push(req.user.username);
|
||||||
conv.members.push(data.username);
|
conv.members.push(data.username);
|
||||||
await this.chatService.createConv(conv);
|
await this.chatService.createConv(conv);
|
||||||
|
|
||||||
return await this.userService.addFriend(user, data.username);
|
return await this.userService.addFriend(user, data.username);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/06/17 01:00:07 by apommier #+# #+# */
|
/* Created: 2023/06/17 01:00:07 by apommier #+# #+# */
|
||||||
/* Updated: 2023/06/24 19:29:33 by apommier ### ########.fr */
|
/* Updated: 2023/06/24 23:30:52 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -75,6 +75,7 @@ export class UsersService {
|
|||||||
user.friendRequest = user.friendRequest || [];
|
user.friendRequest = user.friendRequest || [];
|
||||||
if (user.friendRequest.find(item => item === username))
|
if (user.friendRequest.find(item => item === username))
|
||||||
return (1);
|
return (1);
|
||||||
|
user.friends = user.friends || [];
|
||||||
if (user.friends.find(item => item === username))
|
if (user.friends.find(item => item === username))
|
||||||
return (1);
|
return (1);
|
||||||
user.friendRequest.push(username);
|
user.friendRequest.push(username);
|
||||||
@ -104,17 +105,16 @@ export class UsersService {
|
|||||||
|
|
||||||
if (user)
|
if (user)
|
||||||
{
|
{
|
||||||
|
// const ret = await this.matchRepository.query("SELECT * FROM \"MatchLog\"");
|
||||||
|
|
||||||
// const ret = await this.matchRepository.query("SELECT * FROM \"MatchLog\" WHERE id = ($1);", [user.id]);
|
console.log("user id=0 ", user.id);
|
||||||
const ret = await this.matchRepository.query("SELECT * FROM \"MatchLog\"");
|
// const matchLog = await this.userRepository.query("SELECT * FROM \"MatchLog\" WHERE \"parentId\" = ANY ($1);", [[user.id]]);
|
||||||
console.log("all match= ", ret);
|
|
||||||
|
return await this.userRepository.query("SELECT * FROM \"MatchLog\" WHERE \"parentId\" = ANY ($1);", [[user.id]]);
|
||||||
|
|
||||||
|
|
||||||
|
// console.log("all match2= ", matchLog);
|
||||||
}
|
}
|
||||||
// const children = user.children;
|
|
||||||
// console.log(user);
|
|
||||||
// console.log(user.children); // or perform any operations with the children
|
|
||||||
// return children;
|
|
||||||
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async addFriend(user: User, username: string) {
|
async addFriend(user: User, username: string) {
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/06/19 15:18:38 by apommier #+# #+# */
|
/* Created: 2023/06/19 15:18:38 by apommier #+# #+# */
|
||||||
/* Updated: 2023/06/24 17:20:24 by apommier ### ########.fr */
|
/* Updated: 2023/06/24 23:37:39 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -282,13 +282,13 @@ addPrivateParty(client: Socket, payload: any): void {
|
|||||||
@SubscribeMessage('pong:forced')
|
@SubscribeMessage('pong:forced')
|
||||||
forcedMessage(client: Socket, payload: any): void
|
forcedMessage(client: Socket, payload: any): void
|
||||||
{
|
{
|
||||||
console.log(`from: ${client.id}`);
|
// console.log(`from: ${client.id}`);
|
||||||
console.log(payload);
|
// console.log(payload);
|
||||||
|
|
||||||
const game = this.games.get(payload.gameId);
|
const game = this.games.get(payload.gameId);
|
||||||
const playersIds = game.map(socket => socket.id);
|
const playersIds = game.map(socket => socket.id);
|
||||||
|
|
||||||
console.log(`id of 0= ${playersIds[0]}`);
|
// console.log(`id of 0= ${playersIds[0]}`);
|
||||||
|
|
||||||
if (playersIds[0] === payload.id)
|
if (playersIds[0] === payload.id)
|
||||||
{
|
{
|
||||||
@ -298,19 +298,19 @@ addPrivateParty(client: Socket, payload: any): void {
|
|||||||
{
|
{
|
||||||
this.clients[playersIds[0]].emit('pong:info', payload);
|
this.clients[playersIds[0]].emit('pong:info', payload);
|
||||||
}
|
}
|
||||||
console.log("END OF HANDLE");
|
// console.log("END OF HANDLE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeMessage('pong:paddle')
|
@SubscribeMessage('pong:paddle')
|
||||||
handlePaddle(client: Socket, payload: any): void
|
handlePaddle(client: Socket, payload: any): void
|
||||||
{
|
{
|
||||||
console.log(`from: ${client.id}`);
|
// console.log(`from: ${client.id}`);
|
||||||
console.log(payload);
|
// console.log(payload);
|
||||||
|
|
||||||
const game = this.games.get(payload.gameId);
|
const game = this.games.get(payload.gameId);
|
||||||
const playersIds = game.map(socket => socket.id);
|
const playersIds = game.map(socket => socket.id);
|
||||||
|
|
||||||
console.log(`id of 0= ${playersIds[0]}`);
|
// console.log(`id of 0= ${playersIds[0]}`);
|
||||||
|
|
||||||
if (playersIds[0] === payload.id)
|
if (playersIds[0] === payload.id)
|
||||||
{
|
{
|
||||||
@ -320,7 +320,7 @@ addPrivateParty(client: Socket, payload: any): void {
|
|||||||
{
|
{
|
||||||
this.clients[playersIds[0]].emit('pong:paddle', payload);
|
this.clients[playersIds[0]].emit('pong:paddle', payload);
|
||||||
}
|
}
|
||||||
console.log("END OF HANDLE");
|
// console.log("END OF HANDLE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeMessage('pong:point')
|
@SubscribeMessage('pong:point')
|
||||||
@ -363,9 +363,7 @@ addPrivateParty(client: Socket, payload: any): void {
|
|||||||
{
|
{
|
||||||
const game = this.games.get(payload.gameId);
|
const game = this.games.get(payload.gameId);
|
||||||
const playersIds = game.map(socket => socket.id);
|
const playersIds = game.map(socket => socket.id);
|
||||||
|
|
||||||
console.log(`name of client= ${payload.name}`);
|
console.log(`name of client= ${payload.name}`);
|
||||||
|
|
||||||
if (playersIds[0] === payload.id)
|
if (playersIds[0] === payload.id)
|
||||||
{
|
{
|
||||||
this.clients[playersIds[1]].emit('pong:name', payload);
|
this.clients[playersIds[1]].emit('pong:name', payload);
|
||||||
|
|||||||
@ -62,8 +62,20 @@ function WinLoss() {
|
|||||||
const getUser = async ()=>{
|
const getUser = async ()=>{
|
||||||
try{
|
try{
|
||||||
// const tmpUser = await api.get("/profile")
|
// const tmpUser = await api.get("/profile")
|
||||||
const tmpUser = await api.post("/user", {username: username})
|
console.log("username win loss=", username)
|
||||||
const tmpHistory = await api.post("/history", {username: username})
|
let tmpUser;
|
||||||
|
let tmpHistory;
|
||||||
|
|
||||||
|
if (username)
|
||||||
|
{
|
||||||
|
tmpUser = await api.post("/user", {username: username});
|
||||||
|
tmpHistory = await api.post("/history", {username: username})
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmpUser = await api.get("/profile");
|
||||||
|
tmpHistory = await api.post("/history", {username: tmpUser.data.username})
|
||||||
|
}
|
||||||
setHistory(tmpHistory.data);
|
setHistory(tmpHistory.data);
|
||||||
setUser(tmpUser.data);
|
setUser(tmpUser.data);
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|||||||
@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* Home.tsx :+: :+: :+: */
|
/* Home.tsx :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: sadjigui <sadjigui@student.42.fr> +#+ +:+ +#+ */
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/06/09 08:19:04 by apommier #+# #+# */
|
/* Created: 2023/06/09 08:19:04 by apommier #+# #+# */
|
||||||
/* Updated: 2023/06/23 22:11:28 by apommier ### ########.fr */
|
/* Updated: 2023/06/24 23:26:45 by apommier ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@ -224,7 +224,12 @@ function Home () {
|
|||||||
):("")}
|
):("")}
|
||||||
</div>
|
</div>
|
||||||
<div className="home">
|
<div className="home">
|
||||||
<motion.div animate={{x: move ? -200: 120}}
|
<motion.div
|
||||||
|
// style={{
|
||||||
|
// backdropFilter: move ? "blur(10px)" : "none",
|
||||||
|
// WebkitBackdropFilter: move ? "blur(10px)" : "none"
|
||||||
|
// }}
|
||||||
|
animate={{x: move ? '-50%' : '30%'}}
|
||||||
transition={{type: "tween", duration: 0.5}}>
|
transition={{type: "tween", duration: 0.5}}>
|
||||||
<Profile/>
|
<Profile/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|||||||
@ -124,6 +124,8 @@ function DrawCanvas(option: number, gameParam: GameProps) {
|
|||||||
const maxScore = 5;
|
const maxScore = 5;
|
||||||
|
|
||||||
let lastUpdateTime = performance.now();
|
let lastUpdateTime = performance.now();
|
||||||
|
let lastPower = 0;
|
||||||
|
|
||||||
|
|
||||||
const maxAngle = 50;
|
const maxAngle = 50;
|
||||||
let maxBounceAngle = (maxAngle * Math.PI) / 180;
|
let maxBounceAngle = (maxAngle * Math.PI) / 180;
|
||||||
@ -491,7 +493,7 @@ socket.on('pong:hisPoint', (data) => {
|
|||||||
// id: myId,
|
// id: myId,
|
||||||
// option: option,
|
// option: option,
|
||||||
// };
|
// };
|
||||||
|
// await api.post("status", {status: 1});
|
||||||
await api.post("deleteInvite", {username: gameParam.username})
|
await api.post("deleteInvite", {username: gameParam.username})
|
||||||
}
|
}
|
||||||
catch (err){
|
catch (err){
|
||||||
@ -759,6 +761,10 @@ async function draw(timestamp: number)
|
|||||||
}
|
}
|
||||||
else if (event.code === "KeyW")
|
else if (event.code === "KeyW")
|
||||||
{
|
{
|
||||||
|
let date = new Date();
|
||||||
|
console.log("last time =", date.getTime() - lastPower)
|
||||||
|
if (date.getTime() - lastPower < 15000)//10000 + 5000
|
||||||
|
return ;
|
||||||
if (!superpowerModifier)
|
if (!superpowerModifier)
|
||||||
return ;
|
return ;
|
||||||
paddleY = 0;
|
paddleY = 0;
|
||||||
@ -770,13 +776,9 @@ async function draw(timestamp: number)
|
|||||||
paddleY = canvas.height / 2 - paddleHeight / 2;
|
paddleY = canvas.height / 2 - paddleHeight / 2;
|
||||||
console.log('Cinq secondes se sont écoulées.');
|
console.log('Cinq secondes se sont écoulées.');
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
date = new Date();
|
||||||
// setTimeout(() => {
|
lastPower = date.getTime();
|
||||||
// // code à exécuter après 5 secondes
|
// console.log("date= ", date.getTime())
|
||||||
// paddleHeight = canvas.height * 0.25;
|
|
||||||
// paddleY = canvas.height / 2 - paddleHeight / 2;
|
|
||||||
// console.log('Cinq secondes se sont écoulées.');
|
|
||||||
// }, 5000);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user