/**
 * Created by meathill on 15/9/25.
 */
'use strict';

var express = require('express')
  , handlebars = require('handlebars')
  , fs = require('fs')
  , app = new express()
  , server = require('http').Server(app)
  , config = require('./config')
  , io = require('socket.io')(server)
  , Gobang = require('./game/gobang')
  , Admin = require('./admin/admin');

process.title = 'xgame';

server.listen(config.port);

app.use('/', express.static('public'));

app.get('/:game/:room', function (req, res) {
  let template = handlebars.compile(fs.readFileSync('./public/game/' + req.params.game + '.hbs', 'utf8'))
    , page = template({
      room: req.params.room
    });
  res.send(page);
});

var gobang = new Gobang(io.of('/gobang'))
  , admin = new Admin(io.of('/admin'));

console.log('game server start');
