0% found this document useful (0 votes)
7 views

A Probar

Uploaded by

max.asenjoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

A Probar

Uploaded by

max.asenjoo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 63

// Stats: "Auth" : '["0-Games", "1-Wins", "2-Draws", "3-Losses", "4-Winrate", "5-

Goals", "6-Assists", "7-GK", "8-CS", "9-CS%", "10-Role", "11-Nick"]'

/* VARIABLES */

/* ROOM */

const roomName = "〈𝗙𝗦𝗕𝗟〉⚫🔻| FUTSAL 3v3 |🔻⚫";


const botName = "🤖 Bot FSBL 🤖";
const maxPlayers = 30;
const roomPublic = false;
const geo = [{"lat":-33.4520,"lon":-70.6535,"code":"cl"}];

const room = HBInit({ roomName: roomName, maxPlayers: maxPlayers, public:


roomPublic, playerName: botName, geo: geo[0] });

const scoreLimitClassic = 1;
const scoreLimitBig = 1;
const timeLimitClassic = 1;
const timeLimitBig = 1;

room.setTeamsLock(true);

var adminPassword = "09FSBLMX";


console.log("adminPassword : " + adminPassword);

/* COLORES */

var colorredteam = "#FF0000"; // Definir el color para el equipo rojo


var colorblueteam = "#0000FF"; // Definir el color para el equipo azul
var topscolors = "FFC500"; // Color naranjo especial para esto
var statscolors = "0xFF0400"; // Color rojo stasts
var comandoscolors = "0x31F0CA"; // Color celeste comandos
var errorcolors = "0x1506F7"; // Error color
var golescolor = "0xED8C08"; // Color naranjo
var anuncioscolor = "0xF74643"; // Color rojo
var bienvenidacolor = "0xFFF700"; // Color amarillo

/* TIPO DE LETRAS */

var letranegrita = "bold"; // letra negrita basica


var letranormal = "normal" // letra normal

/* ENLACE DISCORD */

var enlacediscord = "https://discord.gg/TBmyAZxxfV";

/* VARIANTE DISCORD WEBHOOK */

var grabaciones-3v3 =
"https://discord.com/api/webhooks/1226650143483498506/MTGq9uEw9dfZXFflS15s-
h2QqgsJPQ-vScGkHT_4DcP4MR9zgntyJXf5qYyJfKSeOt5t";
var estadosalaslink =
"https://discord.com/api/webhooks/1224469731793436725/4Xae1RWyP9LHD_rDpxTnXw_B2li5c
2XQNIrnHpOawbGs6LAEhcRO6wGk2yXKVH2cfibq";
/* STADIUM */

const playerRadius = 15;


var ballRadius = 6.25;
const triggerDistance = playerRadius + ballRadius + 0.01;

var aloneMap = '{"name":"Futsal No Goals |


