add simple fuzz test

This commit is contained in:
Asraelite 2016-03-27 20:26:53 +01:00
parent 0a90b6b77a
commit 27520842e3
59 changed files with 191 additions and 34 deletions

View file

@ -2,6 +2,8 @@
const World = require('./world');
const messages = require('./messages.json');
class Room {
constructor() {
this.players = new Set();
@ -14,13 +16,14 @@ class Room {
}
add(player) {
wingbase.log(`${player.name} joined ${this.name}.`);
player.room = this;
player.connection.room = this.name;
this.players.add(player);
this.setTeam(player, this.teamA.size > this.teamB.size ? 'b' : 'a');
this.world.addPlayer(player);
this.sendWorld(player);
wingbase.log(`${player.name} joined ${this.name}.`);
this.message('roomEnter', player.name);
}
remove(player) {
@ -63,6 +66,22 @@ class Room {
this.players.forEach(player => player.send(msg, data));
}
message(type, values) {
if (!(values instanceof Array)) values = [values];
let messageList = messages[type];
let message = messageList[Math.random() * messageList.length | 0];
// TODO: format name to class.
message = message.replace('@', values[0]);
this.broadcast('chat', {
type: 'server',
message: message
});
}
sendWorld(player) {
let data = {
playerShipId: player.ship.id,

View file

@ -0,0 +1,54 @@
{
"roomEnter": [
"@ has entered the room, the cunt.",
"Oh, looks like @ decided to show up.",
"Here comes @.",
"Guys, it's over, @ is here",
"What a great time we're having. Aw crap, here's @.",
"@ has entered the room.",
"Some guy by the name of @ decided to show up.",
"A wild @ appeared!",
"Oh no, @ just arrived.",
"Look out it's @!",
"@ has come for a visit.",
"Out of nowhere, @ arrives.",
"@ has penetrated the room.",
"@ showed up.",
"Good news, everyone, @ is here.",
"@ joined the room.",
"@ has arrived to play with y'all.",
"@ entered the room, the audacity.",
"Someone let @ in again.",
"@ has decided to participate.",
"@ joined the game.",
"You know @, the weird one? Yeah, he just joined.",
"Uh-oh spaghetti-o, it's @.",
"@ joined the room :/",
"May as well leave now, @ just joined.",
"@ decided to turn up.",
"@ has popped by for a visit.",
"And like that annoying friend who won't go away, @ arrives.",
"@ now arrives, run for your lives",
"@ joined the room. This is a \"good\" thing.",
"For fuck's sake, @ has joined again.",
"Well great, @ entered the room.",
"@ has entered the room, hopefully they'll leave soon.",
"@ didn't listen when we told them to go away and has joined.",
"@ has entered the game. They actually did it. Wow.",
"@ entered the room, but maybe it won't be as bad as last time.",
"Everybody clap for @, the shithead who has joined the room.",
"@ has come by for a visit. Joy of joys."
],
"roomLeave": [
"@ has left, finally.",
"@ has left the room.",
"@ finally decided to leave.",
"@ is now gone, good ridance.",
"@ disconnected. Good.",
"After much waiting, @ has finally left.",
"@ is gone. Hopefully it'll stay that way.",
"Thankfully @ has left the room.",
"@ has exited the game :)",
"@ left. Now hope they don't come back."
]
}

View file

@ -30,8 +30,8 @@ class Ship extends Body {
this.size = traits.size;
// Mounts
traits.mounts.forEach((mount, i) => {
let mounts = new Mount(this, mount);
traits.mounts.forEach((data, i) => {
let mount = new Mount(this, data);
this.mounts.push(mount);
});
@ -112,7 +112,7 @@ class Ship extends Body {
name: this.player.name,
frame: this.frame,
power: this.power,
mounts: this.traits.mounts,
mounts: this.mounts.map(m => m.packFull()),
turrets: this.turrets,
size: this.size,
delta: this.packDelta()

View file

@ -19,6 +19,12 @@ class Mount {
if (!this.fixture) return;
this.fixture.destruct();
}
packFull() {
return {
}
}
}
module.exports = Mount;

View file

@ -20,6 +20,11 @@ class WingbaseServer extends ServerInterface {
this.log(`Wingbase version ${packageJson.version} running.`);
}
stop() {
this.log('Server stopping.');
process.exit();
}
}
function init() {

View file

@ -12,18 +12,26 @@ class WebServer {
}
start() {
this.appServer.listen(8080);
this.appServer.listen(process.env.PORT || 8080);
let app = this.app;
app.get('/starbugs.min.js', (req, res) => {
app.set('views', './public/views');
app.set('view engine', 'jade');
app.engine('jade', require('jade').__express);
app.get('/wingbase.min.js', (req, res) => {
minify(result => {
res.contentType('starbugs.min.js');
res.contentType('wingbase.min.js');
res.end(result);
});
});
app.use(express.static('public'));
app.get('/', (req, res) => {
res.render('index', {});
});
app.use(express.static('public/static'));
}
}

View file

@ -9,7 +9,7 @@ const uglify = require('uglify-js');
function minifyJs(callback) {
callback = callback || function() {};
var dir = path.join(__dirname, '../../public/js/wingbase');
var dir = path.join(__dirname, '../../public/static/js/wingbase');
var cache = '';
var scripts = [];