#!/usr/bin/env jruby require 'rubygems' require 'fileutils' def load_game_machine begin require 'game_machine' rescue LoadError require_relative '../lib/game_machine' end end ARGV << '--help' if ARGV.empty? aliases = { "n" => "new", "b" => "build", "s" => "server", "sl" => "server_loop" } command = ARGV.shift command = aliases[command] || command ENV['APP_ROOT'] ||= File.expand_path(Dir.pwd) ENV['JAVA_ROOT'] = File.join(ENV['APP_ROOT'],'java') ENV['GAME_ENV'] = 'development' require_relative '../lib/game_machine/console' if command == 'new' bin_path = File.dirname(__FILE__) install_source_path = File.expand_path( File.join(bin_path,'../') ) GameMachine::Console::Install.new(ARGV,install_source_path).run! elsif command == 'build' require_relative '../java/local_lib/protostuff-compiler-1.0.7-jarjar.jar' require_relative '../lib/game_machine/protobuf/game_messages.rb' require_relative '../lib/game_machine/protobuf/generate.rb' GameMachine::Console::Build.new(ARGV).run! elsif command == 'server' # Need to set environment vars before loading everything. server = GameMachine::Console::Server.new(ARGV) server.set_environment load_game_machine # Run the server server.run! elsif command == 'server_loop' GameMachine::Console::Server.run_in_loop else puts <