Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dbistuer authored Mar 1, 2019
1 parent 69a957d commit 1b8cae3
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 33 deletions.
Binary file added 3_en_ratlla/img/construccio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3_en_ratlla/img/o.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3_en_ratlla/img/o150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3_en_ratlla/img/tictac.ico
Binary file not shown.
Binary file added 3_en_ratlla/img/tictac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3_en_ratlla/img/x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 3_en_ratlla/img/x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
249 changes: 216 additions & 33 deletions 3_en_ratlla/joc.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Principal</title>
<link href="bootstrap-3/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link rel="shortcut icon" href="tictac.ico"/>
<link rel="shortcut icon" href="img/tictac.ico"/>
<style>
legend{
text-align: center;
Expand All @@ -23,27 +23,57 @@
height: 100%;
}
.esquerra_dreta{
border-left: 1px solid black;
border-right: 1px solid black;
border-left: 5px solid black;
border-right: 5px solid black;

}
.adalt_sota{
border-bottom: 1px solid black;
border-top: 1px solid black;
border-bottom: 5px solid black;
border-top: 5px solid black;
}
td{
height: 150px;
width: 150px;
height: 200px;
width: 200px;
}

.lletra{
font-size:150px;
margin: 0px;
}
</style>
</head>
<body onload="jugadors()">
<br/>
<div class="container">
<legend>A JUGAR =)</legend>
<br/>
<div class="row">
<div class="col-xs-3">
<div class="col-xs-12">
<div class="table-responsive">
<table>
<tbody>
<tr>
<td id="1" class="col-xs-4 text-center" onclick="tictac('1')"><p id="1.1" class='text-center lletra'></p> </td>
<td id="2" class="esquerra_dreta col-xs-4 text-center" onclick="tictac('2')"><p id="2.1" class='text-center lletra'></p></td>
<td id="3" class="col-xs-4 text-center" onclick="tictac('3')"><p id="3.1" class='text-center lletra'></p></td>
</tr>
<tr>
<td id="4" class="adalt_sota col-xs-4 text-center" onclick="tictac('4')"><p id="4.1" class='text-center lletra'></p></td>
<td id="5" class="adalt_sota esquerra_dreta col-xs-4 text-center" onclick="tictac('5')"><p id="5.1" class='text-center lletra'></p></td>
<td id="6" class="adalt_sota col-xs-4 text-center" onclick="tictac('6')"><p id="6.1" class='text-center lletra'></p></td>
</tr>
<tr>
<td id="7" class="col-xs-4 text-center" onclick="tictac('7')"><p id="7.1" class='text-center lletra'></p></td>
<td id="8" class="esquerra_dreta col-xs-4 text-center" onclick="tictac('8')"><p id="8.1" class='text-center lletra'></p></td>
<td id="9" class="col-xs-4 text-center" onclick="tictac('9')"><p id="9.1" class='text-center lletra'></p></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-4">
<span class="label label-success col-xs-12">
<legend>Player 1</legend>
<div class="row">
Expand Down Expand Up @@ -88,30 +118,8 @@
</div>
</span>
</div>
<div class="col-xs-6">
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<td><img src="x150.png"/></td>
<td class="esquerra_dreta"><img src="x150.png"/></td>
<td><img src="x150.png"/></td>
</tr>
<tr>
<td class="adalt_sota"></td>
<td class="adalt_sota esquerra_dreta"></td>
<td class="adalt_sota"></td>
</tr>
<tr>
<td></td>
<td class="esquerra_dreta"></td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-xs-3">
<div class="col-xs-4"></div>
<div class="col-xs-4">
<span class="label label-default col-xs-12">
<legend>Player 2</legend>
<div class="row">
Expand Down Expand Up @@ -157,6 +165,15 @@
</span>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<p>Puntuació J1:</p><p id="guany"></p>
</div>
<div class="col-xs-4"></div>
<div class="col-xs-4">
<p>Puntuació J2:</p><p id="guanyj2"></p>
</div>
</div>
</div>
<script>
function jugadors(){
Expand All @@ -174,6 +191,172 @@
document.getElementById("p2nif").innerHTML = sessionStorage.getItem("j2nif");
document.getElementById("p2email").innerHTML = sessionStorage.getItem("j2email");
}

var x = "<b>X</b>";
var o = "<b>O</b>";
var id = 0;
var sid = ".1";
var contadorJugador = 0;
var taulell = [[0,0,0],
[0,0,0],
[0,0,0]];
var posicioTemp = 0;

if(sessionStorage.getItem("guanyaj1")!=null){
document.getElementById("guany").innerHTML = sessionStorage.getItem("guanyaj1");
}else{
document.getElementById("guany").innerHTML = '0';
}

