Compare commits

..

No commits in common. 'master' and 'stub-api' have entirely different histories.

@ -1,119 +1,23 @@
# This file creates our 2 docker containers # database container deployment
kind: pipeline kind: pipeline
name: Dockers_Builder name: BD
# Creation of the DB docker
steps: steps:
# database container deployment
- name: deploy-container-mysql - name: deploy-container-mysql
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
build:
context: .
dockerfile: ./Dockerfile
environment: environment:
IMAGENAME: mysql:latest IMAGENAME: mysql
CONTAINERNAME: mysql CONTAINERNAME: mysql
COMMAND: create COMMAND: create
OVERWRITE: true # OVERWRITE: false
PRIVATE: true PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD: CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
from_secret: MYSQL_ROOT_PASSWORD from_secret: P@s$w0rd123
CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE: CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE:
from_secret: MYSQL_DATABASE from_secret: BDBOB
CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER: CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER:
from_secret: MYSQL_USER_TOM from_secret: bob
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD: CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
from_secret: MYSQL_PASSWORD_TOM from_secret: P@s$w0rd123
ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours scripts:
- GRANT ALL PRIVILEGES ON *.* TO 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER'@'localhost' IDENTIFIED BY 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD';
# docker image build
- name: container-api
image: plugins/docker
settings:
dockerfile: ./api-rest/Dockerfile
context: .
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/bob_parteam/bob_party/api
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
#container deployment
- name: deploy-api-containers
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/bob_parteam/bob_party/api:latest
CONTAINERNAME: api-bobParty
COMMAND: create
OVERWRITE: true
#PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_DB_SERVER:
from_secret: db_server
CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER:
from_secret: MYSQL_USER_TOM
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
from_secret: MYSQL_PASSWORD_TOM
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
from_secret: MYSQL_ROOT_PASSWORD
CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE:
from_secret: MYSQL_DATABASE
ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours
depends_on: [ deploy-container-mysql, container-api ]
# docker image build
- name: container-server
image: plugins/docker
settings:
dockerfile: ./bob_party/Dockerfile
context: .
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/bob_parteam/bob_party/server
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
from_secret: SECRET_REGISTRY_PASSWORD
#container deployment
- name: deploy-server-containers
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/bob_parteam/bob_party/server:latest
CONTAINERNAME: server-bobParty
COMMAND: create
OVERWRITE: true
#PRIVATE: true
ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours
depends_on: [ container-server ]
# # docker image build
# - name: docker-build-and-push
# image: plugins/docker
# settings:
# dockerfile: Dockerfile
# context: .
# registry: hub.codefirst.iut.uca.fr
# repo: hub.codefirst.iut.uca.fr/thomas.chazot2/bobparty
# username:
# from_secret: SECRET_REGISTRY_USERNAME_TOM
# password:
# from_secret: SECRET_REGISTRY_PASSWORD_TOM
# #container deployment
# - name: deploy-bob_party-container
# image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
# environment:
# IMAGENAME: hub.codefirst.iut.uca.fr/thomas.chazot2/bobparty:latest
# CONTAINERNAME: bob_party_container
# COMMAND: create
# OVERWRITE: true
# ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours,thomasbellembois

@ -1,8 +0,0 @@
FROM mysql:latest
COPY setup.sh /mysql/setup.sh
COPY bobParty.sql /mysql/bobParty.sql
RUN chmod +x /mysql/setup.sh
RUN /mysql/setup.sh

@ -1,22 +1,19 @@
# # Rederection if URL not found # Rederection if URL not found
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILEANME} !-f
RewriteCond %{REQUEST_FILEANME} !-d
RewriteRule (.+) index.php?p=$1 [QSA,L]
</IfModule>
# <IfModule mod_rewrite.c> # Redirecting 403 errors to index.php (does not work)
# RewriteEngine on ErrorDocument 403 http://localhost:8888/api-rest/index.php
# RewriteCond %{REQUEST_FILEANME} !-f
# RewriteCond %{REQUEST_FILEANME} !-d
# RewriteRule (.+) index.php?p=$1 [QSA,L]
# </IfModule>
# # Redirecting 403 errors to index.php (does not work) # Refusing access to all files ending with php
# #ErrorDocument 403 http://localhost:8888/api-rest/index.php Require all denied
# # Refusing access to all files ending with php # Allowing access to index.php
<Files index.php>
Require all granted
# # Allowing access to index.php </Files>
# <Files index.php>
# Require all granted
# </Files>
# Require all denied

@ -1,13 +0,0 @@
FROM php:8.0-apache
RUN docker-php-ext-install mysqli pdo pdo_mysql
COPY api-rest/start-apache /usr/local/bin
RUN chmod 755 /usr/local/bin/start-apache
# Copy application source
ADD api-rest /var/www/html
RUN chown -R www-data:www-data /var/www/html
CMD ["start-apache"]

@ -1,4 +1,4 @@
[database] [database]
dsn = "mysql:host=". getenv("db_server").";dbname=". getenv("MYSQL_DATABASE") dsn = "mysql:host=localhost;port=8888;dbname=bobParty"
username = getenv("MYSQL_USER_TOM") username = "root"
password = getenv("MYSQL_PASSWORD_TOM") password = "root";

