Skip to content

Commit

Permalink
first
Browse files Browse the repository at this point in the history
  • Loading branch information
Chakib-Temal committed Oct 16, 2018
1 parent 7f9cf34 commit 5ad4fb2
Show file tree
Hide file tree
Showing 1,276 changed files with 271 additions and 159,179 deletions.
6 changes: 2 additions & 4 deletions Views/chat.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
<div class="nav-bar">
<ul class="horizontal">
<li><a class="active">Welcome {{ user.getUserName() }}</a></li>
<!--
<li><a href="javascript:void(0)">News</a></li>
<li><a href="javascript:void(0)">Contact</a></li>
-->

<li><a href="{{ url }}/game">Game</a></li>

<li class="rightli" style="float:right"><a href="{{ url }}/deconnect">Logout</a></li>
</ul>
Expand Down
37 changes: 37 additions & 0 deletions Views/game.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!doctype html>
<html>
<head>

<link rel="stylesheet" type="text/css" href="../public/game.css">
<title>Game</title>

</head>
<body>
<div class="nav-bar">
<ul class="horizontal">
<li><a class="active">Welcome {{ user.getUserName() }}</a></li>

<li><a href="{{ url }}/chat">Chat</a></li>



<li class="rightli" style="float:right"><a href="{{ url }}/deconnect">Logout</a></li>
</ul>
</div>
<div id="cont">
<p> Welcome to your favorite games party <strong>Battleship </strong> </p>

<p style="font-family: Times New Roman;">Find the 17 batteships, your score will be displayed at the end of the game, have fun</p>

<div id="grilleDeJeux">
</div>
<p id="score" > </p>
</div>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="../public/game.js"></script>

</div>
</body>
</html>
2 changes: 1 addition & 1 deletion Views/login.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

<script>
function infos(){
alert('Hi this site is realized by a group of students of Supinfo Paris, if you encounter a problem you can contact us at any time on [email protected]');
alert('Hi this site is realized by a group of students of Supinfo Paris, if you encounter a problem you can contact us at any time on [email protected], The two students Chakib and Samy deal with the development part of the application, jeremy takes care of the management and Sarah keeps the business');
}
</script>

Expand Down
6 changes: 0 additions & 6 deletions Views/zzz.html

This file was deleted.

23 changes: 0 additions & 23 deletions app.js

This file was deleted.

25 changes: 0 additions & 25 deletions index.html

This file was deleted.

15 changes: 15 additions & 0 deletions newServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ app.get('/chat',function (req,res) {
}
});

//game
app.get('/game',function (req,res) {
sess = req.session;

if(sess.email) {
var user = new User();
user.setEmail(sess.email);
user.setPassword(sess.password);
user.setUserName(sess.username);

res.render('game.html.twig', {url : generateUrl(req) ,user : user });
}else{
res.redirect( generateUrl(req) + '/login');
}
});



Expand Down
58 changes: 58 additions & 0 deletions public/game.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
@CHARSET "UTF-8";
#cont {

margin: 2% ;
width: 70%;
}

ul.horizontal {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #3498DB;
border: 3px solid;
}

ul.horizontal li {
float: left;
}

ul.horizontal li a {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

ul.horizontal li a:hover:not(.active) {
background-color: #000;
}

ul.horizontal li a.active {
background-color:#4CAF50;
}

#grilleDeJeux {
position:relative;
margin-left: auto;
margin-right: auto;
width:15%;

}

#grilleDeJeux p {
position:absolute;
width:40px;
height:40px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #f6f8f9;
border: 1px solid #ddd;

}



157 changes: 157 additions & 0 deletions public/game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/**
* Created by macbookpro on 26/06/2017.
*/

/**
*
*/