FSBL","width":420,"height":200,"spawnDistance":180,"bg":
{"type":"hockey","width":368,"height":171,"kickOffRadius":65,"cornerRadius":0},"ver
texes":[{"x":-368,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-
368,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-368,"y":-
65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-368,"y":-
171,"trait":"ballArea","bCoef":1,"cMask":["ball"]},
{"x":368,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":368,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":368,"y":-
65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":368,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":0,"y":65,"trait":"line"},
{"x":0,"y":-65,"trait":"line"},{"bCoef":1,"trait":"ballArea","x":368,"y":171},
{"bCoef":1,"trait":"ballArea","x":368,"y":-171},
{"bCoef":0,"trait":"line","x":0,"y":171},{"bCoef":0,"trait":"line","x":0,"y":-171},
{"x":0,"y":65,"trait":"line"},{"x":0,"y":-65,"trait":"line"},{"x":377,"y":-
65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":377,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-377,"y":-
65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":-377,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-
377,"y":65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":-
377,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":377,"y":65,"trait":"line","cMask":["ball"],"bCoef":1},
{"x":377,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":0,"y":65,"trait":"line"},{"x":0,"y":-65,"trait":"line"},{"x":-
368.53340356886,"y":-62.053454903872,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":-400.05760771891,"y":-62.053454903872,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":-400.05760771891,"y":64.043361696331,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":-368.53340356886,"y":64.043361696331,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":368.09926357786,"y":63.94882446641,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":400,"y":64,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":400,"y":-61.927767991658,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":368.9681846993,"y":-62.144998272018,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":-368,"y":-
142.37229643041,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":-90},{"x":-
260.90035258157,"y":-
50.168480548544,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},{"x":-
368,"y":-160.81305960678,"bCoef":0.1,"trait":"line","curve":-90},{"x":-
358.5379338963,"y":-171,"bCoef":0.1,"trait":"line","curve":-90},{"x":-
368,"y":141.33175243687,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":-
260.90035258157,"y":49.127936555002,"bCoef":0.1,"trait":"line","color":"F8F8F8","cu
rve":0},{"x":-368,"y":159.77251561324,"bCoef":0.1,"trait":"line","curve":90},{"x":-
358.5379338963,"y":171,"bCoef":0.1,"trait":"line","curve":90},
{"x":368,"y":159.77251561324,"bCoef":0.1,"trait":"line","curve":-90},
{"x":358.36266315432,"y":171,"bCoef":0.1,"trait":"line","curve":-90},{"x":368,"y":-
160.81305960678,"bCoef":0.1,"trait":"line","curve":90},{"x":358.36266315432,"y":-
171,"bCoef":0.1,"trait":"line","curve":90},{"x":368,"y":-
142.37229643041,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":260.72508183959,"y":-
50.168480548544,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":368,"y":141.33175243687,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":-
90},
{"x":260.72508183959,"y":49.127936555002,"bCoef":0.1,"trait":"line","color":"F8F8F8
","curve":-90},{"x":260.72508183959,"y":-
50.168480548544,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},
{"x":260.72508183959,"y":49.127936555002,"bCoef":0.1,"trait":"line","color":"F8F8F8
","curve":0},{"x":-250.86909422732,"y":-
1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":-160.58776903904,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},{"x":-
160.58776903904,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},{"x":-
80.337702205015,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},{"x":-
80.337702205015,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},
{"x":160.41249829706,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},
{"x":160.41249829706,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},
{"x":80.162431463036,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},
{"x":80.162431463036,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},{"x":-
254.88159756902,"y":-171,"bCoef":0.1,"trait":"line"},{"x":-254.88159756902,"y":-
182.09086327183,"bCoef":0.1,"trait":"line"},{"x":-371.91294503531,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":-384.61920561736,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":371.73767429333,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":384.44393487538,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":-
371.91294503531,"y":86.718723029916,"bCoef":0.1,"trait":"line"},{"x":-
384.61920561736,"y":86.718723029916,"bCoef":0.1,"trait":"line"},
{"x":371.73767429333,"y":86.718723029916,"bCoef":0.1,"trait":"line"},
{"x":384.44393487538,"y":86.718723029916,"bCoef":0.1,"trait":"line"},{"x":-
254.88159756902,"y":171,"bCoef":0.1,"trait":"line"},{"x":-
254.88159756902,"y":181.05031927829,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":-171,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":171,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":181.05031927829,"bCoef":0.1,"trait":"line"},
{"x":369,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":1,"vis":false},
{"x":369,"y":-65,"trait":"ballArea","cMask":["ball"],"bCoef":1,"vis":false},{"x":-
370,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":1,"vis":false},{"x":-
370,"y":-65,"trait":"ballArea","cMask":["ball"],"bCoef":1,"vis":false},
{"x":371,"y":-65,"trait":"ballArea","cMask":
["ball"],"bCoef":0,"_selected":"segment"},{"x":371,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":0,"_selected":"segment"},
{"x":371,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":0},
{"x":371,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-
371,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-
371,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-371,"y":-
65,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-371,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":0}],"segments":
[{"v0":0,"v1":1,"trait":"ballArea"},{"v0":2,"v1":3,"trait":"ballArea"},
{"v0":4,"v1":5,"trait":"ballArea"},{"v0":6,"v1":7,"trait":"ballArea"},
{"v0":8,"v1":9,"trait":"line","curve":180,"cGroup":["blueKO"]},
{"v0":8,"v1":9,"trait":"line","curve":-180,"cGroup":["redKO"]},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":1,"v1":0,"cMask":
["ball"],"x":-368},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":5,"v1":4,"cMask":
["ball"],"x":368},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":2,"v1":3,"cMask":
["ball"],"x":-368},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":6,"v1":7,"cMask":
["ball"],"x":368},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":0,"v1":10,"y":171},
{"vis":true,"color":"FFF
FFF","bCoef":1,"trait":"ballArea","v0":3,"v1":11,"y":-171},
{"curve":0,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":12,"v1":13},
{"curve":-180,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":9,"v1":8},
{"curve":180,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":15,"v1":14},
{"curve":0,"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":2,"v1":1},
{"curve":0,"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":6,"v1":5},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":16,"v1":17,"cMask":
["ball"],"x":330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":18,"v1":19,"cMask":
["ball"],"x":-330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":20,"v1":21,"cMask":
["ball"],"x":-330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":22,"v1":23,"cMask":
["ball"],"x":330},{"v0":26,"v1":27,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,-80],"y":-80},
{"v0":27,"v1":28,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","x":-590},
{"v0":28,"v1":29,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,80],"y":80},
{"v0":30,"v1":31,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,-80],"y":-80},
{"v0":31,"v1":32,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","x":-590},
{"v0":32,"v1":33,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,80],"y":80},
{"v0":34,"v1":35,"curve":94.0263701017,"vis":true,"color":"F8F8F8","bCoef":0.1,"tra
it":"line"},
{"v0":37,"v1":36,"curve":86.632306418889,"vis":true,"color":"F8F8F8","bCoef":0.1,"t
rait":"line"},{"v0":38,"v1":39,"curve":-
94.026370101699,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":35,"v1":39,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":41,"v1":40,"curve":-
86.632306418888,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":43,"v1":42,"curve":86.632306418884,"vis":true,"color":"F8F8F8","bCoef":0.1,"t
rait":"line"},{"v0":45,"v1":44,"curve":-
86.632306418899,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":46,"v1":47,"curve":-
94.026370101699,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":48,"v1":49,"curve":94.026370101699,"vis":true,"color":"F8F8F8","bCoef":0.1,"t
rait":"line"},
{"v0":50,"v1":51,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":390},{"v0":53,"v1":52,"curve":-
180.00692920292,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":52,"v1":53,"curve":-
180.00218240614,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":55,"v1":54,"curve":-
179.64823645332,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":54,"v1":55,"curve":-
180.35758668147,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":57,"v1":56,"curve":-
180.02357323962,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":56,"v1":57,"curve":-
180.00924102399,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":59,"v1":58,"curve":-
180.06885755885,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":58,"v1":59,"curve":-
180.02948353257,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":61,"v1":60,"curve":-
179.99869069543,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":60,"v1":61,"curve":-
179.99939258776,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":63,"v1":62,"curve":-
180.08826047163,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":62,"v1":63,"curve":-
179.91186753664,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":65,"v1":64,"curve":-
179.99528711105,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":64,"v1":65,"curve":-
179.99743836358,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":67,"v1":66,"curve":-
179.98626041101,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":66,"v1":67,"curve":-
179.99175181595,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":69,"v1":68,"curve":-
180.04715562398,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":68,"v1":69,"curve":-
179.95294709391,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":71,"v1":70,"curve":-
179.95715750564,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":70,"v1":71,"curve":-
179.89943871875,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":73,"v1":72,"curve":-
179.94773754738,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":72,"v1":73,"curve":-
179.98221351296,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":75,"v1":74,"curve":-
180.4151727218,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":74,"v1":75,"curve":-
179.58764458796,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":77,"v1":76,"curve":-
180.00086646359,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":76,"v1":77,"curve":-
180.01965986376,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":79,"v1":78,"curve":-
180.03532601389,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":78,"v1":79,"curve":-
179.99380079,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":81,"v1":80,"curve":-
180.0044468452,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":80,"v1":81,"curve":-
180.01386779847,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":83,"v1":82,"curve":-
180.05158287563,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":82,"v1":83,"curve":-
180.01212223878,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":84,"v1":85,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240},
{"v0":86,"v1":87,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-120},
{"v0":88,"v1":89,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":240},
{"v0":90,"v1":91,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":120},
{"v0":92,"v1":93,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-381},
{"v0":94,"v1":95,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":123},
{"v0":96,"v1":97,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":123},
{"v0":98,"v1":99,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":-123},
{"v0":100,"v1":101,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":-240,"y":-123},
{"v0":102,"v1":103,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":-381},
{"v0":104,"v1":105,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":381},
{"v0":106,"v1":107,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":381},
{"curve":0,"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":109,"v1":
108,"x":369},
{"curve":0,"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":111,"v1":
110,"x":-370},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":112,"v1":113,"cMask
":["ball"],"x":371,"_selected":true},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":114,"v1":115,"cMask
":["ball"],"x":371},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":116,"v1":117,"cMask
":["ball"],"x":-371},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":118,"v1":119,"cMask
":["ball"],"x":-371}],"goals":[{"p0":[-374.25,-62.053454903872],"p1":[-
374.25,64.043361696331],"team":"red"},{"p0":[374.25,62],"p1":[374.25,-
62],"team":"blue"}],"discs":[{"radius":3.9405255187564,"pos":[-
368.53340356886,64.043361696331],"color":"6666CC","trait":"goalPost","y":80},
{"radius":3.9405255187564,"pos":[-368.53340356886,-
62.053454903872],"color":"6666CC","trait":"goalPost","y":-80,"x":-560},
{"radius":3.9405255187564,"pos":[368.9681846993,-
62.144998272018],"color":"6666CC","trait":"goalPost","y":80},
{"radius":3.9405255187564,"pos":
[368.09926357786,63.94882446641],"color":"6666CC","trait":"goalPost","y":-80,"x":-
560},{"radius":3,"invMass":0,"pos":[-368,-
171],"color":"FFCC00","bCoef":0.1,"trait":"line"},{"radius":3,"invMass":0,"pos":[-
368,171],"color":"FFCC00","bCoef":0.1,"trait":"line"},
{"radius":3,"invMass":0,"pos":
[368,171],"color":"FFCC00","bCoef":0.1,"trait":"line"},
{"radius":3,"invMass":0,"pos":[368,-
171],"color":"FFCC00","bCoef":0.1,"trait":"line"}],"planes":[{"normal":
[0,1],"dist":-171,"trait":"ballArea"},{"normal":[0,-1],"dist":-
171,"trait":"ballArea"},{"normal":[0,1],"dist":-200,"bCoef":0.2,"cMask":["all"]},
{"normal":[0,-1],"dist":-200,"bCoef":0.2,"cMask":["all"]},{"normal":[1,0],"dist":-
420,"bCoef":0.2,"cMask":["all"]},{"normal":[-1,0],"dist":-420,"bCoef":0.2,"cMask":
["all"]}],"traits":{"ballArea":{"vis":false,"bCoef":1,"cMask":["ball"]},"goalPost":
{"radius":8,"invMass":0,"bCoef":1},"goalNet":{"vis":true,"bCoef":0.1,"cMask":
["all"]},"kickOffBarrier":{"vis":false,"bCoef":0.1,"cGroup":
["redKO","blueKO"],"cMask":["red","blue"]},"line":{"vis":true,"bCoef":0,"cMask":
[""]},"arco":{"radius":2,"cMask":["n\/d"],"color":"cccccc"}},"playerPhysics":
{"acceleration":0.11,"kickingAcceleration":0.083,"kickStrength":5,"bCoef":0},"ballP
hysics":{"radius":6.25,"color":"FFCC00","bCoef":0.4,"invMass":1.5,"damping":0.99}}'

var classicMap = '{"name":"Futsal x1 x2 |


FSBL","width":420,"height":200,"spawnDistance":180,"bg":
{"type":"hockey","width":368,"height":171,"kickOffRadius":65,"cornerRadius":0},"ver
texes":[{"x":-368,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-
368,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-368,"y":-
65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-368,"y":-
171,"trait":"ballArea","bCoef":1,"cMask":["ball"]},
{"x":368,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":368,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":368,"y":-
65,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":368,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":0,"y":65,"trait":"kickOffBarrier"},{"x":0,"y":-65,"trait":"line"},
{"bCoef":1,"trait":"ballArea","x":368,"y":171},
{"bCoef":1,"trait":"ballArea","x":368,"y":-171},
{"bCoef":0,"trait":"line","x":0,"y":171},{"bCoef":0,"trait":"line","x":0,"y":-171},
{"x":0,"y":65,"trait":"kickOffBarrier"},{"x":0,"y":-65,"trait":"kickOffBarrier"},
{"x":377,"y":-65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":377,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-377,"y":-
65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":-377,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-
377,"y":65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":-
377,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":377,"y":65,"trait":"line","cMask":["ball"],"bCoef":1},
{"x":377,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":0,"y":199,"trait":"kickOffBarrier"},{"x":0,"y":65,"trait":"kickOffBarrier"},
{"x":0,"y":-65,"trait":"kickOffBarrier"},{"x":0,"y":-199,"trait":"kickOffBarrier"},
{"x":-368.53340356886,"y":-62.053454903872,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":-400.05760771891,"y":-62.053454903872,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":-400.05760771891,"y":64.043361696331,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":-368.53340356886,"y":64.043361696331,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":368.09926357786,"y":63.94882446641,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":400,"y":64,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":400,"y":-61.927767991658,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":368.9681846993,"y":-62.144998272018,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":-368,"y":-
142.37229643041,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":-90},{"x":-
260.90035258157,"y":-
50.168480548544,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},{"x":-
368,"y":-160.81305960678,"bCoef":0.1,"trait":"line","curve":-90},{"x":-
358.5379338963,"y":-171,"bCoef":0.1,"trait":"line","curve":-90},{"x":-
368,"y":141.33175243687,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":-
260.90035258157,"y":49.127936555002,"bCoef":0.1,"trait":"line","color":"F8F8F8","cu
rve":0},{"x":-368,"y":159.77251561324,"bCoef":0.1,"trait":"line","curve":90},{"x":-
358.5379338963,"y":171,"bCoef":0.1,"trait":"line","curve":90},
{"x":368,"y":159.77251561324,"bCoef":0.1,"trait":"line","curve":-90},
{"x":358.36266315432,"y":171,"bCoef":0.1,"trait":"line","curve":-90},{"x":368,"y":-
160.81305960678,"bCoef":0.1,"trait":"line","curve":90},{"x":358.36266315432,"y":-
171,"bCoef":0.1,"trait":"line","curve":90},{"x":368,"y":-
142.37229643041,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":260.72508183959,"y":-
50.168480548544,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":368,"y":141.33175243687,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":-
90},
{"x":260.72508183959,"y":49.127936555002,"bCoef":0.1,"trait":"line","color":"F8F8F8
","curve":-90},{"x":260.72508183959,"y":-
50.168480548544,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},
{"x":260.72508183959,"y":49.127936555002,"bCoef":0.1,"trait":"line","color":"F8F8F8
","curve":0},{"x":-250.86909422732,"y":-
1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},{"x":-
250.86909422732,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},
{"x":250.69382348534,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},
{"x":-185.66591492467,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-1.2295321189394,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":0.18898812539692,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-2.6480523632758,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":1.6075083697333,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":0.89824824756514,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-1.9387922411076,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":1.9621384308174,"bCoef":0.1,"trait":"line","curve":180},
{"x":185.49064418269,"y":-3.0026824243599,"bCoef":0.1,"trait":"line","curve":180},
{"x":-160.58776903904,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},{"x":-
160.58776903904,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},{"x":-
80.337702205015,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},{"x":-
80.337702205015,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},
{"x":160.41249829706,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},
{"x":160.41249829706,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},
{"x":80.162431463036,"y":-159.39453936245,"bCoef":0.1,"trait":"line"},
{"x":80.162431463036,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},{"x":-
254.88159756902,"y":-171,"bCoef":0.1,"trait":"line"},{"x":-254.88159756902,"y":-
182.09086327183,"bCoef":0.1,"trait":"line"},{"x":-371.91294503531,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":-384.61920561736,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":371.73767429333,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":384.44393487538,"y":-
87.759267023458,"bCoef":0.1,"trait":"line"},{"x":-
371.91294503531,"y":86.718723029916,"bCoef":0.1,"trait":"line"},{"x":-
384.61920561736,"y":86.718723029916,"bCoef":0.1,"trait":"line"},
{"x":371.73767429333,"y":86.718723029916,"bCoef":0.1,"trait":"line"},
{"x":384.44393487538,"y":86.718723029916,"bCoef":0.1,"trait":"line"},{"x":-
254.88159756902,"y":171,"bCoef":0.1,"trait":"line"},{"x":-
254.88159756902,"y":181.05031927829,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":-171,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":-182.09086327183,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":171,"bCoef":0.1,"trait":"line"},
{"x":254.70632682704,"y":181.05031927829,"bCoef":0.1,"trait":"line"},{"x":377,"y":-
65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":377,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-377,"y":-
65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":-377,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":-
377,"y":65,"trait":"line","cMask":["ball"],"bCoef":1},{"x":-
377,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},
{"x":377,"y":65,"trait":"line","cMask":["ball"],"bCoef":1},
{"x":377,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":1},{"x":371,"y":-
65,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":371,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":0},
{"x":371,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":0},
{"x":371,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-
371,"y":65,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-
371,"y":171,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-371,"y":-
65,"trait":"ballArea","cMask":["ball"],"bCoef":0},{"x":-371,"y":-
171,"trait":"ballArea","cMask":["ball"],"bCoef":0}],"segments":
[{"v0":0,"v1":1,"trait":"ballArea"},{"v0":2,"v1":3,"trait":"ballArea"},
{"v0":4,"v1":5,"trait":"ballArea"},{"v0":6,"v1":7,"trait":"ballArea"},
{"v0":8,"v1":9,"trait":"kickOffBarrier","curve":180,"cGroup":["blueKO"]},
{"v0":8,"v1":9,"trait":"kickOffBarrier","curve":-180,"cGroup":["redKO"]},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":1,"v1":0,"cMask":
["ball"],"x":-368},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":5,"v1":4,"cMask":
["ball"],"x":368}
,{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":2,"v1":3,"cMask":
["ball"],"x":-368},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":6,"v1":7,"cMask":
["ball"],"x":368},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":0,"v1":10,"y":171},
{"vis":true,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":3,"v1":11,"y":-171},
{"curve":0,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":12,"v1":13},
{"curve":-180,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":9,"v1":8},
{"curve":180,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":15,"v1":14},
{"curve":0,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":2,"v1":1},
{"curve":0,"vis":true,"color":"FFFFFF","bCoef":0,"trait":"line","v0":6,"v1":5},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":16,"v1":17,"cMask":
["ball"],"x":330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":18,"v1":19,"cMask":
["ball"],"x":-330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":20,"v1":21,"cMask":
["ball"],"x":-330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":22,"v1":23,"cMask":
["ball"],"x":330},{"v0":24,"v1":25,"trait":"kickOffBarrier"},
{"v0":26,"v1":27,"trait":"kickOffBarrier"},
{"v0":28,"v1":29,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,-80],"y":-80},
{"v0":29,"v1":30,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","x":-590},
{"v0":30,"v1":31,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,80],"y":80},
{"v0":32,"v1":33,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,-80],"y":-80},
{"v0":33,"v1":34,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","x":-590},
{"v0":34,"v1":35,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,80],"y":80},
{"v0":36,"v1":37,"curve":94.0263701017,"vis":true,"color":"F8F8F8","bCoef":0.1,"tra
it":"line"},
{"v0":39,"v1":38,"curve":86.632306418889,"vis":true,"color":"F8F8F8","bCoef":0.1,"t
rait":"line"},{"v0":40,"v1":41,"curve":-
94.026370101699,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":37,"v1":41,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":43,"v1":42,"curve":-
86.632306418888,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":45,"v1":44,"curve":86.632306418884,"vis":true,"color":"F8F8F8","bCoef":0.1,"t
rait":"line"},{"v0":47,"v1":46,"curve":-
86.632306418899,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":48,"v1":49,"curve":-
94.026370101699,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":50,"v1":51,"curve":94.026370101699,"vis":true,"color":"F8F8F8","bCoef":0.1,"t
rait":"line"},
{"v0":52,"v1":53,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":390},{"v0":55,"v1":54,"curve":-
180.00692920292,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":54,"v1":55,"curve":-
180.00218240614,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":57,"v1":56,"curve":-
179.64823645332,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":56,"v1":57,"curve":-
180.35758668147,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":59,"v1":58,"curve":-
180.02357323962,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":58,"v1":59,"curve":-
180.00924102399,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":61,"v1":60,"curve":-
180.06885755885,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":60,"v1":61,"curve":-
180.02948353257,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-375},
{"v0":63,"v1":62,"curve":-
179.99869069543,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":62,"v1":63,"curve":-
179.99939258776,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":65,"v1":64,"curve":-
180.08826047163,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":64,"v1":65,"curve":-
179.91186753664,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":67,"v1":66,"curve":-
179.99528711105,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":66,"v1":67,"curve":-
179.99743836358,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":69,"v1":68,"curve":-
179.98626041101,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":68,"v1":69,"curve":-
179.99175181595,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":375},
{"v0":71,"v1":70,"curve":-
180.04715562398,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":70,"v1":71,"curve":-
179.95294709391,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":73,"v1":72,"curve":-
179.95715750564,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":72,"v1":73,"curve":-
179.89943871875,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":75,"v1":74,"curve":-
179.94773754738,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":74,"v1":75,"curve":-
179.98221351296,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":77,"v1":76,"curve":-
180.4151727218,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":76,"v1":77,"curve":-
179.58764458796,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":-277.5},
{"v0":79,"v1":78,"curve":-
180.00086646359,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":78,"v1":79,"curve":-
180.01965986376,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":81,"v1":80,"curve":-
180.03532601389,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":80,"v1":81,"curve":-
179.99380079,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":83,"v1":82,"curve":-
180.0044468452,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":82,"v1":83,"curve":-
180.01386779847,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":85,"v1":84,"curve":-
180.05158287563,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":84,"v1":85,"curve":-
180.01212223878,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","x":277.5},
{"v0":86,"v1":87,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240},
{"v0":88,"v1":89,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-120},
{"v0":90,"v1":91,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":240},
{"v0":92,"v1":93,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":120},
{"v0":94,"v1":95,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-381},
{"v0":96,"v1":97,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":123},
{"v0":98,"v1":99,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":123},
{"v0":100,"v1":101,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":-240,"y":-123},
{"v0":102,"v1":103,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":-240,"y":-123},
{"v0":104,"v1":105,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":-381},
{"v0":106,"v1":107,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":381},
{"v0":108,"v1":109,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":381},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":110,"v1":111,"cMask
":["ball"],"x":330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":112,"v1":113,"cMask
":["ball"],"x":-330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":114,"v1":115,"cMask
":["ball"],"x":-330},
{"vis":false,"color":"FFFFFF","bCoef":1,"trait":"ballArea","v0":116,"v1":117,"cMask
":["ball"],"x":330},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":118,"v1":119,"cMask
":["ball"],"x":371},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":120,"v1":121,"cMask
":["ball"],"x":371},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":122,"v1":123,"cMask
":["ball"],"x":-371},
{"vis":false,"color":"FFFFFF","bCoef":0,"trait":"ballArea","v0":124,"v1":125,"cMask
":["ball"],"x":-371}],"goals":[{"p0":[-374.25,-62.053454903872],"p1":[-
374.25,64.043361696331],"team":"red"},{"p0":[374.25,62],"p1":[374.25,-
62],"team":"blue"}],"discs":[{"radius":3.9405255187564,"pos":[-
368.53340356886,64.043361696331],"color":"6666CC","trait":"goalPost","y":80},
{"radius":3.9405255187564,"pos":[-368.53340356886,-
62.053454903872],"color":"6666CC","trait":"goalPost","y":-80,"x":-560},
{"radius":3.9405255187564,"pos":[368.9681846993,-
62.144998272018],"color":"6666CC","trait":"goalPost","y":80},
{"radius":3.9405255187564,"pos":
[368.09926357786,63.94882446641],"color":"6666CC","trait":"goalPost","y":-80,"x":-
560},{"radius":3,"invMass":0,"pos":[-368,-
171],"color":"FFCC00","bCoef":0.1,"trait":"line"},{"radius":3,"invMass":0,"pos":[-
368,171],"color":"FFCC00","bCoef":0.1,"trait":"line"},
{"radius":3,"invMass":0,"pos":
[368,171],"color":"FFCC00","bCoef":0.1,"trait":"line"},
{"radius":3,"invMass":0,"pos":[368,-
171],"color":"FFCC00","bCoef":0.1,"trait":"line"}],"planes":[{"normal":
[0,1],"dist":-171,"trait":"ballArea"},{"normal":[0,-1],"dist":-
171,"trait":"ballArea"},{"normal":[0,1],"dist":-200,"bCoef":0.2,"cMask":["all"]},
{"normal":[0,-1],"dist":-200,"bCoef":0.2,"cMask":["all"]},{"normal":[1,0],"dist":-
420,"bCoef":0.2,"cMask":["all"]},{"normal":[-1,0],"dist":-420,"bCoef":0.2,"cMask":
["all"]}],"traits":{"ballArea":{"vis":false,"bCoef":1,"cMask":["ball"]},"goalPost":
{"radius":8,"invMass":0,"bCoef":1},"goalNet":{"vis":true,"bCoef":0.1,"cMask":
["all"]},"kickOffBarrier":{"vis":false,"bCoef":0.1,"cGroup":
["redKO","blueKO"],"cMask":["red","blue"]},"line":{"vis":true,"bCoef":0,"cMask":
[""]},"arco":{"radius":2,"cMask":["n\/d"],"color":"cccccc"}},"playerPhysics":
{"acceleration":0.11,"kickingAcceleration":0.083,"kickStrength":5,"b
Coef":0},"ballPhysics":
{"radius":6.25,"color":"FFCC00","bCoef":0.4,"invMass":1.5,"damping":0.99}}'; //
Insert your map for 1v1 and 2v2 here. To get minimum file size, here are the
instructions : 1. Download the map 2. Go to https://cssminifier.com 3. Paste the
result

var bigMap = '{"name":"Futsal x3 |


FSBL","width":620,"height":270,"spawnDistance":350,"bg":
{"type":"hockey","width":550,"height":240,"kickOffRadius":80,"cornerRadius":0},"ver
texes":[{"x":550,"y":240,"trait":"ballArea"},{"x":550,"y":-240,"trait":"ballArea"},
{"x":0,"y":270,"trait":"kickOffBarrier"},
{"x":0,"y":80,"bCoef":0.15,"trait":"kickOffBarrier","color":"F8F8F8","vis":true,"cu
rve":180},{"x":0,"y":-
80,"bCoef":0.15,"trait":"kickOffBarrier","color":"F8F8F8","vis":true,"curve":180},
{"x":0,"y":-270,"trait":"kickOffBarrier"},{"x":-550,"y":-80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":-590,"y":-80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-700,-
80]},{"x":-590,"y":80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":-550,"y":80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[-
700,80]},{"x":550,"y":-80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[700,-
80]},{"x":590,"y":-80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[700,-
80]},{"x":590,"y":80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[700,80]},
{"x":550,"y":80,"cMask":
["red","blue","ball"],"trait":"goalNet","curve":0,"color":"F8F8F8","pos":[700,80]},
{"x":-550,"y":80,"bCoef":1.15,"cMask":
["ball"],"trait":"ballArea","color":"F8F8F8","pos":[-700,80]},{"x":-
550,"y":240,"bCoef":1.15,"cMask":["ball"],"trait":"ballArea","color":"F8F8F8"},
{"x":-550,"y":-80,"bCoef":1.15,"cMask":
["ball"],"trait":"ballArea","color":"F8F8F8","pos":[-700,-80]},{"x":-550,"y":-
240,"bCoef":1.15,"cMask":["ball"],"trait":"ballArea","color":"F8F8F8"},{"x":-
550,"y":240,"bCoef":1,"cMask":["ball"],"trait":"ballArea"},
{"x":550,"y":240,"bCoef":1,"cMask":["ball"],"trait":"ballArea"},
{"x":550,"y":80,"bCoef":1.15,"cMask":["ball"],"trait":"ballArea","pos":[700,80]},
{"x":550,"y":240,"bCoef":1.15,"cMask":["ball"],"trait":"ballArea"},{"x":550,"y":-
240,"bCoef":1.15,"cMask":["ball"],"trait":"ballArea","color":"F8F8F8"},
{"x":550,"y":-80,"bCoef":1.15,"cMask":
["ball"],"trait":"ballArea","color":"F8F8F8","pos":[700,-80]},{"x":550,"y":-
240,"bCoef":0,"cMask":["ball"],"trait":"ballArea"},{"x":550,"y":-
240,"bCoef":0,"cMask":["ball"],"trait":"ballArea"},{"x":-550,"y":-
240,"bCoef":1,"cMask":["ball"],"trait":"ballArea","curve":0},{"x":550,"y":-
240,"bCoef":1,"cMask":["ball"],"trait":"ballArea","curve":0},{"x":0,"y":-
240,"bCoef":0.1,"cMask":["red","blue"],"cGroup":
["redKO","blueKO"],"trait":"kickOffBarrier"},{"x":0,"y":-80,"bCoef":0.1,"cMask":
["red","blue"],"cGroup":["redKO","blueKO"],"trait":"kickOffBarrier"},
{"x":0,"y":80,"bCoef":0.1,"cMask":["red","blue"],"cGroup":
["redKO","blueKO"],"trait":"kickOffBarrier"},{"x":0,"y":240,"bCoef":0.1,"cMask":
["red","blue"],"cGroup":["redKO","blueKO"],"trait":"kickOffBarrier"},{"x":0,"y":-
80,"bCoef":0.1,"cMask":
["red","blue"],"trait":"kickOffBarrier","vis":true,"color":"F8F8F8"},
{"x":0,"y":80,"bCoef":0.1,"cMask":
["red","blue"],"trait":"kickOffBarrier","vis":true,"color":"F8F8F8"},
{"x":0,"y":80,"trait":"kickOffBarrier","color":"F8F8F8","vis":true,"curve":-180},
{"x":0,"y":-80,"trait":"kickOffBarrier","color":"F8F8F8","vis":true,"curve":-180},
{"x":0,"y":80,"trait":"kickOffBarrier","color":"F8F8F8","vis":true,"curve":0},
{"x":0,"y":-80,"trait":"kickOffBarrier","color":"F8F8F8","vis":true,"curve":0},
{"x":-557.5,"y":80,"bCoef":1,"cMask":
["ball"],"trait":"ballArea","curve":0,"vis":false,"pos":[-700,80]},{"x":-
557.5,"y":240,"bCoef":1,"cMask":["ball"],"trait":"ballArea","curve":0,"vis":false},
{"x":-557.5,"y":-240,"bCoef":1,"cMask":
["ball"],"trait":"ballArea","vis":false,"curve":0},{"x":-557.5,"y":-
80,"bCoef":1,"cMask":["ball"],"trait":"ballArea","vis":false,"curve":0,"pos":[-
700,-80]},{"x":557.5,"y":-240,"bCoef":1,"cMask":
["ball"],"trait":"ballArea","vis":false,"curve":0},{"x":557.5,"y":-
80,"bCoef":1,"cMask":["ball"],"trait":"ballArea","vis":false,"curve":0,"pos":[700,-
80]},{"x":557.5,"y":80,"bCoef":1,"cMask":
["ball"],"trait":"ballArea","curve":0,"vis":false,"pos":[700,80]},
{"x":557.5,"y":240,"bCoef":1,"cMask":
["ball"],"trait":"ballArea","curve":0,"vis":false},{"x":0,"y":-
80,"bCoef":0.1,"trait":"line"},{"x":0,"y":80,"bCoef":0.1,"trait":"line"},{"x":-
550,"y":-80,"bCoef":0.1,"trait":"line"},{"x":-
550,"y":80,"bCoef":0.1,"trait":"line"},{"x":550,"y":-
80,"bCoef":0.1,"trait":"line"},{"x":550,"y":80,"bCoef":0.1,"trait":"line"},{"x":-
240,"y":256,"bCoef":0.1,"trait":"line"},{"x":-
120,"y":256,"bCoef":0.1,"trait":"line"},{"x":-240,"y":-
256,"bCoef":0.1,"trait":"line"},{"x":-120,"y":-224,"bCoef":0.1,"trait":"line"},
{"x":-120,"y":-256,"bCoef":0.1,"trait":"line"},
{"x":240,"y":256,"bCoef":0.1,"trait":"line"},
{"x":120,"y":224,"bCoef":0.1,"trait":"line"},
{"x":120,"y":256,"bCoef":0.1,"trait":"line"},{"x":240,"y":-
224,"bCoef":0.1,"trait":"line"},{"x":240,"y":-256,"bCoef":0.1,"trait":"line"},
{"x":120,"y":-224,"bCoef":0.1,"trait":"line"},{"x":120,"y":-
256,"bCoef":0.1,"trait":"line"},{"x":-381,"y":240,"bCoef":0.1,"trait":"line"},
{"x":-381,"y":256,"bCoef":0.1,"trait":"line"},{"x":-
550,"y":200,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":-90},{"x":-
390,"y":70,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},{"x":-
550,"y":226,"bCoef":0.1,"trait":"line","curve":-90},{"x":-
536,"y":240,"bCoef":0.1,"trait":"line","curve":-90},{"x":-550,"y":-
200,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},{"x":-390,"y":-
70,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},{"x":-550,"y":-
226,"bCoef":0.1,"trait":"line","curve":90},{"x":-536,"y":-
240,"bCoef":0.1,"trait":"line","curve":90},{"x":-
556,"y":123,"bCoef":0.1,"trait":"line"},{"x":-
575,"y":123,"bCoef":0.1,"trait":"line"},
{"x":556,"y":123,"bCoef":0.1,"trait":"line"},
{"x":575,"y":123,"bCoef":0.1,"trait":"line"},{"x":-556,"y":-
123,"bCoef":0.1,"trait":"line"},{"x":-575,"y":-123,"bCoef":0.1,"trait":"line"},
{"x":556,"y":-123,"bCoef":0.1,"trait":"line"},{"x":575,"y":-
123,"bCoef":0.1,"trait":"line"},{"x":-381,"y":-240,"bCoef":0.1,"trait":"line"},
{"x":-381,"y":-256,"bCoef":0.1,"trait":"line"},
{"x":381,"y":240,"bCoef":0.1,"trait":"line"},
{"x":381,"y":256,"bCoef":0.1,"trait":"line"},{"x":381,"y":-
240,"bCoef":0.1,"trait":"line"},{"x":381,"y":-256,"bCoef":0.1,"trait":"line"},
{"x":550,"y":-226,"bCoef":0.1,"trait":"line","curve":-90},{"x":536,"y":-
240,"bCoef":0.1,"trait":"line","curve":-90},
{"x":550,"y":226,"bCoef":0.1,"trait":"line","curve":90},
{"x":536,"y":240,"bCoef":0.1,"trait":"line","curve":90},
{"x":550,"y":200,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":390,"y":70,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":90},
{"x":550,"y":-200,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":-90},
{"x":390,"y":-70,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":-90},
{"x":390,"y":70,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},
{"x":390,"y":-70,"bCoef":0.1,"trait":"line","color":"F8F8F8","curve":0},{"x":-
375,"y":1,"bCoef":0.1,"trait":"line","curve":180},{"x":-375,"y":-
1,"bCoef":0.1,"trait":"line","curve":180},{"x":-
375,"y":3,"bCoef":0.1,"trait":"line","curve":180},{"x":-375,"y":-
3,"bCoef":0.1,"trait":"line","curve":180},{"x":-375,"y":-
2,"bCoef":0.1,"trait":"line","curve":180},{"x":-
375,"y":2,"bCoef":0.1,"trait":"line","curve":180},{"x":-375,"y":-
3.5,"bCoef":0.1,"trait":"line","curve":180},{"x":-
375,"y":3.5,"bCoef":0.1,"trait":"line","curve":180},
{"x":375,"y":1,"bCoef":0.1,"trait":"line","curve":180},{"x":375,"y":-
1,"bCoef":0.1,"trait":"line","curve":180},
{"x":375,"y":3,"bCoef":0.1,"trait":"line","curve":180},{"x":375,"y":-
3,"bCoef":0.1,"trait":"line","curve":180},{"x":375,"y":-
2,"bCoef":0.1,"trait":"line","curve":180},
{"x":375,"y":2,"bCoef":0.1,"trait":"line","curve":180},{"x":375,"y":-
3.5,"bCoef":0.1,"trait":"line","curve":180},
{"x":375,"y":3.5,"bCoef":0.1,"trait":"line","curve":180},{"x":-
277.5,"y":1,"bCoef":0.1,"trait":"line","curve":180},{"x":-277.5,"y":-
1,"bCoef":0.1,"trait":"line","curve":180},{"x":-
277.5,"y":3,"bCoef":0.1,"trait":"line","curve":180},{"x":-277.5,"y":-
3,"bCoef":0.1,"trait":"line","curve":180},{"x":-277.5,"y":-
2,"bCoef":0.1,"trait":"line","curve":180},{"x":-
277.5,"y":2,"bCoef":0.1,"trait":"line","curve":180},{"x":-277.5,"y":-
3.5,"bCoef":0.1,"trait":"line","curve":180},{"x":-
277.5,"y":3.5,"bCoef":0.1,"trait":"line","curve":180},
{"x":277.5,"y":1,"bCoef":0.1,"trait":"line","curve":180},{"x":277.5,"y":-
1,"bCoef":0.1,"trait":"line","curve":180},
{"x":277.5,"y":3,"bCoef":0.1,"trait":"line","curve":180},{"x":277.5,"y":-
3,"bCoef":0.1,"trait":"line","curve":180},{"x":277.5,"y":-
2,"bCoef":0.1,"trait":"line","curve":180},
{"x":277.5,"y":2,"bCoef":0.1,"trait":"line","curve":180},{"x":277.5,"y":-
3.5,"bCoef":0.1,"trait":"line","curve":180},
{"x":277.5,"y":3.5,"bCoef":0.1,"trait":"line","curve":180}],"segments":
[{"v0":6,"v1":7,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,-80],"y":-80},
{"v0":7,"v1":8,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","x":-590},
{"v0":8,"v1":9,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[-700,80],"y":80},
{"v0":10,"v1":11,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[700,-80],"y":-80},
{"v0":11,"v1":12,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","x":590},
{"v0":12,"v1":13,"curve":0,"color":"F8F8F8","cMask":
["red","blue","ball"],"trait":"goalNet","pos":[700,80],"y":80},
{"v0":2,"v1":3,"trait":"kickOffBarrier"},
{"v0":3,"v1":4,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.15,"cGroup":
["blueKO"],"trait":"kickOffBarrier"},{"v0":3,"v1":4,"curve":-
180,"vis":true,"color":"F8F8F8","bCoef":0.15,"cGroup":
["redKO"],"trait":"kickOffBarrier"},{"v0":4,"v1":5,"trait":"kickOffBarrier"},
{"v0":14,"v1":15,"vis":true,"color":"F8F8F8","bCoef":1.15,"cMask":
["ball"],"trait":"ballArea","x":-550},
{"v0":16,"v1":17,"vis":true,"color":"F8F8F8","bCoef":1.15,"cMask":
["ball"],"trait":"ballArea","x":-550},{"v0":18,"
v1":19,"vis":true,"color":"F8F8F8","bCoef":1,"cMask":
["ball"],"trait":"ballArea","y":240},
{"v0":20,"v1":21,"vis":true,"color":"F8F8F8","bCoef":1.15,"cMask":
["ball"],"trait":"ballArea","x":550},
{"v0":22,"v1":23,"vis":true,"color":"F8F8F8","bCoef":1.15,"cMask":
["ball"],"trait":"ballArea","x":550},
{"v0":24,"v1":25,"vis":true,"color":"F8F8F8","bCoef":0,"cMask":
["ball"],"trait":"ballArea","x":550,"y":-240},
{"v0":26,"v1":27,"curve":0,"vis":true,"color":"F8F8F8","bCoef":1,"cMask":
["ball"],"trait":"ballArea","y":-240},
{"v0":28,"v1":29,"vis":true,"color":"F8F8F8","bCoef":0.1,"cMask":
["red","blue"],"cGroup":["redKO","blueKO"],"trait":"kickOffBarrier"},
{"v0":30,"v1":31,"vis":true,"color":"F8F8F8","bCoef":0.1,"cMask":
["red","blue"],"cGroup":["redKO","blueKO"],"trait":"kickOffBarrier"},
{"v0":38,"v1":39,"curve":0,"vis":false,"color":"F8F8F8","bCoef":1,"cMask":
["ball"],"trait":"ballArea","x":-557.5},
{"v0":40,"v1":41,"curve":0,"vis":false,"color":"F8F8F8","bCoef":1,"cMask":
["ball"],"trait":"ballArea","x":-557.5},
{"v0":42,"v1":43,"curve":0,"vis":false,"color":"F8F8F8","bCoef":1,"cMask":
["ball"],"trait":"ballArea","x":557.5},
{"v0":44,"v1":45,"curve":0,"vis":false,"color":"F8F8F8","bCoef":1,"cMask":
["ball"],"trait":"ballArea","x":557.5},
{"v0":46,"v1":47,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":0},
{"v0":48,"v1":49,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-550},
{"v0":50,"v1":51,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":550},
{"v0":64,"v1":65,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-381},{"v0":66,"v1":67,"curve":-
90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":69,"v1":68,"curve":-
90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":70,"v1":71,"curve":90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"}
,
{"v0":67,"v1":71,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":73,"v1":72,"curve":90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"}
,
{"v0":74,"v1":75,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":123},
{"v0":76,"v1":77,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":123},
{"v0":78,"v1":79,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":-123},
{"v0":80,"v1":81,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-240,"y":-123},
{"v0":82,"v1":83,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":-381},
{"v0":84,"v1":85,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":381},
{"v0":86,"v1":87,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":381},{"v0":89,"v1":88,"curve":-
90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":91,"v1":90,"curve":90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"}
,
{"v0":92,"v1":93,"curve":90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"}
,{"v0":94,"v1":95,"curve":-
90,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"},
{"v0":96,"v1":97,"curve":0,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line","
x":390},
{"v0":99,"v1":98,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":-375},
{"v0":98,"v1":99,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"line"
,"x":-375},
{"v0":101,"v1":100,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-375},
{"v0":100,"v1":101,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-375},
{"v0":103,"v1":102,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-375},
{"v0":102,"v1":103,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-375},
{"v0":105,"v1":104,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-375},
{"v0":104,"v1":105,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-375},
{"v0":107,"v1":106,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":106,"v1":107,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":109,"v1":108,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":108,"v1":109,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":111,"v1":110,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":110,"v1":111,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":113,"v1":112,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":112,"v1":113,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":375},
{"v0":115,"v1":114,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":114,"v1":115,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":117,"v1":116,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":116,"v1":117,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":119,"v1":118,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":118,"v1":119,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":121,"v1":120,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":120,"v1":121,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":-277.5},
{"v0":123,"v1":122,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5},
{"v0":122,"v1":123,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5},
{"v0":125,"v1":124,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5},
{"v0":124,"v1":125,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5},
{"v0":127,"v1":126,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5},
{"v0":126,"v1":127,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5},
{"v0":129,"v1":128,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5},
{"v0":128,"v1":129,"curve":180,"vis":true,"color":"F8F8F8","bCoef":0.1,"trait":"lin
e","x":277.5}],"goals":[{"p0":[-557.5,-80],"p1":[-557.5,80],"team":"red"},{"p0":
[557.5,80],"p1":[557.5,-80],"team":"blue"}],"discs":[{"radius":5,"pos":[-
550,80],"color":"FF6666","trait":"goalPost","y":80},{"radius":5,"pos":[-550,-
80],"color":"FF6666","trait":"goalPost","y":-80,"x":-560},{"radius":5,"pos":
[550,80],"color":"6666FF","trait":"goalPost","y":80},{"radius":5,"pos":[550,-
80],"color":"6666FF","trait":"goalPost","y":-80},{"radius":3,"invMass":0,"pos":[-
550,240],"color":"FFCC00","bCoef":0.1,"trait":"line"},
{"radius":3,"invMass":0,"pos":[-550,-
240],"color":"FFCC00","bCoef":0.1,"trait":"line"},{"radius":3,"invMass":0,"pos":
[550,-240],"color":"FFCC00","bCoef":0.1,"trait":"line"},
{"radius":3,"invMass":0,"pos":
[550,240],"color":"FFCC00","bCoef":0.1,"trait":"line"}],"planes":[{"normal":
[0,1],"dist":-240,"bCoef":1,"trait":"ballArea","vis":false,"curve":0},{"normal":
[0,-1],"dist":-240,"bCoef":1,"trait":"ballArea"},{"normal":[0,1],"dist":-
270,"bCoef":0.1},{"normal":[0,-1],"dist":-270,"bCoef":0.1},{"normal":[1,0],"dist":-
620,"bCoef":0.1},{"normal":[-1,0],"dist":-620,"bCoef":0.1},{"normal":[1,0],"dist":-
620,"bCoef":0.1,"trait":"ballArea","vis":false,"curve":0},{"normal":[-1,0],"dist":-
620,"bCoef":0.1,"trait":"ballArea","vis":false,"curve":0}],"traits":{"ballArea":
{"vis":false,"bCoef":1,"cMask":["ball"]},"goalPost":
{"radius":8,"invMass":0,"bCoef":0.5},"goalNet":{"vis":true,"bCoef":0.1,"cMask":
["ball"]},"line":{"vis":true,"bCoef":0.1,"cMask":[""]},"kickOffBarrier":
{"vis":false,"bCoef":0.1,"cGroup":["redKO","blueKO"],"cMask":
["red","blue"]}},"playerPhysics":
{"bCoef":0,"acceleration":0.11,"kickingAcceleration":0.083,"kickStrength":5},"ballP
hysics":
{"radius":6.25,"bCoef":0.4,"invMass":1.5,"damping":0.99,"color":"FFCC00"}}'; //
Read above

/* OPTIONS */

var afkLimit = 10;


var drawTimeLimit = 80;
var maxTeamSize = 1; // This works for 1 (you might want to adapt things to remove
some useless stats in 1v1 like assist or cs), 2, 3 or 4
var slowMode = 4;

/* PLAYERS */

const Team = { SPECTATORS: 0, RED: 1, BLUE: 2 };


var extendedP = [];
const eP = { ID: 0, AUTH: 1, CONN: 2, AFK: 3, ACT: 4, GK: 5, MUTE: 6 };
const Ss = { GA: 0, WI: 1, DR: 2, LS: 3, WR: 4, GL: 5, AS: 6, GK: 7, CS: 8, CP: 9,
RL: 10, NK: 11}
var players;
var teamR;
var teamB;
var teamS;

/* GAME */

var lastTeamTouched;
var lastPlayersTouched; // These allow to get good goal notifications (it should be
lastPlayersKicked, waiting on a next update to get better track of shots on target)
var countAFK = false; // Created to get better track of activity
var activePlay = false; // Created to get better track of the possession
var goldenGoal = false;
var SMSet = new Set(); // Set created to get slow mode which is useful in
chooseMode
var banList = []; // Getting track of the bans, so we can unban ppl if we want
/* STATS */

var game;
var GKList = ["",""];
var Rposs = 0;
var Bposs = 0;
var point = [{"x": 0, "y": 0}, {"x": 0, "y": 0}]; // created to get ball speed
var ballSpeed;
var lastWinner = Team.SPECTATORS;
var streak = 0;
var allBlues = []; // This is to count the players who should be counted for the
stats. This includes players who left after the game has started, doesn't include
those who came too late or ...
var allReds = []; // ... those who came in a very unequal game.

/* BALANCE & CHOOSE */

var inChooseMode = false; // This variable enables to distinguish the 2 phases of


playing and choosing which should be dealt with very differently
var redCaptainChoice = "";
var blueCaptainChoice = "";
var chooseTime = 20;
var timeOutCap;

/* AUXILIARY */

var checkTimeVariable = false; // This is created so the chat doesn't get spammed
when a game is ending via timeLimit
var statNumber = 0; // This allows the room to be given stat information every X
minutes
var endGameVariable = false; // This variable with the one below helps distinguish
the cases where games are stopped because they have finished to the ones where
games are stopped due to player movements or resetting teams
var resettingTeams = false;
var capLeft = false;
var statInterval = 6;

loadMap(aloneMap, 0, 0);

/* OBJECTS */

function Goal(time, team, striker, assist) {


this.time = time;
this.team = team;
this.striker = striker;
this.assist = assist;
}

function Game(date, scores, goals) {


this.date = date;
this.scores = scores;
this.goals = goals;
}

/* FUNCTIONS */

/* AUXILIARY FUNCTIONS */

function getRandomInt(max) { // returns a random number from 0 to max-1


return Math.floor(Math.random() * Math.floor(max));
}

function getTime(scores) { // returns the current time of the game


return "[" + Math.floor(Math.floor(scores.time/60)/10).toString() +
Math.floor(Math.floor(scores.time/60)%10).toString() + ":" +
Math.floor(Math.floor(scores.time - (Math.floor(scores.time/60) *
60))/10).toString() + Math.floor(Math.floor(scores.time -
(Math.floor(scores.time/60) * 60))%10).toString() + "]"
}

function pointDistance(p1, p2) {


var d1 = p1.x - p2.x;
var d2 = p1.y - p2.y;
return Math.sqrt(d1 * d1 + d2 * d2);
}

/* BUTTONS */

function topBtn() {
if (teamS.length == 0) {
return;
}
else {
if (teamR.length == teamB.length) {
if (teamS.length > 1) {
room.setPlayerTeam(teamS[0].id, Team.RED);
room.setPlayerTeam(teamS[1].id, Team.BLUE);
}
return;
}
else if (teamR.length < teamB.length) {
room.setPlayerTeam(teamS[0].id, Team.RED);
}
else {
room.setPlayerTeam(teamS[0].id, Team.BLUE);
}
}
}

function randomBtn() {
if (teamS.length == 0) {
return;
}
else {
if (teamR.length == teamB.length) {
if (teamS.length > 1) {
var r = getRandomInt(teamS.length);
room.setPlayerTeam(teamS[r].id, Team.RED);
teamS = teamS.filter((spec) => spec.id != teamS[r].id);
room.setPlayerTeam(teamS[getRandomInt(teamS.length)].id,
Team.BLUE);
}
return;
}
else if (teamR.length < teamB.length) {
room.setPlayerTeam(teamS[getRandomInt(teamS.length)].id,
Team.RED);
}
else {
room.setPlayerTeam(teamS[getRandomInt(teamS.length)].id,
Team.BLUE);
}
}
}

function blueToSpecBtn() {
resettingTeams = true;
setTimeout(() => { resettingTeams = false; }, 100);
for (var i = 0; i < teamB.length; i++) {
room.setPlayerTeam(teamB[teamB.length - 1 - i].id, Team.SPECTATORS);
}
}

function redToSpecBtn() {
resettingTeams = true;
setTimeout(() => { resettingTeams = false; }, 100);
for (var i = 0; i < teamR.length; i++) {
room.setPlayerTeam(teamR[teamR.length - 1 - i].id, Team.SPECTATORS);
}
}

function resetBtn() {
resettingTeams = true;
setTimeout(() => { resettingTeams = false; }, 100);
if (teamR.length <= teamB.length) {
for (var i = 0; i < teamR.length; i++) {
room.setPlayerTeam(teamB[teamB.length - 1 - i].id,
Team.SPECTATORS);
room.setPlayerTeam(teamR[teamR.length - 1 - i].id,
Team.SPECTATORS);
}
for (var i = teamR.length; i < teamB.length; i++) {
room.setPlayerTeam(teamB[teamB.length - 1 - i].id,
Team.SPECTATORS);
}
}
else {
for (var i = 0; i < teamB.length; i++) {
room.setPlayerTeam(teamB[teamB.length - 1 - i].id,
Team.SPECTATORS);
room.setPlayerTeam(teamR[teamR.length - 1 - i].id,
Team.SPECTATORS);
}
for (var i = teamB.length; i < teamR.length; i++) {
room.setPlayerTeam(teamR[teamR.length - 1 - i].id,
Team.SPECTATORS);
}
}
}

function blueToRedBtn() {
resettingTeams = true;
setTimeout(() => { resettingTeams = false; }, 100);
for (var i = 0; i < teamB.length; i++) {
room.setPlayerTeam(teamB[i].id, Team.RED);
}
}
/* GAME FUNCTIONS */

// Evento que se activa cada vez que se recibe un mensaje


room.onMessage = (player, message) => {
const currentTime = new Date().getTime();

// Verificar si ha pasado el tiempo suficiente desde el último mensaje


if (currentTime - lastMessageTime < spamInterval) {
// Si el tiempo entre mensajes es demasiado corto, incrementar el contador
de mensajes
player.spamCounter = (player.spamCounter || 0) + 1;

// Verificar si el jugador ha excedido el límite de mensajes


if (player.spamCounter > spamLimit) {
// Si el jugador ha excedido el límite, advertirle
room.sendChat("¡No envíes mensajes tan rápido, espera 5 segundos para
volver a poner mensajes!");

// Opcionalmente, puedes realizar otras acciones aquí, como expulsar al


jugador
}
} else {
// Si ha pasado suficiente tiempo desde el último mensaje, reiniciar el
contador de mensajes
player.spamCounter = 1;
}

// Actualizar el tiempo del último mensaje


lastMessageTime = currentTime;

function checkTime() {
const scores = room.getScores();
game.scores = scores;
if (Math.abs(scores.time - scores.timeLimit) <= 0.01 && scores.timeLimit !=
0) {
if (scores.red != scores.blue) {
if (checkTimeVariable == false) {
checkTimeVariable = true;
setTimeout(() => { checkTimeVariable = false; }, 3000);
scores.red > scores.blue ? endGame(Team.RED) :
endGame(Team.BLUE);
setTimeout(() => { room.stopGame(); }, 2000);
}
return;
}
goldenGoal = true;
room.sendAnnouncement(" ⌛ GOL DE ORO ⌛ ", null, 0xFF0000,'bold',);
}
if (Math.abs(drawTimeLimit * 60 - scores.time - 60) <= 0.01 && players.length
> 2) {
if (checkTimeVariable == false) {
checkTimeVariable = true;
setTimeout(() => { checkTimeVariable = false; }, 10);
room.sendChat(" ⌛ OK 🙂 ");
}
}
if (Math.abs(scores.time - drawTimeLimit * 60) <= 0.01 && players.length > 2)
{
if (checkTimeVariable == false) {
checkTimeVariable = true;
setTimeout(() => { checkTimeVariable = false; }, 10);
endGame(Team.SPECTATORS);
room.stopGame();
goldenGoal = false;
}
}
}

function endGame(winner) {
// Handles the end of a game - no stopGame function inside
players.length >= 2 * maxTeamSize - 1 ? activateChooseMode() : null;

const scores = room.getScores();


game.scores = scores;

Rposs = Rposs / (Rposs + Bposs);


Bposs = 1 - Rposs;

lastWinner = winner;
endGameVariable = true;

if (winner == Team.RED) {
streak++;

room.sendAnnouncement("◤-----------------------------------------------------------
---------------◥", null, 0xff0000, 'bold');
room.sendAnnouncement("| FINAL DEL PARTIDO
", null, 0xff0000, 'bold');
room.sendAnnouncement("| 🟥 Red Team " + scores.red + "-" +
scores.blue + " Blue Team 🟦 ", null, 0xff0000, 'bold');
room.sendAnnouncement("|🏆 El Red Team lleva " + streak + " victorias
consecutivas", null, 0xff0000, 'normal');

room.sendAnnouncement("◣-----------------------------------------------------------
---------------◢", null, 0xff0000, 'bold');
} else if (winner == Team.BLUE) {
streak = 1;

room.sendAnnouncement("◤-----------------------------------------------------------
---------------◥", null, 0x2200ff, 'bold');
room.sendAnnouncement("| FINAL DEL PARTIDO
", null, 0x2200ff, 'bold');
room.sendAnnouncement("| 🟥 Red Team " + scores.red + "-" +
scores.blue + " Blue Team 🟦 ", null, 0x2200ff, 'bold');

room.sendAnnouncement("◣-----------------------------------------------------------
---------------◢", null, 0x2200ff, 'bold');
} else {
streak = 0;
room.sendChat("💤 ¡FINAL DEL JUEGO, HA SIDO UN EMPATE! 💤");
}

if (scores.red == 0) {
if (scores.blue == 0) {

} else {
}
} else if (scores.blue == 0) {

updateStats();
}

function quickRestart() {
room.stopGame();
setTimeout(() => { room.startGame(); }, 2000);
}

function resumeGame() {
setTimeout(() => { room.startGame(); }, 2000);
setTimeout(() => { room.pauseGame(false); }, 1000);
}

function activateChooseMode() {
inChooseMode = true;
slowMode = 2;
}

function deactivateChooseMode() {
inChooseMode = false;
clearTimeout(timeOutCap);
if (slowMode != 0) {
slowMode = 0;
}
redCaptainChoice = "";
blueCaptainChoice = "";
}

function loadMap(map, scoreLim, timeLim) {


if (map == aloneMap) {
room.setCustomStadium(aloneMap);
}
else if (map == classicMap) {
(classicMap != '') ? room.setCustomStadium(classicMap) :
room.setDefaultStadium("Classic");
}
else if (map == bigMap) {
(bigMap != '.') ? room.setCustomStadium(bigMap) :
room.setDefaultStadium("Big");
}
else {
room.setCustomStadium(map);
}
room.setScoreLimit(scoreLim);
room.setTimeLimit(timeLim);
}

/* PLAYER FUNCTIONS */

function updateTeams() { // update the players' list and all the teams' list
players = room.getPlayerList().filter((player) => player.id != 0 && !
getAFK(player));
teamR = players.filter(p => p.team === Team.RED);
teamB = players.filter(p => p.team === Team.BLUE);
teamS = players.filter(p => p.team === Team.SPECTATORS);
}

function handleInactivity() { // handles inactivity : players will be kicked after


afkLimit
if (countAFK && (teamR.length + teamB.length) > 1) {
for (var i = 0; i < teamR.length ; i++) {
setActivity(teamR[i], getActivity(teamR[i]) + 1);
}
for (var i = 0; i < teamB.length ; i++) {
setActivity(teamB[i], getActivity(teamB[i]) + 1);
}
}
for (var i = 0; i < extendedP.length ; i++) {
if (extendedP[i][eP.ACT] == 60 * (2/3 * afkLimit)) {
room.sendAnnouncement("[PV] ⛔ @" + room.getPlayer(extendedP[i]
[eP.ID]).name + ", si no te mueves o envías un mensaje dentro de los siguientes " +
Math.floor(afkLimit / 3) + " segundos, seras kickeado!", extendedP[i][eP.ID]);
}
if (extendedP[i][eP.ACT] >= 60 * afkLimit) {
extendedP[i][eP.ACT] = 0;
if (room.getScores().time <= afkLimit - 1.5) {
setTimeout(() => { !inChooseMode ? quickRestart() :
room.stopGame(); }, 10);
}
room.kickPlayer(extendedP[i][eP.ID], "AFK", false);
}
}
}
function getAuth(player) {
return extendedP.filter((a) => a[0] == player.id) != null ?
extendedP.filter((a) => a[0] == player.id)[0][eP.AUTH] : null;
}

function getAFK(player) {
return extendedP.filter((a) => a[0] == player.id) != null ?
extendedP.filter((a) => a[0] == player.id)[0][eP.AFK] : null;
}

function setAFK(player, value) {


extendedP.filter((a) => a[0] == player.id).forEach((player) => player[eP.AFK]
= value);
}

function getActivity(player) {
return extendedP.filter((a) => a[0] == player.id) != null ?
extendedP.filter((a) => a[0] == player.id)[0][eP.ACT] : null;
}

function setActivity(player, value) {


extendedP.filter((a) => a[0] == player.id).forEach((player) => player[eP.ACT]
= value);
}

function getGK(player) {
return extendedP.filter((a) => a[0] == player.id) != null ?
extendedP.filter((a) => a[0] == player.id)[0][eP.GK] : null;
}

function setGK(player, value) {


extendedP.filter((a) => a[0] == player.id).forEach((player) => player[eP.GK]
= value);
}

function getMute(player) {
return extendedP.filter((a) => a[0] == player.id) != null ?
extendedP.filter((a) => a[0] == player.id)[0][eP.MUTE] : null;
}

function setMute(player, value) {


extendedP.filter((a) => a[0] == player.id).forEach((player) =>
player[eP.MUTE] = value);
}

/* BALANCE & CHOOSE FUNCTIONS */

function updateRoleOnPlayerIn() {
updateTeams();
if (inChooseMode) {
if (players.length == 6) {
loadMap(bigMap, scoreLimitBig, timeLimitBig);
}
getSpecList(teamR.length <= teamB.length ? teamR[0] : teamB[0]);
}
balanceTeams();
}

function updateRoleOnPlayerOut() {
updateTeams();
if (room.getScores() != null) {
var scores = room.getScores();
if (players.length >= 2 * maxTeamSize && scores.time >= (5/6) *
game.scores.timeLimit && teamR.length != teamB.length) {
if (teamR.length < teamB.length) {
if (scores.blue - scores.red == 2) {
endGame(Team.BLUE);
room.sendAnnouncement("🤖 Abandono detectado. Juego
terminado 🤖");
setTimeout(() => { room.stopGame(); }, 100);
return;
}
}
else {
if (scores.red - scores.blue == 2) {
endGame(Team.RED);
room.sendAnnouncement("🤖 Abandono detectado. Juego
terminado 🤖");
setTimeout(() => { room.stopGame(); }, 100);
return;
}
}
}
}
if (inChooseMode) {
if (players.length == 5) {
loadMap(classicMap, scoreLimitClassic, timeLimitClassic);
}
if (teamR.length == 0 || teamB.length == 0) {
teamR.length == 0 ? room.setPlayerTeam(teamS[0].id, Team.RED) :
room.setPlayerTeam(teamS[0].id, Team.BLUE);
return;
}
if (Math.abs(teamR.length - teamB.length) == teamS.length) {
room.sendAnnouncement(" Equilibrando equipos... ");
deactivateChooseMode();
resumeGame();
var b = teamS.length;
if (teamR.length > teamB.length) {
for (var i = 0 ; i < b ; i++) {
setTimeout(() => { room.setPlayerTeam(teamS[0].id,
Team.BLUE); }, 5*i);
}
}
else {
for (var i = 0 ; i < b ; i++) {
setTimeout(() => { room.setPlayerTeam(teamS[0].id,
Team.RED); }, 5*i);
}
}
return;
}
if (streak == 0 && room.getScores() == null) {
if (Math.abs(teamR.length - teamB.length) == 2) { // if someone
left a team has 2 more players than the other one, put the last chosen guy back in
his place so it's fair
room.sendAnnouncement("🤖 Equilibrando equipos... 🤖");
teamR.length > teamB.length ?
room.setPlayerTeam(teamR[teamR.length - 1].id, Team.SPECTATORS) :
room.setPlayerTeam(teamB[teamB.length - 1].id, Team.SPECTATORS);
}
}
if (teamR.length == teamB.length && teamS.length < 2) {
deactivateChooseMode();
resumeGame();
return;
}
capLeft ? choosePlayer() : getSpecList(teamR.length <= teamB.length ?
teamR[0] : teamB[0]);
}
balanceTeams();
}

function balanceTeams() {
if (!inChooseMode) {
if (players.length == 1 && teamR.length == 0) {
quickRestart();
loadMap(aloneMap, 0, 0);
room.setPlayerTeam(players[0].id, Team.RED);
}
else if (Math.abs(teamR.length - teamB.length) == teamS.length &&
teamS.length > 0) {
const n = Math.abs(teamR.length - teamB.length);
if (players.length == 2) {
quickRestart();
loadMap(classicMap, scoreLimitClassic, timeLimitClassic);
}
if (teamR.length > teamB.length) {
for (var i = 0 ; i < n ; i++) {
room.setPlayerTeam(teamS[i].id, Team.BLUE);
}
}
else {
for (var i = 0 ; i < n ; i++) {
room.setPlayerTeam(teamS[i].id, Team.RED);
}
}
}
else if (Math.abs(teamR.length - teamB.length) > teamS.length) {
const n = Math.abs(teamR.length - teamB.length);
if (players.length == 1) {
quickRestart();
loadMap(aloneMap, 0, 0);
room.setPlayerTeam(players[0].id, Team.RED);
return;
}
else if (players.length == 5) {
quickRestart();
loadMap(classicMap, scoreLimitClassic, timeLimitClassic);
}
if (players.length == maxTeamSize * 2 - 1) {
allReds = [];
allBlues = [];
}
if (teamR.length > teamB.length) {
for (var i = 0 ; i < n ; i++) {
room.setPlayerTeam(teamR[teamR.length - 1 - i].id,
Team.SPECTATORS);
}
}
else {
for (var i = 0 ; i < n ; i++) {
room.setPlayerTeam(teamB[teamB.length - 1 - i].id,
Team.SPECTATORS);
}
}
}
else if (Math.abs(teamR.length - teamB.length) < teamS.length &&
teamR.length != teamB.length) {
room.pauseGame(true);
activateChooseMode();
choosePlayer();
}
else if (teamS.length >= 2 && teamR.length == teamB.length &&
teamR.length < maxTeamSize) {
if (teamR.length == 2) {
quickRestart();
loadMap(bigMap, scoreLimitBig, timeLimitBig);
}
topBtn();
}
}
}

function choosePlayer() {
clearTimeout(timeOutCap);
if (teamR.length <= teamB.length && teamR.length != 0) {
room.sendAnnouncement("[PV] Para elegir un jugador, ingrese su número
de la lista'.", teamR[0].id);
timeOutCap = setTimeout(function (player) { room.sendAnnouncement("[PV]
Date prisa @" + player.name + ", solo quedan " + Number.parseInt(chooseTime / 2) +
" segundos para elegir !", player.id); timeOutCap = setTimeout(function (player)
{ room.kickPlayer(player.id, " ¡No sabe elegir o quizás murió! ", false); },
chooseTime * 500, teamR[0]); }, chooseTime * 1000, teamR[0]);
}
else if (teamB.length < teamR.length && teamB.length != 0) {
room.sendAnnouncement("[PV] Para elegir un jugador, ingrese su número
de la lista'.", teamB[0].id);
timeOutCap = setTimeout(function (player) { room.sendAnnouncement("[PV]
Date prisa @" + player.name + ", solo quedan " + Number.parseInt(chooseTime / 2) +
" segundos para elegir !", player.id); timeOutCap = setTimeout(function (player)
{ room.kickPlayer(player.id, " ¡No sabe elegir o quizás murió! ", false); },
chooseTime * 500, teamB[0]); }, chooseTime * 1000, teamB[0]);
}
if (teamR.length != 0 && teamB.length != 0) getSpecList(teamR.length <=
teamB.length ? teamR[0] : teamB[0]);
}

function getSpecList(player) {
var cstm = "[PV] Jugadores : ";
for (var i = 0 ; i < teamS.length ; i++) {
if (140 - cstm.length < (teamS[i].name + "[" + (i+1) + "], ").length) {
room.sendAnnouncement(cstm, player.id);
cstm = "... ";
}
cstm += teamS[i].name + "[" + (i+1) + "], ";
}
cstm = cstm.substring(0,cstm.length - 2);
cstm += ".";
room.sendAnnouncement(cstm, player.id);
}

/* STATS FUNCTIONS */

function getLastTouchOfTheBall() {
const ballPosition = room.getBallPosition();
updateTeams();
for (var i = 0; i < players.length; i++) {
if (players[i].position != null) {
var distanceToBall = pointDistance(players[i].position,
ballPosition);
if (distanceToBall < triggerDistance) {
!activePlay ? activePlay = true : null;
if (lastTeamTouched == players[i].team &&
lastPlayersTouched[0] != null && lastPlayersTouched[0].id != players[i].id) {
lastPlayersTouched[1] = lastPlayersTouched[0];
lastPlayersTouched[0] = players[i];
}
lastTeamTouched = players[i].team;
}
}
}
}
function getStats() { // gives possession, ball speed and GK of each team
if (activePlay) {
updateTeams();
lastTeamTouched == Team.RED ? Rposs++ : Bposs++;
var ballPosition = room.getBallPosition();
point[1] = point[0];
point[0] = ballPosition;
ballSpeed = (pointDistance(point[0], point[1]) * 60 * 60 * 60)/15000;
var k = [-1, Infinity];
for (var i = 0; i < teamR.length; i++) {
if (teamR[i].position.x < k[1]) {
k[0] = teamR[i];
k[1] = teamR[i].position.x;
}
}
k[0] != -1 ? setGK(k[0], getGK(k[0]) + 1) : null;
k = [-1, -Infinity];
for (var i = 0; i < teamB.length; i++) {
if (teamB[i].position.x > k[1]) {
k[0] = teamB[i];
k[1] = teamB[i].position.x;
}
}
k[0] != -1 ? setGK(k[0], getGK(k[0]) + 1) : null;
findGK();
}
}

function updateStats() {
if (players.length >= 2 * maxTeamSize && (game.scores.time >= (5 / 6) *
game.scores.timeLimit || game.scores.red == game.scores.scoreLimit ||
game.scores.blue == game.scores.scoreLimit) && allReds.length >= maxTeamSize &&
allBlues.length >= maxTeamSize) {
var stats;
for (var i = 0; i < allReds.length; i++) {
localStorage.getItem(getAuth(allReds[i])) ? stats =
JSON.parse(localStorage.getItem(getAuth(allReds[i]))) : stats = [0, 0, 0, 0,
"0.00", 0, 0, 0, 0, "0.00", "player", allReds[i].name];
stats[Ss.GA]++;
lastWinner == Team.RED ? stats[Ss.WI]++ : lastWinner == Team.BLUE
? stats[Ss.LS]++ : stats[Ss.DR]++;
stats[Ss.WR] = (100 * stats[Ss.WI] /
stats[Ss.GA]).toPrecision(3);
localStorage.setItem(getAuth(allReds[i]), JSON.stringify(stats));
}
for (var i = 0; i < allBlues.length; i++) {
localStorage.getItem(getAuth(allBlues[i])) ? stats =
JSON.parse(localStorage.getItem(getAuth(allBlues[i]))) : stats = [0, 0, 0, 0,
"0.00", 0, 0, 0, 0, "0.00", "player", allBlues[i].name];
stats[Ss.GA]++;
lastWinner == Team.BLUE ? stats[Ss.WI]++ : lastWinner == Team.RED
? stats[Ss.LS]++ : stats[Ss.DR]++;
stats[Ss.WR] = (100 * stats[Ss.WI] /
stats[Ss.GA]).toPrecision(3);
localStorage.setItem(getAuth(allBlues[i]),
JSON.stringify(stats));
}
for (var i = 0; i < game.goals.length; i++) {
if (game.goals[i].striker != null) {
if ((allBlues.concat(allReds)).findIndex((player) =>
player.id == game.goals[i].striker.id) != -1) {
stats =
JSON.parse(localStorage.getItem(getAuth(game.goals[i].striker)));
stats[Ss.GL]++;
localStorage.setItem(getAuth(game.goals[i].striker),
JSON.stringify(stats));
}
}
if (game.goals[i].assist != null) {
if ((allBlues.concat(allReds)).findIndex((player) =>
player.name == game.goals[i].assist.name) != -1) {
stats =
JSON.parse(localStorage.getItem(getAuth(game.goals[i].assist)));
stats[Ss.AS]++;
localStorage.setItem(getAuth(game.goals[i].assist),
JSON.stringify(stats));
}
}
}
if (allReds.findIndex((player) => player.id == GKList[0].id) != -1) {
stats = JSON.parse(localStorage.getItem(getAuth(GKList[0])));
stats[Ss.GK]++;
game.scores.blue == 0 ? stats[Ss.CS]++ : null;
stats[Ss.CP] = (100 * stats[Ss.CS] /
stats[Ss.GK]).toPrecision(3);
localStorage.setItem(getAuth(GKList[0]), JSON.stringify(stats));
}
if (allBlues.findIndex((player) => player.id == GKList[1].id) != -1) {
stats = JSON.parse(localStorage.getItem(getAuth(GKList[1])));
stats[Ss.GK]++;
game.scores.red == 0 ? stats[Ss.CS]++ : null;
stats[Ss.CP] = (100 * stats[Ss.CS] /
stats[Ss.GK]).toPrecision(3);
localStorage.setItem(getAuth(GKList[1]), JSON.stringify(stats));
}
}
}

function findGK() {
var tab = [[-1,""], [-1,""]];
for (var i = 0; i < extendedP.length ; i++) {
if (room.getPlayer(extendedP[i][eP.ID]) != null &&
room.getPlayer(extendedP[i][eP.ID]).team == Team.RED) {
if (tab[0][0] < extendedP[i][eP.GK]) {
tab[0][0] = extendedP[i][eP.GK];
tab[0][1] = room.getPlayer(extendedP[i][eP.ID]);
}
}
else if (room.getPlayer(extendedP[i][eP.ID]) != null &&
room.getPlayer(extendedP[i][eP.ID]).team == Team.BLUE) {
if (tab[1][0] < extendedP[i][eP.GK]) {
tab[1][0] = extendedP[i][eP.GK];
tab[1][1] = room.getPlayer(extendedP[i][eP.ID]);
}
}
}
GKList = [tab[0][1], tab[1][1]];
}
setInterval(() => {
var tableau = [];
if (statNumber % 5 == 0) {
Object.keys(localStorage).forEach(function (key) { if (!["player_name",
"view_mode", "geo", "avatar", "player_auth_key"].includes(key))
{ tableau.push([(JSON.parse(localStorage.getItem(key))[Ss.NK]),
(JSON.parse(localStorage.getItem(key))[Ss.GA])]); } });
if (tableau.length < 5) {
return false;
}
tableau.sort(function (a, b) { return b[1] - a[1]; });
room.sendChat("Partidos Jugados> #1 " + tableau[0][0] + ": " +
tableau[0][1] + " #2 " + tableau[1][0] + ": " + tableau[1][1] + " #3 " + tableau[2]
[0] + ": " + tableau[2][1] + " #4 " + tableau[3][0] + ": " + tableau[3][1] + " #5 "
+ tableau[4][0] + ": " + tableau[4][1]);
}
if (statNumber % 5 == 1) {
Object.keys(localStorage).forEach(function (key) { if (!["player_name",
"view_mode", "geo", "avatar", "player_auth_key"].includes(key))
{ tableau.push([(JSON.parse(localStorage.getItem(key))[Ss.NK]),
(JSON.parse(localStorage.getItem(key))[Ss.WI])]); } });
if (tableau.length < 5) {
return false;
}
tableau.sort(function (a, b) { return b[1] - a[1]; });
room.sendChat("Victorias> #1 " + tableau[0][0] + ": " + tableau[0][1] +
" #2 " + tableau[1][0] + ": " + tableau[1][1] + " #3 " + tableau[2][0] + ": " +
tableau[2][1] + " #4 " + tableau[3][0] + ": " + tableau[3][1] + " #5 " + tableau[4]
[0] + ": " + tableau[4][1]);
}
if (statNumber % 5 == 2) {
Object.keys(localStorage).forEach(function (key) { if (!["player_name",
"view_mode", "geo", "avatar", "player_auth_key"].includes(key))
{ tableau.push([(JSON.parse(localStorage.getItem(key))[Ss.NK]),
(JSON.parse(localStorage.getItem(key))[Ss.GL])]); } });
if (tableau.length < 5) {
return false;
}
tableau.sort(function (a, b) { return b[1] - a[1]; });
room.sendChat("Goles> #1 " + tableau[0][0] + ": " + tableau[0][1] + "
#2 " + tableau[1][0] + ": " + tableau[1][1] + " #3 " + tableau[2][0] + ": " +
tableau[2][1] + " #4 " + tableau[3][0] + ": " + tableau[3][1] + " #5 " + tableau[4]
[0] + ": " + tableau[4][1]);
}
if (statNumber % 5 == 3) {
Object.keys(localStorage).forEach(function (key) { if (!["player_name",
"view_mode", "geo", "avatar", "player_auth_key"].includes(key))
{ tableau.push([(JSON.parse(localStorage.getItem(key))[Ss.NK]),
(JSON.parse(localStorage.getItem(key))[Ss.AS])]); } });
if (tableau.length < 5) {
return false;
}
tableau.sort(function (a, b) { return b[1] - a[1]; });
room.sendChat("Asistencias> #1 " + tableau[0][0] + ": " + tableau[0][1]
+ " #2 " + tableau[1][0] + ": " + tableau[1][1] + " #3 " + tableau[2][0] + ": " +
tableau[2][1] + " #4 " + tableau[3][0] + ": " + tableau[3][1] + " #5 " + tableau[4]
[0] + ": " + tableau[4][1]);
}
if (statNumber % 5 == 4) {
Object.keys(localStorage).forEach(function (key) { if (!["player_name",
"view_mode", "geo", "avatar", "player_auth_key"].includes(key))
{ tableau.push([(JSON.parse(localStorage.getItem(key))[Ss.NK]),
(JSON.parse(localStorage.getItem(key))[Ss.CS])]); } });
if (tableau.length < 5) {
return false;
}
tableau.sort(function (a, b) { return b[1] - a[1]; });
room.sendChat("CS> #1 " + tableau[0][0] + ": " + tableau[0][1] + " #2 "
+ tableau[1][0] + ": " + tableau[1][1] + " #3 " + tableau[2][0] + ": " + tableau[2]
[1] + " #4 " + tableau[3][0] + ": " + tableau[3][1] + " #5 " + tableau[4][0] + ": "
+ tableau[4][1]);
}
statNumber++;
}, statInterval * 60 * 1000);

/* EVENTS */

/* PLAYER MOVEMENT */

room.onPlayerJoin = function(player) {
// Extiende la matriz 'extendedP' con información del jugador que se ha unido
extendedP.push([player.id, player.auth, player.conn, false, 0, 0, false]);

// Actualiza el rol del jugador en el juego


updateRoleOnPlayerIn();

room.sendAnnouncement("------------------------------------------------------------
----------------------------------------", player.id, bienvenidacolor,
"letranegrita");
room.sendAnnouncement("| 🔴 𝗕𝗶𝗲𝗻𝘃𝗲𝗻𝗶𝗱𝗼 𝗮 𝗙𝘂𝘁 𝗦𝗽𝗮𝗰𝗲 𝗕𝗹𝗮𝗰𝗸 𝗟𝗲𝗮𝗴𝘂𝗲 🔴 ",
player.id, bienvenidacolor, "letranegrita");
room.sendAnnouncement("| Presiona !ayuda para ver todos los comandos ! ",
player.id, bienvenidacolor, "letranegrita");
room.sendAnnouncement("| Discord: https://discord.gg/TBmyAZxxfV ", player.id,
bienvenidacolor, "letranegrita");
room.sendAnnouncement("| Version: 10.2 ", player.id, bienvenidacolor,
"letranegrita");

room.sendAnnouncement("------------------------------------------------------------
----------------------------------------", player.id, bienvenidacolor,
"letranegrita");

if (localStorage.getItem(player.auth) != null) {
if (JSON.parse(localStorage.getItem(player.auth))[Ss.RL] != "player") {
room.setPlayerAdmin(player.id, true);
room.sendAnnouncement((JSON.parse(localStorage.getItem(player.auth))[Ss.RL]
== "master" ? " El admin " : "Admin ") + player.name + " ha ingresado !", null,
0x00FFFF, 'bold');
}
}
}

room.onPlayerTeamChange = function(changedPlayer, byPlayer) {


if (changedPlayer.id == 0) {
room.setPlayerTeam(0, Team.SPECTATORS);
return;
}
if (getAFK(changedPlayer) && changedPlayer.team != Team.SPECTATORS) {
room.setPlayerTeam(changedPlayer.id, Team.SPECTATORS);
room.sendAnnouncement(changedPlayer.name + " Está AFK ++");
return;
}
updateTeams();
if (room.getScores() != null) {
var scores = room.getScores();
if (changedPlayer.team != Team.SPECTATORS && scores.time <= (3/4) *
scores.timeLimit && Math.abs(scores.blue - scores.red) < 2) {
(changedPlayer.team == Team.RED) ? allReds.push(changedPlayer) :
allBlues.push(changedPlayer);
}
}
if (changedPlayer.team == Team.SPECTATORS) {
setActivity(changedPlayer, 0);
}
if (inChooseMode && resettingTeams == false && byPlayer.id == 0) {
if (Math.abs(teamR.length - teamB.length) == teamS.length) {
deactivateChooseMode();
resumeGame();
var b = teamS.length;
if (teamR.length > teamB.length) {
for (var i = 0 ; i < b ; i++) {
setTimeout(() => { room.setPlayerTeam(teamS[0].id,
Team.BLUE); }, 200*i);
}
}
else {
for (var i = 0 ; i < b ; i++) {
setTimeout(() => { room.setPlayerTeam(teamS[0].id,
Team.RED); }, 200*i);
}
}
return;
}
else if ((teamR.length == maxTeamSize && teamB.length == maxTeamSize)
|| (teamR.length == teamB.length && teamS.length < 2)) {
deactivateChooseMode();
resumeGame();
}
else if (teamR.length <= teamB.length && redCaptainChoice != "") { //
choice remembered
redCaptainChoice == "top" ? room.setPlayerTeam(teamS[0].id,
Team.RED) : redCaptainChoice == "random" ?
room.setPlayerTeam(teamS[getRandomInt(teamS.length)].id, Team.RED) :
room.setPlayerTeam(teamS[teamS.length - 1].id, Team.RED);
return;
}
else if (teamB.length < teamR.length && blueCaptainChoice != "") {
blueCaptainChoice == "top" ? room.setPlayerTeam(teamS[0].id,
Team.BLUE) : blueCaptainChoice == "random" ?
room.setPlayerTeam(teamS[getRandomInt(teamS.length)].id, Team.BLUE) :
room.setPlayerTeam(teamS[teamS.length - 1].id, Team.BLUE);
return;
}
else {
choosePlayer();
}
}
}

room.onPlayerLeave = function(player) {
if (teamR.findIndex((red) => red.id == player.id) == 0 && inChooseMode &&
teamR.length <= teamB.length) {
choosePlayer();
capLeft = true; setTimeout(() => { capLeft = false; }, 10);
}
if (teamB.findIndex((blue) => blue.id == player.id) == 0 && inChooseMode &&
teamB.length < teamR.length) {
choosePlayer();
capLeft = true; setTimeout(() => { capLeft = false; }, 10);
}
setActivity(player, 0);
updateRoleOnPlayerOut();
}

room.onPlayerKicked = function(kickedPlayer, reason, ban, byPlayer) {


ban == true ? banList.push([kickedPlayer.name, kickedPlayer.id]) : null;
}

/* PLAYER ACTIVITY */

function onPlayerChat(player, message) {


// Verifica si el mensaje comienza con "!"
if (message.startsWith('!')) {
// Procesa comandos aquí (agrega lógica para manejar comandos)
const commandHandled = handleCommands(player, message);
if (commandHandled) {
// Si el comando fue manejado, no enviamos el mensaje original en blanco
return false;
}
} else if (teamR.length != 0 && teamB.length != 0 && inChooseMode) {
// Verifica si estamos en el modo de elección y ambos equipos tienen jugadores
if (player.id == teamR[0].id || player.id == teamB[0].id) {
// Verifica si el jugador es uno de los capitanes

if (teamR.length <= teamB.length && player.id == teamR[0].id) {


// Turno del equipo rojo y el capitán rojo está eligiendo
if (["top", "auto"].includes(message[0].toLowerCase())) {
room.setPlayerTeam(teamS[0].id, Team.RED);
redCaptainChoice = "top";
clearTimeout(timeOutCap);
room.sendAnnouncement(player.name + " elegiste Top !");
return false;
} else if (["random", "rand"].includes(message[0].toLowerCase())) {
var r = getRandomInt(teamS.length);
room.setPlayerTeam(teamS[r].id, Team.RED);
redCaptainChoice = "random";
clearTimeout(timeOutCap);
room.sendAnnouncement(player.name + " elegiste Random !");
return false;
} else if (["bottom", "bot"].includes(message[0].toLowerCase())) {
room.setPlayerTeam(teamS[teamS.length - 1].id, Team.RED);
redCaptainChoice = "bottom";
clearTimeout(timeOutCap);
room.sendAnnouncement(player.name + " elegiste Bottom !");
return false;
} else if (!Number.isNaN(Number.parseInt(message[0]))) {
if (Number.parseInt(message[0]) > teamS.length ||
Number.parseInt(message[0]) < 1) {
room.sendAnnouncement("[PV] El número que elegiste es inválido !",
player.id);
return false;
} else {
room.setPlayerTeam(teamS[Number.parseInt(message[0]) - 1].id,
Team.RED);
room.sendAnnouncement(player.name + " eligió a " +
teamS[Number.parseInt(message[0]) - 1].name + " !");
return false;
}
}
}

if (teamR.length > teamB.length && player.id == teamB[0].id) {


// Turno del equipo azul y el capitán azul está eligiendo
if (["top", "auto"].includes(message[0].toLowerCase())) {
room.setPlayerTeam(teamS[0].id, Team.BLUE);
blueCaptainChoice = "top";
clearTimeout(timeOutCap);
room.sendAnnouncement(player.name + " seleccionó Top !");
return false;
} else if (["random", "rand"].includes(message[0].toLowerCase())) {
room.setPlayerTeam(teamS[getRandomInt(teamS.length)].id, Team.BLUE);
blueCaptainChoice = "random";
clearTimeout(timeOutCap);
room.sendAnnouncement(player.name + " seleccionó Random !");
return false;
} else if (["bottom", "bot"].includes(message[0].toLowerCase())) {
room.setPlayerTeam(teamS[teamS.length - 1].id, Team.BLUE);
blueCaptainChoice = "bottom";
clearTimeout(timeOutCap);
room.sendAnnouncement(player.name + " seleccionó Bottom !");
return false;
} else if (!Number.isNaN(Number.parseInt(message[0]))) {
if (Number.parseInt(message[0]) > teamS.length ||
Number.parseInt(message[0]) < 1) {
room.sendAnnouncement("[PV] El número que elegiste es inválido !",
player.id);
return false;
} else {
room.setPlayerTeam(teamS[Number.parseInt(message[0]) - 1].id,
Team.BLUE);
room.sendAnnouncement(player.name + " eligió " +
teamS[Number.parseInt(message[0]) - 1].name + " !");
return false;
}
}
}
}
} else {
let emoji; // Declarar la variable emoji aquí
if (player.team === Team.SPECTATORS) {
emoji = "[⬜] ";
} else if (player.team === Team.BLUE) {
emoji = "[🟦] ";
} else if (player.team === Team.RED) {
emoji = "[🟥] ";
}

var stats;
localStorage.getItem(getAuth(player))
? (stats = JSON.parse(localStorage.getItem(getAuth(player))))
: (stats = [0, 0, 0, 0, "0.00", 0, 0, 0, 0, "0.00"]);
var numVictorias = parseInt(stats[Ss.WI]); // Obtener el número de victorias como
número entero

function obtenerRango(numVictorias) {
let color;

if (numVictorias >= 0 && numVictorias <= 14) {


color = 16764057; // Blanco
return { rango: "Novato", color: color };
} else if (numVictorias >= 15 && numVictorias <= 29) {
color = 16776960; // Amarillo brillante
return { rango: "Principiante", color: color };
} else if (numVictorias >= 30 && numVictorias <= 44) {
color = 16711935; // Verde brillante
return { rango: "Aprendiz", color: color };
} else if (numVictorias >= 45 && numVictorias <= 59) {
color = 65535; // Azul brillante
return { rango: "Novicio", color: color };
} else if (numVictorias >= 60 && numVictorias <= 74) {
color = 65280; // Verde claro brillante
return { rango: "Iniciado", color: color };
} else if (numVictorias >= 75 && numVictorias <= 89) {
color = 16711935; // Verde esmeralda brillante
return { rango: "Entusiasta", color: color };
} else if (numVictorias >= 90 && numVictorias <= 104) {
color = 16776960; // Amarillo brillante
return { rango: "Competente", color: color };
} else if (numVictorias >= 105 && numVictorias <= 119) {
color = 16711680; // Rojo brillante
return { rango: "Habilidoso", color: color };
} else if (numVictorias >= 120 && numVictorias <= 134) {
color = 16764057; // Rosa brillante
return { rango: "Experto", color: color };
} else if (numVictorias >= 135 && numVictorias <= 149) {
color = 4278255360; // Azul real brillante
return { rango: "Maestro", color: color };
} else if (numVictorias >= 150 && numVictorias <= 164) {
color = 16711680; // Azul brillante
return { rango: "Virtuoso", color: color };
} else if (numVictorias >= 165 && numVictorias <= 179) {
color = 255; // Azul oscuro brillante
return { rango: "Profesional", color: color };
} else if (numVictorias >= 180 && numVictorias <= 194) {
color = 65280; // Verde claro brillante
return { rango: "Sobresaliente", color: color };
} else if (numVictorias >= 195 && numVictorias <= 209) {
color = 16711935; // Verde azulado brillante
return { rango: "Destacado", color: color };
} else if (numVictorias >= 210 && numVictorias <= 224) {
color = 16764057; // Rosa brillante
return { rango: "Experimentado", color: color };
} else if (numVictorias >= 225 && numVictorias <= 239) {
color = 16776960; // Amarillo brillante
return { rango: "Avanzado", color: color };
} else if (numVictorias >= 240 && numVictorias <= 254) {
color = 16764057; // Rosa brillante
return { rango: "Sobresaliente", color: color };
} else if (numVictorias >= 255 && numVictorias <= 269) {
color = 4278258049; // Azul real oscuro brillante
return { rango: "Distinguido", color: color };
} else if (numVictorias >= 270 && numVictorias <= 284) {
color = 16711680; // Azul brillante
return { rango: "Excelso", color: color };
} else if (numVictorias >= 285 && numVictorias <= 299) {
color = 255; // Azul oscuro brillante
return { rango: "Eminente", color: color };
} else if (numVictorias >= 300 && numVictorias <= 314) {
color = 65280; // Verde claro brillante
return { rango: "Brillante", color: color };
} else if (numVictorias >= 315 && numVictorias <= 329) {
color = 16711935; // Verde azulado brillante
return { rango: "Destacado", color: color };
} else if (numVictorias >= 330 && numVictorias <= 344) {
color = 16764057; // Rosa brillante
return { rango: "Héroe", color: color };
} else if (numVictorias >= 345 && numVictorias <= 359) {
color = 4278258049; // Azul real oscuro brillante
return { rango: "Máximo", color: color };
} else if (numVictorias >= 360 && numVictorias <= 374) {
color = 65280; // Verde claro brillante
return { rango: "Legendario", color: color };
} else if (numVictorias >= 375 && numVictorias <= 389) {
color = 16711680; // Azul brillante
return { rango: "Ilustre", color: color };
} else if (numVictorias >= 390 && numVictorias <= 404) {
color = 255; // Azul oscuro brillante
return { rango: "Magnífico", color: color };
} else if (numVictorias >= 405 && numVictorias <= 419) {
color = 65280; // Verde claro brillante
return { rango: "Supremo", color: color };
} else if (numVictorias >= 420 && numVictorias <= 434) {
color = 16711935; // Verde azulado brillante
return { rango: "Monarca", color: color };
} else if (numVictorias >= 435 && numVictorias <= 5000) {
color = 8679435; // Celeste brillante
return { rango: "The King", color: color };
} else {
color = 16777215; // Blanco (para casos fuera de rango)
return { rango: "Fuera de rango", color: color };
}
}

var resultado = obtenerRango(numVictorias); // Obtener el rango

// Por ejemplo, puedes verificar otros mensajes y realizar acciones adicionales.

// Accede a las propiedades del objeto resultado para obtener el rango y el color
var rango = resultado.rango;
var color = resultado.color;

room.sendAnnouncement(emoji + "[ " + rango + " ] 👤 " + player.name + ": " +


message,
null,
color,
"bold"
);
return false;
}
}

// Registra la función onPlayerChat para manejar los mensajes de chat de los


jugadores
room.onPlayerChat = onPlayerChat;

// Función para manejar comandos


function handleCommands(player, message) {
message = message.split(/ +/);
if (player.team !== Team.SPECTATORS) {
setActivity(player, 0);
}

if (message[0].toLowerCase() === '!afk') {


if (players.length != 1 && player.team != Team.SPECTATORS) {
if (player.team == Team.RED && streak > 0 && room.getScores() == null) {
room.setPlayerTeam(player.id, Team.SPECTATORS);
} else {
room.sendAnnouncement("No te puedes poner AFK mientras estás en un
equipo.", player.id);
return true; // Indicamos que el comando fue manejado
}
} else if (players.length == 1 && !getAFK(player)) {
room.setPlayerTeam(player.id, Team.SPECTATORS);
}
setAFK(player, !getAFK(player));
room.sendAnnouncement(player.name + (getAFK(player) ? " entró al modo AFK !" :
" salió del modo AFK !"));
getAFK(player) ? updateRoleOnPlayerOut() : updateRoleOnPlayerIn();
return true; // Indicamos que el comando fue manejado
} else if (message[0].toLowerCase() === '!afks' || message[0].toLowerCase() ===
'!afklist') {
var cstm = "[PV] Lista de AFK : ";
for (var i = 0; i < extendedP.length; i++) {
if (room.getPlayer(extendedP[i][eP.ID]) != null &&
getAFK(room.getPlayer(extendedP[i][eP.ID]))) {
if (140 - cstm.length < (room.getPlayer(extendedP[i][eP.ID]).name + ",
").length) {
room.sendAnnouncement(cstm, player.id);
cstm = "... ";
}
cstm += room.getPlayer(extendedP[i][eP.ID]).name + ", ";
}
}
if (cstm == "[PV] Lista de AFK : ") {
room.sendAnnouncement("[PV] No hay nadie en la lista de AFK !", player.id);
return true; // Indicamos que el comando fue manejado
}
cstm = cstm.substring(0, cstm.length - 2);
cstm += ".";
room.sendAnnouncement(cstm, player.id);
return true; // Indicamos que el comando fue manejado
}

if (["!me", "!stats"].includes(message[0].toLowerCase())) {
var stats = localStorage.getItem(getAuth(player)) ?
JSON.parse(localStorage.getItem(getAuth(player))) :
[0, 0, 0, 0, "0.00", 0, 0, 0, 0, "0.00", "player", player.name];

room.sendAnnouncement("◤-----------------------------------------------------------
----------------------------------------------------------◥", null, statscolors,
'letranegrita');
room.sendAnnouncement("| 👤 Stats de " + player.name + "", null,
statscolors, 'letranegrita');
room.sendAnnouncement("| Pj: " + stats[Ss.GA] + " | 🟩 Victorias: " +
stats[Ss.WI] + " | 🟥 Derrotas: " + stats[Ss.LS] + "| ⚽ Goles: " + stats[Ss.GL] + "
| 👟 Asistencias: " + stats[Ss.AS] + "", null, statscolors, 'letranegrita');
room.sendAnnouncement("| 🥅 GK: " + stats[Ss.GK] + " | 🥅🚫 Porterias en
cero: " + stats[Ss.CS] + "", null, statscolors, 'letranegrita');

room.sendAnnouncement("◣-----------------------------------------------------------
----------------------------------------------------------◢", null, statscolors,
'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (["!vamos"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"VAMOS CTM QUE GANAMOS",
"¡Vamos a ganar shushetumaireeeee⚡",
"¡Vamos equipo ctm",
"¡vamooss vamoos vamooos a ganaaaaaarrrrrr",
"¡Vamos equipo, a demostrar quien manda 💪",
"¡Vamos equipo ql que ganamos🎯",
"¡vamos a ganar sin complicarnos ctmeee ",
// Agrega más mensajes al azar aquí
];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (["!q"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"ooh hermano la wea loka won ooh",
"perooo hermaaaanoooooo",
"daaaleee weooon oooooh",
"pero weooon",
"ooh weon el weon aweonao weon ooh",
"pésimo servicio",
"noooo por la chucha",
"que wea hermanooo",
"Callampin bombin",
"pero dale po ctm",
"estos ql son entero malos",
"que?",
"que wea oeee",
"aaa dale malo ctm",
"La embarraste perro ctm",

];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (["!gk"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"¡Ese gk parece un muro!",
"¡Que tapada!",
"¡Denle guante de oro a ese gk!",
"Uff, pero que tapada",
"¡Ese gk es el nuevo iker casillas!",
"¿Eso es un portero o un muro?",
"¡Tapo bravoo!",
"¡Mamita que gk!",
"¡El gk es un muro, impresionante!",
"¡Que buen gk tenemos en el equipo!",
"Que 1 hermanoo",

];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (["!gol"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"¡Mamita, que golazo!",
"¡DENLE EL PUSKASS!",
"¡Que golazo!",
"¡UFF, LO QUE METE!",
"¡Ni a mi me la meten asi, golazo!",
"GOLLLL",
"¡GOLAZOOOOOO!",

];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (["!ole"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"¡Mamita, que ole!",
"¡Comistee!",
"¡Lo esta bailando!",
"¡Llamen al enfermero, quedo sin piernas el pobre!",
"¡Oleeee!",

];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}
if (["!insulto"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"Que wea sapo ctm",
"Perro ctm",
"Weon maloooo",
"Lo unico bien que haces en chupar pico",
"Aweonao ctm",
"Que wea hijo del pico",
"Ni para DT sirves",

];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (["!0"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"Este gk tiene las manos de mantequilla...",
"¿Tiene manos este gk?",
"Naaa, pero el gk ni se inmuto a moverse...",
"Saquen a ese gk pronto....",
"¿Esto es un portero o una momia?",

];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (["!erro"].includes(message[0].toLowerCase())) {
const mensajesAzar = [
"Mamita, que erra...",
"¡Andate para defensa gil!",
"Quedate en la banca para la proxima..",
"Pero que elige este muchacho...",
"Hasta una persona sin pies puede meter ese gol, mamita...",
"Denle la medalla 'el peor tiro del mundo', le queda bien... ",
];

const mensajeSeleccionado = mensajesAzar[Math.floor(Math.random() *


mensajesAzar.length)];
room.sendAnnouncement(player.name + " dice: " + mensajeSeleccionado,
null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (message[0].toLowerCase() === "!tarjeta") {


const mentionedPlayer = message.slice(1).find((word) => word.startsWith("@"));
if (mentionedPlayer) {
const jugadorEtiquetado = mentionedPlayer.slice(1);
const messageToSend = jugadorEtiquetado.toLowerCase() !==
player.name.toLowerCase()
? `${player.name} le ha sacado una tarjeta amarilla a $
{jugadorEtiquetado} 🟨`
: "¡No puedes sacar tarjetas a ti mismo!";
room.sendAnnouncement(messageToSend, mentionedPlayer ? null : player.id,
comandoscolors, mentionedPlayer ? "letranegrita" : "normal");
} else {
room.sendAnnouncement("Uso incorrecto del comando. Debes etiquetar a un
jugador usando '@'", player.id, errorcolors, "normal");
}
return true;
}

if (message[0].toLowerCase() === "!toque") {


const mentionedPlayer = message.find((word) => word.startsWith("@"));

if (mentionedPlayer) {
const jugadorEtiquetado = mentionedPlayer.slice(1);

if (jugadorEtiquetado.toLowerCase() !== player.name.toLowerCase()) {


const messageToSend = player.name + " le a dado un toque a " +
jugadorEtiquetado + ".";
room.sendAnnouncement(messageToSend, null, 0x00fbff, 'bold');
} else {
room.sendAnnouncement("¡No puedes violarte a ti mismo!", player.id,
comandoscolors, "normal");
}
} else {
room.sendAnnouncement("Error: Debes etiquetar a un jugador.", player.id,
errorcolors, "normal");
}

return true; // Indicamos que el comando fue manejado


}

if (message[0].toLowerCase() === "!tarjeta2") {


const mentionedPlayer = message.slice(1).find((word) => word.startsWith("@"));
if (mentionedPlayer) {
const jugadorEtiquetado = mentionedPlayer.slice(1);
const messageToSend = jugadorEtiquetado.toLowerCase() !==
player.name.toLowerCase()
? `${player.name} le ha sacado una tarjeta roja a $
{jugadorEtiquetado} 🟥`
: "¡No puedes sacar tarjetas a ti mismo!";
room.sendAnnouncement(messageToSend, mentionedPlayer ? null : player.id,
comandoscolors, mentionedPlayer ? "letranegrita" : "normal");
} else {
room.sendAnnouncement("Uso incorrecto del comando. Debes etiquetar a un
jugador usando '@'", player.id, errorcolors, "normal");
}
return true;
}

else if (["!rangos"].includes(message[0].toLowerCase())) {
room.sendAnnouncement("<<<<<<<<<VICTORIAS REQUERIDAS PARA CADA
RANGO>>>>>>>>>", player.id, 0xf06400, 'bold');
room.sendAnnouncement(" Novato: 0 | Principiante: 15 | Aprendiz: 30 |
Novicio: 45 | Iniciado: 60 | Entusiasta: 75 | Competente: 90", player.id,
statscolors, 'letranegrita');
room.sendAnnouncement(" Habilidoso: 105 | Experto: 120 | Maestro: 135 |
Virtuoso: 150 | Profesional: 165 | Sobresaliente: 180", player.id, statscolors,
'letranegrita');
room.sendAnnouncement(" Destacado: 195 | Experimentado: 210 | Avanzado:
225 | Sobresaliente: 240 | Distinguido: 255 | Excelso: 270", player.id,
statscolors, 'letranegrita');
room.sendAnnouncement(" Eminente: 285 | Brillante: 300 | Destacado: 315
| Héroe: 330 | Máximo: 345 | Legendario: 360", player.id, statscolors,
'letranegrita');
room.sendAnnouncement(" Ilustre: 375 | Magnífico: 390 | Supremo: 405 |
Monarca: 420 | The King: 435", player.id, statscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!ayuda", "!help"].includes(message[0].toLowerCase())) {


room.sendAnnouncement("| <Comandos>", player.id, comandoscolors,
"letranegrita");
room.sendAnnouncement("| !me ♦ !goles ♦ !asistencias ♦ !cs ♦ !jugados ♦
!victorias !stats ♦ !rangos ♦ !afk ♦ !afks ♦ !bans ♦ !version", player.id,
comandoscolors, "normal");
room.sendAnnouncement("| <Comandos Random>", player.id, comandoscolors,
"letranegrita");
room.sendAnnouncement("| !tula ♦ !gk ♦ !insulto ♦ !peso ♦ !bicho ♦ !
messi ♦ !gary ♦ !frio ♦ !sueño ♦ !que ♦ !tarjeta ♦ !tarjeta2 ", player.id,
comandoscolors, "normal");
room.sendAnnouncement("| !toque ♦ !ole ♦ !vamos ♦ !djmario ♦ !popin ♦ !
q ♦ !9 ♦ !erro ♦ !nalguear ♦ !culear ♦ !cumear ♦ !0 ♦ !gol.", player.id,
comandoscolors, "normal");
return true; // Indicamos que el comando fue manejado

} else if (["!djmario"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " dice: A MAMAAAARRRR 😆😆😆", null,
comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!bicho"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " dice: SIUUUUUUU", null,
comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
} else if (["!popin"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " dice: QUE AWEONAO SE EQUIVOCÓ LO
HIZO MAAAAAALLLLL😂😂😂😂", null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!version"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(" Esta es la version 10.2 del host ", null,
comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!que"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " dice: Que? ", null,
comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!sueño"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " tiene mucho sueño 😴 ", null,
comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!frio"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " tiene mucho frio 🥶 ", null,
comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!messi"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " dice: ANDÁ, ANDA PA ALLÁ BOBO 😤😤
😤", null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!gary"].includes(message[0].toLowerCase())) {
room.sendAnnouncement(player.name + " dice: Qué sucede? ", null,
comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!peso"].includes(message[0].toLowerCase())) {
const random_number = Math.floor(Math.random() * 130) + 2;
room.sendAnnouncement(player.name + " pesa " + random_number + "
kilos", null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado

} else if (["!tula"].includes(message[0].toLowerCase())) {
const random_number = Math.floor(Math.random() * 32) + 1;
room.sendAnnouncement(" La tula de " + player.name + " mide " +
random_number + " cm", null, comandoscolors, 'letranegrita');
return true; // Indicamos que el comando fue manejado
}

if (message[0].toLowerCase() === "!nalguear") {


const mentionedPlayer = message.slice(1).find((word) => word.startsWith("@"));

if (mentionedPlayer) {
const jugadorEtiquetado = mentionedPlayer.slice(1);
const mensaje = jugadorEtiquetado.toLowerCase() !==
player.name.toLowerCase()
? `${player.name} nalgueo a ${jugadorEtiquetado}`
: "¡No puedes nalgearte a ti mismo!";
room.sendAnnouncement(mensaje, mentionedPlayer ? null : player.id,
comandoscolors, mentionedPlayer ? "letranegrita" : "normal");
} else {
room.sendAnnouncement("Uso incorrecto del comando. Debes etiquetar a un
jugador usando '@'", player.id, errorcolors, "normal");
}

return true;
}

else if (["!goles", "!goals"].includes(message[0].toLowerCase())) {


var tableau = [];
Object.keys(localStorage).forEach(function (key) {
if (!["player_name", "view_mode", "geo", "avatar",
"player_auth_key"].includes(key)) {
try {
var parsedData = JSON.parse(localStorage.getItem(key));
tableau.push([parsedData[Ss.NK], parsedData[Ss.GL]]);
} catch (error) {
console.error("Error parsing JSON for key:", key, error);
}
}
});

if (tableau.length < 5) {
room.sendAnnouncement("Aún no se han jugado partidos suficientes.",
player.id, errorcolors, "letranegrita");
return false;
}

tableau.sort(function (a, b) {
return b[1] - a[1];
});

room.sendAnnouncement("Top Goles --> Top 1 " + tableau[0][0] + ": " +


tableau[0][1] +
" Top 2 " + tableau[1][0] + ": " + tableau[1][1] +
" Top 3 " + tableau[2][0] + ": " + tableau[2][1] +
" Top 4 " + tableau[3][0] + ": " + tableau[3][1] +
" Top 5 " + tableau[4][0] + ": " + tableau[4][1], player.id, topscolors,
'letranegrita');
}

if (["!asistencias", "!assists"].includes(message[0].toLowerCase())) {
var tableau = [];
Object.keys(localStorage).forEach(function (key) {
if (!["player_name", "view_mode", "geo", "avatar",
"player_auth_key"].includes(key)) {
try {
var parsedData = JSON.parse(localStorage.getItem(key));
tableau.push([parsedData[Ss.NK], parsedData[Ss.AS]]);
} catch (error) {
console.error("Error parsing JSON for key:", key, error);
}
}
});

if (tableau.length < 5) {
room.sendAnnouncement("Aún no se han jugado partidos suficientes.",
player.id, errorcolors, "letranegrita");
return false;
}

tableau.sort(function (a, b) {
return b[1] - a[1];
});

room.sendAnnouncement("Top Asistencias --> Top 1 " + tableau[0][0] + ": " +


tableau[0][1] +
" Top 2 " + tableau[1][0] + ": " + tableau[1][1] +
" Top 3 " + tableau[2][0] + ": " + tableau[2][1] +
" Top 4 " + tableau[3][0] + ": " + tableau[3][1] +
" Top 5 " + tableau[4][0] + ": " + tableau[4][1], player.id, topscolors,
'letranegrita');
}

if (["!jugados", "!played"].includes(message[0].toLowerCase())) {
var tableau = [];
Object.keys(localStorage).forEach(function (key) {
if (!["player_name", "view_mode", "geo", "avatar",
"player_auth_key"].includes(key)) {
try {
var parsedData = JSON.parse(localStorage.getItem(key));
tableau.push([parsedData[Ss.NK], parsedData[Ss.GA]]);
} catch (error) {
console.error("Error parsing JSON for key:", key, error);
}
}
});

if (tableau.length < 5) {
room.sendChat("[PV] Aún no se han jugado partidos suficientes.", player.id,
errorcolors, "letranegrita");
return false;
}

tableau.sort(function (a, b) {
return b[1] - a[1];
});

room.sendChat("[PV] Partidos Jugados> #1 " + tableau[0][0] + ": " + tableau[0]


[1] +
" #2 " + tableau[1][0] + ": " + tableau[1][1] +
" #3 " + tableau[2][0] + ": " + tableau[2][1] +
" #4 " + tableau[3][0] + ": " + tableau[3][1] +
" #5 " + tableau[4][0] + ": " + tableau[4][1], player.id, topscolors,
'letranegrita');
}

if (["!victorias", "!wins"].includes(message[0].toLowerCase())) {
var tableau = [];
Object.keys(localStorage).forEach(function (key) {
if (!["player_name", "view_mode", "geo", "avatar",
"player_auth_key"].includes(key)) {
try {
var parsedData = JSON.parse(localStorage.getItem(key));
tableau.push([parsedData[Ss.NK], parsedData[Ss.WI]]);
} catch (error) {
console.error("Error parsing JSON for key:", key, error);
}
}
});

if (tableau.length < 5) {
room.sendChat("[PV] Aún no se han jugado partidos suficientes.", player.id,
errorcolors, "letranegrita");
return false;
}

tableau.sort(function (a, b) {
return b[1] - a[1];
});

room.sendChat("[PV] Victorias> #1 " + tableau[0][0] + ": " + tableau[0][1] +


" #2 " + tableau[1][0] + ": " + tableau[1][1] +
" #3 " + tableau[2][0] + ": " + tableau[2][1] +
" #4 " + tableau[3][0] + ": " + tableau[3][1] +
" #5 " + tableau[4][0] + ": " + tableau[4][1], player.id, topscolors,
'letranegrita');
}

if (["!cs"].includes(message[0].toLowerCase())) {
var tableau = [];
Object.keys(localStorage).forEach(function (key) {
if (!["player_name", "view_mode", "geo", "avatar",
"player_auth_key"].includes(key)) {
try {
var parsedData = JSON.parse(localStorage.getItem(key));
tableau.push([parsedData[Ss.NK], parsedData[Ss.CS]]);
} catch (error) {
console.error("Error parsing JSON for key:", key, error);
}
}
});

if (tableau.length < 5) {
room.sendChat("[PV] Aún no se han jugado partidos suficientes.", player.id,
errorcolors, "letranegrita");
return false;
}

tableau.sort(function (a, b) {
return b[1] - a[1];
});

room.sendChat("[PV] Vallas Invictas> #1 " + tableau[0][0] + ": " + tableau[0]


[1] +
" #2 " + tableau[1][0] + ": " + tableau[1][1] +
" #3 " + tableau[2][0] + ": " + tableau[2][1] +
" #4 " + tableau[3][0] + ": " + tableau[3][1] +
" #5 " + tableau[4][0] + ": " + tableau[4][1], player.id, topscolors,
'letranegrita');
}

if (message[0].toLowerCase() === "!cumear") {


const mentionedPlayer = message.slice(1).find((word) => word.startsWith("@"));

if (mentionedPlayer) {
const jugadorEtiquetado = mentionedPlayer.slice(1);
const mensaje = jugadorEtiquetado.toLowerCase() !==
player.name.toLowerCase()
? `${player.name} Cumeo a ${jugadorEtiquetado}`
: "¡No puedes cumearte a ti mismo!";

room.sendAnnouncement(mensaje, mentionedPlayer ? null : player.id,


comandoscolors, mentionedPlayer ? "letranegrita" : "normal");
} else {
room.sendAnnouncement("Uso incorrecto del comando. Debes etiquetar a un
jugador usando '@'", player.id, errorcolors, "normal");
}

return true;
}

if (message[0].toLowerCase() === "!culear") {


const mentionedPlayer = message.slice(1).find((word) => word.startsWith("@"));

if (mentionedPlayer) {
const jugadorEtiquetado = mentionedPlayer.slice(1);
const mensaje = jugadorEtiquetado.toLowerCase() !==
player.name.toLowerCase()
? `${player.name} Se culeo a ${jugadorEtiquetado}`
: "¡No puedes culearte a ti mismo!";

room.sendAnnouncement(mensaje, mentionedPlayer ? null : player.id,


comandoscolors, mentionedPlayer ? "letranegrita" : "normal");
} else {
room.sendAnnouncement("Uso incorrecto del comando. Debes etiquetar a un
jugador usando '@'", player.id, errorcolors, "normal");
}

return true;
}

if (["!login"].includes(message[0].toLowerCase())) {
if (message[1] == adminPassword) {
room.setPlayerAdmin(player.id, true);
var stats = localStorage.getItem(getAuth(player)) ?
JSON.parse(localStorage.getItem(getAuth(player))) : [0, 0, 0, 0, "0.00", 0, 0, 0,
0, "0.00", "player", player.name];
if (stats[Ss.RL] != "master") {
stats[Ss.RL] = "master";
room.sendAnnouncement(player.name + " ¡Ahora es admin!", null, 0xff0000,
'bold');
localStorage.setItem(getAuth(player), JSON.stringify(stats));
}
return true; // Evita enviar el comando al chat
}
} else if (["!setadmin", "!admin"].includes(message[0].toLowerCase())) {
if (localStorage.getItem(getAuth(player)) &&
JSON.parse(localStorage.getItem(getAuth(player)))[Ss.RL] == "master") {
if (message.length >= 2 && message[1][0] == "#") {
message[1] = message[1].substring(1, message[1].length);
if (!Number.isNaN(Number.parseInt(message[1])) &&
room.getPlayer(Number.parseInt(message[1])) != null) {
var stats;

localStorage.getItem(getAuth(room.getPlayer(Number.parseInt(message[1])))) ? stats
=
JSON.parse(localStorage.getItem(getAuth(room.getPlayer(Number.parseInt(message[1]))
))) : stats = [0, 0, 0, 0, "0.00", 0, 0, 0, 0, "0.00", "player",
room.getPlayer(Number.parseInt(message[1])).name];
if (stats[Ss.RL] == "player") {
stats[Ss.RL] = "admin";

localStorage.setItem(getAuth(room.getPlayer(Number.parseInt(message[1]))),
JSON.stringify(stats));
room.setPlayerAdmin(room.getPlayer(Number.parseInt(message[1])).id,
true);
return true; // Evita enviar el comando al chat
}
}
}
}
} else if (["!setplayer", "!removeadmin"].includes(message[0].toLowerCase())) {
if (localStorage.getItem(getAuth(player)) &&
JSON.parse(localStorage.getItem(getAuth(player)))[Ss.RL] == "master") {
if (message.length >= 2 && message[1][0] == "#") {
message[1] = message[1].substring(1, message[1].length);
if (!Number.isNaN(Number.parseInt(message[1])) &&
room.getPlayer(Number.parseInt(message[1])) != null) {
var stats;

localStorage.getItem(getAuth(room.getPlayer(Number.parseInt(message[1])))) ? stats
=
JSON.parse(localStorage.getItem(getAuth(room.getPlayer(Number.parseInt(message[1]))
))) : stats = [0, 0, 0, 0, "0.00", 0, 0, 0, 0, "0.00", "player",
room.getPlayer(Number.parseInt(message[1])).name];
if (stats[Ss.RL] == "admin") {
room.sendAnnouncement(room.getPlayer(Number.parseInt(message[1])).name +
" Ya no es administrador del host !");
stats[Ss.RL] = "player";

localStorage.setItem(getAuth(room.getPlayer(Number.parseInt(message[1]))),
JSON.stringify(stats));
room.setPlayerAdmin(room.getPlayer(Number.parseInt(message[1])).id,
false);
return true; // Evita enviar el comando al chat
}
}
}
}
}
if (["!mutes", "!mutelist"].includes(message[0].toLowerCase())) {
var cstm = "[PV] Lista de muteados : ";
for (var i = 0; i < extendedP.length; i++) {
if (room.getPlayer(extendedP[i][eP.ID]) != null &&
getMute(room.getPlayer(extendedP[i][eP.ID]))) {
if (140 - cstm.length < (room.getPlayer(extendedP[i][eP.ID]).name + "["
+ (extendedP[i][eP.ID]) + "], ").length) {
room.sendAnnouncement(cstm, player.id);
cstm = "... ";
}
cstm += room.getPlayer(extendedP[i][eP.ID]).name + "[" + (extendedP[i]
[eP.ID]) + "], ";
}
}
if (cstm == "[PV] Lista de Muteados : ") {
room.sendAnnouncement("[PV] No hay nadie en la lista de muteados !",
player.id);
} else {
cstm = cstm.substring(0, cstm.length - 2);
cstm += ".";
room.sendAnnouncement(cstm, player.id);
}
return true;
} else if (["!mutee"].includes(message[0].toLowerCase())) {
if (player.admin) {
updateTeams();
var timeOut;
if (!Number.isNaN(Number.parseInt(message[1])) && message.length > 1) {
if (Number.parseInt(message[1]) > 0) {
timeOut = Number.parseInt(message[1]) * 60 * 1000;
} else {
timeOut = 3 * 60 * 1000;
}
if (message[2].length > 1 && message[2][0] == "#") {
message[2] = message[2].substring(1, message[2].length);
if (!Number.isNaN(Number.parseInt(message[2])) &&
room.getPlayer(Number.parseInt(message[2])) != null) {
if (room.getPlayer(Number.parseInt(message[2])).admin ||
getMute(room.getPlayer(Number.parseInt(message[2])))) {
return true;
}
setTimeout(function (player) { setMute(player, false); },
timeOut, room.getPlayer(Number.parseInt(message[2])));
setMute(room.getPlayer(Number.parseInt(message[2])), true);

room.sendAnnouncement(room.getPlayer(Number.parseInt(message[2])).name + " ha sido


muteado por " + (timeOut / 60000) + " minutos !", null, 0xeeff00, 'bold',);
}
}
} else if (Number.isNaN(Number.parseInt(message[1]))) {
if (message[1].length > 1 && message[1][0] == "#") {
message[1] = message[1].substring(1, message[1].length);
if (!Number.isNaN(Number.parseInt(message[1])) &&
room.getPlayer(Number.parseInt(message[1])) != null) {
if (room.getPlayer(Number.parseInt(message[1])).admin ||
getMute(room.getPlayer(Number.parseInt(message[1])))) {
return true;
}
setTimeout(function (player) { setMute(player, false); }, 3 *
60 * 1000, room.getPlayer(Number.parseInt(message[1])));
setMute(room.getPlayer(Number.parseInt(message[1])), true);

room.sendAnnouncement(room.getPlayer(Number.parseInt(message[1])).name + " Te han


muteado por 3 minutos!");
}
}
}
}
return true;
} else if (["!unmute"].includes(message[0].toLowerCase())) {
if (player.admin && message.length >= 2) {
if (message[1] == "all") {
extendedP.forEach((ePlayer) => { ePlayer[eP.MUTE] = false; });
room.sendAnnouncement("Se ha limpiado la lista de muteados");
} else if (!Number.isNaN(Number.parseInt(message[1])) &&
room.getPlayer(Number.parseInt(message[1])) != null &&
getMute(room.getPlayer(Number.parseInt(message[1])))) {
setMute(room.getPlayer(Number.parseInt(message[1])), false);
room.sendAnnouncement(room.getPlayer(Number.parseInt(message[1])).name
+ " ha sido desmuteado !");
} else if (Number.isNaN(Number.parseInt(message[1]))) {
if (message[1].length > 1 && message[1][0] == "#") {
message[1] = message[1].substring(1, message[1].length);
if (!Number.isNaN(Number.parseInt(message[1])) &&
room.getPlayer(Number.parseInt(message[1])) != null &&
getMute(room.getPlayer(Number.parseInt(message[1])))) {
setMute(room.getPlayer(Number.parseInt(message[1])), false);

room.sendAnnouncement(room.getPlayer(Number.parseInt(message[1])).name + " ha sido


desmuteado!");
}
}
}
}
return true;
}
if (["!slow"].includes(message[0].toLowerCase())) {
if (player.admin) {
if (message.length == 1) {
slowMode = 2;
room.sendAnnouncement("Modo lento activado (2 segundos)!");
} else if (message.length == 2) {
if (!Number.isNaN(Number.parseInt(message[1]))) {
if (Number.parseInt(message[1]) > 0) {
slowMode = Number.parseInt(message[1]);
room.sendAnnouncement(slowMode + " segundos, modo lento
activado !");
return true;
}
}
slowMode = 2;
room.sendAnnouncement("Modo lento activado (2 segundos)!");
}
}
return true;
} else if (["!endslow"].includes(message[0].toLowerCase())) {
if (player.admin) {
slowMode != 0 ? room.sendAnnouncement("Modo lento terminado.") : null;
slowMode = 0;
}
return true;
} else if (["!banlist", "!bans"].includes(message[0].toLowerCase())) {
if (banList.length == 0) {
room.sendAnnouncement("[PV] No hay nadie en la lista de baneados!",
player.id);
} else {
var cstm = "[PV] Lista de baneados : ";
for (var i = 0; i < banList.length; i++) {
if (140 - cstm.length < (banList[i][0] + "[" + (banList[i][1]) + "],
").length) {
room.sendAnnouncement(cstm, player.id);
cstm = "... ";
}
cstm += banList[i][0] + "[" + (banList[i][1]) + "], ";
}
cstm = cstm.substring(0, cstm.length - 2);
cstm += ".";
room.sendAnnouncement(cstm, player.id);
}
return true;
} else if (["!limpiarbans2001"].includes(message[0].toLowerCase())) {
if (player.admin) {
if (message.length == 1) {
room.clearBans();
room.sendAnnouncement("Bans removidos!");
banList = [];
}
if (message.length == 2) {
if (!Number.isNaN(Number.parseInt(message[1]))) {
if (Number.parseInt(message[1]) > 0) {
ID = Number.parseInt(message[1]);
room.clearBan(ID);
if (banList.length != banList.filter((array) => array[1] !=
ID)) {
room.sendAnnouncement(banList.filter((array) => array[1] ==
ID)[0][0] + " ha sido baneado del host !");
}
setTimeout(() => { banList = banList.filter((array) => array[1]
!= ID); }, 20);
}
}
}
}
return true;
}
// Comprobar si el mensaje es uno de los comandos de despedida
if (["!bb", "!bye", "!cya", "!gn"].includes(message[0].toLowerCase())) {
// Verificar si el jugador NO está en un equipo
if (player.team === Team.SPECTATORS) {
// Expulsar al jugador si utiliza uno de los comandos de despedida y no está en
un equipo
room.kickPlayer(player.id, "¡Adiós!", false);
return true; // Evitar que el jugador realice más acciones después de ser
expulsado
} else {
// El jugador está en un equipo, mostrar un mensaje de advertencia
room.sendAnnouncement("[PV] No puedes expulsarte mientras estás en un equipo.
Si lo haces, podrías ser sancionado", player.id);
return true; // Evitar que el jugador se expulse a sí mismo
}
}

// Verificar si el mensaje comienza con "!"


if (message[0][0] == "!") {
return true; // Cambiado a true
}

// Verificar si el jugador está muteado


if (getMute(player)) {
room.sendAnnouncement("Usted está muteado.", player.id);
return true; // Cambiado a true
}
// Verificar si está habilitado el modo lento (slowMode)
if (slowMode > 0) {
if (!player.admin) {
if (!SMSet.has(player.id)) {
SMSet.add(player.id);
setTimeout((number) => { SMSet.delete(number); }, slowMode * 1000,
player.id);
} else {
return true; // Cambiado a true
}
}
}

// Devolver true por defecto si no se cumple ninguna condición anterior


return true; // Cambiado a true
}

room.onPlayerActivity = function(player) {
setActivity(player, 0);
return true; // Cambiado a true
}

room.onPlayerBallKick = function(player) {
if (lastPlayersTouched[0] == null || player.id != lastPlayersTouched[0].id) {
!activePlay ? activePlay = true : null;
lastTeamTouched = player.team;
lastPlayersTouched[1] = lastPlayersTouched[0];
lastPlayersTouched[0] = player;
}
return true; // Cambiado a true
}

/* GAME MANAGEMENT */

room.onGameStart = function(byPlayer) {
game = new Game(Date.now(), room.getScores(), []);
countAFK = true;
activePlay = false;
goldenGoal = false;
endGameVariable = false;
lastPlayersTouched = [null, null];
Rposs = 0;
Bposs = 0;
GKList = [];
allReds = [];
allBlues = [];
if (teamR.length == maxTeamSize && teamB.length == maxTeamSize) {
for (var i = 0; i < maxTeamSize; i++) {
allReds.push(teamR[i]);
allBlues.push(teamB[i]);
}
}
for (var i = 0; i < extendedP.length; i++) {
extendedP[i][eP.GK] = 0;
extendedP[i][eP.ACT] = 0;
room.getPlayer(extendedP[i][eP.ID]) == null ? extendedP.splice(i, 1) :
null;
}
deactivateChooseMode();
}

room.onGameStop = function(byPlayer) {
if (byPlayer.id == 0 && endGameVariable) {
updateTeams();
if (inChooseMode) {
if (players.length == 2 * maxTeamSize) {
inChooseMode = false;
resetBtn();
for (var i = 0; i < maxTeamSize; i++) {
setTimeout(() => { randomBtn(); }, 400*i);
}
setTimeout(() => { room.startGame(); }, 2000);
}
else {
if (lastWinner == Team.RED) {
blueToSpecBtn();
}
else if (lastWinner == Team.BLUE) {
redToSpecBtn();
blueToRedBtn();
}
else {
resetBtn();
}
setTimeout(() => { topBtn(); }, 500);
}
}
else {
if (players.length == 2) {
if (lastWinner == Team.BLUE) {
room.setPlayerTeam(teamB[0].id, Team.RED);
room.setPlayerTeam(teamR[0].id, Team.BLUE);
}
setTimeout(() => { room.startGame(); }, 2000);
}
else if (players.length == 3 || players.length >= 2 * maxTeamSize
+ 1) {
if (lastWinner == Team.RED) {
blueToSpecBtn();
}
else {
redToSpecBtn();
blueToRedBtn();
}
setTimeout(() => { topBtn(); }, 200);
setTimeout(() => { room.startGame(); }, 2000);
}
else if (players.length == 4) {
resetBtn();
setTimeout(() => { randomBtn(); setTimeout(() =>
{ randomBtn(); }, 500); }, 500);
setTimeout(() => { room.startGame(); }, 2000);
}
else if (players.length == 5 || players.length >= 2 * maxTeamSize
+ 1) {
if (lastWinner == Team.RED) {
blueToSpecBtn();
}
else {
redToSpecBtn();
blueToRedBtn();
}
setTimeout(() => { topBtn(); }, 200);
activateChooseMode();
}
else if (players.length == 6) {
resetBtn();
setTimeout(() => { randomBtn(); setTimeout(() =>
{ randomBtn(); setTimeout(() => { randomBtn(); }, 500); }, 500); }, 500);
setTimeout(() => { room.startGame(); }, 2000);
}
}
}
}

room.onGamePause = function(byPlayer) {
}

room.onGameUnpause = function (byPlayer) {


if (teamR.length == 4 && teamB.length == 4 && inChooseMode || (teamR.length
== teamB.length && teamS.length < 2 && inChooseMode)) {
deactivateChooseMode();
}
}

// Función para cambiar el avatar a un emoji de pelota o risa cuando se marca un


gol o autogol
function setAvatarToEmoji(playerID, emoji) {
room.setPlayerAvatar(playerID, emoji);
setTimeout(() => {
room.setPlayerAvatar(playerID, null);
}, 5000); // Cambia 5000 a la cantidad de milisegundos que desees que el emoji
sea visible (en este caso, 5 segundos).
}

// Función para cambiar el avatar entre pelota y carita con gafas


function alternateAvatar(playerID) {
let isBall = true;

const intervalID = setInterval(() => {


if (isBall) {
room.setPlayerAvatar(playerID, null); // Cambiar a carita con gafas
} else {
room.setPlayerAvatar(playerID, '⚽'); // Cambiar a la pelota
}

isBall = !isBall; // Alternar entre la pelota y la carita con gafas


}, 350); // Cambiar cada 0.5 segundos

// Detener la alternancia después de 5 segundos


setTimeout(() => {
clearInterval(intervalID); // Detener la alternancia
room.setPlayerAvatar(playerID, null); // Restaurar el avatar a su valor
original
}, 7000); // Cambiar durante 5 segundos
}
// Función que maneja el evento de gol
function handleGoal(team) {
activePlay = false;
countAFK = false;

const scores = room.getScores();


game.scores = scores;

let responseColor;
let teamEmoji = team == Team.RED ? "🔴" : "🔵";

if (lastPlayersTouched[0] != null && lastPlayersTouched[0].team == team) {


if (lastPlayersTouched[1] != null && lastPlayersTouched[1].team == team) {
const scorer = lastPlayersTouched[0].name;
const assistant = lastPlayersTouched[1].name;

// Cambiar el avatar a emojis de pelota para el jugador que marcó el gol y el


asistente
setAvatarToEmoji(lastPlayersTouched[0].id, '⚽');
setAvatarToEmoji(lastPlayersTouched[1].id, '👟');

// Anuncios separados para gol asistido

room.sendAnnouncement("◤-----------------------------------------------------------
-------------------------------------------------------◥", null, golescolor,
"bold");
room.sendAnnouncement(`⚽ Gol de ${scorer} | 🟥 ${scores.red} - ${scores.blue}
🟦 | 🕒 ${getTime(scores)}`, null, golescolor, "bold");
room.sendAnnouncement("👟 Asistencia de " + lastPlayersTouched[1].name + ".",
null, golescolor, "bold");

room.sendAnnouncement("◣-----------------------------------------------------------
-------------------------------------------------------◢", null, golescolor,
"bold");

// Llamar a alternateAvatar para el jugador que marcó el gol


alternateAvatar(lastPlayersTouched[0].id);
game.goals.push(new Goal(scores.time, team, lastPlayersTouched[0],
lastPlayersTouched[1]));
} else {
const scorer = lastPlayersTouched[0].name;

// Cambiar el avatar a un emoji de pelota para el jugador que marcó el gol


setAvatarToEmoji(lastPlayersTouched[0].id, '⚽');

// Anuncios separados para gol en solitario

room.sendAnnouncement("◤-----------------------------------------------------------
-------------------------------------------------------◥", null, golescolor,
"bold");
room.sendAnnouncement(`⚽ Gol de ${scorer} | 🟥 ${scores.red} - ${scores.blue}
🟦 | 🕒 ${getTime(scores)}`, null, golescolor, "bold");

room.sendAnnouncement("◣-----------------------------------------------------------
-------------------------------------------------------◢", null, golescolor,
"bold");
// Llamar a alternateAvatar para el jugador que marcó el gol
alternateAvatar(lastPlayersTouched[0].id);
game.goals.push(new Goal(scores.time, team, lastPlayersTouched[0], null));
}
} else {
const scorer = lastPlayersTouched[0].name;

// Cambiar el avatar a un emoji de risa para el jugador que marcó el autogol


setAvatarToEmoji(lastPlayersTouched[0].id, '🤡');

// Anuncios separados para autogol

room.sendAnnouncement("◤-----------------------------------------------------------
-------------------------------------------------------◥", null, golescolor,
"bold");
room.sendAnnouncement(`😂 ¡era para el otro arco! ${scorer} | 🟥 ${scores.red} -
${scores.blue} 🟦 | 🕒 ${getTime(scores)}`, null, golescolor, "bold");

room.sendAnnouncement("◣-----------------------------------------------------------
-------------------------------------------------------◢", null, golescolor,
"letranegrita");

// Llamar a alternateAvatar para el jugador que marcó el autogol


alternateAvatar(lastPlayersTouched[0].id);
game.goals.push(new Goal(scores.time, team, null, null));
}

if (scores.scoreLimit != 0 && (scores.red == scores.scoreLimit || (scores.blue ==


scores.scoreLimit && scores.blue > 0) || goldenGoal)) {
endGame(team);
goldenGoal = false;
setTimeout(() => {
room.stopGame();
}, 1000);
}
}

// Evento de gol del equipo


room.onTeamGoal = handleGoal;

/* MISCELLANEOUS */

room.onRoomLink = function(url) {
}

room.onPlayerAdminChange = function (changedPlayer, byPlayer) {


if (getMute(changedPlayer) && changedPlayer.admin) {
room.sendAnnouncement(changedPlayer.name + " ha sido desmuteado.");
setMute(changedPlayer, false);
}
if (byPlayer.id != 0 && localStorage.getItem(getAuth(byPlayer)) &&
JSON.parse(localStorage.getItem(getAuth(byPlayer)))[Ss.RL] == "admin") {
room.sendAnnouncement("No tienes permiso para nombrar a un jugador como
Administrador !", byPlayer.id);
room.setPlayerAdmin(changedPlayer.id, false);
}
}
room.onStadiumChange = function(newStadiumName, byPlayer) {
}

room.onGameTick = function() {
checkTime();
getLastTouchOfTheBall();
getStats();
handleInactivity();
}

setInterval(() => {

room.sendAnnouncement("◤-----------------------------------------------------------
--------------------------------------------------◥", null, anuncioscolor,
'letranegrita');
room.sendAnnouncement(" Unete al discord oficial de FSBL:
https://discord.gg/TBmyAZxxfV ", null, anuncioscolor, 'letranegrita');
room.sendAnnouncement(" Recuerda poner !ayuda para ver los comandos.", null,
anuncioscolor, 'letranegrita');

room.sendAnnouncement("◣-----------------------------------------------------------
--------------------------------------------------◢", null, anuncioscolor,
'letranegrita');
}, 60 * 1000); // Enviar cada 1 minuto

/* ESTADO SALAS AL DISCORD */

var AnuncioHostAbierto = estadosalaslink;


var roomLink = null;
var nombredesala = roomName;

function sendLinkToDiscord(url) {
let xhr = new XMLHttpRequest();
xhr.open("POST", AnuncioHostAbierto);
xhr.setRequestHeader("Content-type", "application/json");

let message = {
username: "🔴 ESTADO SALA 🔴",
content: `**Nombre:** ${nombredesala}\n• **Link:** ${url}`
};

xhr.send(JSON.stringify(message));
}

// Evento de enlace de la sala


room.onRoomLink = function(url) {
roomLink = url;
console.log(roomLink);
sendLinkToDiscord(roomLink);
}
/* GRABACIONES 3V3 DISCORD */

function endGame(winner) {
// Handles the end of a game; no stopGame function inside
players.length >= 2 * maxTeamSize - 1 ? activateChooseMode() : null;

const scores = room.getScores();


game.scores = scores;

// Calculate possession percentages


let Rposs = scores.red > 0 ? scores.red / (scores.red + scores.blue) : 0;
let Bposs = 1 - Rposs;

lastWinner = winner;
endGameVariable = true;

let teamColor = winner === Team.RED ? "🔴 RED TEAM " : "🔵 BLUE TEAM ";

if (winner == Team.RED) {
streak++;
room.sendAnnouncement("🔴 Triunfo del Red Team por " + scores.red + " a " +
scores.blue + "", null, colorredteam, "bold");
room.sendAnnouncement("🏆 Victorias consecutivas: " + streak + "", null,
colorredteam, "bold");
room.sendAnnouncement("🎥 La REC del partido fue enviada al discord: " +
enlacediscord, null, colorredteam, "bold");
} else if (winner == Team.BLUE) {
streak = 1;
room.sendAnnouncement("🔵 Triunfo del Blue Team por " + scores.blue + " a "
+ scores.red + "", null, colorblueteam, "bold");
room.sendAnnouncement("🎥 La REC del partido fue enviada al discord: " +
enlacediscord, null, colorblueteam, "bold");
}

// Update stats at the end of the game


updateStats();

// Inserta el enlace del webhook de Discord aquí


let webhookLink = grabacionesunovsuno;

// Send game end announcement to Discord


sendGameEndAnnouncementToDiscord(webhookLink, teamColor, scores, Rposs, Bposs,
GKList, roomLink, players, teamR, teamB, teamS);
}

function sendGameEndAnnouncementToDiscord(webhookLink, teamColor, scores, Rposs,


Bposs, GKList, roomLink, players, teamR, teamB, teamS) {
let xhr = new XMLHttpRequest();
xhr.open("POST", webhookLink);
xhr.setRequestHeader("Content-type", "application/json");

// Check if goalkeepers kept a clean sheet


let cleanSheetMessage = null;
if (scores.red === 0) {
cleanSheetMessage = (scores.blue === 0) ? `**${GKList[0].name} y $
{GKList[1].name}**` : `**${GKList[1].name}**`;
} else if (scores.blue === 0) {
cleanSheetMessage = `**${GKList[0].name}**`;
}

// Extract player names for each team


const playerNamesRed = teamR.map(player => player.name).join('\n');
const playerNamesBlue = teamB.map(player => player.name).join('\n');
const playerNamesSpec = teamS.map(player => `${player.name}[$
{teamS.indexOf(player) + 1}]`).join('\n');

// Obtener la duración del partido


const endTime = new Date();
const startTime = new Date(endTime - room.getScores().time * 1000); // time es
en segundos
const durationInSeconds = Math.floor((endTime - startTime) / 1000); // duración
en segundos

const durationMinutes = Math.floor(durationInSeconds / 60);


const remainingSeconds = durationInSeconds % 60;

let embedMessage = {
embeds: [{
title: "",
color: (teamColor === "🔴 RED TEAM ") ? 0xFF0000 : 0x0000FF, // Red or
Blue color
fields: [
{ name: "🔴 RED TEAM " + scores.red + " - " + scores.blue + " BLUE
TEAM 🔵", value: "\n ", inline: false },
{ name: "⏰Duración del partido⏰", value: `${durationMinutes}
minutos y ${remainingSeconds} segundos\n `, inline: false },
{ name: "📋Formaciones📋", value: "", inline: false },
{ name: "🔴 Red Team", value: "```\n" + playerNamesRed + "\n```",
inline: true },
{ name: "🔵 Blue Team", value: "```\n" + playerNamesBlue + "\n```",
inline: true },
{ name: "⚪ Espectadores", value: "```\n" + playerNamesSpec + "\
n```", inline: false },
{ name: "Link sala", value: roomLink, inline: false },

],
timestamp: new Date().toISOString()
}]
};

xhr.send(JSON.stringify(embedMessage));
}

const gameWebhook = grabaciones-3v3;

function fetchRecording(recInfo) {
if (gameWebhook !== "" && recInfo.rec) {
let formData = new FormData();
formData.append("file", recInfo.rec, getRecordingName(recInfo));

fetch(gameWebhook, {
method: 'POST',
body: formData
}).then(response => {
if (response.ok) {
console.log("La grabación del juego se ha enviado correctamente al
webhook de Discord.");
} else {
console.error("Error al enviar la grabación del juego al webhook de
Discord:", response.status);
}
}).catch(error => {
console.error("Error en la solicitud fetch:", error);
});
} else {
console.error("El webhook de Discord no está configurado correctamente o no
se proporcionó una grabación válida.");
}
};

You might also like