Skip to content
This repository has been archived by the owner on May 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #6 from arxanas/master
Browse files Browse the repository at this point in the history
arxanas updates
  • Loading branch information
dev-id authored Jul 17, 2016
2 parents 5c18da6 + c3eec0e commit f5cacea
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ var server = http.createServer(function(req, res) {
var eioServer = eio(server).on('connection', router)

require('log-timestamp')
console.log('Started up')
console.log(`Started up ${CONFIG.VERSION}`)
23 changes: 23 additions & 0 deletions config.server.js.default
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
'use strict';

const execSync = require('child_process').execSync

let versionInfo = execSync('git describe --always --long')
.toString()
.trim()
let versionInfoParts = versionInfo.split('-')

const VERSION =
versionInfoParts.length === 3

// Show the number of commits past the most recent tag, and the commit hash
// identifier. For example, `v2.0.0+3 (123abc)` indicates three commits past
// version 2.0.0, at commit `123abc`. (In the `git-describe` output, there is
// always a `g` before the commit hash, which stands for 'git', so we remove
// that.)
? `${versionInfoParts[0]}+${versionInfoParts[1]} (${versionInfoParts[2].slice(1)})`

// If there is no tag, just display the commit hash.
: versionInfo

module.exports = {
PORT: 1337,
VERSION,
STRINGS: {
BRANDING: {
DEFAULT_USERNAME: 'ninja',
Expand Down
1 change: 1 addition & 0 deletions public/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let App = {
id: null,
name: STRINGS.BRANDING.DEFAULT_USERNAME,

serverVersion: null,
numUsers: 0,
numPlayers: 0,
numActiveGames: 0,
Expand Down
33 changes: 22 additions & 11 deletions public/src/components/lobby.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,7 @@ export default React.createClass({
d.header({},
d.h1({ className: 'lobby-header' },
Spaced(...STRINGS.BRANDING.SITE_NAME))),

d.p({},
Spaced(
`${App.state.numUsers}
${App.state.numUsers === 1 ? 'user' : 'users'}
connected`,
`${App.state.numPlayers}
${App.state.numPlayers === 1 ? 'player' : 'players'}
playing
${App.state.numActiveGames}
${App.state.numActiveGames === 1 ? 'game' : 'games'}`)),
ServerInfo(),
d.p({ className: 'error' }, App.err),
Create(),
Join(),
Expand Down Expand Up @@ -98,6 +88,27 @@ function Motd() {
d.div({}, motd))
}

function ServerInfo() {
let numUsers =
`${App.state.numUsers}
${App.state.numUsers === 1 ? 'user' : 'users'}
connected`

let numPlayers =
`${App.state.numPlayers}
${App.state.numPlayers === 1 ? 'player' : 'players'}
playing
${App.state.numActiveGames}
${App.state.numActiveGames === 1 ? 'game' : 'games'}`

let serverVersion =
App.state.serverVersion
? `Running ${App.state.serverVersion}`
: null

return d.p({}, Spaced(...[numUsers, numPlayers, serverVersion]))
}

function Create() {
let seats = _.seq(100, 2).map(x =>
d.option({}, x))
Expand Down
2 changes: 2 additions & 0 deletions public/src/components/spacer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
let d = React.DOM

export function Spaced(...elements) {
elements = elements.filter(x => x)

let parts = []
for (let part of elements) {
parts.push(d.span({}, part))
Expand Down
4 changes: 2 additions & 2 deletions src/router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {MOTD} = require('../config.server')
const {VERSION} = require('../config.server')
var Game = require('./game')
var Room = require('./room')
var Sock = require('./sock')
Expand Down Expand Up @@ -40,5 +40,5 @@ module.exports = function (ws) {
sock.on('create', create)

Game.broadcastGameInfo()
sock.send('set', { motd: MOTD })
sock.send('set', { serverVersion: VERSION })
}

0 comments on commit f5cacea

Please sign in to comment.