Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
araujozb authored Jun 10, 2024
1 parent a629c53 commit e0d1f92
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 0 deletions.
Binary file added img/PAmarelo.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 img/PLaranja.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 img/PRoxo.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 img/Peao-Grow-Azul.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 img/Peao-Grow-Verde.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 img/Peao-Grow-Vermelho.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
93 changes: 93 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!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="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://araujozb.github.io/wardice/style.css" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<title>WarDice</title>
</head>

<body>
<div class="limitador">
<div class="container-fluid">
<div class="row">
<div class="col-md-4 offset-md-4 col-sm-6 offset-sm-3">

<div class="card my-3 shadow">
<div class="card-header">
<h2 class="m-0">WarDice</h2>
</div>
<div class="card-body">
<div class="form-group">
<label for="atq">Time que ataca</label>
<div class="row">
<button class="btn btn-atq" style="border: none; padding: 0;" onclick="escolherTime('atq', 'azul')">
<img id="imgAtqAzul" src="https://araujozb.github.io/wardice/img/Peao-Grow-Azul.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('atq', 'vermelho')">
<img src="https://araujozb.github.io/wardice/img/Peao-Grow-Vermelho.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('atq', 'verde')">
<img src="https://araujozb.github.io/wardice/img/Peao-Grow-Verde.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('atq', 'laranja')">
<img src="https://araujozb.github.io/wardice/img/PLaranja.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('atq', 'roxo')">
<img src="https://araujozb.github.io/wardice/img/PRoxo.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('atq', 'amarelo')">
<img src="https://araujozb.github.io/wardice/img/PAmarelo.png" alt="" style="height: 52px;">
</button>

</div>
</div>
<div class="form-group">
<label for="df">Time que defende</label>
<div class="row">
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('df', 'azul')">
<img src="https://araujozb.github.io/wardice/img/Peao-Grow-Azul.png" alt="" style="height: 52px;">
</button>
<button class="btn active" style="border: none; padding: 0;" onclick="escolherTime('df', 'vermelho')">
<img src="https://araujozb.github.io/wardice/img/Peao-Grow-Vermelho.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('df', 'verde')">
<img src="https://araujozb.github.io/wardice/img/Peao-Grow-Verde.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('df', 'laranja')">
<img src="https://araujozb.github.io/wardice/img/PLaranja.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('df', 'roxo')">
<img src="https://araujozb.github.io/wardice/img/PRoxo.png" alt="" style="height: 52px;">
</button>
<button class="btn" style="border: none; padding: 0;" onclick="escolherTime('df', 'amarelo')">
<img src="https://araujozb.github.io/wardice/img/PAmarelo.png" alt="" style="height: 52px;">
</button>

</div>
</div>
<div class="form-group">
<label for="qntAtq">Quantidade de dados do ataque</label>
<input type="number" id="qntAtq" min="1" max="3" value="1" class="form-control" />
</div>
<div class="form-group">
<label for="qntDf">Quantidade de dados da defesa</label>
<input type="number" id="qntDf" min="1" max="3" value="1" class="form-control" />
</div>
<button type="button" class="btn btn-primary" onclick="jogar()">Jogar dados</button>
<div id="result"></div>
</div>
</div>

</div>
</div>
</div>
</div>

<script src="https://araujozb.github.io/wardice/index.js"></script>
</body>
</html>
50 changes: 50 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
let atqColor = "";
let dfColor = "";

function escolherTime(tipo, cor) {

if (tipo === 'atq') {
atqColor = cor;
} else if (tipo === 'df') {
dfColor = cor;
}
console.log(atqColor);
console.log(dfColor);
}
function jogar(){
let atq = atqColor;
let df = dfColor;
let qntAtq = parseInt(document.getElementById("qntAtq").value);
let qntDf = parseInt(document.getElementById("qntDf").value);


let dadosAtq = GerarDado(qntAtq);
let dadosDf = GerarDado(qntDf);

dadosAtq.sort((a, b) => b - a);
dadosDf.sort((a, b) => b - a);

let pAtq = 0;
let pDf = 0;

const menor = dadosDf.length >= dadosAtq.length ? dadosAtq : dadosDf;

for (let i = 0; i < menor.length; i++) {
if (dadosAtq[i] > dadosDf[i]) {
pAtq++;
} else {
pDf++;
}
}

let result = document.getElementById("result");
result.innerHTML = `<p>${pAtq > pDf ? atq : df} venceu!</p> <p>Dados do ${atq}: ${dadosAtq.join(', ')}</p> <p>Dados do ${df}: ${dadosDf.join(', ')}</p>`;

}
function GerarDado(qnt){
let dado = [];
for(let i = 0; i < qnt; i++){
dado.push(Math.floor(Math.random() * 6) + 1);
}
return dado;
}
9 changes: 9 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.limitador {
max-width: 1300px;
margin: 0 auto;
}

img {
max-width: 100%;
}

0 comments on commit e0d1f92

Please sign in to comment.