Compare commits
2 Commits
master
...
typescript
Author | SHA1 | Date |
---|---|---|
|
b6aadddaef | 2 years ago |
|
8ff594f749 | 2 years ago |
@ -1,119 +1,23 @@
|
||||
# This file creates our 2 docker containers
|
||||
# database container deployment
|
||||
kind: pipeline
|
||||
name: Dockers_Builder
|
||||
name: BD
|
||||
|
||||
# Creation of the DB docker
|
||||
steps:
|
||||
# database container deployment
|
||||
- name: deploy-container-mysql
|
||||
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
environment:
|
||||
IMAGENAME: mysql:latest
|
||||
IMAGENAME: mysql
|
||||
CONTAINERNAME: mysql
|
||||
COMMAND: create
|
||||
OVERWRITE: true
|
||||
# OVERWRITE: false
|
||||
PRIVATE: true
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
|
||||
from_secret: MYSQL_ROOT_PASSWORD
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
|
||||
from_secret: P@s$w0rd123
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_DATABASE:
|
||||
from_secret: MYSQL_DATABASE
|
||||
from_secret: BDBOB
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER:
|
||||
from_secret: MYSQL_USER_TOM
|
||||
from_secret: bob
|
||||
CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD:
|
||||
from_secret: MYSQL_PASSWORD_TOM
|
||||
ADMINS: thomaschazot2,mathildejean3,lilianbreton,luciebedouret,albanguilhot,cedricbouhours
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
from_secret: P@s$w0rd123
|
||||
scripts:
|
||||
- GRANT ALL PRIVILEGES ON *.* TO 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_USER'@'localhost' IDENTIFIED BY 'CODEFIRST_CLIENTDRONE_ENV_MYSQL_PASSWORD';
|
@ -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 +0,0 @@
|
||||
# # 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>
|
||||
|
||||
# # Redirecting 403 errors to index.php (does not work)
|
||||
# #ErrorDocument 403 http://localhost:8888/api-rest/index.php
|
||||
|
||||
# # Refusing access to all files ending with php
|
||||
|
||||
|
||||
# # Allowing access to index.php
|
||||
# <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 +0,0 @@
|
||||
[database]
|
||||
dsn = "mysql:host=". getenv("db_server").";dbname=". getenv("MYSQL_DATABASE")
|
||||
username = getenv("MYSQL_USER_TOM")
|
||||
password = getenv("MYSQL_PASSWORD_TOM")
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
class DatabaseConnection extends PDO{
|
||||
private $stmt;
|
||||
|
||||
public function __construct(string $dsn, string $username, string $password){
|
||||
parent::__construct($dsn,$username,$password);
|
||||
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
public function execQuery(string $query, array $parameters=[]) :bool{
|
||||
$this->stmt = parent::prepare($query);
|
||||
foreach($parameters as $name => $value){
|
||||
$this->stmt->bindValue($name, $value[0], $value[1]);
|
||||
}
|
||||
return $this->stmt->execute();
|
||||
}
|
||||
|
||||
public function getRes():array{
|
||||
return $this->stmt->fetchall();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,167 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('model/conversation.php');
|
||||
require_once('model/message.php');
|
||||
|
||||
class ConversationGateway{
|
||||
|
||||
private $connection;
|
||||
|
||||
// Constructor
|
||||
public function __construct($_connection){
|
||||
$this->connection=$_connection;
|
||||
}
|
||||
|
||||
/* Functions implemented to manage conversations' data from database
|
||||
|
||||
* getConversations : returning all the ids of the conversations of an user
|
||||
(with all the id of the messages and the users in the conversation)
|
||||
* postConversation : adding a NEW conversation in database
|
||||
* putMatch : modifying an EXISTING conversation in database
|
||||
* deleteMatch : deleting an conversation from database
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/// Brief : Returning all the ids of the conversations where an user belongs
|
||||
///(with all the id of the messages and the users in the conversation)
|
||||
/// Parameters : * $idUser (string): identifier of the user we want to get the conversations
|
||||
public function getConversations(string $_idUser):?array{
|
||||
// Declaration of arrays (NULL) and queries
|
||||
$tabConversations=[];
|
||||
$tabUsers=[];
|
||||
$tabMessages=[];
|
||||
$conversationQuery = "SELECT c.PK_ID, c.COV_NAME
|
||||
FROM T_H_CONVERSATION_COV c, T_J_DISCUSS_DIS d
|
||||
WHERE c.PK_ID=d.FK_CONVERSATION
|
||||
AND d.FK_USER=:idUser";
|
||||
$messagesQuery = "SELECT m.PK_ID, m.MSG_MESSAGE, m.FK_SENDER, m.MSG_DATEENVOIE
|
||||
FROM T_H_MESSAGE_MSG m, T_J_CONTAIN_MESSAGE_CMG c
|
||||
WHERE m.PK_ID=c.FK_MESSAGE
|
||||
AND c.FK_CONVERSATION=:idConv";
|
||||
$usersQuery = "SELECT d.FK_USER
|
||||
FROM T_J_DISCUSS_DIS d
|
||||
WHERE d.FK_CONVERSATION = :idConv";
|
||||
//Find all the conversations where the user belong
|
||||
$argIdUser=array('idUser'=>array($_idUser, PDO::PARAM_INT));
|
||||
$this->connection->execQuery($conversationQuery,$argIdUser);
|
||||
$res=$this->connection->getRes();
|
||||
|
||||
foreach($res as $row){
|
||||
$argIdConv= array('idConv'=>array($row['PK_ID'], PDO::PARAM_INT));
|
||||
// Find all messages of the conversation
|
||||
$this->connection->execQuery($messagesQuery,$argIdConv);
|
||||
$resMessages=$this->connection->getRes();
|
||||
foreach($resMessages as $rowMessages){
|
||||
$tabMessages[] = new Message($rowMessages['PK_ID'],
|
||||
$rowMessages['MSG_MESSAGE'],
|
||||
$rowMessages['FK_SENDER'],
|
||||
$rowMessages['MSG_DATEENVOIE']);
|
||||
}
|
||||
// Find all the users in the conversation
|
||||
$this->connection->execQuery($usersQuery,$argIdConv);
|
||||
$resUsers=$this->connection->getRes();
|
||||
foreach($resUsers as $rowUsers){
|
||||
$tabUsers[] = $rowUsers['FK_USER'];
|
||||
}
|
||||
// Add the conversation into the array
|
||||
$tabConversations[] = new Conversation($row['PK_ID'],
|
||||
$row['COV_NAME'],
|
||||
$tabMessages,
|
||||
$tabUsers);
|
||||
// Restore the arrays
|
||||
$tabUsers=array();
|
||||
$tabMessages=array();
|
||||
}
|
||||
return $tabConversations;
|
||||
}
|
||||
|
||||
/// Brief : Adding a new conversation in database
|
||||
public function postConversation(string $name, array $idUsers): int{
|
||||
// Declare queries
|
||||
$convCreationQuery = "INSERT INTO T_H_CONVERSATION_COV VALUES(NULL,:name)";
|
||||
$addUserInConvQuery = "INSERT INTO T_J_DISCUSS_DIS VALUES(:idUser,:idConv)";
|
||||
$argconvCreationQuery = array('name'=>array($name, PDO::PARAM_STR));
|
||||
|
||||
// Create a new conversation
|
||||
$this->connection->execQuery($convCreationQuery,$argconvCreationQuery);
|
||||
$this->connection->execQuery("SELECT PK_ID
|
||||
FROM T_H_CONVERSATION_COV
|
||||
WHERE PK_ID >= ALL (SELECT max(c2.PK_ID)
|
||||
FROM T_H_CONVERSATION_COV c2)",[]);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$id=$row['PK_ID'];
|
||||
}
|
||||
foreach ($idUsers as $idUs){
|
||||
$argUserInConvQuery = array('idUser'=>array($idUs, PDO::PARAM_INT),
|
||||
'idConv'=>array($id, PDO::PARAM_INT));
|
||||
$this->connection->execQuery($addUserInConvQuery,$argUserInConvQuery);
|
||||
}
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/// Brief : Modifying an EXISTING conversation in database
|
||||
public function putConversation(int $id, string $name):void{
|
||||
$conversationUpdateQuery = "UPDATE T_H_CONVERSATION_COV
|
||||
SET COV_NAME=:name
|
||||
WHERE PK_ID=:id";
|
||||
$argConversationUpdate = array('name'=>array($name, PDO::PARAM_STR),
|
||||
'id'=>array($id,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($conversationUpdateQuery,$argConversationUpdate);
|
||||
}
|
||||
|
||||
/// Brief : Adding an user to a conversation
|
||||
public function addUserToConversation(int $idConv, int $idUser){
|
||||
$insertUserQuery = "INSERT INTO T_J_DISCUSS_DIS VALUES(:idUser,:idConv)";
|
||||
$argQuery = array('idUser'=>array($idUser,PDO::PARAM_INT),
|
||||
'idConv'=>array($idConv,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($insertUserQuery,$argQuery);
|
||||
}
|
||||
|
||||
/// Brief : Deleting an user from a conversation
|
||||
public function deleteUserFromConversation(int $idConv, int $idUser){
|
||||
$insertUserQuery = "DELETE FROM T_J_DISCUSS_DIS WHERE FK_USER=:idUser AND FK_CONVERSATION=:idConv";
|
||||
$argQuery = array('idUser'=>array($idUser,PDO::PARAM_INT),
|
||||
'idConv'=>array($idConv,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($insertUserQuery,$argQuery);
|
||||
}
|
||||
|
||||
/// Brief : adding a new message into a conversation
|
||||
public function addMessageToConversation(string $message, int $idSender, int $idConv, string $date): int{
|
||||
$insertMessageQuery = "INSERT INTO T_H_MESSAGE_MSG VALUES(NULL,:message,:idSender, :date)";
|
||||
$insertMsgInConvQuery = "INSERT INTO T_J_CONTAIN_MESSAGE_CMG VALUES(:idConv,:idMessage)";
|
||||
|
||||
$argInsertMessage= array('message'=>array($message,PDO::PARAM_STR),
|
||||
'idSender'=>array($idSender,PDO::PARAM_INT),
|
||||
'date'=>array($date,PDO::PARAM_STR));
|
||||
$this->connection->execQuery($insertMessageQuery,$argInsertMessage);
|
||||
$this->connection->execQuery("SELECT PK_ID
|
||||
FROM T_H_MESSAGE_MSG
|
||||
WHERE PK_ID >= ALL (SELECT max(m2.PK_ID)
|
||||
FROM T_H_MESSAGE_MSG m2)",[]);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$idMsg=$row['PK_ID'];
|
||||
}
|
||||
$argMsgInConv = array('idConv'=>array($idConv,PDO::PARAM_INT),
|
||||
'idMessage'=>array($idMsg,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($insertMsgInConvQuery,$argMsgInConv);
|
||||
return $idMsg;
|
||||
}
|
||||
|
||||
/// Brief : Deleting a conversation and its messages from database
|
||||
public function deleteConversation(int $id):void{
|
||||
$deleteConv = "DELETE FROM T_H_CONVERSATION_COV
|
||||
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));
|
||||
$this->connection->execQuery($deleteConv,$argIdConv);
|
||||
$this->connection->execQuery($deleteMessages,$argIdConv);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('model/game.php');
|
||||
|
||||
class GameGateway{
|
||||
|
||||
private $connecion;
|
||||
|
||||
// Constructor
|
||||
public function __construct($_connection){
|
||||
$this->connection=$_connection;
|
||||
}
|
||||
|
||||
/* Functions implemented to manage games' data from database
|
||||
* getGames : returning all the games found in database
|
||||
* getGameById : returning a game found in database with its id
|
||||
*/
|
||||
|
||||
/// Brief : Returning all the games found in database
|
||||
public function getGames():?array{
|
||||
$tabGames=null;
|
||||
$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,[]);
|
||||
$res = $this->connection->getRes();
|
||||
$i=0;
|
||||
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'],
|
||||
$row['GAM_NAME'],
|
||||
$row['GAM_IMAGE'],
|
||||
$row['GAM_TYPE'],
|
||||
$row['GAM_NB_PLAYER_MIN'],
|
||||
$row['GAM_NB_PLAYER_MAX'],
|
||||
$tabKey,
|
||||
$tabValue);
|
||||
}
|
||||
return $tabGames;
|
||||
}
|
||||
|
||||
/// Brief : Returning a game found in database with its id
|
||||
/// Parameters : * $id (string): identifier of the game we are looking for
|
||||
public function getGameById(string $id):?Game{
|
||||
$game=null;
|
||||
$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));
|
||||
$this->connection->execQuery($gameInfoQuery,$arg);
|
||||
$res=$this->connection->getRes();
|
||||
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'],
|
||||
$row['GAM_NAME'],
|
||||
$row['GAM_IMAGE'],
|
||||
$row['GAM_TYPE'],
|
||||
$row['GAM_NB_PLAYER_MIN'],
|
||||
$row['GAM_NB_PLAYER_MAX'],
|
||||
$tabKey,
|
||||
$tabValue);
|
||||
}
|
||||
return $game;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,98 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('model/match.php');
|
||||
|
||||
class MatchGateway{
|
||||
|
||||
private $connection;
|
||||
|
||||
// Constructor
|
||||
public function __construct($con){
|
||||
$this->connection=$con;
|
||||
}
|
||||
|
||||
/* Functions implemented to manage matches' data from database
|
||||
|
||||
* getMatchById : returning a match found in database with its id
|
||||
* postMatch : adding a NEW user in database
|
||||
* putMatch : modifying an EXISTING user in database
|
||||
* deleteMatch : deleting an user from database
|
||||
|
||||
*/
|
||||
|
||||
/// Brief : Returning a match found in database with his id
|
||||
/// Parameters : * $id (string): identifier of the match we are looking for
|
||||
public function getMatchById(string $matchId):?Matchs{
|
||||
$match=NULL;
|
||||
$matchInfoQuery="SELECT PK_ID, MTC_IN_GAME, FK_GAME FROM T_E_MATCH_MTC WHERE PK_ID = :id";
|
||||
$playersInMatchQuery="SELECT FK_USER FROM T_J_PLAY_MATCH_PLM WHERE FK_MATCH=:id";
|
||||
$argId=array('id' => array($matchId, PDO::PARAM_INT));
|
||||
$this->connection->execQuery($playersInMatchQuery, $argId);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$tabUser[] = $row['FK_USER'];
|
||||
}
|
||||
$this->connection->execQuery($matchInfoQuery, $argId);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$match = new Matchs($row['PK_ID'],$row['MTC_IN_GAME'],$row['FK_GAME'],$tabUser);
|
||||
}
|
||||
return $match;
|
||||
}
|
||||
|
||||
/// Brief : Adding a NEW match in database
|
||||
public function postMatch(int $idGame, int $idCreator): ?Matchs{
|
||||
$insertMatchQuery="INSERT INTO T_E_MATCH_MTC VALUES(NULL,0,:idGame)";
|
||||
$insertPlayQuery = "INSERT INTO T_J_PLAY_MATCH_PLM VALUES(:idCreator,:id);";
|
||||
$argInsertMatch=array('idGame'=>array($idGame, PDO::PARAM_INT));
|
||||
$this->connection->execQuery($insertMatchQuery,$argInsertMatch);
|
||||
$this->connection->execQuery("SELECT PK_ID
|
||||
FROM T_E_MATCH_MTC
|
||||
WHERE PK_ID >= ALL (SELECT max(m2.PK_ID)
|
||||
FROM T_E_MATCH_MTC m2)",[]);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$id=$row['PK_ID'];
|
||||
}
|
||||
$argInsertPlay= array('idCreator'=>array($idCreator,PDO::PARAM_INT),
|
||||
'id'=>array($id,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($insertPlayQuery,$argInsertPlay);
|
||||
return new Matchs($id, 0, $idGame, [$idCreator]);
|
||||
}
|
||||
|
||||
/// Brief : Modifying an EXISTING match in database
|
||||
public function putMatch(int $id){
|
||||
$updateQuery="UPDATE T_E_MATCH_MTC SET MTC_IN_GAME=1 WHERE PK_ID=:id";
|
||||
$argUpdate=array('id'=>array($id,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($updateQuery,$argUpdate);
|
||||
return;
|
||||
}
|
||||
|
||||
/// Brief : Adding an user into a match
|
||||
public function addUserToMatch(int $idMatch, int $idUser){
|
||||
$insertQuery = "INSERT INTO T_J_PLAY_MATCH_PLM VALUES(:idUser,:idMatch)";
|
||||
$argInsert= array('idUser'=>array($idUser,PDO::PARAM_INT),
|
||||
'idMatch'=>array($idMatch,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($insertQuery,$argInsert);
|
||||
return;
|
||||
}
|
||||
|
||||
/// Brief : Deleting an user from a match
|
||||
public function deleteUserFromMatch(int $idUser){
|
||||
$deleteQuery = "DELETE FROM T_J_PLAY_MATCH_PLM WHERE FK_USER=:idUser";
|
||||
$argDelete = array('idUser'=>array($idUser,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($deleteQuery,$argDelete);
|
||||
return;
|
||||
}
|
||||
|
||||
/// Brief : Deleting a match from database
|
||||
/// Parameters : * $u (Matchs): match we want to delete from database
|
||||
public function deleteMatch(int $id){
|
||||
$query="DELETE FROM T_E_MATCH_MTC WHERE PK_ID=:id";
|
||||
$arg=array('id'=>array($id, PDO::PARAM_INT));
|
||||
$this->connection->execQuery($query,$arg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('model/skin.php');
|
||||
|
||||
class SkinGateway{
|
||||
|
||||
private $connection;
|
||||
|
||||
public function __construct($_connection){
|
||||
$this->connection=$_connection;
|
||||
}
|
||||
|
||||
/* Functions implemented to manage skins' data from database
|
||||
* getGames : returning all the skins found in database
|
||||
* getGameById : returning a skin found in database with its id
|
||||
*/
|
||||
|
||||
/// Brief : Returning all the skins found in database
|
||||
public function getSkins():?array{
|
||||
$tabSkins=null;
|
||||
$skinQuery="SELECT * FROM T_H_SKIN_SKI";
|
||||
$this->connection->execQuery($skinQuery,[]);
|
||||
$res = $this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
$tabSkins[]= new Skin($row['PK_ID'],
|
||||
$row['SKI_NAME'],
|
||||
$row['SKI_IMAGE'],
|
||||
$row['SKI_PRICE']);
|
||||
}
|
||||
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,203 +0,0 @@
|
||||
<?php
|
||||
|
||||
require_once('model/user.php');
|
||||
require_once('model/skin.php');
|
||||
|
||||
|
||||
class UserGateway{
|
||||
|
||||
private $connection;
|
||||
|
||||
public function __construct(DatabaseConnection $con){
|
||||
$this->connection=$con;
|
||||
}
|
||||
|
||||
/* CRUD methods
|
||||
* getUserById : returning an user found in database with its id
|
||||
* getUserByUsername : returning an user found in database with its username
|
||||
* getUserForConnection : returning an user if there is a correspondance between
|
||||
the username and the password, used for connection
|
||||
* postUser : adding a NEW user in database
|
||||
* putUser : modifying an EXISTING user in database
|
||||
* putSkinList : adding a skin into the list of skins of the user
|
||||
* deleteUser : deleting an user from database
|
||||
* addSkin : adding a skin to the list of skins bleonged by an user
|
||||
*/
|
||||
|
||||
/* Other methods
|
||||
* convertResToUser : converting the result of a PDO query into an instance of User
|
||||
* getSkinList : search into database the list of skin the user have
|
||||
*/
|
||||
|
||||
|
||||
/// Brief : Converting the result of a PDO query into an instance of User
|
||||
/// Parameter : * $res : result of the PDO query
|
||||
public function convertResToUser($res):?User{
|
||||
$usr=null;
|
||||
foreach($res as $row){
|
||||
$skinGateway=new SkinGateway($this->connection);
|
||||
$skinId=$row['FK_CURRENT_SKIN'];
|
||||
$skin=$skinGateway->getSkinById($skinId);
|
||||
$usr= new User($row['PK_ID'],
|
||||
$row['USR_USERNAME'],
|
||||
$row['USR_PASSWORD'],
|
||||
$row['USR_NATIONALITY'],
|
||||
$row['USR_SEX'],
|
||||
$row['USR_DATE_OF_BIRTH'],
|
||||
$row['USR_CURRENT_NB_COINS'],
|
||||
$row['USR_TOTAL_NB_COINS'],
|
||||
$row['USR_NB_GAMES_PLAYED'],
|
||||
$skin,
|
||||
null);
|
||||
}
|
||||
return $usr;
|
||||
}
|
||||
|
||||
/// Brief : Research into database the list of skin the user have
|
||||
/// Parameter : * $id (int) : id of the user we want to get the list
|
||||
public function getSkinList(int $id):?array{
|
||||
$tabSkin=null;
|
||||
$skinsOfUserQuery="SELECT s.*
|
||||
FROM T_H_SKIN_SKI s, T_J_OWN_SKIN_OWN o
|
||||
WHERE o.FK_USER=:id AND s.PK_ID=o.FK_SKIN";
|
||||
$argIdUser=array('id'=>array($id,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($skinsOfUserQuery,$argIdUser);
|
||||
$resSkin=$this->connection->getRes();
|
||||
foreach($resSkin as $row){
|
||||
$tabSkin[]= new Skin($row['PK_ID'], $row['SKI_NAME'], $row['SKI_IMAGE'],$row['SKI_PRICE']);
|
||||
}
|
||||
return $tabSkin;
|
||||
}
|
||||
|
||||
|
||||
/// Brief : Returning an user found in database with his id
|
||||
/// Parameters : * $id (string): identifier of the user we are looking for
|
||||
public function getUserById(int $id):?User{
|
||||
$userQuery="SELECT *
|
||||
FROM T_S_USER_USR
|
||||
WHERE PK_ID = :id";
|
||||
$argIdUser=array('id'=>array($id,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($userQuery,$argIdUser);
|
||||
$res=$this->connection->getRes();
|
||||
$usr=$this->convertResToUser($res);
|
||||
if ($usr != null){
|
||||
$usr->tabSkin=$this->getSkinList($usr->id);
|
||||
}
|
||||
return $usr;
|
||||
}
|
||||
|
||||
/// Brief : Returning an user found in database with his username
|
||||
/// Parameters : * $username (string): username of the user we are looking for
|
||||
public function getUserByUsername (string $username):?User{
|
||||
$userQuery = "SELECT *
|
||||
FROM T_S_USER_USR
|
||||
WHERE USR_USERNAME=:username";
|
||||
$argUsername=array('username'=>array($username,PDO::PARAM_STR));
|
||||
$this->connection->execQuery($userQuery,$argUsername);
|
||||
$res=$this->connection->getRes();
|
||||
$usr=$this->convertResToUser($res);
|
||||
if ($usr != null){
|
||||
$usr->tabSkin=$this->getSkinList($usr->id);
|
||||
}
|
||||
return $usr;
|
||||
}
|
||||
|
||||
/// Brief : Returning an user if there is a correspondance between the username and the password, used for connection
|
||||
/// Parameters : * $username (string): username of the user we are looking for
|
||||
/// * $password (string): password of the user we are looking for
|
||||
/// Comment : this function returns an user if it finds a match between an username and password,
|
||||
/// if it doesn't, it means there are no corresponding user
|
||||
public function getUserForConnection(string $username,string $password):?User{
|
||||
$userQuery = "SELECT *
|
||||
FROM T_S_USER_USR
|
||||
WHERE USR_USERNAME=:username";
|
||||
$argUsernamePassword=(array('username'=>array($username,PDO::PARAM_STR)));
|
||||
$this->connection->execQuery($userQuery,$argUsernamePassword);
|
||||
$res=$this->connection->getRes();
|
||||
foreach($res as $row){
|
||||
if(!password_verify($password,$row["USR_PASSWORD"])){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
$usr=$this->convertResToUser($res);
|
||||
if ($usr != null){
|
||||
$usr->tabSkin=$this->getSkinList($usr->id);
|
||||
}
|
||||
return $usr;
|
||||
}
|
||||
|
||||
/// Brief : Adding a NEW user in database
|
||||
/// Parameters : * $u (User): user we want to insert in database
|
||||
/// Returning TRUE if the user has been added succesfully, FALSE otherwise
|
||||
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)";
|
||||
$getLastIdQuery = "SELECT max(PK_ID) id FROM T_S_USER_USR";
|
||||
$argUser=array('username' => array($username, PDO::PARAM_STR),
|
||||
'password' => array($password, PDO::PARAM_STR),
|
||||
'nationality' => array($nationality, PDO::PARAM_STR),
|
||||
'sex' => array($sex, PDO::PARAM_STR),
|
||||
'dateOfBirth' => array($dateOfBirth, PDO::PARAM_STR));
|
||||
$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
|
||||
/// Parameters : * $u (User): user we want to update in database
|
||||
/// 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){
|
||||
$password=password_hash($password,PASSWORD_DEFAULT);
|
||||
$updateUserQuery="UPDATE T_S_USER_USR
|
||||
SET USR_USERNAME = :username,
|
||||
USR_PASSWORD=:password,
|
||||
USR_SEX=:sex,
|
||||
USR_NATIONALITY=:nationality,
|
||||
USR_CURRENT_NB_COINS=:currentBobCoins,
|
||||
USR_TOTAL_NB_COINS=:totalBobCoins,
|
||||
USR_NB_GAMES_PLAYED=:nbGamesPlayed,
|
||||
FK_CURRENT_SKIN=:currentSkin
|
||||
WHERE PK_ID=:id";
|
||||
$argUser=array('username' => array($username, 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),
|
||||
'totalBobCoins' => array($totalBobCoins, PDO::PARAM_INT),
|
||||
'nbGamesPlayed' => array($nbGamesPlayed, PDO::PARAM_INT),
|
||||
'currentSkin'=> array($currentSkin, PDO::PARAM_INT),
|
||||
'id' => array($id, PDO::PARAM_INT));
|
||||
$this->connection->execQuery($updateUserQuery, $argUser);
|
||||
}
|
||||
|
||||
/// Brief : Adding a skin into the list of skins of the user
|
||||
/// Parameter : * $u (User) : user
|
||||
public function putSkinList(int $idUser, int $idSkin){
|
||||
$addSkinQuery = "INSERT INTO T_J_OWN_SKIN_OWN VALUES(:idUser,:idSkin)";
|
||||
$updateBobCoinsQuery = "UPDATE T_S_USER_USR
|
||||
SET USR_CURRENT_NB_COINS = USR_CURRENT_NB_COINS - (SELECT SKI_PRICE
|
||||
FROM T_H_SKIN_SKI
|
||||
WHERE PK_ID=:idSkin)
|
||||
WHERE PK_ID=:idUser";
|
||||
$argOwn = array('idUser'=>array($idUser,PDO::PARAM_INT),
|
||||
'idSkin'=>array($idSkin,PDO::PARAM_INT));
|
||||
$argUpdate = array('idSkin'=>array($idSkin,PDO::PARAM_INT),
|
||||
'idUser'=>array($idUser,PDO::PARAM_INT));
|
||||
$this->connection->execQuery($addSkinQuery, $argOwn);
|
||||
$this->connection->execQuery($updateBobCoinsQuery,$argUpdate);
|
||||
}
|
||||
|
||||
/// Brief : Deleting an user from database
|
||||
/// Parameter : * $u (User): user we want to delete from database
|
||||
public function deleteUser(int $id): void{
|
||||
$query = "DELETE from T_S_USER_USR WHERE PK_ID = :id";
|
||||
$arg=array('id' => array($id, PDO::PARAM_STR));
|
||||
$this->connection->execQuery($query,$arg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,391 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
$conn = new mysqli("BOB_PARTEAM-mysql",getenv("MYSQL_USER"),getenv("MYSQL_PASSWORD"),getenv("MYSQL_DATABASE"));
|
||||
$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 :
|
||||
/// All the values must be cleaned on the application side before using this API
|
||||
///
|
||||
|
||||
include ('dbConnection.php');
|
||||
include (__DIR__ .'/gateways/userGateway.php');
|
||||
include (__DIR__ .'/gateways/matchGateway.php');
|
||||
include (__DIR__ .'/gateways/conversationGateway.php');
|
||||
include (__DIR__ .'/gateways/gameGateway.php');
|
||||
include (__DIR__ .'/gateways/skinGateway.php');
|
||||
|
||||
|
||||
// Connection to database
|
||||
// ------
|
||||
// Comment faire un fichier .htaccess pour protéger ce fichier ?????????
|
||||
// ------
|
||||
//$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
|
||||
try{
|
||||
$database = new DatabaseConnection($dsn,$username,$password);
|
||||
} catch (PDOException $e) {
|
||||
echo "ERROR connection";
|
||||
echo $e->getMessage();
|
||||
//echo $dsn;
|
||||
//header("HTTP/1.0 ".$e->getMessage());
|
||||
http_response_code(600); // Quel code pour les erreurs PDO?
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Initializing Gateways
|
||||
// ------
|
||||
// Passer en mode objet ou rester en mode comportemental mais assumé ???
|
||||
// ------
|
||||
$usergw = new UserGateway($database);
|
||||
$matchgw = new MatchGateway($database);
|
||||
$conversationgw = new ConversationGateway($database);
|
||||
$gamegw = new GameGateway($database);
|
||||
$skingw = new SkinGateway($database);
|
||||
|
||||
// Managing request, routing and sending
|
||||
// ------
|
||||
// RAPPEL POUR MOI MÊME : NE PAS OUBLIER DE FAIRE DES TRY CATCH !!!!!!!
|
||||
// ------
|
||||
|
||||
$request_method = $_SERVER['REQUEST_METHOD'];
|
||||
$request_uri = $_SERVER['REQUEST_URI'];
|
||||
$url = rtrim($request_uri,"/");
|
||||
$url = filter_var($url, FILTER_SANITIZE_URL);
|
||||
$url = explode('/', $url);
|
||||
|
||||
$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){
|
||||
//header("HTTP/1.0 400 Request Name Empty");
|
||||
http_response_code(400);
|
||||
|
||||
}
|
||||
switch ($request_method){
|
||||
case 'GET':
|
||||
if($method_name === "getUserById"){ // test : OK
|
||||
if(empty($url[3])){
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
} else{
|
||||
$id = (int)$url[3];
|
||||
$user = $usergw->getUserById($id);
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($user, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "getUserByUsername"){ // test : OK
|
||||
$username = !empty($url[3]) ? (string) $url[3] : null;
|
||||
if ($username !== null){
|
||||
$user =$usergw->getUserByUsername($username);
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($user, JSON_PRETTY_PRINT);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 Username not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "getUserForConnection"){ // test : OK
|
||||
$username = !empty($url[3]) ? (string) $url[3] : null;
|
||||
$password = !empty($url[4]) ? (string) $url[4] : null;
|
||||
if ($username != null || $password != null){
|
||||
$user =$usergw->getUserForConnection($username,$password);
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($user, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 Username or password not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "getSkins"){ // test : OK
|
||||
$tabSkin = $skingw->getSkins();
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($tabSkin, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
}
|
||||
elseif($method_name === "getGames"){ // test : OK
|
||||
$tabGame = $gamegw->getGames();
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($tabGame, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
}
|
||||
elseif($method_name === "getGameById"){ // test : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if ($id !== null){
|
||||
$game = $gamegw->getGameById($id);
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($game, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "getMatchById"){ // test : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if ($id !== null){
|
||||
$match = $matchgw->getMatchById($id);
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($match, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "getConversations"){ // tests : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if ($id !== null){
|
||||
$conversations = $conversationgw->getConversations($id);
|
||||
//header('Content-Type: application/json');
|
||||
echo json_encode($conversations, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
else{
|
||||
////header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
||||
http_response_code(401);
|
||||
}
|
||||
break;
|
||||
case 'POST':
|
||||
if($method_name === "postUser"){ // test : OK
|
||||
if (count($url)<7){
|
||||
//header("HTTP/1.0 400 Invalid number of arguments");
|
||||
http_response_code(400);
|
||||
}
|
||||
$username = !empty($url[3]) ? (string) $url[3] : null;
|
||||
$password = !empty($url[4]) ? (string) $url[4] : null;
|
||||
$nationality = !empty($url[5]) ? (string) $url[5] : null;
|
||||
$sex = !empty($url[6]) ? (string) $url[6] : null;
|
||||
$dateOfBirth = !empty($url[7]) ? (string) $url[7] : null;
|
||||
$usergw->postUser($username,$password,$nationality,$sex,$dateOfBirth);
|
||||
http_response_code(200);
|
||||
}
|
||||
elseif($method_name === "postMatch"){ // test : OK
|
||||
$idGame = !empty($url[3]) ? (int) $url[3] : null;
|
||||
$idCreator = !empty($url[4]) ? (int) $url[4] : null;
|
||||
if ($idGame != null || $idCreator != null){
|
||||
$match =$matchgw->postMatch($idGame,$idCreator);
|
||||
echo json_encode($match, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 idGame or idCreator not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "postConversation"){ // test : OK
|
||||
$name = !empty($url[3]) ? (string) $url[3] : null;
|
||||
$idList = !empty($url[4]) ? (array) explode(",",$url[4]) : null;
|
||||
$name=urldecode($name);
|
||||
if ($name != null || $idList != null){
|
||||
$id=$conversationgw->postConversation($name,$idList);
|
||||
echo json_encode($id, JSON_PRETTY_PRINT);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 name or creator not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
||||
http_response_code(401);
|
||||
}
|
||||
break;
|
||||
case 'PUT':
|
||||
if($method_name === "putUser"){ // test : OK
|
||||
if (count($url)<11){
|
||||
//header("HTTP/1.0 400 Invalid number of arguments");
|
||||
http_response_code(400);
|
||||
}
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
$username = !empty($url[4]) ? (string) $url[4] : null;
|
||||
$password = !empty($url[5]) ? (string) $url[5] : null;
|
||||
$sexe = !empty($url[6]) ? (string) $url[6] : null;
|
||||
$nationality = !empty($url[7]) ? (string) $url[7] : null;
|
||||
$nbCurrentCoins = (int) $url[8];
|
||||
$totalnbCoins = (int) $url[9];
|
||||
$nbGames = (int) $url[10];
|
||||
$currentSkin = !empty($url[11]) ? (int) $url[11] : null;
|
||||
$usergw->putUser($id,$username,$password,$sexe, $nationality, $nbCurrentCoins,$totalnbCoins,$nbGames,$currentSkin);
|
||||
http_response_code(200);
|
||||
}
|
||||
elseif($method_name === "putSkinList"){ // test : OK
|
||||
$idUser = !empty($url[3]) ? (int) $url[3] : null;
|
||||
$idSkin = !empty($url[4]) ? (int) $url[4] : null;
|
||||
if ($idUser != null || $idSkin != null){
|
||||
$usergw->putSkinList($idUser,$idSkin);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 idSkin or idUser not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "putMatch"){ // test : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if ($id !== null){
|
||||
$matchgw->putMatch($id);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "addUserToMatch"){ // test : OK
|
||||
$idMatch = !empty($url[3]) ? (int) $url[3] : null;
|
||||
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
||||
if ($idUser != null || $idMatch != null){
|
||||
$matchgw->addUserToMatch($idMatch,$idUser);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 idSkin or idUser not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "deleteUserFromMatch"){ // test : OK
|
||||
$idUser = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if ($idUser != null){
|
||||
$matchgw->deleteUserFromMatch($idUser);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 idUser not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "putConversation"){ // test : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
$newName = !empty($url[4]) ? (string) $url[4] : null;
|
||||
$newName=urldecode($newName);
|
||||
|
||||
if ($id != null && $newName != null){
|
||||
$conversationgw->putConversation($id,$newName);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 id or new name not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "addUserToConversation"){ // test : OK
|
||||
$idConv = !empty($url[3]) ? (int) $url[3] : null;
|
||||
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
||||
if ($idConv != null && $idUser != null){
|
||||
$conversationgw->addUserToConversation($idConv,$idUser);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 id conv or id user not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "deleteUserFromConversation"){ // test : OK
|
||||
$idConv = !empty($url[3]) ? (int) $url[3] : null;
|
||||
$idUser = !empty($url[4]) ? (int) $url[4] : null;
|
||||
if ($idConv != null && $idUser != null){
|
||||
$conversationgw->deleteUserFromConversation($idConv,$idUser);
|
||||
http_response_code(200);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 id conv or id user not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "addMessageToConversation"){ // test : OK
|
||||
$msg=!empty($url[3]) ? (string) $url[3] : null;
|
||||
$idSender=!empty($url[4]) ? (int) $url[4] : null;
|
||||
$idConv=!empty($url[5]) ? (int) $url[5] : null;
|
||||
$date=!empty($url[6]) ? (string) $url[6] : null;
|
||||
$date=urldecode($date);
|
||||
$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);
|
||||
} else{
|
||||
//header("HTTP/1.0 400 id conv or message or sender not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
||||
http_response_code(401);
|
||||
}
|
||||
break;
|
||||
case 'DELETE':
|
||||
if($method_name === "deleteUser"){ // test : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if($id!=null){
|
||||
$usergw->deleteUser($id);
|
||||
http_response_code(200);
|
||||
}else{
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name == "deleteMatch"){ // test : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if($id!=null){
|
||||
$matchgw->deleteMatch($id);
|
||||
http_response_code(200);
|
||||
}else{
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
elseif($method_name === "deleteConversation"){ // test : OK
|
||||
$id = !empty($url[3]) ? (int) $url[3] : null;
|
||||
if($id!=null){
|
||||
$conversationgw->deleteConversation($id);
|
||||
http_response_code(200);
|
||||
}else{
|
||||
//header("HTTP/1.0 400 Id not given");
|
||||
http_response_code(400);
|
||||
}
|
||||
}
|
||||
else{
|
||||
//header("HTTP/1.0 401 UNAUTHORIZED REQUEST");
|
||||
http_response_code(401);
|
||||
}
|
||||
break;
|
||||
default :
|
||||
//header("HTTP/1.0 405 Invalid request method");
|
||||
http_response_code(405);
|
||||
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');");
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Conversation{
|
||||
|
||||
// Object attributes
|
||||
public string $id;
|
||||
public string $name;
|
||||
public $tabMessages;
|
||||
public $listIdUsers;
|
||||
|
||||
public function __construct($_id,$_name,$_tabMessages,$_listIdUsers){
|
||||
$this->id=$_id;
|
||||
$this->name=$_name;
|
||||
$this->tabMessages=$_tabMessages;
|
||||
$this->listIdUsers=$_listIdUsers;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Game{
|
||||
public int $id;
|
||||
public string $name;
|
||||
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){
|
||||
$this->id=$_id;
|
||||
$this->name=$_name;
|
||||
$this->image=$_image;
|
||||
$this->type=$_type;
|
||||
$this->nbPlayerMin=$_nbPlayerMin;
|
||||
$this->nbPlayerMax=$_nbPlayerMax;
|
||||
$this->keys=$_keys;
|
||||
$this->values=$_values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
// appelé "Matchs" car match sans s ne marche pas
|
||||
class Matchs{
|
||||
|
||||
// Object attributes
|
||||
public string $id;
|
||||
public bool $inGame;
|
||||
public string $idGame;
|
||||
public $listIdUsers;
|
||||
|
||||
|
||||
public function __construct(string $_id,bool $_inGame, string $_idGame, $_listIdUsers){
|
||||
$this->id=$_id;
|
||||
$this->inGame=$_inGame;
|
||||
$this->idGame=$_idGame;
|
||||
// Only one user at creation
|
||||
$this->listIdUsers=$_listIdUsers;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Message {
|
||||
|
||||
// Object attributes
|
||||
public string $id;
|
||||
public string $content;
|
||||
public string $idSender;
|
||||
public string $dateEnvoie;
|
||||
|
||||
public function __construct(string $_id, string $_content, string $_idSender, string $_dateEnvoie){
|
||||
$this->id=$_id;
|
||||
$this->content=$_content;
|
||||
$this->idSender=$_idSender;
|
||||
$this->dateEnvoie=$_dateEnvoie;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
class Skin{
|
||||
|
||||
public int $id;
|
||||
public string $name;
|
||||
public string $source;
|
||||
public int $cost;
|
||||
|
||||
public function __construct(int $_id, string $_name, string $_source, int $_cost){
|
||||
$this->id=$_id;
|
||||
$this->name=$_name;
|
||||
$this->source=$_source;
|
||||
$this->cost=$_cost;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
class User {
|
||||
|
||||
// Object attributes
|
||||
public int $id;
|
||||
public string $username;
|
||||
public string $password;
|
||||
public string $nationality;
|
||||
public string $sexe;
|
||||
public string $dateOfBirth;
|
||||
public int $currentCoins;
|
||||
public int $totalCoins;
|
||||
public int $nbGamesPlayed;
|
||||
public Skin $currentSkin;
|
||||
public ?array $tabSkin;
|
||||
|
||||
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){
|
||||
$this->id=$_id;
|
||||
$this->username=$_username;
|
||||
$this->password=$_password;
|
||||
$this->nationality=$_nationality;
|
||||
$this->sexe=$_sexe;
|
||||
$this->dateOfBirth=$_dateOfBirth;
|
||||
$this->currentCoins=$_currentCoins;
|
||||
$this->totalCoins=$_totalCoins;
|
||||
$this->nbGamesPlayed=$_nbGamesPlayed;
|
||||
$this->currentSkin=$_currentSkin;
|
||||
$this->tabSkin=$_tabSkin;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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,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" ]
|
@ -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);
|
Before Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 320 B |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 448 KiB |
Before Width: | Height: | Size: 405 KiB |
Before Width: | Height: | Size: 1009 KiB |
Before Width: | Height: | Size: 447 KiB |
Before Width: | Height: | Size: 595 KiB |
Before Width: | Height: | Size: 634 KiB |
Before Width: | Height: | Size: 798 KiB |
@ -1,9 +1,6 @@
|
||||
module.exports = function (api) {
|
||||
api.cache(true);
|
||||
return {
|
||||
presets: [
|
||||
['babel-preset-expo'],
|
||||
['@babel/preset-env', { targets: { node: 'current' } }]
|
||||
],
|
||||
};
|
||||
module.exports = {
|
||||
presets: [
|
||||
['@babel/preset-env', { targets: { node: 'current' } }],
|
||||
'@babel/preset-typescript',
|
||||
],
|
||||
};
|
@ -0,0 +1,17 @@
|
||||
import React from 'react'
|
||||
import App from './App'
|
||||
import store from './src/redux/store'
|
||||
import { Provider } from 'react-redux'
|
||||
|
||||
|
||||
export default function Index(){
|
||||
|
||||
return(
|
||||
<App/>
|
||||
/*
|
||||
<Provider store={store}>
|
||||
<App />
|
||||
</Provider>
|
||||
*/
|
||||
)
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
testEnvironment: 'node',
|
||||
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$',
|
||||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']
|
||||
};
|
@ -1,5 +0,0 @@
|
||||
module.exports = {
|
||||
testEnvironment: "node",
|
||||
preset: "ts-jest/presets/js-with-ts",
|
||||
transformIgnorePatterns: [ "/node_modules/(?!MODULE_NAME_HERE).+\\.js$"],
|
||||
};
|
@ -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
|
||||
}
|
||||
});
|
||||
|
||||
|
Before Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 5.8 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 7.3 KiB |