@ -28,14 +28,14 @@ class ConversationGateway{
/// Parameters : * $idUser (string): identifier of the user we want to get the conversations /// Parameters : * $idUser (string): identifier of the user we want to get the conversations
public function getConversations(string $_idUser):?array{ public function getConversations(string $_idUser):?array{
// Declaration of arrays (NULL) and queries // Declaration of arrays (NULL) and queries
$tabConversations=[]; $tabConversations=NULL;
$tabUsers=[]; $tabUsers=NULL;
$tabMessages=[]; $tabMessages=NULL;
$conversationQuery = "SELECT c.PK_ID, c.COV_NAME $conversationQuery = "SELECT c.PK_ID, c.COV_NAME
FROM T_H_CONVERSATION_COV c, T_J_DISCUSS_DIS d FROM T_H_CONVERSATION_COV c, T_J_DISCUSS_DIS d
WHERE c.PK_ID=d.FK_CONVERSATION WHERE c.PK_ID=d.FK_CONVERSATION
AND d.FK_USER=:idUser"; AND d.FK_USER=:idUser";
$messagesQuery = "SELECT m.PK_ID, m.MSG_MESSAGE, m.FK_SENDER, m.MSG_DATEENVOIE $messagesQuery = "SELECT m.PK_ID, m.MSG_MESSAGE, m.FK_SENDER
FROM T_H_MESSAGE_MSG m, T_J_CONTAIN_MESSAGE_CMG c FROM T_H_MESSAGE_MSG m, T_J_CONTAIN_MESSAGE_CMG c
WHERE m.PK_ID=c.FK_MESSAGE WHERE m.PK_ID=c.FK_MESSAGE
AND c.FK_CONVERSATION=:idConv"; AND c.FK_CONVERSATION=:idConv";
@ -53,10 +53,9 @@ class ConversationGateway{
$this->connection->execQuery($messagesQuery,$argIdConv); $this->connection->execQuery($messagesQuery,$argIdConv);
$resMessages=$this->connection->getRes(); $resMessages=$this->connection->getRes();
foreach($resMessages as $rowMessages){ foreach($resMessages as $rowMessages){
$tabMessages[] = new Message($rowMessages['PK_ID'], $tabUsers[] = new Message($rowMessages['PK_ID'],
$rowMessages['MSG_MESSAGE'], $rowMessages['MSG_MESSAGE'],
$rowMessages['FK_SENDER'], $rowMessages['FK_SENDER']);
$rowMessages['MSG_DATEENVOIE']);
} }
// Find all the users in the conversation // Find all the users in the conversation
$this->connection->execQuery($usersQuery,$argIdConv); $this->connection->execQuery($usersQuery,$argIdConv);
@ -77,7 +76,7 @@ class ConversationGateway{
} }
/// Brief : Adding a new conversation in database /// Brief : Adding a new conversation in database
public function postConversation(string $name, array $idUsers): int{ public function postConversation(string $name, int $idUser): void{
// Declare queries // Declare queries
$convCreationQuery = "INSERT INTO T_H_CONVERSATION_COV VALUES(NULL,:name)"; $convCreationQuery = "INSERT INTO T_H_CONVERSATION_COV VALUES(NULL,:name)";
$addUserInConvQuery = "INSERT INTO T_J_DISCUSS_DIS VALUES(:idUser,:idConv)"; $addUserInConvQuery = "INSERT INTO T_J_DISCUSS_DIS VALUES(:idUser,:idConv)";
@ -93,13 +92,10 @@ class ConversationGateway{
foreach($res as $row){ foreach($res as $row){
$id=$row['PK_ID']; $id=$row['PK_ID'];
} }
foreach ($idUsers as $idUs){ $argUserInConvQuery = array('idUser'=>array($idUser, PDO::PARAM_INT),
$argUserInConvQuery = array('idUser'=>array($idUs, PDO::PARAM_INT),
'idConv'=>array($id, PDO::PARAM_INT)); 'idConv'=>array($id, PDO::PARAM_INT));
$this->connection->execQuery($addUserInConvQuery,$argUserInConvQuery); $this->connection->execQuery($addUserInConvQuery,$argUserInConvQuery);
} }
return $id;
}
/// Brief : Modifying an EXISTING conversation in database /// Brief : Modifying an EXISTING conversation in database
@ -129,13 +125,12 @@ public function deleteUserFromConversation(int $idConv, int $idUser){
} }
/// Brief : adding a new message into a conversation /// Brief : adding a new message into a conversation
public function addMessageToConversation(string $message, int $idSender, int $idConv, string $date): int{ public function addMessageToConversation(string $message, int $idSender, int $idConv){
$insertMessageQuery = "INSERT INTO T_H_MESSAGE_MSG VALUES(NULL,:message,:idSender, :date)"; $insertMessageQuery = "INSERT INTO T_H_MESSAGE_MSG VALUES(NULL,:message,:idSender)";
$insertMsgInConvQuery = "INSERT INTO T_J_CONTAIN_MESSAGE_CMG VALUES(:idConv,:idMessage)"; $insertMsgInConvQuery = "INSERT INTO T_J_CONTAIN_MESSAGE_CMG VALUES(:idConv,:idMessage)";
$argInsertMessage= array('message'=>array($message,PDO::PARAM_STR), $argInsertMessage= array('message'=>array($message,PDO::PARAM_STR),
'idSender'=>array($idSender,PDO::PARAM_INT), 'idSender'=>array($idSender,PDO::PARAM_INT));
'date'=>array($date,PDO::PARAM_STR));
$this->connection->execQuery($insertMessageQuery,$argInsertMessage); $this->connection->execQuery($insertMessageQuery,$argInsertMessage);
$this->connection->execQuery("SELECT PK_ID $this->connection->execQuery("SELECT PK_ID
FROM T_H_MESSAGE_MSG FROM T_H_MESSAGE_MSG
@ -148,19 +143,14 @@ public function deleteUserFromConversation(int $idConv, int $idUser){
$argMsgInConv = array('idConv'=>array($idConv,PDO::PARAM_INT), $argMsgInConv = array('idConv'=>array($idConv,PDO::PARAM_INT),
'idMessage'=>array($idMsg,PDO::PARAM_INT)); 'idMessage'=>array($idMsg,PDO::PARAM_INT));
$this->connection->execQuery($insertMsgInConvQuery,$argMsgInConv); $this->connection->execQuery($insertMsgInConvQuery,$argMsgInConv);
return $idMsg;
} }
/// Brief : Deleting a conversation and its messages from database /// Brief : Deleting a conversation and its messages from database
public function deleteConversation(int $id):void{ public function deleteConversation(int $id):void{
$deleteConv = "DELETE FROM T_H_CONVERSATION_COV $deleteConv = "DELETE FROM T_H_CONVERSATION_COV
WHERE PK_ID=:idConv"; WHERE PK_ID=:idConv";
$deleteMessages="DELETE FROM T_H_MESSAGE_MSG WHERE PK_ID = (SELECT FK_MESSAGE
FROM T_J_CONTAIN_MESSAGE_CMG
WHERE FK_CONVERSATION=:id)";
$argIdConv = array('idConv'=>array($id,PDO::PARAM_INT)); $argIdConv = array('idConv'=>array($id,PDO::PARAM_INT));
$this->connection->execQuery($deleteConv,$argIdConv); $this->connection->execQuery($deleteConv,$argIdConv);
$this->connection->execQuery($deleteMessages,$argIdConv);
} }
} }

@ -20,28 +20,14 @@ class GameGateway{
public function getGames():?array{ public function getGames():?array{
$tabGames=null; $tabGames=null;
$gamesQuery="SELECT * FROM T_E_GAME_GAM"; $gamesQuery="SELECT * FROM T_E_GAME_GAM";
$mapQuery="SELECT * FROM T_J_GAME_MAP_GMP WHERE FK_GAME=:id ORDER BY GMP_KEY";
$this->connection->execQuery($gamesQuery,[]); $this->connection->execQuery($gamesQuery,[]);
$res = $this->connection->getRes(); $res = $this->connection->getRes();
$i=0;
foreach($res as $row){ foreach($res as $row){
$tabKey=[];
$tabValue=[];
$arg=array(':id'=>array($row['PK_ID'], PDO::PARAM_INT));
$this->connection->execQuery($mapQuery,$arg);
$resMap = $this->connection->getRes();
foreach($resMap as $rowMap){
$tabKey[]=$rowMap['GMP_KEY'];
$tabValue[]=$rowMap['GMP_VALUE'];
}
$tabGames[]= new Game($row['PK_ID'], $tabGames[]= new Game($row['PK_ID'],
$row['GAM_NAME'], $row['GAM_NAME'],
$row['GAM_IMAGE'], $row['GAM_IMAGE'],
$row['GAM_TYPE'],
$row['GAM_NB_PLAYER_MIN'], $row['GAM_NB_PLAYER_MIN'],
$row['GAM_NB_PLAYER_MAX'], $row['GAM_NB_PLAYER_MAX']);
$tabKey,
$tabValue);
} }
return $tabGames; return $tabGames;
} }
@ -51,28 +37,15 @@ class GameGateway{
public function getGameById(string $id):?Game{ public function getGameById(string $id):?Game{
$game=null; $game=null;
$gameInfoQuery="SELECT * FROM T_E_GAME_GAM WHERE PK_ID=:id"; $gameInfoQuery="SELECT * FROM T_E_GAME_GAM WHERE PK_ID=:id";
$mapQuery="SELECT * FROM T_J_GAME_MAP_GMP WHERE FK_GAME=:id ORDER BY GMP_KEY";
$arg=array('id'=>array($id,PDO::PARAM_STR)); $arg=array('id'=>array($id,PDO::PARAM_STR));
$this->connection->execQuery($gameInfoQuery,$arg); $this->connection->execQuery($gameInfoQuery,$arg);
$res=$this->connection->getRes(); $res=$this->connection->getRes();
foreach($res as $row){ foreach($res as $row){
$tabKey=[];
$tabValue=[];
$arg=array(':id'=>array($row['PK_ID'], PDO::PARAM_INT));
$this->connection->execQuery($mapQuery,$arg);
$resMap = $this->connection->getRes();
foreach($resMap as $rowMap){
$tabKey[]=$rowMap['GMP_KEY'];
$tabValue[]=$rowMap['GMP_VALUE'];
}
$game= new Game($row['PK_ID'], $game= new Game($row['PK_ID'],
$row['GAM_NAME'], $row['GAM_NAME'],
$row['GAM_IMAGE'], $row['GAM_IMAGE'],
$row['GAM_TYPE'],
$row['GAM_NB_PLAYER_MIN'], $row['GAM_NB_PLAYER_MIN'],
$row['GAM_NB_PLAYER_MAX'], $row['GAM_NB_PLAYER_MAX']);
$tabKey,
$tabValue);
} }
return $game; return $game;
} }

@ -24,7 +24,7 @@ class MatchGateway{
/// Parameters : * $id (string): identifier of the match we are looking for /// Parameters : * $id (string): identifier of the match we are looking for
public function getMatchById(string $matchId):?Matchs{ public function getMatchById(string $matchId):?Matchs{
$match=NULL; $match=NULL;
$matchInfoQuery="SELECT PK_ID, MTC_IN_GAME, FK_GAME FROM T_E_MATCH_MTC WHERE PK_ID = :id"; $matchInfoQuery="SELECT PK_ID, MTC_IN_GAME, FK_ID_GAME FROM T_E_MATCH_MTC WHERE PK_ID = :id";
$playersInMatchQuery="SELECT FK_USER FROM T_J_PLAY_MATCH_PLM WHERE FK_MATCH=:id"; $playersInMatchQuery="SELECT FK_USER FROM T_J_PLAY_MATCH_PLM WHERE FK_MATCH=:id";
$argId=array('id' => array($matchId, PDO::PARAM_INT)); $argId=array('id' => array($matchId, PDO::PARAM_INT));
$this->connection->execQuery($playersInMatchQuery, $argId); $this->connection->execQuery($playersInMatchQuery, $argId);
@ -35,13 +35,13 @@ class MatchGateway{
$this->connection->execQuery($matchInfoQuery, $argId); $this->connection->execQuery($matchInfoQuery, $argId);
$res=$this->connection->getRes(); $res=$this->connection->getRes();
foreach($res as $row){ foreach($res as $row){
$match = new Matchs($row['PK_ID'],$row['MTC_IN_GAME'],$row['FK_GAME'],$tabUser); $match = new Matchs($row['PK_ID'],$row['MTC_IN_GAME'],$row['FK_ID_GAME'],$tabUser);
} }
return $match; return $match;
} }
/// Brief : Adding a NEW match in database /// Brief : Adding a NEW match in database
public function postMatch(int $idGame, int $idCreator): ?Matchs{ public function postMatch(int $idGame, int $idCreator){
$insertMatchQuery="INSERT INTO T_E_MATCH_MTC VALUES(NULL,0,:idGame)"; $insertMatchQuery="INSERT INTO T_E_MATCH_MTC VALUES(NULL,0,:idGame)";
$insertPlayQuery = "INSERT INTO T_J_PLAY_MATCH_PLM VALUES(:idCreator,:id);"; $insertPlayQuery = "INSERT INTO T_J_PLAY_MATCH_PLM VALUES(:idCreator,:id);";
$argInsertMatch=array('idGame'=>array($idGame, PDO::PARAM_INT)); $argInsertMatch=array('idGame'=>array($idGame, PDO::PARAM_INT));
@ -57,7 +57,7 @@ class MatchGateway{
$argInsertPlay= array('idCreator'=>array($idCreator,PDO::PARAM_INT), $argInsertPlay= array('idCreator'=>array($idCreator,PDO::PARAM_INT),
'id'=>array($id,PDO::PARAM_INT)); 'id'=>array($id,PDO::PARAM_INT));
$this->connection->execQuery($insertPlayQuery,$argInsertPlay); $this->connection->execQuery($insertPlayQuery,$argInsertPlay);
return new Matchs($id, 0, $idGame, [$idCreator]); return;
} }
/// Brief : Modifying an EXISTING match in database /// Brief : Modifying an EXISTING match in database

@ -29,20 +29,6 @@ class SkinGateway{
} }
return $tabSkins; return $tabSkins;
} }
public function getSkinById(int $id):?Skin{
$skin=null;
$skinQuery="SELECT * FROM T_H_SKIN_SKI WHERE PK_ID=:id";
$this->connection->execQuery($skinQuery,array('id'=>array($id, PDO::PARAM_INT)));
$res = $this->connection->getRes();
foreach($res as $row){
$skin= new Skin($row['PK_ID'],
$row['SKI_NAME'],
$row['SKI_IMAGE'],
$row['SKI_PRICE']);
}
return $skin;
}
} }
?> ?>

@ -1,8 +1,6 @@
<?php <?php
require_once('model/user.php'); require_once('model/user.php');
require_once('model/skin.php');
class UserGateway{ class UserGateway{
@ -35,9 +33,6 @@ class UserGateway{
public function convertResToUser($res):?User{ public function convertResToUser($res):?User{
$usr=null; $usr=null;
foreach($res as $row){ foreach($res as $row){
$skinGateway=new SkinGateway($this->connection);
$skinId=$row['FK_CURRENT_SKIN'];
$skin=$skinGateway->getSkinById($skinId);
$usr= new User($row['PK_ID'], $usr= new User($row['PK_ID'],
$row['USR_USERNAME'], $row['USR_USERNAME'],
$row['USR_PASSWORD'], $row['USR_PASSWORD'],
@ -47,7 +42,7 @@ class UserGateway{
$row['USR_CURRENT_NB_COINS'], $row['USR_CURRENT_NB_COINS'],
$row['USR_TOTAL_NB_COINS'], $row['USR_TOTAL_NB_COINS'],
$row['USR_NB_GAMES_PLAYED'], $row['USR_NB_GAMES_PLAYED'],
$skin, $row['FK_CURRENT_SKIN'],
null); null);
} }
return $usr; return $usr;
@ -59,8 +54,8 @@ class UserGateway{
$tabSkin=null; $tabSkin=null;
$skinsOfUserQuery="SELECT s.* $skinsOfUserQuery="SELECT s.*
FROM T_H_SKIN_SKI s, T_J_OWN_SKIN_OWN o FROM T_H_SKIN_SKI s, T_J_OWN_SKIN_OWN o
WHERE o.FK_USER=:id AND s.PK_ID=o.FK_SKIN"; WHERE o.FK_USER=:id";
$argIdUser=array('id'=>array($id,PDO::PARAM_INT)); $argIdUser=array('id'=>array($id,PDO::PARAM_STR));
$this->connection->execQuery($skinsOfUserQuery,$argIdUser); $this->connection->execQuery($skinsOfUserQuery,$argIdUser);
$resSkin=$this->connection->getRes(); $resSkin=$this->connection->getRes();
foreach($resSkin as $row){ foreach($resSkin as $row){
@ -81,7 +76,7 @@ class UserGateway{
$res=$this->connection->getRes(); $res=$this->connection->getRes();
$usr=$this->convertResToUser($res); $usr=$this->convertResToUser($res);
if ($usr != null){ if ($usr != null){
$usr->tabSkin=$this->getSkinList($usr->id); $usr->listSkin=$this->getSkinList($usr->id);
} }
return $usr; return $usr;
} }
@ -97,7 +92,7 @@ class UserGateway{
$res=$this->connection->getRes(); $res=$this->connection->getRes();
$usr=$this->convertResToUser($res); $usr=$this->convertResToUser($res);
if ($usr != null){ if ($usr != null){
$usr->tabSkin=$this->getSkinList($usr->id); $usr->listSkin=$this->getSkinList($usr->id);
} }
return $usr; return $usr;
} }
@ -110,18 +105,15 @@ class UserGateway{
public function getUserForConnection(string $username,string $password):?User{ public function getUserForConnection(string $username,string $password):?User{
$userQuery = "SELECT * $userQuery = "SELECT *
FROM T_S_USER_USR FROM T_S_USER_USR
WHERE USR_USERNAME=:username"; WHERE USR_USERNAME=:username
$argUsernamePassword=(array('username'=>array($username,PDO::PARAM_STR))); AND USR_PASSWORD=:password";
$argUsernamePassword=(array('username'=>array($username,PDO::PARAM_STR),
'password'=>array($password,PDO::PARAM_STR)));
$this->connection->execQuery($userQuery,$argUsernamePassword); $this->connection->execQuery($userQuery,$argUsernamePassword);
$res=$this->connection->getRes(); $res=$this->connection->getRes();
foreach($res as $row){
if(!password_verify($password,$row["USR_PASSWORD"])){
return null;
}
}
$usr=$this->convertResToUser($res); $usr=$this->convertResToUser($res);
if ($usr != null){ if ($usr != null){
$usr->tabSkin=$this->getSkinList($usr->id); $usr->listSkin=$this->getSkinList($usr->id);
} }
return $usr; return $usr;
} }
@ -130,32 +122,22 @@ class UserGateway{
/// Parameters : * $u (User): user we want to insert in database /// Parameters : * $u (User): user we want to insert in database
/// Returning TRUE if the user has been added succesfully, FALSE otherwise /// Returning TRUE if the user has been added succesfully, FALSE otherwise
public function postUser(string $username, string $password, string $nationality, string $sex, string $dateOfBirth) { public function postUser(string $username, string $password, string $nationality, string $sex, string $dateOfBirth) {
$password=password_hash($password,PASSWORD_DEFAULT);
$insertUserQuery = "INSERT INTO T_S_USER_USR VALUES (NULL, :username, :password, :nationality, :sex, :dateOfBirth, 0, 0, 0, 1)"; $insertUserQuery = "INSERT INTO T_S_USER_USR VALUES (NULL, :username, :password, :nationality, :sex, :dateOfBirth, 0, 0, 0, 1)";
$getLastIdQuery = "SELECT max(PK_ID) id FROM T_S_USER_USR";
$argUser=array('username' => array($username, PDO::PARAM_STR), $argUser=array('username' => array($username, PDO::PARAM_STR),
'password' => array($password, PDO::PARAM_STR), 'password' => array($password, PDO::PARAM_STR),
'nationality' => array($nationality, PDO::PARAM_STR), 'nationality' => array($nationality, PDO::PARAM_STR),
'sex' => array($sex, PDO::PARAM_STR), 'sex' => array($sex, PDO::PARAM_STR),
'dateOfBirth' => array($dateOfBirth, PDO::PARAM_STR)); 'dateOfBirth' => array($dateOfBirth, PDO::PARAM_STR));
$this->connection->execQuery($insertUserQuery, $argUser); $this->connection->execQuery($insertUserQuery, $argUser);
$this->connection->execQuery($getLastIdQuery, array());
$res=$this->connection->getRes();
foreach($res as $row){
$this->putSkinList($row['id'], 1);
}
} }
/// Brief : Modifying an EXISTING user in database /// Brief : Modifying an EXISTING user in database
/// Parameters : * $u (User): user we want to update in database /// Parameters : * $u (User): user we want to update in database
/// Returning TRUE if the modifications has been done succesfully, FALSE otherwise /// Returning TRUE if the modifications has been done succesfully, FALSE otherwise
public function putUser(int $id,string $username, string $password, string $sex, string $nationality, int $currentBobCoins,int $totalBobCoins,int $nbGamesPlayed, int $currentSkin){ public function putUser(int $id,string $username, string $password, int $currentBobCoins,int $totalBobCoins,int $nbGamesPlayed, int $currentSkin){
$password=password_hash($password,PASSWORD_DEFAULT);
$updateUserQuery="UPDATE T_S_USER_USR $updateUserQuery="UPDATE T_S_USER_USR
SET USR_USERNAME = :username, SET USR_USERNAME = :username,
USR_PASSWORD=:password, USR_PASSWORD=:password,
USR_SEX=:sex,
USR_NATIONALITY=:nationality,
USR_CURRENT_NB_COINS=:currentBobCoins, USR_CURRENT_NB_COINS=:currentBobCoins,
USR_TOTAL_NB_COINS=:totalBobCoins, USR_TOTAL_NB_COINS=:totalBobCoins,
USR_NB_GAMES_PLAYED=:nbGamesPlayed, USR_NB_GAMES_PLAYED=:nbGamesPlayed,
@ -163,8 +145,6 @@ class UserGateway{
WHERE PK_ID=:id"; WHERE PK_ID=:id";
$argUser=array('username' => array($username, PDO::PARAM_STR), $argUser=array('username' => array($username, PDO::PARAM_STR),
'password' => array($password, PDO::PARAM_STR), 'password' => array($password, PDO::PARAM_STR),
'sex' => array($sex, PDO::PARAM_STR),
'nationality' => array($nationality, PDO::PARAM_STR),
'currentBobCoins' => array($currentBobCoins, PDO::PARAM_INT), 'currentBobCoins' => array($currentBobCoins, PDO::PARAM_INT),
'totalBobCoins' => array($totalBobCoins, PDO::PARAM_INT), 'totalBobCoins' => array($totalBobCoins, PDO::PARAM_INT),
'nbGamesPlayed' => array($nbGamesPlayed, PDO::PARAM_INT), 'nbGamesPlayed' => array($nbGamesPlayed, PDO::PARAM_INT),

@ -1,59 +1,34 @@
<?php <?php
echo "hey you ";
/* header('Access-Control-Allow-Origin: *');
$conn = new mysqli("BOB_PARTEAM-mysql",getenv("MYSQL_USER"),getenv("MYSQL_PASSWORD"),getenv("MYSQL_DATABASE")); header('Access-Control-Allow-Methods: POST,GET,DELETE,PUT');
$conn->query("DROP TABLE IF EXISTS `common_absences`;");
$conn->query("CREATE TABLE coucou (`COUCOU_ID` int(10) unsigned NOT NULL,`COUCOU_TEXT` char(10) NOT NULL);");
$res = $conn->query("SELECT * FROM coucou");
while ($une_valeur = $res->fetch_array()) {
echo $une_valeur["COUCOU_ID"]." ".$une_valeur["COUCOU_TEXT"];
}
exit;
*/
require_once("initBdd.php");
//header('Access-Control-Allow-Origin: *');
//header('Access-Control-Allow-Methods: POST,GET,DELETE,PUT');
/// Good to know : /// Good to know :
/// All the values must be cleaned on the application side before using this API /// All the values must be cleaned on the application side before using this API
/// ///
include ('dbConnection.php'); include ('dbConnection.php');
include (__DIR__ .'/gateways/userGateway.php'); include ('gateways/userGateway.php');
include (__DIR__ .'/gateways/matchGateway.php'); include ('gateways/matchGateway.php');
include (__DIR__ .'/gateways/conversationGateway.php'); include ('gateways/conversationGataway.php');
include (__DIR__ .'/gateways/gameGateway.php'); include ('gateways/gameGateway.php');
include (__DIR__ .'/gateways/skinGateway.php'); include ('gateways/skinGateway.php');
// Connection to database // Connection to database
// ------ // ------
// Comment faire un fichier .htaccess pour protéger ce fichier ????????? // Comment faire un fichier .htaccess pour protéger ce fichier ?????????
// ------ // ------
//$ini_array= parse_ini_file("config.ini"); $ini_array= parse_ini_file("config.ini");
$dsn = "mysql:host=BOB_PARTEAM-mysql;dbname=" . getenv("MYSQL_DATABASE");
$username = getenv("MYSQL_USER");
$password = getenv("MYSQL_PASSWORD");
// Initializing Database // Initializing Database
try{ try{
$database = new DatabaseConnection($dsn,$username,$password); $database = new DatabaseConnection($ini_array['dsn'],$ini_array['username'],$ini_array['password']);
} catch (PDOException $e) { } catch (PDOException $e) {
echo "ERROR connection"; echo "ERROR connection";
echo $e->getMessage(); header("HTTP/1.0 ".$e->getMessage());
//echo $dsn;
//header("HTTP/1.0 ".$e->getMessage());
http_response_code(600); // Quel code pour les erreurs PDO? http_response_code(600); // Quel code pour les erreurs PDO?
} }
// Initializing Gateways // Initializing Gateways
// ------ // ------
// Passer en mode objet ou rester en mode comportemental mais assumé ??? // Passer en mode objet ou rester en mode comportemental mais assumé ???
@ -74,315 +49,289 @@
$url = rtrim($request_uri,"/"); $url = rtrim($request_uri,"/");
$url = filter_var($url, FILTER_SANITIZE_URL); $url = filter_var($url, FILTER_SANITIZE_URL);
$url = explode('/', $url); $url = explode('/', $url);
$method_name = !empty($url[3]) ? (string)$url[3] : null;
$i=0;
while ($url[$i]!=="index.php" && count($url)>0){
unset($url[$i]);
$i++;
}
if (empty($url)){
exit;
}
//echo json_encode($url);
$method_name = !empty($url[2]) ? (string)$url[2] : null;
if($method_name == null){ if($method_name == null){
//header("HTTP/1.0 400 Request Name Empty"); header("HTTP/1.0 400 Request Name Empty");
http_response_code(400); http_response_code(400);
} }
switch ($request_method){ switch ($request_method){
case 'GET': case 'GET':
if($method_name === "getUserById"){ // test : OK if($method_name === "getUserById"){ // test : OK
if(empty($url[3])){ if(empty($url[4])){
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} else{ } else{
$id = (int)$url[3]; $id = (int)$url[4];
$user = $usergw->getUserById($id); $user = $usergw->getUserById($id);
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($user, JSON_PRETTY_PRINT); echo json_encode($user, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} }
} }
elseif($method_name === "getUserByUsername"){ // test : OK elseif($method_name === "getUserByUsername"){ // test : OK
$username = !empty($url[3]) ? (string) $url[3] : null; $username = !empty($url[4]) ? (string) $url[4] : null;
if ($username !== null){ if ($username !== null){
$user =$usergw->getUserByUsername($username); $user =$usergw->getUserByUsername($username);
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($user, JSON_PRETTY_PRINT); echo json_encode($user, JSON_PRETTY_PRINT);
} else{ } else{
//header("HTTP/1.0 400 Username not given"); header("HTTP/1.0 400 Username not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "getUserForConnection"){ // test : OK elseif($method_name === "getUserForConnection"){ // test : OK
$username = !empty($url[3]) ? (string) $url[3] : null; $username = !empty($url[4]) ? (string) $url[4] : null;
$password = !empty($url[4]) ? (string) $url[4] : null; $password = !empty($url[5]) ? (string) $url[5] : null;
if ($username != null || $password != null){ if ($username != null || $password != null){
$user =$usergw->getUserForConnection($username,$password); $user =$usergw->getUserForConnection($username,$password);
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($user, JSON_PRETTY_PRINT); echo json_encode($user, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 Username or password not given"); header("HTTP/1.0 400 Username or password not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "getSkins"){ // test : OK elseif($method_name === "getSkins"){ // test : OK
$tabSkin = $skingw->getSkins(); $tabSkin = $skingw->getSkins();
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($tabSkin, JSON_PRETTY_PRINT); echo json_encode($tabSkin, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} }
elseif($method_name === "getGames"){ // test : OK elseif($method_name === "getGames"){ // test : OK
$tabGame = $gamegw->getGames(); $tabGame = $gamegw->getGames();
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($tabGame, JSON_PRETTY_PRINT); echo json_encode($tabGame, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} }
elseif($method_name === "getGameById"){ // test : OK elseif($method_name === "getGameById"){ // test : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
if ($id !== null){ if ($id !== null){
$game = $gamegw->getGameById($id); $game = $gamegw->getGameById($id);
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($game, JSON_PRETTY_PRINT); echo json_encode($game, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "getMatchById"){ // test : OK elseif($method_name === "getMatchById"){ // test : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
if ($id !== null){ if ($id !== null){
$match = $matchgw->getMatchById($id); $match = $matchgw->getMatchById($id);
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($match, JSON_PRETTY_PRINT); echo json_encode($match, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "getConversations"){ // tests : OK elseif($method_name === "getConversations"){ // tests : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
if ($id !== null){ if ($id !== null){
$conversations = $conversationgw->getConversations($id); $conversations = $conversationgw->getConversations($id);
//header('Content-Type: application/json'); header('Content-Type: application/json');
echo json_encode($conversations, JSON_PRETTY_PRINT); echo json_encode($conversations, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} }
} }
else{ else{
////header("HTTP/1.0 401 UNAUTHORIZED REQUEST"); header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401); http_response_code(401);
} }
break;
case 'POST': case 'POST':
if($method_name === "postUser"){ // test : OK if($method_name === "postUser"){ // test : OK
if (count($url)<7){ if (count($url)<8){
//header("HTTP/1.0 400 Invalid number of arguments"); header("HTTP/1.0 400 Invalid number of arguments");
http_response_code(400); http_response_code(400);
} }
$username = !empty($url[3]) ? (string) $url[3] : null; $username = !empty($url[4]) ? (string) $url[4] : null;
$password = !empty($url[4]) ? (string) $url[4] : null; $password = !empty($url[5]) ? (string) $url[5] : null;
$nationality = !empty($url[5]) ? (string) $url[5] : null; $nationality = !empty($url[5]) ? (string) $url[5] : null;
$sex = !empty($url[6]) ? (string) $url[6] : null; $sex = !empty($url[7]) ? (string) $url[7] : null;
$dateOfBirth = !empty($url[7]) ? (string) $url[7] : null; $dateOfBirth = !empty($url[8]) ? (string) $url[8] : null;
$usergw->postUser($username,$password,$nationality,$sex,$dateOfBirth); $usergw->postUser($username,$password,$nationality,$sex,$dateOfBirth);
http_response_code(200); http_response_code(200);
} }
elseif($method_name === "postMatch"){ // test : OK elseif($method_name === "postMatch"){ // test : OK
$idGame = !empty($url[3]) ? (int) $url[3] : null; $idGame = !empty($url[4]) ? (int) $url[4] : null;
$idCreator = !empty($url[4]) ? (int) $url[4] : null; $idCreator = !empty($url[5]) ? (int) $url[5] : null;
if ($idGame != null || $idCreator != null){ if ($idGame != null || $idCreator != null){
$match =$matchgw->postMatch($idGame,$idCreator); $match =$matchgw->postMatch($idGame,$idCreator);
echo json_encode($match, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 idGame or idCreator not given"); header("HTTP/1.0 400 idGame or idCreator not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "postConversation"){ // test : OK elseif($method_name === "postConversation"){ // test : OK
$name = !empty($url[3]) ? (string) $url[3] : null; $name = !empty($url[4]) ? (string) $url[4] : null;
$idList = !empty($url[4]) ? (array) explode(",",$url[4]) : null; $idCreator = !empty($url[5]) ? (int) $url[5] : null;
$name=urldecode($name); if ($name != null || $idCreator != null){
if ($name != null || $idList != null){ $conversationgw->postConversation($name,$idCreator);
$id=$conversationgw->postConversation($name,$idList);
echo json_encode($id, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 name or creator not given"); header("HTTP/1.0 400 name or creator not given");
http_response_code(400); http_response_code(400);
} }
} }
else{ else{
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST"); header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401); http_response_code(401);
} }
break; break;
case 'PUT': case 'PUT':
if($method_name === "putUser"){ // test : OK if($method_name === "putUser"){ // test : OK
if (count($url)<11){ if (count($url)<10){
//header("HTTP/1.0 400 Invalid number of arguments"); header("HTTP/1.0 400 Invalid number of arguments");
http_response_code(400); http_response_code(400);
} }
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
$username = !empty($url[4]) ? (string) $url[4] : null; $username = !empty($url[5]) ? (string) $url[5] : null;
$password = !empty($url[5]) ? (string) $url[5] : null; $password = !empty($url[6]) ? (string) $url[6] : null;
$sexe = !empty($url[6]) ? (string) $url[6] : null; $nbCurrentCoins = !empty($url[7]) ? (int) $url[7] : null;
$nationality = !empty($url[7]) ? (string) $url[7] : null; $totalnbCoins = !empty($url[8]) ? (int) $url[8] : null;
$nbCurrentCoins = (int) $url[8]; $nbGames = !empty($url[9]) ? (int) $url[9] : null;
$totalnbCoins = (int) $url[9]; $currentSkin = !empty($url[10]) ? (int) $url[10] : null;
$nbGames = (int) $url[10]; $usergw->putUser($id,$username,$password,$nbCurrentCoins,$totalnbCoins,$nbGames,$currentSkin);
$currentSkin = !empty($url[11]) ? (int) $url[11] : null;
$usergw->putUser($id,$username,$password,$sexe, $nationality, $nbCurrentCoins,$totalnbCoins,$nbGames,$currentSkin);
http_response_code(200); http_response_code(200);
} }
elseif($method_name === "putSkinList"){ // test : OK elseif($method_name === "putSkinList"){ // test : OK
$idUser = !empty($url[3]) ? (int) $url[3] : null; $idUser = !empty($url[4]) ? (int) $url[4] : null;
$idSkin = !empty($url[4]) ? (int) $url[4] : null; $idSkin = !empty($url[5]) ? (int) $url[5] : null;
if ($idUser != null || $idSkin != null){ if ($idUser != null || $idSkin != null){
$usergw->putSkinList($idUser,$idSkin); $usergw->putSkinList($idUser,$idSkin);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 idSkin or idUser not given"); header("HTTP/1.0 400 idSkin or idUser not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "putMatch"){ // test : OK elseif($method_name === "putMatch"){ // test : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
if ($id !== null){ if ($id !== null){
$matchgw->putMatch($id); $matchgw->putMatch($id);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "addUserToMatch"){ // test : OK elseif($method_name === "addUserToMatch"){ // test : OK
$idMatch = !empty($url[3]) ? (int) $url[3] : null; $idMatch = !empty($url[4]) ? (int) $url[4] : null;
$idUser = !empty($url[4]) ? (int) $url[4] : null; $idUser = !empty($url[5]) ? (int) $url[5] : null;
if ($idUser != null || $idMatch != null){ if ($idUser != null || $idMatch != null){
$matchgw->addUserToMatch($idMatch,$idUser); $matchgw->addUserToMatch($idMatch,$idUser);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 idSkin or idUser not given"); header("HTTP/1.0 400 idSkin or idUser not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "deleteUserFromMatch"){ // test : OK elseif($method_name === "deleteUserFromMatch"){ // test : OK
$idUser = !empty($url[3]) ? (int) $url[3] : null; $idUser = !empty($url[4]) ? (int) $url[4] : null;
if ($idUser != null){ if ($idUser != null){
$matchgw->deleteUserFromMatch($idUser); $matchgw->deleteUserFromMatch($idUser);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 idUser not given"); header("HTTP/1.0 400 idUser not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "putConversation"){ // test : OK elseif($method_name === "putConversation"){ // test : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
$newName = !empty($url[4]) ? (string) $url[4] : null; $newName = !empty($url[5]) ? (string) $url[5] : null;
$newName=urldecode($newName);
if ($id != null && $newName != null){ if ($id != null && $newName != null){
$conversationgw->putConversation($id,$newName); $conversationgw->putConversation($id,$newName);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 id or new name not given"); header("HTTP/1.0 400 id or new name not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "addUserToConversation"){ // test : OK elseif($method_name === "addUserToConversation"){ // test : OK
$idConv = !empty($url[3]) ? (int) $url[3] : null; $idConv = !empty($url[4]) ? (int) $url[4] : null;
$idUser = !empty($url[4]) ? (int) $url[4] : null; $idUser = !empty($url[5]) ? (int) $url[5] : null;
if ($idConv != null && $idUser != null){ if ($idConv != null && $idUser != null){
$conversationgw->addUserToConversation($idConv,$idUser); $conversationgw->addUserToConversation($idConv,$idUser);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 id conv or id user not given"); header("HTTP/1.0 400 id conv or id user not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "deleteUserFromConversation"){ // test : OK elseif($method_name === "deleteUserFromConversation"){ // test : OK
$idConv = !empty($url[3]) ? (int) $url[3] : null; $idConv = !empty($url[4]) ? (int) $url[4] : null;
$idUser = !empty($url[4]) ? (int) $url[4] : null; $idUser = !empty($url[5]) ? (int) $url[5] : null;
if ($idConv != null && $idUser != null){ if ($idConv != null && $idUser != null){
$conversationgw->deleteUserFromConversation($idConv,$idUser); $conversationgw->deleteUserFromConversation($idConv,$idUser);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 id conv or id user not given"); header("HTTP/1.0 400 id conv or id user not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "addMessageToConversation"){ // test : OK elseif($method_name === "addMessageToConversation"){ // test : OK
$msg=!empty($url[3]) ? (string) $url[3] : null; $msg=!empty($url[4]) ? (string) $url[4] : null;
$idSender=!empty($url[4]) ? (int) $url[4] : null; $idSender=!empty($url[5]) ? (int) $url[5] : null;
$idConv=!empty($url[5]) ? (int) $url[5] : null; $idConv=!empty($url[6]) ? (int) $url[6] : null;
$date=!empty($url[6]) ? (string) $url[6] : null; if ($msg != null && $idSender != null && $idConv != null){
$date=urldecode($date); $conversationgw->addMessageToConversation($msg,$idSender,$idConv);
$msg=urldecode($msg);
if ($msg != null && $idSender != null && $idConv != null && $date!=null){
$id=$conversationgw->addMessageToConversation($msg,$idSender,$idConv, $date);
echo json_encode($id, JSON_PRETTY_PRINT);
http_response_code(200); http_response_code(200);
} else{ } else{
//header("HTTP/1.0 400 id conv or message or sender not given"); header("HTTP/1.0 400 id conv or message or sender not given");
http_response_code(400); http_response_code(400);
} }
} }
else{ else{
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST"); header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401); http_response_code(401);
} }
break; break;
case 'DELETE': case 'DELETE':
if($method_name === "deleteUser"){ // test : OK if($method_name === "deleteUser"){ // test : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
if($id!=null){ if($id!=null){
$usergw->deleteUser($id); $usergw->deleteUser($id);
http_response_code(200); http_response_code(200);
}else{ }else{
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name == "deleteMatch"){ // test : OK elseif($method_name == "deleteMatch"){ // test : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
if($id!=null){ if($id!=null){
$matchgw->deleteMatch($id); $matchgw->deleteMatch($id);
http_response_code(200); http_response_code(200);
}else{ }else{
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} }
} }
elseif($method_name === "deleteConversation"){ // test : OK elseif($method_name === "deleteConversation"){ // test : OK
$id = !empty($url[3]) ? (int) $url[3] : null; $id = !empty($url[4]) ? (int) $url[4] : null;
if($id!=null){ if($id!=null){
$conversationgw->deleteConversation($id); $conversationgw->deleteConversation($id);
http_response_code(200); http_response_code(200);
}else{ }else{
//header("HTTP/1.0 400 Id not given"); header("HTTP/1.0 400 Id not given");
http_response_code(400); http_response_code(400);
} }
} }
else{ else{
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST"); header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
http_response_code(401); http_response_code(401);
} }
break; break;
default : default :
//header("HTTP/1.0 405 Invalid request method"); header("HTTP/1.0 405 Invalid request method");
http_response_code(405); http_response_code(405);
break; break;
} }

@ -1,202 +0,0 @@
<?php
$conn = new mysqli("BOB_PARTEAM-mysql",getenv("MYSQL_USER"),getenv("MYSQL_PASSWORD"),getenv("MYSQL_DATABASE"));
$conn->query("CREATE TABLE `T_J_OWN_SKIN_OWN` (
`FK_USER` int(11) NOT NULL,
`FK_SKIN` int(11) NOT NULL
); ");
$conn->query("CREATE TABLE `T_E_GAME_GAM` (
`PK_ID` int(11) NOT NULL,
`GAM_NAME` varchar(50) DEFAULT NULL,
`GAM_IMAGE` varchar(200) DEFAULT NULL,
`GAM_NB_PLAYER_MIN` int(11) DEFAULT NULL,
`GAM_NB_PLAYER_MAX` int(11) DEFAULT NULL,
`GAM_TYPE` varchar(50) NOT NULL
);");
$conn->query("CREATE TABLE `T_E_MATCH_MTC` (
`PK_ID` int(11) NOT NULL,
`MTC_IN_GAME` tinyint(1) DEFAULT NULL,
`FK_GAME` int(11) DEFAULT NULL
);");
$conn->query("CREATE TABLE `T_H_CONVERSATION_COV` (
`PK_ID` int(11) NOT NULL,
`COV_NAME` varchar(20) DEFAULT NULL
) ;");
$conn->query("CREATE TABLE `T_H_MESSAGE_MSG` (
`PK_ID` int(11) NOT NULL,
`MSG_MESSAGE` text,
`FK_SENDER` int(11) DEFAULT NULL,
`MSG_DATEENVOIE` datetime NOT NULL
);");
$conn->query("CREATE TABLE `T_H_SKIN_SKI` (
`PK_ID` int(11) NOT NULL,
`SKI_NAME` varchar(50) NOT NULL,
`SKI_IMAGE` varchar(200) NOT NULL,
`SKI_PRICE` varchar(30) DEFAULT NULL
);");
$conn->query("CREATE TABLE `T_J_CONTAIN_MESSAGE_CMG` (
`FK_CONVERSATION` int(11) NOT NULL,
`FK_MESSAGE` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_J_DISCUSS_DIS` (
`FK_USER` int(11) NOT NULL,
`FK_CONVERSATION` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_J_GAME_MAP_GMP` (
`FK_GAME` int(11) NOT NULL,
`GMP_KEY` int(11) NOT NULL,
`GMP_VALUE` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_J_PLAY_MATCH_PLM` (
`FK_USER` int(11) NOT NULL,
`FK_MATCH` int(11) NOT NULL
);");
$conn->query("CREATE TABLE `T_S_USER_USR` (
`PK_ID` int(11) NOT NULL,
`USR_USERNAME` varchar(50) NOT NULL,
`USR_PASSWORD` varchar(200) NOT NULL,
`USR_NATIONALITY` varchar(20) NOT NULL,
`USR_SEX` varchar(30) NOT NULL,
`USR_DATE_OF_BIRTH` date DEFAULT NULL,
`USR_CURRENT_NB_COINS` int(11) DEFAULT '0',
`USR_TOTAL_NB_COINS` int(11) DEFAULT '0',
`USR_NB_GAMES_PLAYED` int(11) DEFAULT '0',
`FK_CURRENT_SKIN` int(11) DEFAULT '1'
);");
$conn->query("ALTER TABLE `T_E_GAME_GAM`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`);");
$conn->query("ALTER TABLE `T_E_MATCH_MTC`
ADD PRIMARY KEY (`PK_ID`),
ADD KEY `FK_GAME` (`FK_GAME`);");
$conn->query("ALTER TABLE `T_H_CONVERSATION_COV`
ADD PRIMARY KEY (`PK_ID`);");
$conn->query("ALTER TABLE `T_H_MESSAGE_MSG`
ADD PRIMARY KEY (`PK_ID`),
ADD KEY `FK_SENDER` (`FK_SENDER`);");
$conn->query("ALTER TABLE `T_H_SKIN_SKI`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `SKI_NAME` (`SKI_NAME`),
ADD UNIQUE KEY `SKI_IMAGE` (`SKI_IMAGE`);");
$conn->query("ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
ADD PRIMARY KEY (`FK_CONVERSATION`,`FK_MESSAGE`),
ADD KEY `FK_MESSAGE` (`FK_MESSAGE`);");
$conn->query("ALTER TABLE `T_J_DISCUSS_DIS`
ADD PRIMARY KEY (`FK_USER`,`FK_CONVERSATION`),
ADD KEY `FK_CONVERSATION` (`FK_CONVERSATION`);");
$conn->query("ALTER TABLE `T_J_GAME_MAP_GMP`
ADD PRIMARY KEY (`FK_GAME`,`GMP_KEY`,`GMP_VALUE`);");
$conn->query("ALTER TABLE `T_J_OWN_SKIN_OWN`
ADD PRIMARY KEY (`FK_SKIN`,`FK_USER`),
ADD KEY `FK_USER` (`FK_USER`);");
$conn->query("ALTER TABLE `T_J_PLAY_MATCH_PLM`
ADD PRIMARY KEY (`FK_USER`,`FK_MATCH`),
ADD KEY `FK_MATCH` (`FK_MATCH`);");
$conn->query("ALTER TABLE `T_S_USER_USR`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `USR_USERNAME` (`USR_USERNAME`),
ADD KEY `FK_CURRENT_SKIN` (`FK_CURRENT_SKIN`);");
$conn->query("ALTER TABLE `T_E_GAME_GAM`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_E_MATCH_MTC`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_H_CONVERSATION_COV`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_H_MESSAGE_MSG`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_H_SKIN_SKI`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_S_USER_USR`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;");
$conn->query("ALTER TABLE `T_E_MATCH_MTC`
ADD CONSTRAINT `t_e_match_mtc_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);");
$conn->query("ALTER TABLE `T_H_MESSAGE_MSG`
ADD CONSTRAINT `t_h_message_msg_ibfk_1` FOREIGN KEY (`FK_SENDER`) REFERENCES `T_S_USER_USR` (`PK_ID`);");
$conn->query("ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_1` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_2` FOREIGN KEY (`FK_MESSAGE`) REFERENCES `T_H_MESSAGE_MSG` (`PK_ID`) ON DELETE CASCADE;");
$conn->query("ALTER TABLE `T_J_DISCUSS_DIS`
ADD CONSTRAINT `t_j_discuss_dis_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_discuss_dis_ibfk_2` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE;");
$conn->query("ALTER TABLE `T_J_GAME_MAP_GMP`
ADD CONSTRAINT `t_j_game_map_gmp_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);");
$conn->query("ALTER TABLE `T_J_OWN_SKIN_OWN`
ADD CONSTRAINT `t_j_own_skin_own_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_own_skin_own_ibfk_2` FOREIGN KEY (`FK_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);");
$conn->query("ALTER TABLE `T_J_PLAY_MATCH_PLM`
ADD CONSTRAINT `t_j_play_match_plm_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_play_match_plm_ibfk_2` FOREIGN KEY (`FK_MATCH`) REFERENCES `T_E_MATCH_MTC` (`PK_ID`) ON DELETE CASCADE;");
$conn->query("ALTER TABLE `T_S_USER_USR`
ADD CONSTRAINT `t_s_user_usr_ibfk_1` FOREIGN KEY (`FK_CURRENT_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);");
$conn->query("INSERT INTO `T_J_GAME_MAP_GMP` (`FK_GAME`, `GMP_KEY`, `GMP_VALUE`) VALUES
(1, 0, 0),
(1, 1000, 25),
(1, 10000, 30),
(1, 100000, 40),
(1, 1000000, 50),
(1, 10000000, 75),
(2, 0, 5),
(3, 0, 0),
(3, 1, 25),
(3, 2, 50);");
$conn->query("INSERT INTO `T_H_SKIN_SKI` (`PK_ID`, `SKI_NAME`, `SKI_IMAGE`, `SKI_PRICE`) VALUES
(1, 'Bob', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png', '0'),
(2, 'Bob blue', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBlue.png', '100'),
(3, 'Bob green', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobGreen.png', '100'),
(4, 'Bob BW', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBW.png', '100');");
$conn->query("INSERT INTO `T_E_GAME_GAM` (`PK_ID`, `GAM_NAME`, `GAM_IMAGE`, `GAM_NB_PLAYER_MIN`, `GAM_NB_PLAYER_MAX`, `GAM_TYPE`) VALUES
(1, 'Cookie Clicker', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/CookieClicker.png', 1, 1, 'GameSolo'),
(2, 'TicTacToe', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 1, 1, 'GameSolo'),
(3, 'TicTacToe Online', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 2, 2, 'GameMulti'),
(4, 'BlackJack', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/peristanceBDD/bob_party/assets/ImagesJeux/blackjack.jpg', 1, 1, 'GameCasino');");
?>

@ -5,13 +5,13 @@ class Conversation{
// Object attributes // Object attributes
public string $id; public string $id;
public string $name; public string $name;
public $tabMessages; public $listMessages;
public $listIdUsers; public $listIdUsers;
public function __construct($_id,$_name,$_tabMessages,$_listIdUsers){ public function __construct($_id,$_name,$_listMessages,$_listIdUsers){
$this->id=$_id; $this->id=$_id;
$this->name=$_name; $this->name=$_name;
$this->tabMessages=$_tabMessages; $this->listMessages=$_listMessages;
$this->listIdUsers=$_listIdUsers; $this->listIdUsers=$_listIdUsers;
} }
} }

@ -4,21 +4,12 @@ class Game{
public int $id; public int $id;
public string $name; public string $name;
public string $image; public string $image;
public string $type;
public int $nbPlayerMin;
public int $nbPlayerMax;
public array $keys;
public array $values;
public function __construct(int $_id, string $_name, string $_image, string $_type, $_nbPlayerMin, $_nbPlayerMax, array $_keys, array $_values){
public function __construct(int $_id, string $_name, string $_image){
$this->id=$_id; $this->id=$_id;
$this->name=$_name; $this->name=$_name;
$this->image=$_image; $this->image=$_image;
$this->type=$_type;
$this->nbPlayerMin=$_nbPlayerMin;
$this->nbPlayerMax=$_nbPlayerMax;
$this->keys=$_keys;
$this->values=$_values;
} }
} }

@ -3,16 +3,14 @@
class Message { class Message {
// Object attributes // Object attributes
public string $id; public String $id;
public string $content; public String $message;
public string $idSender; public String $idSender;
public string $dateEnvoie;
public function __construct(string $_id, string $_content, string $_idSender, string $_dateEnvoie){ public function __construct(String $_id, String $_message, String $_idSender){
$this->id=$_id; $this->id=$_id;
$this->content=$_content; $this->message=$_message;
$this->idSender=$_idSender; $this->idSender=$_idSender;
$this->dateEnvoie=$_dateEnvoie;
} }
} }

@ -4,14 +4,14 @@ class Skin{
public int $id; public int $id;
public string $name; public string $name;
public string $source; public string $image;
public int $cost; public int $price;
public function __construct(int $_id, string $_name, string $_source, int $_cost){ public function __construct(int $_id, string $_name, string $_image, int $_price){
$this->id=$_id; $this->id=$_id;
$this->name=$_name; $this->name=$_name;
$this->source=$_source; $this->image=$_image;
$this->cost=$_cost; $this->price=$_price;
} }
} }

@ -7,26 +7,26 @@ class User {
public string $username; public string $username;
public string $password; public string $password;
public string $nationality; public string $nationality;
public string $sexe; public string $sex;
public string $dateOfBirth; public string $dateOfBirth;
public int $currentCoins; public int $currentBobCoins;
public int $totalCoins; public int $totalBobCoins;
public int $nbGamesPlayed; public int $nbGamesPlayed;
public Skin $currentSkin; public int $currentSkin;
public ?array $tabSkin; public ?array $listSkin;
public function __construct(int $_id,string $_username,string $_password, string $_nationality,string $_sexe, string $_dateOfBirth, int $_currentCoins, int $_totalCoins, int $_nbGamesPlayed, Skin $_currentSkin,?array $_tabSkin){ public function __construct(int $_id,string $_username,string $_password, string $_nationality,string $_sex, string $_dateOfBirth, int $_currentBobCoins, int $_totalBobCoins, int $_nbGamesPlayed, int $_currentSkin,?array $_listSkin){
$this->id=$_id; $this->id=$_id;
$this->username=$_username; $this->username=$_username;
$this->password=$_password; $this->password=$_password;
$this->nationality=$_nationality; $this->nationality=$_nationality;
$this->sexe=$_sexe; $this->sex=$_sex;
$this->dateOfBirth=$_dateOfBirth; $this->dateOfBirth=$_dateOfBirth;
$this->currentCoins=$_currentCoins; $this->currentBobCoins=$_currentBobCoins;
$this->totalCoins=$_totalCoins; $this->totalBobCoins=$_totalBobCoins;
$this->nbGamesPlayed=$_nbGamesPlayed; $this->nbGamesPlayed=$_nbGamesPlayed;
$this->currentSkin=$_currentSkin; $this->currentSkin=$_currentSkin;
$this->tabSkin=$_tabSkin; $this->listSkin=$_listSkin;
} }
} }

@ -1,4 +0,0 @@
#!/usr/bin/env bash
sed -i "s/Listen 80/Listen ${PORT:-80}/g" /etc/apache2/ports.conf
sed -i "s/:80/:${PORT:-80}/g" /etc/apache2/sites-enabled/*
apache2-foreground

@ -1,564 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 5.1.1
-- https://www.phpmyadmin.net/
--
-- Hôte : localhost:8889
-- Généré le : mar. 10 jan. 2023 à 09:00
-- Version du serveur : 5.7.34
-- Version de PHP : 7.4.21
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Base de données : `bobParty`
--
-- --------------------------------------------------------
--
-- Structure de la table `T_E_GAME_GAM`
--
CREATE TABLE `T_E_GAME_GAM` (
`PK_ID` int(11) NOT NULL,
`GAM_NAME` varchar(50) DEFAULT NULL,
`GAM_IMAGE` varchar(200) DEFAULT NULL,
`GAM_NB_PLAYER_MIN` int(11) DEFAULT NULL,
`GAM_NB_PLAYER_MAX` int(11) DEFAULT NULL,
`GAM_TYPE` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_E_GAME_GAM`
--
INSERT INTO `T_E_GAME_GAM` (`PK_ID`, `GAM_NAME`, `GAM_IMAGE`, `GAM_NB_PLAYER_MIN`, `GAM_NB_PLAYER_MAX`, `GAM_TYPE`) VALUES
(1, 'Cookie Clicker', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/CookieClicker.png', 1, 1, 'GameSolo'),
(2, 'TicTacToe', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 1, 1, 'GameSolo'),
(3, 'TicTacToe Online', 'https://is3-ssl.mzstatic.com/image/thumb/Purple123/v4/f2/06/ef/f206ef53-7206-ffae-af6b-52460ba5636f/source/256x256bb.jpg', 2, 2, 'GameMulti'),
(4, 'BlackJack', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/peristanceBDD/bob_party/assets/ImagesJeux/blackjack.jpg', 1, 1, 'GameCasino');
-- --------------------------------------------------------
--
-- Structure de la table `T_E_MATCH_MTC`
--
CREATE TABLE `T_E_MATCH_MTC` (
`PK_ID` int(11) NOT NULL,
`MTC_IN_GAME` tinyint(1) DEFAULT NULL,
`FK_GAME` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_E_MATCH_MTC`
--
INSERT INTO `T_E_MATCH_MTC` (`PK_ID`, `MTC_IN_GAME`, `FK_GAME`) VALUES
(12, 0, 3),
(13, 0, 4),
(16, 0, 3);
-- --------------------------------------------------------
--
-- Structure de la table `T_H_CONVERSATION_COV`
--
CREATE TABLE `T_H_CONVERSATION_COV` (
`PK_ID` int(11) NOT NULL,
`COV_NAME` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_H_CONVERSATION_COV`
--
INSERT INTO `T_H_CONVERSATION_COV` (`PK_ID`, `COV_NAME`) VALUES
(32, 'Wesh la conv'),
(33, 'bonjour'),
(34, 'bony'),
(35, 'la conversation'),
(36, 'fratitude'),
(37, 'coucouuuuuuuuu'),
(38, 'coucou les copains'),
(39, 'ccc'),
(40, 'wesh ca marche'),
(41, 'salut'),
(48, 'saluuuuut'),
(49, 'to'),
(50, 'wesh');
--
-- Déclencheurs `T_H_CONVERSATION_COV`
--
DELIMITER $$
CREATE TRIGGER `before_delete_conversation` BEFORE DELETE ON `T_H_CONVERSATION_COV` FOR EACH ROW DELETE FROM T_H_MESSAGE_MSG WHERE PK_ID = (SELECT FK_MESSAGE
FROM T_J_CONTAIN_MESSAGE_CMG
WHERE FK_CONVERSATION=OLD.PK_ID)
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Structure de la table `T_H_MESSAGE_MSG`
--
CREATE TABLE `T_H_MESSAGE_MSG` (
`PK_ID` int(11) NOT NULL,
`MSG_MESSAGE` text,
`FK_SENDER` int(11) DEFAULT NULL,
`MSG_DATEENVOIE` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_H_MESSAGE_MSG`
--
INSERT INTO `T_H_MESSAGE_MSG` (`PK_ID`, `MSG_MESSAGE`, `FK_SENDER`, `MSG_DATEENVOIE`) VALUES
(21, 'tom a créé une conversation', 1, '2022-12-29 00:00:00'),
(25, 'Salut test', 1, '2022-12-30 09:39:15'),
(57, 'Salut by', 1, '2022-12-30 11:01:17'),
(58, 'Wesh', 1, '2022-12-30 11:12:04'),
(59, 'Salut', 1, '2022-12-30 11:15:44'),
(60, 'Bonjour', 1, '2022-12-30 11:15:52'),
(61, 'Wesh', 1, '2022-12-30 11:16:25'),
(62, 'Bite', 1, '2022-12-30 11:17:38'),
(63, 'Cc', 2, '2022-12-30 11:21:04'),
(64, 'Cc', 2, '2022-12-30 11:21:06'),
(65, 'Bonjour', 2, '2022-12-30 11:24:58'),
(66, 'Hé ho', 2, '2022-12-30 11:25:02'),
(68, 'Salut ça va marcher', 1, '2022-12-30 11:55:21'),
(69, 'Bonjour', 1, '2023-01-04 14:24:12'),
(70, 'to created a conversation', 1, '2023-01-04 22:39:07'),
(71, 'Salut !!!', 2, '2023-01-04 22:42:01'),
(72, 'leilla20 created a conversation', 2, '2023-01-04 22:42:16'),
(73, 'to created a conversation', 1, '2023-01-04 22:44:07'),
(74, 'Salut les bags', 1, '2023-01-04 22:44:16'),
(75, 'to created a conversation', 1, '2023-01-05 08:15:50'),
(76, 'Wesh les fratés', 2, '2023-01-05 08:16:18'),
(77, 'to created a conversation', 1, '2023-01-05 08:25:54'),
(78, 'to created a conversation', 1, '2023-01-05 08:38:21'),
(79, 'to created a conversation', 1, '2023-01-05 09:40:42'),
(86, 'to created a conversation', 1, '2023-01-05 16:53:48'),
(87, 'to created a conversation', 1, '2023-01-05 17:12:14'),
(88, 'to created a conversation', 1, '2023-01-05 17:13:07');
-- --------------------------------------------------------
--
-- Structure de la table `T_H_SKIN_SKI`
--
CREATE TABLE `T_H_SKIN_SKI` (
`PK_ID` int(11) NOT NULL,
`SKI_NAME` varchar(50) NOT NULL,
`SKI_IMAGE` varchar(200) NOT NULL,
`SKI_PRICE` varchar(30) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_H_SKIN_SKI`
--
INSERT INTO `T_H_SKIN_SKI` (`PK_ID`, `SKI_NAME`, `SKI_IMAGE`, `SKI_PRICE`) VALUES
(1, 'Bob', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png', '0'),
(2, 'Bob blue', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBlue.png', '100'),
(3, 'Bob green', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobGreen.png', '100'),
(4, 'Bob BW', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobBW.png', '100');
-- --------------------------------------------------------
--
-- Structure de la table `T_J_CONTAIN_MESSAGE_CMG`
--
CREATE TABLE `T_J_CONTAIN_MESSAGE_CMG` (
`FK_CONVERSATION` int(11) NOT NULL,
`FK_MESSAGE` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_J_CONTAIN_MESSAGE_CMG`
--
INSERT INTO `T_J_CONTAIN_MESSAGE_CMG` (`FK_CONVERSATION`, `FK_MESSAGE`) VALUES
(32, 21),
(32, 25),
(32, 57),
(32, 58),
(32, 59),
(32, 60),
(32, 61),
(32, 62),
(32, 63),
(32, 64),
(32, 65),
(40, 65),
(32, 66),
(32, 68),
(32, 69),
(33, 70),
(33, 71),
(34, 72),
(35, 73),
(35, 74),
(36, 75),
(36, 76),
(37, 77),
(39, 78),
(41, 79),
(48, 86),
(49, 87),
(50, 88);
-- --------------------------------------------------------
--
-- Structure de la table `T_J_DISCUSS_DIS`
--
CREATE TABLE `T_J_DISCUSS_DIS` (
`FK_USER` int(11) NOT NULL,
`FK_CONVERSATION` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_J_DISCUSS_DIS`
--
INSERT INTO `T_J_DISCUSS_DIS` (`FK_USER`, `FK_CONVERSATION`) VALUES
(1, 32),
(2, 32),
(3, 32),
(2, 33),
(3, 33),
(1, 34),
(2, 34),
(3, 34),
(2, 35),
(3, 35),
(2, 36),
(7, 36),
(2, 37),
(6, 37),
(2, 41),
(3, 41),
(2, 48),
(3, 48),
(1, 49),
(2, 49),
(1, 50),
(2, 50);
-- --------------------------------------------------------
--
-- Structure de la table `T_J_GAME_MAP_GMP`
--
CREATE TABLE `T_J_GAME_MAP_GMP` (
`FK_GAME` int(11) NOT NULL,
`GMP_KEY` int(11) NOT NULL,
`GMP_VALUE` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_J_GAME_MAP_GMP`
--
INSERT INTO `T_J_GAME_MAP_GMP` (`FK_GAME`, `GMP_KEY`, `GMP_VALUE`) VALUES
(1, 0, 0),
(1, 100, 25),
(1, 1000, 30),
(1, 10000, 40),
(1, 100000, 50),
(1, 1000000, 75),
(2, 0, 5),
(3, 0, 0),
(3, 1, 25),
(3, 2, 50);
-- --------------------------------------------------------
--
-- Structure de la table `T_J_OWN_SKIN_OWN`
--
CREATE TABLE `T_J_OWN_SKIN_OWN` (
`FK_USER` int(11) NOT NULL,
`FK_SKIN` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_J_OWN_SKIN_OWN`
--
INSERT INTO `T_J_OWN_SKIN_OWN` (`FK_USER`, `FK_SKIN`) VALUES
(1, 1),
(1, 2),
(1, 3),
(1, 4),
(2, 1),
(2, 2),
(3, 1),
(6, 1),
(7, 1),
(8, 1),
(10, 1),
(11, 1),
(12, 1);
-- --------------------------------------------------------
--
-- Structure de la table `T_J_PLAY_MATCH_PLM`
--
CREATE TABLE `T_J_PLAY_MATCH_PLM` (
`FK_USER` int(11) NOT NULL,
`FK_MATCH` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_J_PLAY_MATCH_PLM`
--
INSERT INTO `T_J_PLAY_MATCH_PLM` (`FK_USER`, `FK_MATCH`) VALUES
(1, 12),
(7, 12),
(1, 13),
(1, 16);
-- --------------------------------------------------------
--
-- Structure de la table `T_S_USER_USR`
--
CREATE TABLE `T_S_USER_USR` (
`PK_ID` int(11) NOT NULL,
`USR_USERNAME` varchar(50) NOT NULL,
`USR_PASSWORD` varchar(50) NOT NULL,
`USR_NATIONALITY` varchar(20) NOT NULL,
`USR_SEX` varchar(30) NOT NULL,
`USR_DATE_OF_BIRTH` date DEFAULT NULL,
`USR_CURRENT_NB_COINS` int(11) DEFAULT '0',
`USR_TOTAL_NB_COINS` int(11) DEFAULT '0',
`USR_NB_GAMES_PLAYED` int(11) DEFAULT '0',
`FK_CURRENT_SKIN` int(11) DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Déchargement des données de la table `T_S_USER_USR`
--
INSERT INTO `T_S_USER_USR` (`PK_ID`, `USR_USERNAME`, `USR_PASSWORD`, `USR_NATIONALITY`, `USR_SEX`, `USR_DATE_OF_BIRTH`, `USR_CURRENT_NB_COINS`, `USR_TOTAL_NB_COINS`, `USR_NB_GAMES_PLAYED`, `FK_CURRENT_SKIN`) VALUES
(1, 'to', 't', 'Anglais(e)', 'M', '2003-07-01', 135, 260, 12, 2),
(2, 'leilla20', 't', 'Anglais(e)', 'M', '2003-11-22', 100, 225, 12, 2),
(3, 'test', 't', 'Français(e)', 'H', '1999-12-27', 0, 0, 0, 1),
(6, 'LEBg', 'belleBite63*', 'Espagnol(e)', 'Autre', '2001-12-27', 0, 0, 0, 1),
(7, 'DYLAN', 'argGR65**', 'Anglais(e)', 'Autre', '2002-12-27', 0, 0, 0, 1),
(8, 'Marche', 'je45tE**', 'Anglais(e)', 'Femme', '1999-12-27', 0, 0, 0, 1),
(10, 'dsqdz', 'AEZQzze1*', 'Francais(e)', 'null', '2005-12-27', 0, 0, 0, 1),
(11, 'qdsqdz', 'dqzA12****', 'Francais(e)', 'Homme', '2002-12-27', 0, 0, 0, 1),
(12, 'thilde', 'coucoulesnazes*M0', 'Francais(e)', 'Femme', '2004-11-02', 0, 0, 0, 1);
--
-- Déclencheurs `T_S_USER_USR`
--
DELIMITER $$
CREATE TRIGGER `after_insert_user` AFTER INSERT ON `T_S_USER_USR` FOR EACH ROW INSERT INTO T_J_OWN_SKIN_OWN VALUES(NEW.PK_ID,1)
$$
DELIMITER ;
--
-- Index pour les tables déchargées
--
--
-- Index pour la table `T_E_GAME_GAM`
--
ALTER TABLE `T_E_GAME_GAM`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`) USING BTREE;
--
-- Index pour la table `T_E_MATCH_MTC`
--
ALTER TABLE `T_E_MATCH_MTC`
ADD PRIMARY KEY (`PK_ID`),
ADD KEY `FK_GAME` (`FK_GAME`);
--
-- Index pour la table `T_H_CONVERSATION_COV`
--
ALTER TABLE `T_H_CONVERSATION_COV`
ADD PRIMARY KEY (`PK_ID`);
--
-- Index pour la table `T_H_MESSAGE_MSG`
--
ALTER TABLE `T_H_MESSAGE_MSG`
ADD PRIMARY KEY (`PK_ID`),
ADD KEY `FK_SENDER` (`FK_SENDER`);
--
-- Index pour la table `T_H_SKIN_SKI`
--
ALTER TABLE `T_H_SKIN_SKI`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `SKI_NAME` (`SKI_NAME`),
ADD UNIQUE KEY `SKI_IMAGE` (`SKI_IMAGE`);
--
-- Index pour la table `T_J_CONTAIN_MESSAGE_CMG`
--
ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
ADD PRIMARY KEY (`FK_CONVERSATION`,`FK_MESSAGE`),
ADD KEY `FK_MESSAGE` (`FK_MESSAGE`);
--
-- Index pour la table `T_J_DISCUSS_DIS`
--
ALTER TABLE `T_J_DISCUSS_DIS`
ADD PRIMARY KEY (`FK_USER`,`FK_CONVERSATION`),
ADD KEY `FK_CONVERSATION` (`FK_CONVERSATION`);
--
-- Index pour la table `T_J_GAME_MAP_GMP`
--
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD PRIMARY KEY (`FK_GAME`,`GMP_KEY`,`GMP_VALUE`) USING BTREE;
--
-- Index pour la table `T_J_OWN_SKIN_OWN`
--
ALTER TABLE `T_J_OWN_SKIN_OWN`
ADD PRIMARY KEY (`FK_SKIN`,`FK_USER`),
ADD KEY `FK_USER` (`FK_USER`);
--
-- Index pour la table `T_J_PLAY_MATCH_PLM`
--
ALTER TABLE `T_J_PLAY_MATCH_PLM`
ADD PRIMARY KEY (`FK_USER`,`FK_MATCH`),
ADD KEY `FK_MATCH` (`FK_MATCH`);
--
-- Index pour la table `T_S_USER_USR`
--
ALTER TABLE `T_S_USER_USR`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `USR_USERNAME` (`USR_USERNAME`),
ADD KEY `FK_CURRENT_SKIN` (`FK_CURRENT_SKIN`);
--
-- AUTO_INCREMENT pour les tables déchargées
--
--
-- AUTO_INCREMENT pour la table `T_E_GAME_GAM`
--
ALTER TABLE `T_E_GAME_GAM`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT pour la table `T_E_MATCH_MTC`
--
ALTER TABLE `T_E_MATCH_MTC`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;
--
-- AUTO_INCREMENT pour la table `T_H_CONVERSATION_COV`
--
ALTER TABLE `T_H_CONVERSATION_COV`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51;
--
-- AUTO_INCREMENT pour la table `T_H_MESSAGE_MSG`
--
ALTER TABLE `T_H_MESSAGE_MSG`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=89;
--
-- AUTO_INCREMENT pour la table `T_H_SKIN_SKI`
--
ALTER TABLE `T_H_SKIN_SKI`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT pour la table `T_S_USER_USR`
--
ALTER TABLE `T_S_USER_USR`
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
--
-- Contraintes pour les tables déchargées
--
--
-- Contraintes pour la table `T_E_MATCH_MTC`
--
ALTER TABLE `T_E_MATCH_MTC`
ADD CONSTRAINT `t_e_match_mtc_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);
--
-- Contraintes pour la table `T_H_MESSAGE_MSG`
--
ALTER TABLE `T_H_MESSAGE_MSG`
ADD CONSTRAINT `t_h_message_msg_ibfk_1` FOREIGN KEY (`FK_SENDER`) REFERENCES `T_S_USER_USR` (`PK_ID`);
--
-- Contraintes pour la table `T_J_CONTAIN_MESSAGE_CMG`
--
ALTER TABLE `T_J_CONTAIN_MESSAGE_CMG`
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_1` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_contain_message_cmg_ibfk_2` FOREIGN KEY (`FK_MESSAGE`) REFERENCES `T_H_MESSAGE_MSG` (`PK_ID`) ON DELETE CASCADE;
--
-- Contraintes pour la table `T_J_DISCUSS_DIS`
--
ALTER TABLE `T_J_DISCUSS_DIS`
ADD CONSTRAINT `t_j_discuss_dis_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_discuss_dis_ibfk_2` FOREIGN KEY (`FK_CONVERSATION`) REFERENCES `T_H_CONVERSATION_COV` (`PK_ID`) ON DELETE CASCADE;
--
-- Contraintes pour la table `T_J_GAME_MAP_GMP`
--
ALTER TABLE `T_J_GAME_MAP_GMP`
ADD CONSTRAINT `t_j_game_map_gmp_ibfk_1` FOREIGN KEY (`FK_GAME`) REFERENCES `T_E_GAME_GAM` (`PK_ID`);
--
-- Contraintes pour la table `T_J_OWN_SKIN_OWN`
--
ALTER TABLE `T_J_OWN_SKIN_OWN`
ADD CONSTRAINT `t_j_own_skin_own_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_own_skin_own_ibfk_2` FOREIGN KEY (`FK_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);
--
-- Contraintes pour la table `T_J_PLAY_MATCH_PLM`
--
ALTER TABLE `T_J_PLAY_MATCH_PLM`
ADD CONSTRAINT `t_j_play_match_plm_ibfk_1` FOREIGN KEY (`FK_USER`) REFERENCES `T_S_USER_USR` (`PK_ID`) ON DELETE CASCADE,
ADD CONSTRAINT `t_j_play_match_plm_ibfk_2` FOREIGN KEY (`FK_MATCH`) REFERENCES `T_E_MATCH_MTC` (`PK_ID`) ON DELETE CASCADE;
--
-- Contraintes pour la table `T_S_USER_USR`
--
ALTER TABLE `T_S_USER_USR`
ADD CONSTRAINT `t_s_user_usr_ibfk_1` FOREIGN KEY (`FK_CURRENT_SKIN`) REFERENCES `T_H_SKIN_SKI` (`PK_ID`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

@ -1,34 +1,6 @@
import React from 'react'
import MainTabNavigator from './src/navigation/AppNavigator' import MainTabNavigator from './src/navigation/AppNavigator'
import store from './src/redux/store'
import { Provider } from 'react-redux'
import React, { useCallback } from 'react';
import { useFonts } from 'expo-font';
import TicTacToeOnline from './src/Games/Tic-Tac-Toe/tic_tac_toe_online';
import BlackJack from './src/Games/BlackJack/blackJack';
// RN >= 0.63
import { LogBox } from 'react-native';
export default function App() { export default function App() {
return <MainTabNavigator/>
const [fontsLoaded] = useFonts({
'Helvetica': require('./assets/fonts/Helvetica.ttf'),
});
if (!fontsLoaded) {
return null;
}
LogBox.ignoreLogs(['Warning:...', 'Require', 'Constants']);
return (
<Provider store={store} >
<MainTabNavigator />
</Provider>
);
} }

@ -1,20 +0,0 @@
FROM node:latest
# Create app directory
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY bob_party/package*.json ./
RUN yarn
# If you are building your code for production
# RUN npm ci --only=production
# Bundle app source
COPY bob_party/server.js .
EXPOSE 3000
CMD [ "node", "server.js" ]

@ -24,8 +24,7 @@
"adaptiveIcon": { "adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png", "foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF" "backgroundColor": "#FFFFFF"
}, }
"softwareKeyboardLayoutMode": "pan"
}, },
"web": { "web": {
"favicon": "./assets/favicon.png" "favicon": "./assets/favicon.png"

@ -1,21 +0,0 @@
import { FakeSaverConversation } from "./src/services/conversationService/fakeSaverConversation";
import { LoaderConversationApi } from "./src/services/conversationService/loaderConversationApi";
import ManagerConversation from "./src/services/conversationService/managerConversation";
import { SaverConversationApi } from "./src/services/conversationService/saverConversationApi";
import LoaderGameApi from "./src/services/gameService/loaderGameApi";
import ManagerGame from "./src/services/gameService/managerGame";
import LoaderMatchApi from "./src/services/matchServices/loaderMatchApi";
import ManagerMatch from "./src/services/matchServices/managerMatch";
import SaverMatchApi from "./src/services/matchServices/saverMatchApi";
import LoaderSkinApi from "./src/services/skinService/loaderSkinApi";
import ManagerSkin from "./src/services/skinService/managerSkin";
import FakeSaverUser from "./src/services/userServices/fakeSaverUser";
import LoaderUserApi from "./src/services/userServices/loaderUserApi";
import ManagerUser from "./src/services/userServices/managerUser";
import SaverUserApi from "./src/services/userServices/saverUserApi";
export const MANAGER_USER = new ManagerUser(new LoaderUserApi, new SaverUserApi);
export const MANAGER_CONVERSATION = new ManagerConversation(new LoaderConversationApi, new SaverConversationApi);
export const MANAGER_MATCH = new ManagerMatch(new LoaderMatchApi, new SaverMatchApi);
export const MANAGER_GAME = new ManagerGame(new LoaderGameApi);
export const MANAGER_SKIN = new ManagerSkin(new LoaderSkinApi);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1009 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 447 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 595 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 634 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 798 KiB

@ -1,9 +1,6 @@
module.exports = function (api) { module.exports = function(api) {
api.cache(true); api.cache(true);
return { return {
presets: [ presets: ['babel-preset-expo'],
['babel-preset-expo'],
['@babel/preset-env', { targets: { node: 'current' } }]
],
}; };
}; };

@ -0,0 +1,12 @@
import React from 'react'
import App from './App'
import store from './src/redux/store'
import { Provider } from 'react-redux'
export default function Index(){
return(
<Provider store={store}>
<App />
</Provider>
)
}

@ -1,5 +0,0 @@
module.exports = {
testEnvironment: "node",
preset: "ts-jest/presets/js-with-ts",
transformIgnorePatterns: [ "/node_modules/(?!MODULE_NAME_HERE).+\\.js$"],
};

File diff suppressed because it is too large Load Diff

@ -6,70 +6,37 @@
"start": "expo start", "start": "expo start",
"android": "expo start --android", "android": "expo start --android",
"ios": "expo start --ios", "ios": "expo start --ios",
"web": "expo start --web", "web": "expo start --web"
"test": "jest"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.20.6",
"@dietime/react-native-date-picker": "^1.2.0",
"@react-native-community/datetimepicker": "^6.7.1",
"@react-native-picker/picker": "^2.4.8", "@react-native-picker/picker": "^2.4.8",
"@react-navigation/bottom-tabs": "^6.4.0", "@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13", "@react-navigation/native": "^6.0.13",
"@react-navigation/stack": "^6.3.2", "@react-navigation/stack": "^6.3.2",
"@reduxjs/toolkit": "^1.8.6", "@reduxjs/toolkit": "^1.8.6",
"axios": "^1.1.3", "expo": "^46.0.15",
"babel-core": "^6.26.3",
"babel-jest": "^29.3.1",
"babel-plugin-transform-typescript": "^7.0.0-alpha.19",
"babel-preset-env": "^1.7.0",
"babel-preset-typescript": "^7.0.0-alpha.19",
"babel-test": "^0.2.4",
"cors": "^2.8.5",
"expo": "^46.0.17",
"expo-linear-gradient": "^12.0.1",
"expo-status-bar": "~1.4.0", "expo-status-bar": "~1.4.0",
"express": "^4.18.2", "jest": "^26.6.3",
"is-docker": "^3.0.0",
"jest": "^29.3.1",
"jquery": "^3.6.1",
"node": "^18.10.0", "node": "^18.10.0",
"nodemon": "^2.0.20",
"react": "18.0.0", "react": "18.0.0",
"react-dom": "18.0.0", "react-dom": "18.0.0",
"react-native": "^0.69.6", "react-native": "^0.69.6",
"react-native-date-picker": "^4.2.5",
"react-native-dialog": "^9.2.2", "react-native-dialog": "^9.2.2",
"react-native-dialog-input": "^1.0.8", "react-native-dialog-input": "^1.0.8",
"react-native-gesture-handler": "~2.5.0", "react-native-gesture-handler": "~2.5.0",
"react-native-picker-select": "^8.0.4", "react-native-picker-select": "^8.0.4",
"react-native-safe-area-context": "4.3.1", "react-native-safe-area-context": "4.3.1",
"react-native-status-bar-height": "^2.6.0",
"react-native-web": "~0.18.7", "react-native-web": "~0.18.7",
"react-native-woodpicker": "^0.3.17", "react-redux": "^8.0.4"
"react-redux": "^8.0.4",
"socket.io": "^4.5.4",
"socket.io-client": "^4.5.4",
"ts-node": "^10.9.1",
"zustand": "^4.1.4"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.12.9", "@babel/core": "^7.12.9",
"@babel/plugin-proposal-class-properties": "^7.0.0", "@types/jest": "^29.1.2",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/runtime": "^7.5.5",
"@jest/globals": "^29.3.1",
"@types/jest": "^29.2.3",
"@types/jquery": "^3.5.14",
"@types/mocha": "^10.0.0", "@types/mocha": "^10.0.0",
"@types/node": "^18.8.4", "@types/node": "^18.8.4",
"@types/react": "~18.0.14", "@types/react": "~18.0.14",
"@types/react-native": "~0.69.1", "@types/react-native": "~0.69.1",
"babel-preset-react-native": "^4.0.0", "typescript": "~4.3.5"
"ts-jest": "^29.0.3",
"typescript": "^4.9.3"
}, },
"private": true "private": true
} }

@ -1,55 +0,0 @@
const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
io.on('connection', (socket) => {
console.log(socket.id);
socket.on('signIn', (id) => {
socket.join("U"+id);
});
socket.on('inConv', (conv) => {
socket.join("C" + conv.id);
});
socket.on('quitConv', (conv) => {
socket.off("C" + conv.id);
});
socket.on("messageSent", (conv) =>{
socket.to("C"+conv.id).emit("messageReceived");
console.log("Message envoyé");
});
socket.on("createConversation", (tabId, conv) =>{
tabId.forEach(id => {
socket.to("U"+id).emit("addedToConv", conv);
});
});
socket.on('joinMatch', (match) => {
socket.join("M" + match.code);
socket.to("M"+ match.code).emit("matchUsersChanged");
});
socket.on('launchMatch', (match) => {
socket.to("M"+ match.code).emit("matchLaunched");
});
socket.on('quitMatch', (match) => {
socket.to("M"+ match.code).emit("matchUsersChanged")
});
socket.on("playTicTacToe", (match, rowIndex, columnIndex, turn) =>{
socket.to("M"+match.code).emit("oppPlayTicTacToe", rowIndex, columnIndex, turn);
});
});
server.listen(3000);

@ -1,4 +0,0 @@
const { io } = require("socket.io-client");
export const socket = io("http://172.20.10.2:3000");

@ -1,242 +0,0 @@
import React,{Component, useState} from 'react';
import {
View,
StyleSheet,
ImageBackground,
UIManager,
StatusBar,
NativeModules,
AppState,
Platform
} from 'react-native';
import cardsDeck from './source/data/cards';
import {shuffle} from './source/helpers';
import {Overlay,ChipSelector, UserControls,FloatingText} from './source/components';
import boardBg from './source/assets/board.png';
import { MANAGER_USER } from '../../../appManagers';
import { UserCoinsModifier } from '../../core/User/userCoinsModifier';
import { useNavigation } from '@react-navigation/native';
import { useUserStore } from '../../context/userContext';
export default function BlackJack(props){
const [totalBet, setTotalBet] = useState(0);
const [amount, setAmount] = useState(MANAGER_USER.getCurrentUser()?.getCurrentCoins());
const [playerHand, setPlayerHand] = useState([]);
const [dealerHand, setDealerHand] = useState([]);
const [gameover, setGameover] = useState(false);
const [cardCount, setCardCount] = useState(0);
const [gameMessage, setGameMessage] = useState("");
const [gameStarted, setGameStarted] = useState(false);
const [startGame, setStartGame] = useState(false);
const navigation = useNavigation();
const setUser = useUserStore((state) => state.setUser);
return(
<>
<ImageBackground
source={boardBg}
style={styles.container}>
<StatusBar backgroundColor={"green"} translucent={true} />
<View style={styles.bottom}>
<UserControls
playerHand={playerHand}
dealerHand={dealerHand}
goBack={() => navigation.goBack()}
hit={() => hit()}
doubleGame={() => doubleGame()}
endgame={() => endgame()}
gameover={gameover}
totalBet={totalBet}
/>
<View style={styles.center}>
<FloatingText
text={`Total Bet ${totalBet} BobCoins`}
/>
</View>
<ChipSelector
onSelect={(chipValue) => {
if(!gameover && startGame){
if(chipValue <= amount && !gameStarted){
setTotalBet(totalBet+chipValue);
setAmount(amount-chipValue);
}
}
else{
if (amount > 0 && amount>=chipValue){
newGame();
setTotalBet(totalBet+chipValue);
setAmount(amount-chipValue);
}
}
}}
/>
<View style={styles.center}>
<FloatingText
text={`Available ${amount} BobCoins`}
/>
</View>
{gameover && gameMessage != "" && <Overlay text={gameMessage} onClose={() => { newGame() }} />}
</View>
</ImageBackground>
</>
)
async function modifAmount(money){
const modif = new UserCoinsModifier();
const tmp=MANAGER_USER.getCurrentUser();
setAmount(money);
if (tmp!=null){
await modif.changeCurrentCoins(tmp, money);
setUser(MANAGER_USER.getCurrentUser());
}
}
function newGame(){
let cardCount = 0;
shuffle(cardsDeck);
let playerHand = [],
dealerHand = [];
for(let i = 0; i < 2; i++){
playerHand.push(cardsDeck[cardCount]);
cardCount++;
dealerHand.push(cardsDeck[cardCount]);
cardCount++;
}
setPlayerHand(playerHand);
setDealerHand(dealerHand);
setGameover(false);
setCardCount(cardCount);
setGameMessage("");
setStartGame(true);
}
function hit(){
const hand=playerHand;
hand.push(cardsDeck[cardCount]);
let userPoints = checkTotalPlayerPoints(hand);
setGameStarted(true);
setPlayerHand(hand);
setCardCount(cardCount+1)
if(userPoints > 21){
endgame();
return;
}
}
function doubleGame(){
hit();
endgame();
}
async function endgame(){
let _cardCount = cardCount;
let dealerPoints = checkTotalPlayerPoints(dealerHand),
playerPoints = checkTotalPlayerPoints(playerHand);
//alert(dealerPoints)
while(dealerPoints < 17){
dealerHand.push(cardsDeck[_cardCount]);
_cardCount++;
dealerPoints = checkTotalPlayerPoints(dealerHand);
}
let betValue = totalBet * 1.5;
setGameStarted(false);
//who won
if(playerPoints == 21 && playerHand.length == 2){
let newAmount = totalBet * 1.5;
await modifAmount(newAmount);
setTotalBet(0);
setGameover(true);
setGameMessage("Player BlackJack!");
}
if(
(playerPoints < 22 && dealerPoints < playerPoints) ||
(dealerPoints > 21 && playerPoints < 22)
){
await modifAmount(amount+betValue);
setTotalBet(0);
setGameover(true);
setGameMessage("You Win "+ betValue+" BobCoins");
}
else if(playerPoints > 21 && dealerPoints <= 21){
await modifAmount(amount);
setCardCount(_cardCount);
setTotalBet(0);
setGameover(true);
setGameMessage("Bust!");
}else if(playerPoints == dealerPoints){
await modifAmount(amount+totalBet);
setTotalBet(0);
setGameover(true);
setGameMessage("Push!");
}else{
await modifAmount(amount);
setTotalBet(0);
setGameover(true);
setGameMessage("Dealer Wins, You Lost");
}
}
function checkTotalPlayerPoints(playerHand){
let aceAdjuts = false,
points = 0;
playerHand.map((card,_index) => {
if(card.name == 'A' && !aceAdjuts) {
aceAdjuts = true;
points = points + 10;
}
points = points + card.value;
});
if(aceAdjuts && points > 21){
points = points - 10;
}
return points;
}
}
const styles = StyleSheet.create({
container : {
flex : 1
},
center : {
alignItems : "center"
},
bottom : {
position : "absolute",
left : 0,
right : 0,
bottom : 0,
zIndex : 2
}
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save