$(document).ready(function(){

var score = 0;
var conteneur = document.getElementById("grilleDeJeux");

//construction de la grille
for (i = 0; i < 10; i++) {
for (j = 0; j < 10; j++) {
var carre = document.createElement("p");
conteneur.appendChild(carre);
carre.id = 's' + j + i;

carre.style.top = j * 40 + 'px';
carre.style.left = i * 40 + 'px';
}
}

var test1 = 1;
var test2 = 1;
var test3 = 1;
var test4 = 1;
var test5 = 1;

var jeux = [
[a(),0,a(),a(),0,a(),a(),a(),0,a()],
[a(),0,a(),a(),a(),0,a(),a(),a(),0],
[b(),0,b(),b(),0,b(),0,b(),b(),b()],
[b(),b(),0,b(),b(),b(),0,b(),0,b()],
[c(),c(),0,c(),c(),c(),0,c(),0,c()],
[c(),c(),0,c(),c(),c(),0,c(),c(),0],
[0,d(),0,d(),d(),0,d(),d(),d(),d()],
[d(),d(),d(),0,d(),0,d(),0,d(),d()],
[e(),0,0,e(),e(),0,e(),e(),e(),e()],
[e(),e(),e(),e(),0,e(),0,e(),0,e()]
];
//la logique des cellule
function a(){
var a = [1, 0][Math.floor(Math.random() * 2)];
if(test1 < 4){
if(a == 1){
test1++ ;
return a;
}else {
return a;
}
}else {
return 0;
}
}

function b(){
var a = [1, 0][Math.floor(Math.random() * 2)];
if(test2 < 5){
if(a == 1){
test2++ ;
return a;
}else {
return a;
}
}else {
return 0;
}
}

function c(){
var a = [1, 0][Math.floor(Math.random() * 2)];
if(test3 < 4){
if(a == 1){
test3++ ;
return a;
}else {
return a;
}
}else {
return 0;
}
}

function d(){
var a = [1, 0][Math.floor(Math.random() * 2)];
if(test4 < 4){
if(a == 1){
test4++ ;
return a;
}else {
return a;
}
}else {
return 0;
}
}

function e(){
var a = [1, 0][Math.floor(Math.random() * 2)];
if(test5 < 5){
if(a == 1){
test5++ ;
return a;
}else {
return a;
}
}else {
return 0;
}
}

var nombrePrises = 0;

//evenement
conteneur.addEventListener("click", logic, false);

//la logique du jeux
function logic(e) {

if (e.target !== e.currentTarget) {

var ligne = e.target.id.substring(1,2);
var colonne = e.target.id.substring(2,3);

if (jeux[ligne][colonne] == 0) {
e.target.style.background = '#bbb';

jeux[ligne][colonne] = 3;
score++;

} else if (jeux[ligne][colonne] == 1) {
e.target.style.background = 'red';

jeux[ligne][colonne] = 2;
score++;

nombrePrises++;
//fin de la partie
if (nombrePrises == 17) {
alert("All enemy battleships have been defeated! You win!");
alert('your score is '+score+' click');
$('#score').css('text-align', 'left').css('font-size', '150%').css('color', 'green');
$('#score').text('your win after '+score+' clicks');
}

// en cas de click une deuxieme fois dans une cellule selectionnée
} else if (jeux[ligne][colonne] > 1) {
alert("Stop wasting your torpedos! You already fired at this location.");
}
}
e.stopPropagation();
}

});
Binary file removed public/icon.png
Binary file not shown.
2 changes: 1 addition & 1 deletion public/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $(document).ready(function() {
});

$('#infos').on('click', function () {
alert('Hi this site is realized by a group of students of Supinfo Paris, if you encounter a problem you can contact us at any time on [email protected]');
alert('Hi this site is realized by a group of students of Supinfo Paris, if you encounter a problem you can contact us at any time on [email protected], The two students Chakib and Samy deal with the development part of the application, jeremy takes care of the management and Sarah keeps the business');
})


Expand Down
Binary file removed xxx/.DS_Store
Binary file not shown.
Loading

0 comments on commit 5ad4fb2

Please sign in to comment.