Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Jorge Rubiano Jorger

🎯
Focusing
Block or report user

Report or block Jorger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View server.js
"use strict";
const availableUsers = [];
const rooms = [];
/**
* Socket.IO on connect event
* @param {Socket} socket
*/
module.exports = {
io: socket => {
View inferAttack.js
/**
* Inferir un ataque teniendo posiciones conocidas.
* @param {*} board
*/
const inferAttack = board => {
const boardSize = DIMENSION_BOARD - 1;
let newRow = 0;
let newCol = 0;
let inferredAttack = false;
View create board.js
/**
* Crea un nuevo board, estableciendo la posición de las figuras en la misma
* @param {*} showFigure
*/
const createBoard = (showFigure = 1) => {
const board = [...new Array(DIMENSION_BOARD)].map(() =>
new Array(DIMENSION_BOARD).fill(0)
);
const figures = [];
View locateFigure.js
/**
* Establece una posición aleatoria de una figura en el escenario
* @param {*} size
* @param {*} board
*/
const locateFigure = (size, board) => {
const boardSize = DIMENSION_BOARD - 1;
let position = [];
do {
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
View readDataLevels.js
const readDataLevels = data => {
const dataWord = [];
const splitdata = data.split(";");
for (let value of splitdata) {
const splitWorld = value.split("#");
const splitDimensionColors = splitWorld[0].split(",");
const pipesValue = splitWorld[1];
//Partir los valores que se necesitan...
//Guardar los valores de inicio...
const limitPoints = { s: [], e: [] };
View all_connection.js
//Saber si todos están conectados...
if (globalPipes.length === actualWorld[1].length) {
const pipesFinish = numFinalElements.reduce(
(a, s) => a + (s[1] !== 0),
0
);
if (pipesFinish === actualWorld[2].length) {
finishLevel = true;
modalText(true, "Next Level");
}
View check_connection.js
let finalElements = 0;
for (let connected of connectedPipes) {
if (
actualWorld[1][connected][2] !== 1 &&
actualWorld[1][connected][2] !== 2
) {
//Se establece el color...
actualWorld[1][connected][4] = initialColor;
} else {
if (actualWorld[1][connected][2] === 2) {
View getNeighbour.js
const getNeighbour = (pipesInposition, directionPipe) => {
let indexNextPipe = -1;
const posibleDirections = [
[[2], [2], [1, 2, 3], [1, 2], [0, 2]],
[[3], [3], [0, 2, 3], [2, 3], [1, 3]],
[[0], [0], [0, 1, 3], [0, 3], [0, 2]],
[[1], [1], [0, 1, 2], [0, 1], [1, 3]]
][directionPipe];
if (pipesInposition.length !== 0) {
for (let indexPipe of pipesInposition) {
View neighboring_values.js
const getDirections = [
[[1, 0], [0, -1], [-1, 0], [0, 1]], //Figura Inicio (1) y línea (5)
[
//Figura tipo T (3)
[[2, 0, -1, 1, 0, 1, 3], [3, 1, 0, 0, 0, 1, 3], [1, 1, 0, 0, 0, -1, 1]],
[
[3, -1, 0, 2, 1, 0, 0],
[2, 0, -1, 1, -1, 0, 2],
[0, 0, -1, 1, 1, 0, 0]
],
You can’t perform that action at this time.