magicworld
Este commit está contenido en:
45
testing/magicworld/server/lib/colorized.js
Archivo normal
45
testing/magicworld/server/lib/colorized.js
Archivo normal
@@ -0,0 +1,45 @@
|
||||
var colorsConsoleList = {
|
||||
Reset: "\x1b[0m",
|
||||
Bright: "\x1b[1m",
|
||||
Dim: "\x1b[2m",
|
||||
Underscore: "\x1b[4m",
|
||||
Blink: "\x1b[5m",
|
||||
Reverse: "\x1b[7m",
|
||||
Hidden: "\x1b[8m",
|
||||
|
||||
FgBlack: "\x1b[30m",
|
||||
FgRed: "\x1b[31m",
|
||||
FgGreen: "\x1b[32m",
|
||||
FgYellow: "\x1b[33m",
|
||||
FgBlue: "\x1b[34m",
|
||||
FgMagenta: "\x1b[35m",
|
||||
FgCyan: "\x1b[36m",
|
||||
FgWhite: "\x1b[37m",
|
||||
|
||||
BgBlack: "\x1b[40m",
|
||||
BgRed: "\x1b[41m",
|
||||
BgGreen: "\x1b[42m",
|
||||
BgYellow: "\x1b[43m",
|
||||
BgBlue: "\x1b[44m",
|
||||
BgMagenta: "\x1b[45m",
|
||||
BgCyan: "\x1b[46m",
|
||||
BgWhite: "\x1b[47m",
|
||||
};
|
||||
|
||||
var getColors = function(color){
|
||||
return color.reduce((resul, x) => resul + colorsConsoleList[x], "");
|
||||
}
|
||||
|
||||
var setColors = function(smg, color){
|
||||
return getColors(color) + smg + colorsConsoleList["Reset"];
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
log: function (smg, color = []) {
|
||||
console.log(setColors(smg, color));
|
||||
},
|
||||
colorized: function (smg, color){
|
||||
return setColors(smg, color);
|
||||
}
|
||||
};
|
||||
|
||||
55
testing/magicworld/server/lib/logo.js
Archivo normal
55
testing/magicworld/server/lib/logo.js
Archivo normal
@@ -0,0 +1,55 @@
|
||||
var log = require('./colorized').log,
|
||||
c = require('./colorized').colorized,
|
||||
s = {
|
||||
n: ["FgRed", "BgBlack", "Bright"], // Normality
|
||||
bkr: ["FgRed", "BgBlack", "Bright", "Blink"], // Blink red
|
||||
bky: ["FgYellow", "BgBlack", "Bright", "Blink"], // Blink yellow
|
||||
b: ["FgWhite", "BgBlack"], // Border
|
||||
l: ["FgWhite", "BgBlack", "Bright"], // logo
|
||||
lr: ["FgRed", "BgBlack", "Bright"], // logo red
|
||||
ly: ["FgYellow", "BgBlack", "Bright"], // logo yellow
|
||||
lm: ["FgMagenta", "BgBlack", "Bright"], // logo magenta
|
||||
lg: ["FgGreen", "BgBlack", "Bright"] // logo green
|
||||
},
|
||||
b = () => c("---", s.b),
|
||||
bkr = (x) => c(x, s.bkr),
|
||||
bky = (x) => c(x, s.bky),
|
||||
l = (x) => c(x, s.l),
|
||||
ly = (x) => c(x, s.ly),
|
||||
lr = (x) => c(x, s.lr),
|
||||
lm = (x) => c(x, s.lm),
|
||||
lg = (x) => c(x, s.lg);
|
||||
|
||||
module.exports = {
|
||||
logo: function () {
|
||||
log("--------------------------------------------", s.b);
|
||||
log(b() + c(" MW-NodeJS Server 0.3 ", s.lr) + b());
|
||||
log("--------------------------------------------", s.b);
|
||||
|
||||
log(b() + l(" .-. ") + b());
|
||||
log(b() + l(" {{") + lm("#") + l("}} ") + b());
|
||||
log(b() + l(" 888 ") + b());
|
||||
log(b() + l(" 888 ") + b());
|
||||
log(b() + l(" 8@8 ") + b());
|
||||
log(b() + l(" _ )8( _ ") + b());
|
||||
log(b() + l(" ____________________(") + lr("@") + l(")__/8@8\\__(") + lr("@") + l(") ") + b());
|
||||
log(b() + l(' | | | |`~"-=):(=-"~` ') + b());
|
||||
log(b() + l(" | ") + lg("<>") + l(" | | ") + lg("<>") + l(" | |.| ") + b());
|
||||
log(b() + l(" | ") + lg("<><>") + l(" | | ") + lg("<><>") + l(" | |") + bky("A") + l("| ") + b());
|
||||
log(b() + l(" | ") + lg("<> <>") + l("| |") + lg("<> <>") + l(" | |'| ") + b());
|
||||
log(b() + l(" | ") + lg("<>") + l(" .--------. ") + lg("<>") + l(" | |.| ") + b());
|
||||
log(b() + l(" |_____| ") + ly("()") + l(" |_____| |") + bky("C") + l("| ") + b());
|
||||
log(b() + l(" | | ") + ly("(O\\/O)") + l(" | | |'| ") + b());
|
||||
log(b() + l(" | \\ ") + ly("/\\") + l(" / | |.| ") + b());
|
||||
log(b() + l(" |______\\ ") + ly("\\/") + l(" /______| |") + bky("A") + l("| ") + b());
|
||||
log(b() + l(" | '.__.' | |'| ") + b());
|
||||
log(b() + l(" | ") + lg("<>") + l(" | | ") + lg("<>") + l(" | |.| ") + b());
|
||||
log(b() + l(" | ") + lg("<> <>") + l("| |") + lg("<> <>") + l(" | |") + bky("B") + l("| ") + b());
|
||||
log(b() + l(" | ") + lg("<><>") + l(" | | ") + lg("<><>") + l(" | |'| ") + b());
|
||||
log(b() + l(" | ") + lg("<>") + l(" | | ") + lg("<>") + l(" | |.| ") + b());
|
||||
log(b() + l(" |________|__|________| \\ / ") + b());
|
||||
log(b() + l(" v ") + b());
|
||||
|
||||
log("--------------------------------------------", s.b);
|
||||
}
|
||||
}
|
||||
40
testing/magicworld/server/lib/maper.js
Archivo normal
40
testing/magicworld/server/lib/maper.js
Archivo normal
@@ -0,0 +1,40 @@
|
||||
module.exports = {
|
||||
create: channel => {
|
||||
map = require("../public/maps/" + channel + "/index").map;
|
||||
map.players = {};
|
||||
return map;
|
||||
},
|
||||
collision: (a,b) => {
|
||||
return a && b ? parseInt(a.position.x) + parseInt(a.width) > parseInt(b.position.x) && parseInt(a.position.x) < parseInt(b.position.x) + parseInt(b.width) && parseInt(a.position.y) + parseInt(a.height) > parseInt(b.position.y) && parseInt(a.position.y) < parseInt(b.position.y) + parseInt(b.height) : false;
|
||||
},
|
||||
collisionX: (m, a,b) => {
|
||||
return parseInt(a.position.x + m) + parseInt(a.width) > parseInt(b.position.x) && parseInt(a.position.x + m) < parseInt(b.position.x) + parseInt(b.width) && parseInt(a.position.y) + parseInt(a.height) > parseInt(b.position.y) && parseInt(a.position.y) < parseInt(b.position.y) + parseInt(b.height);
|
||||
},
|
||||
collisionY: (m, a,b) => {
|
||||
return parseInt(a.position.y + m) + parseInt(a.height) > parseInt(b.position.y) && parseInt(a.position.y + m) < parseInt(b.position.y) + parseInt(b.height) && parseInt(a.position.x) + parseInt(a.width) > parseInt(b.position.x) && parseInt(a.position.x) < parseInt(b.position.x) + parseInt(b.width);
|
||||
},
|
||||
insideX: (m, item, limits) => {
|
||||
return (item.position.x + m) > limits.x.max && (item.position.x + m) < limits.x.min;
|
||||
},
|
||||
insideY: (m, item, limits) => {
|
||||
return (item.position.y + m) > limits.y.max && (item.position.y + m) < limits.y.min;
|
||||
},
|
||||
moveX: (m, player, channel) => {
|
||||
let maper = module.exports;
|
||||
return maper.insideX(m, player, channel.limits) && !Object.values(channel.players).reduce((acc, x) => acc ? acc : player != x ? maper.collisionX(m, player, x) : false, false) && !Object.values(channel.colliders).reduce((acc, x) => acc ? acc : player != x ? maper.collisionX(m, player, x) : false, false);
|
||||
},
|
||||
moveY: (m, player, channel) => {
|
||||
let maper = module.exports;
|
||||
return maper.insideY(m, player, channel.limits) && !Object.values(channel.players).reduce((acc, x) => acc ? acc : player != x ? maper.collisionY(m, player, x) : false, false) && !Object.values(channel.colliders).reduce((acc, x) => acc ? acc : player != x ? maper.collisionY(m, player, x) : false, false);
|
||||
},
|
||||
getRandom: (min, max) => {
|
||||
return Math.floor(Math.random() * (max - min) ) + min;
|
||||
},
|
||||
getRandomPosition:(limits) =>{
|
||||
let maper = module.exports;
|
||||
return {
|
||||
"x": maper.getRandom(limits.x.min, limits.x.max),
|
||||
"y": maper.getRandom(limits.y.min, limits.y.max)
|
||||
}
|
||||
}
|
||||
}
|
||||
Referencia en una nueva incidencia
Block a user