Compare commits

..

No commits in common. 'master' and 'testDockerToto' have entirely different histories.

@ -2,19 +2,20 @@
kind: pipeline
name: Dockers_Builder
# 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:
settings:
dockerfile: ./Dockerfile
context: .
IMAGENAME: mysql:latest
CONTAINERNAME: mysql
COMMAND: create
OVERWRITE: true
#OVERWRITE: true
PRIVATE: true
CODEFIRST_CLIENTDRONE_ENV_MYSQL_ROOT_PASSWORD:
from_secret: MYSQL_ROOT_PASSWORD
@ -35,7 +36,7 @@ steps:
dockerfile: ./api-rest/Dockerfile
context: .
registry: hub.codefirst.iut.uca.fr
repo: hub.codefirst.iut.uca.fr/bob_parteam/bob_party/api
repo: hub.codefirst.iut.uca.fr/bob_parteam/bob_party
username:
from_secret: SECRET_REGISTRY_USERNAME
password:
@ -47,7 +48,7 @@ steps:
- 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
IMAGENAME: hub.codefirst.iut.uca.fr/bob_parteam/bob_party:latest
CONTAINERNAME: api-bobParty
COMMAND: create
OVERWRITE: true
@ -65,33 +66,6 @@ steps:
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 ]

@ -155,12 +155,8 @@ public function deleteUserFromConversation(int $idConv, int $idUser){
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);
}
}

@ -20,28 +20,14 @@ class GameGateway{
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);
$row['GAM_NB_PLAYER_MAX']);
}
return $tabGames;
}
@ -51,28 +37,15 @@ class GameGateway{
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);
$row['GAM_NB_PLAYER_MAX']);
}
return $game;
}

@ -41,7 +41,7 @@ class MatchGateway{
}
/// 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)";
$insertPlayQuery = "INSERT INTO T_J_PLAY_MATCH_PLM VALUES(:idCreator,:id);";
$argInsertMatch=array('idGame'=>array($idGame, PDO::PARAM_INT));
@ -57,7 +57,7 @@ class MatchGateway{
$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]);
return;
}
/// Brief : Modifying an EXISTING match in database

