Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
Tateti
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Enzo
Tateti
Commits
d29f90cd
Commit
d29f90cd
authored
Oct 05, 2017
by
Enzo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Se agrego los 3 archivos del Tateti
parents
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
144 additions
and
0 deletions
+144
-0
main.css
+18
-0
main.js
+80
-0
tateti.html
+46
-0
No files found.
main.css
0 → 100644
View file @
d29f90cd
table
{
width
:
200px
;
height
:
200px
;
text-align
:
center
;
border
:
2px
solid
black
;
}
td
{
background-color
:
black
;
color
:
white
;
width
:
32px
;
height
:
32px
;
font-size
:
28px
;
align
:
center
;
}
\ No newline at end of file
main.js
0 → 100644
View file @
d29f90cd
var
jugador
=
1
;
function
resetearJugador
(){
jugador
=
1
;
}
//Cambia el HTML de la celda clickeada a X o O, dependiendo del turno del jugador
function
escribirCelda
(
celdaElegida
){
if
(
celdaElegida
.
innerHTML
.
length
>
0
){
alert
(
"La celda ya fue elegida"
);
return
false
;
}
if
(
jugador
===
1
){
celdaElegida
.
innerHTML
=
"X"
;
jugador
=
2
;
}
else
if
(
jugador
===
2
){
celdaElegida
.
innerHTML
=
"O"
;
jugador
=
1
;
}
verGanador
();
}
//Crea una matriz del tateti, y analiza todas las posiblidades, para saber si hay un ganador.
//Avisa que hay un ganador, si hay
function
verGanador
(){
var
celda1
=
document
.
getElementById
(
"celda1"
);
var
celda2
=
document
.
getElementById
(
"celda2"
);
var
celda3
=
document
.
getElementById
(
"celda3"
);
var
celda4
=
document
.
getElementById
(
"celda4"
);
var
celda5
=
document
.
getElementById
(
"celda5"
);
var
celda6
=
document
.
getElementById
(
"celda6"
);
var
celda7
=
document
.
getElementById
(
"celda7"
);
var
celda8
=
document
.
getElementById
(
"celda8"
);
var
celda9
=
document
.
getElementById
(
"celda9"
);
var
valoresTateti
=
[[
celda1
.
innerHTML
,
celda2
.
innerHTML
,
celda3
.
innerHTML
],
[
celda4
.
innerHTML
,
celda5
.
innerHTML
,
celda6
.
innerHTML
],
[
celda7
.
innerHTML
,
celda8
.
innerHTML
,
celda9
.
innerHTML
]]
//HORIZONTALES
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
if
(
valoresTateti
[
i
][
0
]
===
valoresTateti
[
i
][
1
]
&&
valoresTateti
[
i
][
0
]
===
valoresTateti
[
i
][
2
]){
if
(
valoresTateti
[
i
][
0
]
===
"X"
){
var
ban
=
1
;
alert
(
"Gano el jugador 1"
);
}
else
if
(
valoresTateti
[
i
][
0
]
===
"O"
){
var
ban
=
1
;
alert
(
"Gano el jugador 2"
);
}
}
//VERTICALES
else
if
(
valoresTateti
[
0
][
i
]
===
valoresTateti
[
1
][
i
]
&&
valoresTateti
[
0
][
i
]
===
valoresTateti
[
2
][
i
]){
if
(
valoresTateti
[
0
][
i
]
===
"X"
){
var
ban
=
1
;
alert
(
"Gano el jugador 1"
);
}
else
if
(
valoresTateti
[
0
][
i
]
===
"O"
){
var
ban
=
1
;
alert
(
"Gano el jugador 2"
);
}
}
}
//DIAGONALES
if
(
ban
!=
1
){
if
(
valoresTateti
[
0
][
0
]
===
valoresTateti
[
1
][
1
]
&&
valoresTateti
[
0
][
0
]
===
valoresTateti
[
2
][
2
])
{
if
(
valoresTateti
[
0
][
0
]
===
"X"
){
alert
(
"Gano el jugador 1"
);
}
else
if
(
valoresTateti
[
0
][
0
]
===
"O"
){
alert
(
"Gano el jugador 2"
);
}
}
else
if
(
valoresTateti
[
0
][
2
]
===
valoresTateti
[
1
][
1
]
&&
valoresTateti
[
0
][
2
]
===
valoresTateti
[
2
][
0
])
{
if
(
valoresTateti
[
0
][
2
]
===
"X"
){
alert
(
"Gano el jugador 1"
);
}
else
if
(
valoresTateti
[
0
][
2
]
===
"O"
){
alert
(
"Gano el jugador 2"
);
}
}
}
}
\ No newline at end of file
tateti.html
0 → 100644
View file @
d29f90cd
<html>
<head><title>
Tateti
</title></head>
<link
rel=
"stylesheet"
href=
"main.css"
>
<script
src=
"main.js"
></script>
<script>
//Agarra la celda clickeada, y ejecuta la funcion escribirCelda (que le pasa como parametro la celda elegida)
function
clickCelda
(){
var
idCelda
=
event
.
srcElement
.
id
;
var
celdaElegida
=
document
.
getElementById
(
idCelda
);
escribirCelda
(
celdaElegida
);
}
//Al ser presionado el boton jugar de nuevo, cambia todos los HTML a ""
function
eliminarDatos
(){
for
(
var
i
=
1
;
i
<=
9
;
i
++
)
{
var
idActual
=
"celda"
+
i
;
var
elemento
=
document
.
getElementById
(
idActual
);
console
.
log
(
elemento
);
elemento
.
innerHTML
=
""
;
}
resetearJugador
();
}
</script>
<body>
<h1>
Enzo's Tateti
</h1>
<table>
<tr>
<td
id=
"celda1"
onclick=
"clickCelda();"
></td>
<td
id=
"celda2"
onclick=
"clickCelda();"
></td>
<td
id=
"celda3"
onclick=
"clickCelda();"
></td>
</tr>
<tr>
<td
id=
"celda4"
onclick=
"clickCelda();"
></td>
<td
id=
"celda5"
onclick=
"clickCelda();"
></td>
<td
id=
"celda6"
onclick=
"clickCelda();"
></td>
</tr>
<tr>
<td
id=
"celda7"
onclick=
"clickCelda();"
></td>
<td
id=
"celda8"
onclick=
"clickCelda();"
></td>
<td
id=
"celda9"
onclick=
"clickCelda();"
></td>
</tr>
</table>
<br>
<button
id=
"jugDeNuev"
type=
"button"
onclick=
"eliminarDatos();"
>
Jugar de Nuevo
</button>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment