This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const COLUMNS = 7, | |
ROWS = 6, | |
EMPTY_SPACE = " ", | |
PLAYER_1 = "o", | |
PLAYER_2 = "x", | |
PLAYER_CPU = PLAYER_2, | |
CONNECT = 4; // <-- Change this and you can play connect 5, connect 3, connect 100 and so on! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table class="table table-bordered"> | |
<thead> | |
<tr> | |
<th v-for="i in COLUMNS"> | |
<button :disabled="!canPlay" @click="makeMove(i)" class="btn btn-warning">Make move | |
here <i class="fa fa-arrow-down"></i></button> | |
</th> | |
</tr> | |
</thead> | |
<tbody> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
td { | |
background-color: #638CFF; | |
border: 0px !important; | |
padding: 5px !important; | |
} | |
.img-player{ | |
max-width: 100px; | |
} | |
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obtenerNumeroAleatorioEnRango = (min, max) => { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const obtenerNumeroAleatorioEnRango = (min, max) => { | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} | |
// Probar con 10 números aleatorios entre 1 y 100 | |
for(let i = 0; i < 9; i++){ | |
const numeroAleatorio = obtenerNumeroAleatorioEnRango(1, 100); | |
console.log("Aleatorio: ", numeroAleatorio); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": 13, | |
"nombre": "Luis", | |
"createdAt": "2020-07-30T04:57:03.202Z", | |
"updatedAt": "2020-07-30T04:57:03.202Z", | |
"oficinaId": 62, | |
"oficina": { | |
"id": 62, | |
"nombre": "Sala", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const trabajadores = await modeloTrabajador.findAll({ | |
// Queremos que incluya la relación "oficina" | |
include: [ | |
{ | |
association: modeloTrabajador.Oficina | |
} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const trabajadores = await modeloTrabajador.findAll({ | |
// Queremos que incluya la relación "oficina" | |
include: [ | |
{ | |
association: modeloTrabajador.Oficina | |
} | |
] | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Nota: es "oficinaId" porque así le llama a la columna Sequelize | |
const trabajadorRegistrado = await modeloTrabajador.create({ | |
"nombre": peticion.body.nombre, | |
"oficinaId": peticion.body.idOficina, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Definimos nuestro modelo | |
class Trabajador extends Model { } | |
Trabajador.init( | |
{ | |
// Los campos del modelo: | |
nombre: DataTypes.STRING, | |
}, | |
{ | |
sequelize: sequelize, | |
modelName: "trabajadores" |