/*document.getElementById("1").addEventListener("click",clickTaula("1"));
document.getElementById("2").addEventListener("click",clickTaula("2"));
document.getElementById("3").addEventListener("click",clickTaula("3"));
document.getElementById("4").addEventListener("click",clickTaula("4"));
document.getElementById("5").addEventListener("click",clickTaula("5"));
document.getElementById("6").addEventListener("click",clickTaula("6"));
document.getElementById("7").addEventListener("click",clickTaula("7"));
document.getElementById("8").addEventListener("click",clickTaula("8"));
document.getElementById("9").addEventListener("click",clickTaula("9"));
function clickTaula(id){
document.getElementById(id+".1").innerHTML = x;
}*/
/*----------------------------------------------------------------*/


function tictac(id){
if(llocVuid(id)){
if((contadorJugador % 2)== 0)
document.getElementById(id+sid).innerHTML = x;
else
document.getElementById(id+sid).innerHTML = o;

posicionament(id);
comprovarGuanyador();
contadorJugador++;
}else{
alert("Aquest lloc no es vuid, torna a provar.");
}
}

function posicionament(cella){
if(cella<4){
switch(cella){
case '1': posicioTemp =0; break;
case '2': posicioTemp =1; break;
case '3': posicioTemp =2; break;
}
quinJugador(contadorJugador,posicioTemp,0);
}else if(cella<7){
switch(cella){
case '4': posicioTemp =0; break;
case '5': posicioTemp =1; break;
case '6': posicioTemp =2; break;
}
quinJugador(contadorJugador,posicioTemp,1)
}else{
switch(cella){
case '7': posicioTemp =0; break;
case '8': posicioTemp =1; break;
case '9': posicioTemp =2; break;
}
quinJugador(contadorJugador,posicioTemp,2)
}
}
/*si es el jugador 1 = 1 si el 2 = 2*/
function quinJugador(contadorJugador,posicioTemp,index){
if((contadorJugador % 2)== 0)
taulell[index][posicioTemp] = 1;
else
taulell[index][posicioTemp] = 2;
}

function comprovarGuanyador(){
var guanyador = 0;
if (taulell[0][0] == 1 && taulell[0][1] == 1 && taulell[0][2] == 1){
guanyador = 1;
}else if (taulell[1][0] == 1 && taulell[1][1] == 1 && taulell[1][2] == 1){
guanyador = 1;
}else if (taulell[2][0] == 1 && taulell[2][1] == 1 && taulell[2][2] == 1){
guanyador = 1;
}else if (taulell[0][0] == 1 && taulell[1][0] == 1 && taulell[2][0] == 1){
guanyador = 1;
}else if (taulell[0][1] == 1 && taulell[1][1] == 1 && taulell[2][1] == 1){
guanyador = 1;
}else if (taulell[0][2] == 1 && taulell[1][2] == 1 && taulell[2][2] == 1){
guanyador = 1;
}else if (taulell[0][0] == 1 && taulell[1][1] == 1 && taulell[2][2] == 1){
guanyador = 1;
}else if (taulell[0][2] == 1 && taulell[1][1] == 1 && taulell[2][0] == 1){
guanyador = 1;
}
if (guanyador == 1){
alert("Has guanyat 1");
if (sessionStorage.getItem('guanyaj1') != null){
var guany = Number(sessionStorage.getItem('guanyaj1'));
guany++;
sessionStorage.setItem('guanyaj1',guany);
window.location.reload(true);
}else{
sessionStorage.setItem('guanyaj1',1);
window.location.reload(true);
}
}
guanyador = 0;
}

function llocVuid(cella){
if(cella<4){
switch(cella){
case '1':
posicioTemp =0;
index = 0;
break;
case '2':
posicioTemp =1;
index = 0;
break;
case '3':
posicioTemp =2;
index = 0;
break;
}
}else if(cella<7){
switch(cella){
case '4':
posicioTemp =0;
index = 1;
break;
case '5':
posicioTemp =1;
index = 1;
break;
case '6':
posicioTemp =2;
index = 1;
break;
}
}else{
switch(cella){
case '7':
posicioTemp =0;
index = 2;
break;
case '8':
posicioTemp =1;
index = 2;
break;
case '9':
posicioTemp =2;
index = 2;
break;
}
}
if(taulell[index][posicioTemp] == 0) return true;
else return false;
}

</script>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="bootstrap-3/js/bootstrap.min.js"></script>
Expand Down

0 comments on commit 1b8cae3

Please sign in to comment.