/** * Copyright 2015 Christopher Scott. All rights reserved. */ isMiniGame = true; function defineMiniGame() { miniGame = { 'id': 'invasion', 'events': { 'death': function(object) { triggerEvent('end_game', false); }, 'birth': function(object) { }, 'restart': function() { stopFireSounds(); miniGame.variables(); }, 'end_game': function(won) { gameOver = true; game.paused = true; } }, 'variables': function() { ceaseFire = true; networking = true; }, 'unit_attributes': { '138-1': { // archer 'cost': 30, 'attack': 13, 'speed': 70, 'health': 50 } }, 'start_functions': function() { if (!gameReset) { playSoundNext('sunrise', null, .3, true); } } } miniGame.variables(); createNetworkConnection(); chat(); // addExistingObjects(); } function createNetworkConnection() { socket = io('http://feudalwars.net:8087/'); socket.on('game_state', function(options) { ceaseFire = true; networkAction('game_state', options, socket); }); socket.on('move', function(options) { networkAction('move', options); }); socket.on('disconnect', function(options) { networkAction('disconnect', options); }); socket.on('spawn_unit', function(options) { networkAction('spawn_unit', options, socket); }); socket.on('set_player', function(player) { networkAction('set_player', player); }); } function chat() { $('body').append('
'); $('form#chat').submit(function() { socket.emit('chat message', $('#m').val()); $('#m').val(''); return false; }); socket.on('chat message', function(msg) { var li = $('
  • ').text(loggedInUser + ': ' + msg); $('#messages').append(li); setTimeout(function() { li.fadeOut(2000); },4000); }); }