Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/playground #28

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added staff/pau-deu/.gitkeep
Empty file.
Empty file.
38 changes: 38 additions & 0 deletions staff/pau-deu/playground/bash/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Bash cheat sheet

![markdown logo](https://imgs.search.brave.com/y6lRMl2AgCwRDDyyOxolKbWgacOqYMqBZrdcEluxtAQ/rs:fit:500:0:0:0/g:ce/aHR0cHM6Ly9pY29u/cy52ZXJ5aWNvbi5j/b20vcG5nLzEyOC9h/cHBsaWNhdGlvbi9h/bmltYXVpL21hcmtk/b3duLTgucG5n)

### Commands

### pwd (print working directory)

Show current directory

```sh
pwd
/Users/padeuu
```

### ls (list)

```sh
ls
README.md staff
```

### cd (change directory)

```sh
cd staff/pau-deu/playground
```

### cat (view content within a file)

```sh
cat + nombre archivo
```
### mkdir (make directory)

```sh
mkdir hello-world
```
17 changes: 17 additions & 0 deletions staff/pau-deu/playground/git/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Git

![logo Git](https://imgs.search.brave.com/e27s77A-9-SAaDDBDanyor7fCtRoa1n8fG5ZCrx9UnQ/rs:fit:860:0:0:0/g:ce/aHR0cHM6Ly9tZWRp/YS5saWNkbi5jb20v/ZG1zL2ltYWdlL0M0/RDEyQVFIMG5jLVBx/dzlzdncvYXJ0aWNs/ZS1jb3Zlcl9pbWFn/ZS1zaHJpbmtfNjAw/XzIwMDAvMC8xNjEw/MjIzNTI3MjczP2U9/MjE0NzQ4MzY0NyZ2/PWJldGEmdD1iak8x/NVVYUlFUelRxV3Ny/Y2pzektDWTJQUXRf/Sl9NSXRxTF90WXNl/UDJZ)

## Commands

### git clone (clone a repository)

```sh
git clone https:
```

### git branch (list branches and shows current branch)

```sh
git branch
```
Empty file.
87 changes: 87 additions & 0 deletions staff/pau-deu/playground/hangman/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
console.clear()

var word = prompt("word?");
var matches = [];
var attemps = 0;
var maxAttemps = 6;
var guessCharacter = "";

// Inicia las coincidencias con guiones bajos
for (var i = 0; i < word.length; i++) {
matches[i] = "_";
}

function printMatches() {
var matchesString = "";
for (var i = 0; i < matches.length; i++) {
matchesString += matches[i] + " ";
}
console.log(matchesString);
}

function askCharacter() {
guessCharacter = prompt("Guess a character?");
}

function checkGuessCharacterMatches() {
var checkMatch = false;
// Verifica si el carácter adivinado está en la palabra
for (var j = 0; j < word.length; j++) {
if (word[j] === guessCharacter) {
matches[j] = guessCharacter; // Actualiza las coincidencias
checkMatch = true;
}
}
// Si no hay coincidencia, incrementa los intentos
if (!checkMatch) {
attemps++;
console.log("Try again. Attempts: " + attemps);
}
}

// Función para verificar si el jugador ha ganado
function win() {
var isWin = true;
// Verifica si todas las letras han sido adivinadas correctamente
for (var r = 0; r < word.length; r++) {
if (matches[r] !== word[r]) {
isWin = false;
break;
}
}
// Si todas las letras coinciden, el jugador ha ganado
if (isWin) {
alert("You won!");
return true; // Devuelve `true` para indicar que se ganó
}
return false; // Devuelve `false` si no se ha ganado
}

function gameLoop() {
printMatches(); // Muestra el estado actual de las coincidencias

// Bucle del juego: si no has alcanzado los intentos máximos
while (attemps < maxAttemps) {
askCharacter(); // Pide al jugador un carácter
if (guessCharacter === "" || guessCharacter === null) {
throw new Error("Game canceled by user.");
}

checkGuessCharacterMatches(); // Verifica si la letra adivinada es correcta

// Verifica si el jugador ha ganado después de cada intento
if (win()) {
break; // Si ha ganado, rompe el bucle y termina el juego
}

printMatches(); // Imprime las coincidencias después de cada intento

if (attemps === maxAttemps) {
alert("You lost! Try again next time.");
break; // Si alcanza el número máximo de intentos, termina el juego
}
}
}

// Inicia el juego
gameLoop();
4 changes: 4 additions & 0 deletions staff/pau-deu/playground/js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# JS

![logo JS](https://imgs.search.brave.com/FR7MuA8olc09dBXxVLfdhq_B-oIO_adj1UsYi8JKcLQ/rs:fit:860:0:0:0/g:ce/aHR0cHM6Ly9jZG4u/d29ybGR2ZWN0b3Js/b2dvLmNvbS9sb2dv/cy9sb2dvLWphdmFz/Y3JpcHQuc3Zn)