Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
html-e001
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
Jose Figueredo
html-e001
Commits
2a1fa4c7
Commit
2a1fa4c7
authored
Sep 06, 2020
by
Jose Figueredo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ultima subida
parent
47421b81
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
227 additions
and
0 deletions
+227
-0
tateti/app.js
+142
-0
tateti/estilos.css
+23
-0
tateti/tateti.html
+62
-0
No files found.
tateti/app.js
0 → 100644
View file @
2a1fa4c7
var
contador
=
0
;
var
ganador
=
0
;
var
tablero
=
new
Array
(
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
);
function
reiniciar
(
tabla
){
document
.
getElementById
(
tabla
).
innerHTML
=
""
;
}
function
insertar
(
n
,
event
){
if
(
JuegoFin
(
tablero
))
{
return
;
}
casilla
=
event
.
target
;
if
(
tablero
[
n
-
1
]
==
0
&&
contador
%
2
==
0
){
tablero
[
n
-
1
]
=
1
contador
++
;
casilla
.
innerHTML
=
"X"
;
}
else
if
(
tablero
[
n
-
1
]
==
0
&&
contador
%
2
==
1
)
{
tablero
[
n
-
1
]
=
2
contador
++
;
casilla
.
innerHTML
=
"O"
;
}
if
(
JuegoFin
(
tablero
)
&&
ganador
>
0
){
document
.
getElementById
(
'resultado'
).
innerHTML
=
'El ganador es el jugador '
+
ganador
;
}
}
function
JuegoFin
(
tablero
){
for
(
var
i
=
0
;
i
<
9
;
i
+=
3
)
{
if
(
tablero
[
i
]
===
tablero
[
i
+
1
]
&&
tablero
[
i
]
===
tablero
[
i
+
2
]
&&
tablero
[
i
]
!=
0
)
{
ganador
=
tablero
[
i
];
return
true
;
}
}
for
(
var
i
=
0
;
i
<
3
;
i
++
)
{
if
(
tablero
[
i
]
===
tablero
[
i
+
3
]
&&
tablero
[
i
]
===
tablero
[
i
+
6
]
&&
tablero
[
i
]
!=
0
)
// compara el 0 con el 3 y 6 , simulando una matriz
{
ganador
=
tablero
[
i
];
return
true
;
}
}
if
(
tablero
[
0
]
===
tablero
[
4
]
&&
tablero
[
4
]
==
tablero
[
8
]
&&
tablero
[
0
]
!=
0
)
{
ganador
=
tablero
[
0
];
return
true
;
}
if
(
tablero
[
2
]
===
tablero
[
4
]
&&
tablero
[
2
]
===
tablero
[
6
]
&&
tablero
[
2
]
!=
0
){
ganador
=
tablero
[
2
];
return
true
;
}
if
(
contador
>
8
)
{
document
.
getElementById
(
'resultado'
).
innerHTML
=
'EMPATE'
;
return
true
;
}
return
false
;
}
/*
function insertar(id){
miId= id;
contenido= document.getElementById(miId).value;
console.log(contenido);
}
function i(event) {
var casilla = event.target;
if(comprobar(casilla))
{
if(contador%2===0)
{
casilla.innerHTML = "X";
}
else{
casilla.innerHTML="O";
}
contador++;
}
}
function comprobar (casilla){
if(casilla==="X" || casilla==="O"){
return false;
}
return true;
}*/
\ No newline at end of file
tateti/estilos.css
0 → 100644
View file @
2a1fa4c7
h1
{
text-align
:
center
;
}
div
{
text-align
:
center
;
}
table
{
margin
:
0
auto
;
height
:
200px
;
width
:
200px
;
text-align
:
center
;
/* margin: 30px 0 0 100px;*/
}
\ No newline at end of file
tateti/tateti.html
0 → 100644
View file @
2a1fa4c7
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
rel=
"stylesheet"
href=
"estilos.css"
>
<title>
Document
</title>
</head>
<body>
<h1>
Tateti
</h1>
<div>
<table
id=
"tabla"
border=
"1"
>
<tr>
<td
onclick=
"insertar(1,event)"
id=
"11"
>
*
</td>
<td
onclick=
"insertar(2,event)"
id=
"12"
>
*
</td>
<td
onclick=
"insertar(3,event)"
id=
"13"
>
*
</td>
</tr>
<tr>
<td
onclick=
"insertar(4,event)"
id=
"21"
>
*
</td>
<td
onclick=
"insertar(5,event)"
id=
"22"
>
*
</td>
<td
onclick=
"insertar(6,event)"
id=
"23"
>
*
</td>
</tr>
<tr>
<td
onclick=
"insertar(7,event)"
id=
"31"
>
*
</td>
<td
onclick=
"insertar(8,event)"
id=
"32"
>
*
</td>
<td
onclick=
"insertar(9,event)"
id=
"33"
>
*
</td>
</tr>
</table>
<p>
Los * representas casillas vacias
</p>
<a
href=
"javascript:location.reload()"
>
<button>
Reiniciar
</button></a>
<p
id=
"resultado"
></p>
</div>
<script
src=
"app.js"
>
</script>
</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