Skip to content

Commit

Permalink
Merge pull request #12 from OZimbres/LLZBranch
Browse files Browse the repository at this point in the history
Llz branch
  • Loading branch information
LoriaLawrenceZ authored Sep 5, 2023
2 parents 9598bc3 + 7c528a0 commit d1f2cdc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions html/jogoDaVelha.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</head>

<body>
<!--Mensagens que apareçeram ao fim da partida-->
<div class="mensagens">
<div class="msg-vitoria hidden">
<h1>X VENCEU!</h1>
Expand All @@ -36,19 +37,22 @@ <h1>

<main>
<aside class="fim">
<!--Contador de vitórias-->
<div class="vitorias">
<h2 class="vitorias-x">X : 0</h2>

<h2 class="vitorias-o">O : 0</h2>
</div>

<!--Botão de Recomeçar-->
<div class="recomecar">
<figure class="recomecar-img-container">
<img src="../assets/imagens/jogoDaVelha/recomecarBtn.png" alt="">
</figure>
<h2>Recomeçar</h2>
</div>

<!--Temporizador de jogador-->
<h2 class="tempo">Tempo: 10</h2>
</aside>

Expand Down
24 changes: 13 additions & 11 deletions js/jogoDaVelha.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ document.addEventListener("DOMContentLoaded", () => {
iniciarCronometro();
}

//Durante o jogo, ao clicar na celula escolhida
cells.forEach(cell => {
const circuloImg = cell.querySelector(".circulo");
const xImg = cell.querySelector(".x");
Expand Down Expand Up @@ -148,28 +149,29 @@ document.addEventListener("DOMContentLoaded", () => {
const cellB = cells[b];
const cellC = cells[c];

let symbolA = "";
let symbolB = "";
let symbolC = "";
let simboloA = "";
let simboloB = "";
let simboloC = "";

//Checar qual o simbolo na celula em questão
if (cellA.querySelector(".x.ativado")) {
symbolA = "X";
simboloA = "X";
} else if (cellA.querySelector(".circulo.ativado")) {
symbolA = "O";
simboloA = "O";
}
if (cellB.querySelector(".x.ativado")) {
symbolB = "X";
simboloB = "X";
} else if (cellB.querySelector(".circulo.ativado")) {
symbolB = "O";
simboloB = "O";
}
if (cellC.querySelector(".x.ativado")) {
symbolC = "X";
simboloC = "X";
} else if (cellC.querySelector(".circulo.ativado")) {
symbolC = "O";
simboloC = "O";
}

if (symbolA === symbolB && symbolB === symbolC && symbolA !== "") {
if(symbolA == "O"){
if (simboloA === simboloB && simboloB === simboloC && simboloA !== "") {
if(simboloA == "O"){
document.querySelector(".msg-vitoria h1").innerHTML = "O VENCEU!";
document.querySelector(".msg-vitoria h1").style.color = "var(--vermelho-pastel)";

Expand Down

0 comments on commit d1f2cdc

Please sign in to comment.