@ -59,7 +59,7 @@ class UserGateway{
$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";
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();
@ -110,15 +110,12 @@ class UserGateway{
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)));
WHERE USR_USERNAME=:username
AND USR_PASSWORD=:password";
$argUsernamePassword=(array('username'=>array($username,PDO::PARAM_STR),
'password'=>array($password,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);
@ -130,27 +127,19 @@ class UserGateway{
/// 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,

@ -12,7 +12,7 @@
exit;
*/
require_once("initBdd.php");
//require_once("initBdd.php");
@ -47,7 +47,7 @@
} catch (PDOException $e) {
echo "ERROR connection";
echo $e->getMessage();
//echo $dsn;
echo $dsn;
//header("HTTP/1.0 ".$e->getMessage());
http_response_code(600); // Quel code pour les erreurs PDO?
}
@ -76,16 +76,12 @@
$url = explode('/', $url);
$i=0;
while ($url[$i]!=="index.php" && count($url)>0){
while ($url[$i]!=="index.php"){
unset($url[$i]);
$i++;
}
if (empty($url)){
exit;
}
//echo json_encode($url);
echo json_encode($url);
$method_name = !empty($url[2]) ? (string)$url[2] : null;
if($method_name == null){
@ -203,7 +199,6 @@
$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");
@ -239,9 +234,9 @@
$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];
$nbCurrentCoins = !empty($url[8]) ? (int) $url[8] : null;
$totalnbCoins = !empty($url[9]) ? (int) $url[9] : null;
$nbGames = !empty($url[10]) ? (int) $url[10] : null;
$currentSkin = !empty($url[11]) ? (int) $url[11] : null;
$usergw->putUser($id,$username,$password,$sexe, $nationality, $nbCurrentCoins,$totalnbCoins,$nbGames,$currentSkin);
http_response_code(200);

@ -27,6 +27,9 @@ $conn->query("CREATE TABLE `T_H_CONVERSATION_COV` (
`COV_NAME` varchar(20) DEFAULT NULL
) ;");
$conn->query("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);");
$conn->query("CREATE TABLE `T_H_MESSAGE_MSG` (
`PK_ID` int(11) NOT NULL,
@ -70,7 +73,7 @@ $conn->query("CREATE TABLE `T_J_PLAY_MATCH_PLM` (
$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_PASSWORD` varchar(50) NOT NULL,
`USR_NATIONALITY` varchar(20) NOT NULL,
`USR_SEX` varchar(30) NOT NULL,
`USR_DATE_OF_BIRTH` date DEFAULT NULL,
@ -81,6 +84,9 @@ $conn->query("CREATE TABLE `T_S_USER_USR` (
);");
$conn->query("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);");
$conn->query("ALTER TABLE `T_E_GAME_GAM`
ADD PRIMARY KEY (`PK_ID`),
ADD UNIQUE KEY `GAM_NAME` (`GAM_NAME`);");
@ -174,11 +180,11 @@ ADD CONSTRAINT `t_s_user_usr_ibfk_1` FOREIGN KEY (`FK_CURRENT_SKIN`) REFERENCES
$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),
(1, 100, 25),
(1, 1000, 30),
(1, 10000, 40),
(1, 100000, 50),
(1, 1000000, 75),
(2, 0, 5),
(3, 0, 0),
(3, 1, 25),
@ -191,11 +197,13 @@ $conn->query("INSERT INTO `T_H_SKIN_SKI` (`PK_ID`, `SKI_NAME`, `SKI_IMAGE`, `SKI
(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'),
(1, 'Cookie Clicker', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.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');");
$conn->query("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', 105, 230, 12, 2);");

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

@ -0,0 +1,5 @@
<php?
echo "coucou";
?>

@ -3,7 +3,7 @@
-- https://www.phpmyadmin.net/
--
-- Hôte : localhost:8889
-- Généré le : mar. 10 jan. 2023 à 09:00
-- Généré le : jeu. 05 jan. 2023 à 07:29
-- Version du serveur : 5.7.34
-- Version de PHP : 7.4.21
@ -41,7 +41,7 @@ CREATE 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'),
(1, 'Cookie Clicker', 'https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/ImagesJeux/Pong.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');
@ -58,15 +58,6 @@ CREATE TABLE `T_E_MATCH_MTC` (
`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);
-- --------------------------------------------------------
--
@ -75,7 +66,7 @@ INSERT INTO `T_E_MATCH_MTC` (`PK_ID`, `MTC_IN_GAME`, `FK_GAME`) VALUES
CREATE TABLE `T_H_CONVERSATION_COV` (
`PK_ID` int(11) NOT NULL,
`COV_NAME` varchar(30) DEFAULT NULL
`COV_NAME` varchar(20) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
@ -88,14 +79,7 @@ INSERT INTO `T_H_CONVERSATION_COV` (`PK_ID`, `COV_NAME`) VALUES
(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');
(37, 'coucouuuuuuuuu');
--
-- Déclencheurs `T_H_CONVERSATION_COV`
@ -146,12 +130,7 @@ INSERT INTO `T_H_MESSAGE_MSG` (`PK_ID`, `MSG_MESSAGE`, `FK_SENDER`, `MSG_DATEENV
(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');
(77, 'to created a conversation', 1, '2023-01-05 08:25:54');
-- --------------------------------------------------------
@ -203,7 +182,6 @@ INSERT INTO `T_J_CONTAIN_MESSAGE_CMG` (`FK_CONVERSATION`, `FK_MESSAGE`) VALUES
(32, 63),
(32, 64),
(32, 65),
(40, 65),
(32, 66),
(32, 68),
(32, 69),
@ -214,12 +192,7 @@ INSERT INTO `T_J_CONTAIN_MESSAGE_CMG` (`FK_CONVERSATION`, `FK_MESSAGE`) VALUES
(35, 74),
(36, 75),
(36, 76),
(37, 77),
(39, 78),
(41, 79),
(48, 86),
(49, 87),
(50, 88);
(37, 77);
-- --------------------------------------------------------
@ -240,25 +213,21 @@ INSERT INTO `T_J_DISCUSS_DIS` (`FK_USER`, `FK_CONVERSATION`) VALUES
(1, 32),
(2, 32),
(3, 32),
(1, 33),
(2, 33),
(3, 33),
(1, 34),
(2, 34),
(3, 34),
(1, 35),
(2, 35),
(3, 35),
(1, 36),
(2, 36),
(7, 36),
(1, 37),
(2, 37),
(6, 37),
(2, 41),
(3, 41),
(2, 48),
(3, 48),
(1, 49),
(2, 49),
(1, 50),
(2, 50);
(6, 37);
-- --------------------------------------------------------
@ -329,16 +298,6 @@ CREATE TABLE `T_J_PLAY_MATCH_PLM` (
`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);
-- --------------------------------------------------------
--
@ -363,7 +322,7 @@ CREATE 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),
(1, 'to', 't', 'Anglais(e)', 'M', '2003-07-01', 105, 230, 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),
@ -470,25 +429,25 @@ ALTER TABLE `T_S_USER_USR`
-- 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;
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;
--
-- 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;
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT;
--
-- 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;
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=38;
--
-- 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;
MODIFY `PK_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=78;
--
-- AUTO_INCREMENT pour la table `T_H_SKIN_SKI`

@ -3,11 +3,7 @@ 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() {
@ -21,10 +17,8 @@ export default function App() {
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": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"softwareKeyboardLayoutMode": "pan"
}
},
"web": {
"favicon": "./assets/favicon.png"

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

@ -11,9 +11,8 @@
},
"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-community/datetimepicker": "6.2.0",
"@react-native-picker/picker": "2.4.2",
"@react-navigation/bottom-tabs": "^6.4.0",
"@react-navigation/native": "^6.0.13",
"@react-navigation/stack": "^6.3.2",
@ -27,10 +26,8 @@
"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",
"express": "^4.18.2",
"is-docker": "^3.0.0",
"jest": "^29.3.1",
"jquery": "^3.6.1",
"node": "^18.10.0",
@ -44,9 +41,7 @@
"react-native-gesture-handler": "~2.5.0",
"react-native-picker-select": "^8.0.4",
"react-native-safe-area-context": "4.3.1",
"react-native-status-bar-height": "^2.6.0",
"react-native-web": "~0.18.7",
"react-native-woodpicker": "^0.3.17",
"react-redux": "^8.0.4",
"socket.io": "^4.5.4",
"socket.io-client": "^4.5.4",

@ -7,49 +7,21 @@ const { Server } = require("socket.io");
const io = new Server(server);
io.on('connection', (socket) => {
console.log(socket.id);
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);
console.log("C"+conv.id);
});
socket.on("messageSent", (conv) =>{
console.log("C"+conv.id);
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);
server.listen(3000, () => {
console.log('listening on *:3000');
});

@ -1,4 +1,4 @@
const { io } = require("socket.io-client");
export const socket = io("http://172.20.10.2:3000");
export const socket = io("http://192.168.1.54: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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

@ -1,52 +0,0 @@
import React from 'react';
import {
StyleSheet,
View,
TouchableOpacity,
Text
} from 'react-native';
const ActionButton = props => {
return(
<TouchableOpacity
onPress={() => {
if(props.onPress) props.onPress()
}}
>
<View style={[
props.direction == 'right' ? styles.rightDirection :
props.direction == 'left' ? styles.leftDirection : {},
styles.wrap,
props.style
]}>
<Text style={styles.text}>{props.text.replace(" ",'\n')}</Text>
</View>
</TouchableOpacity>
)
}
const styles = StyleSheet.create({
wrap : {
padding : 6,
backgroundColor : "rgba(255,255,255,0.7)",
borderColor : "rgba(255,255,255,0.9)",
borderWidth : 2,
marginBottom : 12
},
rightDirection : {
borderTopRightRadius : 6,
borderBottomRightRadius : 6
},
leftDirection : {
borderTopLeftRadius : 6,
borderBottomLeftRadius : 6
},
text : {
color : "white",
fontWeight : "bold",
fontSize : 14,
textAlign : "center"
}
});
export default ActionButton;

@ -1,65 +0,0 @@
import React,{Component} from 'react';
import {
View,
Text,
Image,
StyleSheet,
Dimensions
} from 'react-native';
import backCard from '../assets/cards/back.png';
const {width} = Dimensions.get("window");
const CARD_WIDTH = (width / 3) - 50;
const CARD_HEIGHT = (width / 3) + 5;
const CARD_SEPARATION = 50;
class CardDeck extends Component{
render(){
const {cards, isDealer, gameover} = this.props
return(
<View style={styles.container}>
<View
style={[
{marginLeft : -(cards.length * CARD_SEPARATION) / 1.8}
,styles.row]}>
{cards && cards.length > 0 && cards.map((card,i) => {
return (
<View
key={i}
style={[
i > 0 ? {
position : "absolute",
left : (i * CARD_SEPARATION),
} : {},
{
//elevation : 2,
borderWidth : 1,
borderColor : "black",
borderRadius : 6
}]}
><Image
source={ (isDealer && i == 0 && !gameover) ? backCard : cards[i].image}
style={{
width : CARD_WIDTH,
height : CARD_HEIGHT,
//position : "absolute",
//left : cards.length == 2 ? -(i * CARD_SEPARATION) : (i * -20)
}}
resizeMode={"stretch"}
/></View>)
})}
</View>
</View>
)
}
}
const styles = StyleSheet.create({
container : {
justifyContent : "center"
},
row : {
}
});
export default CardDeck;

@ -1,79 +0,0 @@
import React,{Component} from 'react';
import {
View,
ScrollView,
StyleSheet,
Image,
Text,
TouchableOpacity,
Dimensions
} from 'react-native';
import chips from '../data/chips';
const {width} = Dimensions.get('window');
const PADDING_WRAP = 8;
const MARGIN_SIDE = 20;
const CHIPS_SHOWN = 7;
const CHIP_WIDTH = (width / CHIPS_SHOWN) - ((MARGIN_SIDE / 2) * 2);
class ChipSelector extends Component{
render(){
const {onSelect} = this.props;
return(
<View style={styles.chipsWrapper}>
<ScrollView
horizontal={true}
contentContainerStyle={styles.scrollableContent}
showsHorizontalScrollIndicator={false}
>
{chips && chips.length > 0 && chips.map((chip,_index) => (
<TouchableOpacity
key={_index}
onPress={() => onSelect(chip.value)}
>
<View style={
_index < (chips.length-1) ? styles.chipWrap : {}
}>
<Image
source={chip.image}
resizeMode={'cover'}
style={styles.chip}
/>
</View>
</TouchableOpacity>
))}
</ScrollView>
</View>
)
}
}
const styles = StyleSheet.create({
chipsWrapper : {
backgroundColor : "#8A5D3C",
borderColor : "#AF7B56",
borderTopWidth : 2,
borderBottomWidth : 2,
/*elevation : 5,
position : "absolute",
bottom : 0,
left : 0,
right : 0,
zIndex : 3*/
},
scrollableContent:{
padding : PADDING_WRAP
},
chipWrap: {
marginRight : MARGIN_SIDE
},
chip : {
width : CHIP_WIDTH,
height: CHIP_WIDTH
}
})
export default ChipSelector;

@ -1,32 +0,0 @@
import React from 'react';
import {
View,
Text,
StyleSheet
} from 'react-native';
const FloatingText = props => {
return(
<View style={styles.indicator}>
<Text style={styles.indicatorTxt}>{props.text}</Text>
</View>
)
}
const styles = StyleSheet.create({
indicator : {
backgroundColor : "rgba(0,0,0,0.6)",
borderColor : "rgba(0,0,0,0.9)",
padding : 8,
alignItems : "center",
marginTop : 8,
marginBottom : 8,
borderRadius : 4
},
indicatorTxt : {
color : "white",
fontSize : 12
}
});
export default FloatingText;

@ -1,62 +0,0 @@
import React from 'react';
import {
View,
Text,
StyleSheet,
TouchableOpacity,
Dimensions
} from 'react-native';
const {width,height} = Dimensions.get("window");
const Overlay = props =>{
return(
<View style={styles.overlay}>
<Text style={styles.text}>{props.text}</Text>
<TouchableOpacity onPress={() => props.onClose()}>
<View style={styles.btn}>
<Text style={styles.continueBtn}>CONTINUE</Text>
</View>
</TouchableOpacity>
</View>
)
}
const styles = StyleSheet.create({
overlay : {
backgroundColor : "rgba(0,0,0,0.8)",
position : "absolute",
top : (height / 2) - 60,
left : 0,
right : 0,
zIndex : 5,
alignItems : "center",
justifyContent : "center",
padding : 12
},
text : {
color : "#fff",
fontSize : 40,
textAlign : "center"
},
center : {
alignItems : "center",
justifyContent : "center"
},
btn : {
marginTop : 10,
borderWidth : 1,
borderColor : "#fff",
padding : 8
},
continueBtn : {
color : "#fff",
fontSize : 14,
textAlign : "center"
}
});
export default Overlay;

@ -1,132 +0,0 @@
import React,{Component} from 'react';
import {
View,
Text,
TouchableOpacity,
StyleSheet,
Dimensions
} from 'react-native';
import {calculatePoints} from '../helpers';
import {ActionButton, FloatingText, CardDeck} from '../components';
const {width} = Dimensions.get('window');
const CIRCLE_BET_SIZE = (width / 4) - 20;
class UserControls extends Component{
constructor(){
super();
this.state = {
playerPoints : 0
}
}
UNSAFE_componentWillReceiveProps(nextProps){
if(nextProps.playerHand){
this.setState({
playerPoints : calculatePoints(nextProps.playerHand),
dealerPoints : calculatePoints(nextProps.dealerHand)
});
}
}
render(){
const {playerHand, dealerHand, goBack, hit, endgame, doubleGame, gameover, totalBet, moreMoney} = this.props;
const {playerPoints, dealerPoints} = this.state;
return(
<View style={styles.centerView}>
{/*<View>
<ActionButton
direction={'right'}
text={"DOUBLE WIN"}
/>
</View>*/}
<View style={styles.center}>
{gameover && <FloatingText text={dealerPoints} />}
<CardDeck
cards={dealerHand}
isDealer={true}
gameover={gameover}
/>
</View>
<View style={styles.center}>
<FloatingText text={playerPoints} />
<CardDeck
cards={playerHand}
/>
</View>
{totalBet == false && (<View style={styles.absoluteBtnRight}>
<ActionButton
direction={'left'}
text={"QUITER PARTIE"}
onPress={() => goBack()}
/>
</View>)}
{!!totalBet && (<View style={[styles.absoluteBtnRight,{top:60}]}>
<ActionButton
direction={'left'}
text={"HIT"}
onPress={() => hit()}
/>
</View>)}
{!!totalBet && (<View style={[styles.absoluteBtnRight,{top:105}]}>
<ActionButton
direction={'left'}
text={"DOUBLE"}
onPress={() => doubleGame()}
/>
</View>)}
{!!totalBet && (<View style={[styles.absoluteBtnRight,{top:150}]}>
<ActionButton
direction={'left'}
text={"DEAL"}
onPress={() => endgame()}
/>
</View>)}
</View>
)
}
}
const styles = StyleSheet.create({
centerView : {
//flexDirection : "row",
alignItems : "center",
justifyContent : "space-around",
paddingTop : 10,
paddingBottom : 10
},
/*betCircle : {
width : CIRCLE_BET_SIZE,
height : CIRCLE_BET_SIZE,
borderRadius : (CIRCLE_BET_SIZE / 2),
borderColor : 'white',
borderWidth : 1,
padding : 2
},*/
betText : {
color : "white",
textAlign : "center"
},
center : {
alignItems : "center",
justifyContent : "center"
},
absoluteBtnRight : {
position : "absolute",
right : 0,
zIndex : 2
}
});
export default UserControls;

@ -1,15 +0,0 @@
import ChipSelector from './ChipSelector';
import UserControls from './UserControls';
import ActionButton from './ActionButton';
import FloatingText from './FloatingText';
import CardDeck from './CardDeck';
import Overlay from './Overlay';
export {
ChipSelector,
UserControls,
ActionButton,
FloatingText,
CardDeck,
Overlay
}

@ -1,314 +0,0 @@
export default [
{
name : 'A',
deck : 'spades',
value : 1,
image : require('../assets/cards/spades/A.png')
},
{
name : 'J',
deck : 'spades',
value : 10,
image : require('../assets/cards/spades/J.png')
},
{
name : 'Q',
deck : 'spades',
value : 10,
image : require('../assets/cards/spades/Q.png')
},
{
name : 'K',
deck : 'spades',
value : 10,
image : require('../assets/cards/spades/K.png')
},
{
name : '2',
deck : 'spades',
value : 2,
image : require('../assets/cards/spades/2.png')
},
{
name : '3',
deck : 'spades',
value : 3,
image : require('../assets/cards/spades/3.png')
},
{
name : '4',
deck : 'spades',
value : 4,
image : require('../assets/cards/spades/4.png')
},
{
name : '5',
deck : 'spades',
value : 5,
image : require('../assets/cards/spades/5.png')
},
{
name : '6',
deck : 'spades',
value : 6,
image : require('../assets/cards/spades/6.png')
},
{
name : '7',
deck : 'spades',
value : 7,
image : require('../assets/cards/spades/7.png')
},
{
name : '8',
deck : 'spades',
value : 8,
image : require('../assets/cards/spades/8.png')
},
{
name : '9',
deck : 'spades',
value : 9,
image : require('../assets/cards/spades/9.png')
},
{
name : '10',
deck : 'spades',
value : 10,
image : require('../assets/cards/spades/10.png')
},
{
name : 'A',
deck : 'hearts',
value : 1,
image : require('../assets/cards/hearts/A.png')
},
{
name : 'J',
deck : 'hearts',
value : 10,
image : require('../assets/cards/hearts/J.png')
},
{
name : 'Q',
deck : 'hearts',
value : 10,
image : require('../assets/cards/hearts/Q.png')
},
{
name : 'K',
deck : 'hearts',
value : 10,
image : require('../assets/cards/hearts/K.png')
},
{
name : '2',
deck : 'hearts',
value : 2,
image : require('../assets/cards/hearts/2.png')
},
{
name : '3',
deck : 'hearts',
value : 3,
image : require('../assets/cards/hearts/3.png')
},
{
name : '4',
deck : 'hearts',
value : 4,
image : require('../assets/cards/hearts/4.png')
},
{
name : '5',
deck : 'hearts',
value : 5,
image : require('../assets/cards/hearts/5.png')
},
{
name : '6',
deck : 'hearts',
value : 6,
image : require('../assets/cards/hearts/6.png')
},
{
name : '7',
deck : 'hearts',
value : 7,
image : require('../assets/cards/hearts/7.png')
},
{
name : '8',
deck : 'hearts',
value : 8,
image : require('../assets/cards/hearts/8.png')
},
{
name : '9',
deck : 'hearts',
value : 9,
image : require('../assets/cards/hearts/9.png')
},
{
name : '10',
deck : 'hearts',
value : 10,
image : require('../assets/cards/hearts/10.png')
},
{
name : 'A',
deck : 'clubs',
value : 1,
image : require('../assets/cards/clubs/A.png')
},
{
name : 'J',
deck : 'clubs',
value : 10,
image : require('../assets/cards/clubs/J.png')
},
{
name : 'Q',
deck : 'clubs',
value : 10,
image : require('../assets/cards/clubs/Q.png')
},
{
name : 'K',
deck : 'clubs',
value : 10,
image : require('../assets/cards/clubs/K.png')
},
{
name : '2',
deck : 'clubs',
value : 2,
image : require('../assets/cards/clubs/2.png')
},
{
name : '3',
deck : 'clubs',
value : 3,
image : require('../assets/cards/clubs/3.png')
},
{
name : '4',
deck : 'clubs',
value : 4,
image : require('../assets/cards/clubs/4.png')
},
{
name : '5',
deck : 'clubs',
value : 5,
image : require('../assets/cards/clubs/5.png')
},
{
name : '6',
deck : 'clubs',
value : 6,
image : require('../assets/cards/clubs/6.png')
},
{
name : '7',
deck : 'clubs',
value : 7,
image : require('../assets/cards/clubs/7.png')
},
{
name : '8',
deck : 'clubs',
value : 8,
image : require('../assets/cards/clubs/8.png')
},
{
name : '9',
deck : 'clubs',
value : 9,
image : require('../assets/cards/clubs/9.png')
},
{
name : '10',
deck : 'clubs',
value : 10,
image : require('../assets/cards/clubs/10.png')
},
{
name : 'A',
deck : 'diamonds',
value : 1,
image : require('../assets/cards/diamonds/A.png')
},
{
name : 'J',
deck : 'diamonds',
value : 10,
image : require('../assets/cards/diamonds/J.png')
},
{
name : 'Q',
deck : 'diamonds',
value : 10,
image : require('../assets/cards/diamonds/Q.png')
},
{
name : 'K',
deck : 'diamonds',
value : 10,
image : require('../assets/cards/diamonds/K.png')
},
{
name : '2',
deck : 'diamonds',
value : 2,
image : require('../assets/cards/diamonds/2.png')
},
{
name : '3',
deck : 'diamonds',
value : 3,
image : require('../assets/cards/diamonds/3.png')
},
{
name : '4',
deck : 'diamonds',
value : 4,
image : require('../assets/cards/diamonds/4.png')
},
{
name : '5',
deck : 'diamonds',
value : 5,
image : require('../assets/cards/diamonds/5.png')
},
{
name : '6',
deck : 'diamonds',
value : 6,
image : require('../assets/cards/diamonds/6.png')
},
{
name : '7',
deck : 'diamonds',
value : 7,
image : require('../assets/cards/diamonds/7.png')
},
{
name : '8',
deck : 'diamonds',
value : 8,
image : require('../assets/cards/diamonds/8.png')
},
{
name : '9',
deck : 'diamonds',
value : 9,
image : require('../assets/cards/diamonds/9.png')
},
{
name : '10',
deck : 'diamonds',
value : 10,
image : require('../assets/cards/diamonds/10.png')
}
];

@ -1,42 +0,0 @@
export default [
{
image : require("../assets/chips/1.png"),
value : 1
},
{
image : require("../assets/chips/5.png"),
value : 5
},
{
image : require("../assets/chips/25.png"),
value : 25
},
{
image : require("../assets/chips/100.png"),
value : 100
},
{
image : require("../assets/chips/500.png"),
value : 500
},
{
image : require("../assets/chips/1k.png"),
value : 1000
},
{
image : require("../assets/chips/2k.png"),
value : 2000
},
{
image : require("../assets/chips/5k.png"),
value : 5000
},
{
image : require("../assets/chips/10k.png"),
value : 10000
},
{
image : require("../assets/chips/25k.png"),
value : 25000
}
]

@ -1,32 +0,0 @@
export function shuffle(a){
for (let i = a.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[a[i], a[j]] = [a[j], a[i]];
}
return a;
}
export function calculatePoints(playerHand){
/*let points = 0;
arr.map((card,_index) => {
//if(card.name == 'A' && card.name == 'J')
points = points + card.value
});
return points;*/
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;
}

@ -22,7 +22,7 @@ let points = 0;
function CookieClicker(props: { navigation: any }) {
const { navigation } = props
const GAMING_TIME = 50;
const GAMING_TIME = 120;
const setUser = useUserStore((state) => state.setUser);
@ -91,7 +91,6 @@ function CookieClicker(props: { navigation: any }) {
if (tmp !== null) {
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)) {
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, points);
MANAGER_USER.setCurrentUser(tmp);
setUser(tmp);
}
}

@ -8,7 +8,7 @@ export default StyleSheet.create({
flex:1,
backgroundColor:"#45444E",
alignItems:"center",
justifyContent:"center",
justifyContent:"center"
},
grid:{
width:375,

@ -3,18 +3,11 @@ import React, {useState} from "react";
import styles from './TicTacToeStyle.js';
import { useMatchStore } from "../../context/matchContext";
import { current } from "@reduxjs/toolkit";
import { ScreenIndicator } from "../../components/ScreenIndicator";
import { TopBar } from "../../components/TopBar";
import { MANAGER_MATCH, MANAGER_USER } from "../../../appManagers";
import { useUserStore } from "../../context/userContext";
import { ScreenIndicator } from "../../components/ScreenIndicator.tsx";
import { TopBar } from "../../components/TopBar.tsx";
export default function TicTacToe(props: { navigation: any}){
const setUser = useUserStore((state) => state.setUser);
const resetMatch = useMatchStore((state) => state.resetMatch);
export default function tic_tac_toe(props: { navigation: any}){
const [map,setMap]=useState([
['','',''],
['','',''],
@ -53,12 +46,12 @@ export default function TicTacToe(props: { navigation: any}){
const isRowOWinning = map[i] .every((cell)=>cell==="o");
if(isRowXWinning==true){
Alert.alert("X won !");
endGame();
navigation.goBack();
return true;
}
else if(isRowOWinning==true){
Alert.alert("O won !");
endGame();
navigation.goBack();
return true;
}
}
@ -77,12 +70,12 @@ export default function TicTacToe(props: { navigation: any}){
}
if (isColumnXWinning == true){
Alert.alert("X won !");
endGame();
navigation.goBack();
return true;
}
if(isColumnOWinning==true){
Alert.alert("O won !");
endGame();
navigation.goBack();
return true;
}
@ -108,12 +101,12 @@ export default function TicTacToe(props: { navigation: any}){
}
if(isDiag1OWinning==true || isDiag2OWinning==true){
Alert.alert("O won !");
endGame();
navigation.goBack();
return true;
}
if(isDiag1XWinning==true || isDiag2XWinning==true){
Alert.alert("X won !");
endGame();
navigation.goBack();
return true;
}
};
@ -124,25 +117,11 @@ export default function TicTacToe(props: { navigation: any}){
const isRow2Full = map[2] .every((cell)=>cell!=="");
if(isRow0Full==true && isRow1Full==true && isRow2Full==true){
Alert.alert("Draw !");
endGame();
navigation.goBack();
return false;
}
};
function endGame() {
const tmp = MANAGER_USER.getCurrentUser();
if (tmp !== null) {
if (MANAGER_MATCH.getCurrentMatch()?.getTabUsers().includes(tmp)) {
MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, 0);
MANAGER_USER.setCurrentUser(tmp);
setUser(tmp);
}
}
resetMatch();
navigation.goBack();
}
return(
<View style={styles.container}>
<TopBar nav={navigation} state={"game"}/>

@ -1,245 +0,0 @@
import {Alert, Button, ImageBackground, Pressable, StyleSheet, Text, View } from "react-native";
import React, {useState} from "react";
import styles from './TicTacToeStyle.js';
import { useMatchStore } from "../../context/matchContext";
import { current } from "@reduxjs/toolkit";
import { ScreenIndicator } from "../../components/ScreenIndicator";
import { TopBar } from "../../components/TopBar";
import { socket } from "../../../socketConfig";
import { MANAGER_MATCH, MANAGER_USER } from "../../../appManagers";
import { useUserStore } from "../../context/userContext";
export default function TicTacToeOnline(props: { navigation: any }){
const [initTic, setInitTic]=useState(0);
const setUser = useUserStore((state) => state.setUser);
setUpTicTacToeOnline();
const [map,setMap]=useState([
['','',''],
['','',''],
['','',''],
]);
const [turnUser, setTurnUser]=useState("x");
const {navigation}=props;
const [currentTurn,setCurrentTurn] = useState("x");
const onPressCell = async (rowIndex:number,columnIndex:number) => {
if (turnUser!==currentTurn){
Alert.alert("ce n'est pas à votre tour de jouer");
return;
}
if(map[rowIndex][columnIndex]==""){
setMap((existingMap) =>{
const updateMap = [...existingMap]
updateMap[rowIndex][columnIndex]=currentTurn;
return updateMap;
});
socket.emit("playTicTacToe", MANAGER_MATCH.getCurrentMatch(), rowIndex, columnIndex, currentTurn);
setCurrentTurn(currentTurn === "x"? "o" : "x");
const retour= await checkWinning();
if(retour!=true){
checkComplete();
}
}else{
Alert.alert("Case déjà prise");
}
};
function setUpTicTacToeOnline() {
if (initTic===0){
setInitTic(1);
socket.on("oppPlayTicTacToe", async (rowIndex, columnIndex, turn) =>{
setMap((existingMap) =>{
const updateMap = [...existingMap]
updateMap[rowIndex][columnIndex]=turn;
return updateMap;
});
const retour= await checkWinning();
if(retour!=true){
checkComplete();
}
if (turn==="x"){
setCurrentTurn("o");
setTurnUser("o");
}
else{
setCurrentTurn("x");
setTurnUser("x");
}
});
}
}
async function endGame(win: number){
socket.off("oppPlayTicTacToe");
navigation.goBack();
const tmp=MANAGER_USER.getCurrentUser();
if (tmp!==null){
await MANAGER_MATCH.getCurrentMatch()?.updatePostMatch(tmp, win);
MANAGER_USER.setCurrentUser(tmp);
setUser(tmp);
}
}
const checkWinning = async () =>{
const tmp=MANAGER_USER.getCurrentUser()
// Checks rows
for (let i=0; i<3; i++){
const isRowXWinning = map[i].every((cell)=> cell==="x");
const isRowOWinning = map[i] .every((cell)=>cell==="o");
if(isRowXWinning==true){
Alert.alert("X won !");
if (turnUser==="x"){
await endGame(2);
}
else{
await endGame(0);
}
return true;
}
else if(isRowOWinning==true){
Alert.alert("O won !");
if (turnUser==="x"){
await endGame(0);
}
else{
await endGame(2);
}
return true;
}
}
// Checks columns
for (let col=0;col<3;col++){
let isColumnXWinning=true;
let isColumnOWinning=true;
for(let row=0;row<3;row++){
if(map[row][col] !== "x"){
isColumnXWinning=false;
}
if(map[row][col] !== "o"){
isColumnOWinning=false;
}
}
if (isColumnXWinning == true){
Alert.alert("X won !");
if (turnUser==="x"){
await endGame(2);
}
else{
await endGame(0);
}
return true;
}
if(isColumnOWinning==true){
Alert.alert("O won !");
if (turnUser==="x"){
await endGame(0);
}
else{
await endGame(2);
}
return true;
}
}
// Checks diag
let isDiag1XWinning=true;
let isDiag1OWinning=true;
let isDiag2XWinning=true;
let isDiag2OWinning=true;
for (let i=0;i<3;i++){
if(map[i][i]!=="x"){
isDiag1XWinning=false;
}
if(map[i][i]!=="o"){
isDiag1OWinning=false;
}
if(map[i][2-i]!=="x"){
isDiag2XWinning=false;
}
if(map[i][2-i]!=="o"){
isDiag2OWinning=false;
}
}
if(isDiag1OWinning==true || isDiag2OWinning==true){
Alert.alert("O won !");
if (turnUser==="x"){
await endGame(0);
}
else{
await endGame(2);
}
return true;
}
if(isDiag1XWinning==true || isDiag2XWinning==true){
Alert.alert("X won !");
if (turnUser==="x"){
await endGame(2);
}
else{
await endGame(0);
}
return true;
}
};
const checkComplete = async () =>{
const isRow0Full = map[0].every((cell)=> cell!=="");
const isRow1Full = map[1] .every((cell)=>cell!=="");
const isRow2Full = map[2] .every((cell)=>cell!=="");
if(isRow0Full==true && isRow1Full==true && isRow2Full==true){
Alert.alert("Draw !");
await endGame(1);
return false;
}
};
return(
<View style={styles.container}>
<ScreenIndicator title='TIC TAC TOE'/>
<Text style={styles.text}>Current turn: {currentTurn}</Text>
<ImageBackground style={styles.grid} source={{uri:"https://upload.wikimedia.org/wikipedia/commons/6/64/Tic-tac-toe.png"}} >
<View style={styles.map}>
{map.map((row, rowIndex)=>(
<View key={`row-${rowIndex}`} style={styles.row}>
{row.map((cell, columnIndex)=> (
<Pressable
onPress={() => onPressCell(rowIndex,columnIndex)}
style={styles.cell}
key={`row-${rowIndex}-col-${columnIndex}`}
>
{cell === "o" && <View style={styles.circle}/>}
{cell === "x" &&(
<View style={styles.cross}>
<View style={styles.crossLine}/>
<View style={[styles.crossLine, styles.crossLineReversed]}/>
</View>
)}
</Pressable>
))}
</View>
))}
</View>
</ImageBackground>
</View>
);
}

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

Loading…
Cancel
Save