Skip to content

Instantly share code, notes, and snippets.

arturas@zeus:~/work/spacegame/server$ jruby --1.9 -S rake spec:controllers
/home/arturas/.rvm/rubies/jruby-1.6.5/bin/jruby -S rspec spec/controllers/players_controller_spec.rb spec/controllers/buildings_controller_spec.rb spec/controllers/technologies_controller_spec.rb spec/controllers/announcements_controller_spec.rb spec/controllers/daily_bonus_controller_spec.rb spec/controllers/player_options_controller_spec.rb spec/controllers/chat_controller_spec.rb spec/controllers/objects_controller_spec.rb spec/controllers/quests_controller_spec.rb spec/controllers/routes_controller_spec.rb spec/controllers/market_controller_spec.rb spec/controllers/solar_systems_controller_spec.rb spec/controllers/planets_controller_spec.rb spec/controllers/alliances_controller_spec.rb spec/controllers/notifications_controller_spec.rb spec/controllers/units_controller_spec.rb spec/controllers/game_controller_spec.rb spec/controllers/combat_logs_controller_spec.rb spec/controllers/galaxies_controller_spec.rb spec/controllers/constru
@@ -23,25 +23,27 @@ package models.healing
public var cooldown: int = 0;
public static function calculateRepairPrice(building: Building): HealPrice
{
var priceMod : Number = tech.repairPriceMod;
var cooldownMod: Number = tech.repairCooldownMod;
- price.metal = Math.round(Upgradable.calculateCost(UpgradableType.BUILDINGS,
- building.type, ResourceType.METAL, {'level': building.level})
- * priceMod * building.damagePercentage);
jruby-1.6.5 :018 > c = ActiveRecord::Base.connection.raw_connection.with_connection_retry_guard { |c| c }
=> #<Java::ComMysqlJdbc::JDBC4Connection:0x1200320>
jruby-1.6.5 :019 > c.create_statement
=> #<Java::ComMysqlJdbc::StatementImpl:0x16f974f>
RSpec::Matchers.define :be_created_from_static_ss_configuration do
|configuration|
def check_planet(position_str, ss_conditions, data)
exp_to = "Expected planet @ #{position_str} to"
if SsObject::Planet.where(ss_conditions).exists?
planet = SsObject::Planet.where(ss_conditions).first
owned_by_player = ! planet.player_id.nil?
@errors << "#{exp_to} have owned_by_player: #{data["owned_by_player"]
Server has encountered an error!
UNEXPECTED EXCEPTION: java.lang.RuntimeException: could not shut down process: java.lang.UNIXProcess@fde438
Message:
{"params":{"version":"2011-1104-1211","web_player_id":2567,"server_player_id":909},"id":"1320523371429","action":"players|login"}
Backtrace:
org.jruby.RubyIO.obliterateProcess(RubyIO.java:4049)
org.jruby.util.ShellLauncher$POpenProcess.destroy(ShellLauncher.java:886)
org.jruby.RubyIO.obliterateProcess(RubyIO.java:4053)
org.jruby.RubyIO.close2(RubyIO.java:1998)
@arturaz
arturaz / gist:1231939
Created September 21, 2011 12:46
SpaceMule::Pathfinder
# Invokes SpaceMule pathfinder.
module SpaceMule::Pathfinder
# Scala constants
Coords = SpaceMule::Pmg.classes.geom.Coords
Pf = SpaceMule::SmModules.pathfinder
PfO = Pf.objects
def self.invoke(source, target, avoid_npc)
avoidable_points = []
@arturaz
arturaz / gist:1231932
Created September 21, 2011 12:43
SpaceMule
lambda do
jar_path = File.join(ROOT_DIR, 'vendor', 'SpaceMule', 'dist', 'SpaceMule.jar')
# Win32 requires us to manually require all the jars before requiring
# main jar.
Dir[File.dirname(jar_path) + "/lib/*.jar"].each { |jar| require jar }
require jar_path
# Scala <-> Ruby interoperability.
class Object
object Finder {
def none = None
def test(t: Option[Int]) { println(t.get) }
}
>> f = SpaceMule::PfO.Finder
=> Java::SpacemuleModulesPathfinderObjects::Finder
>>
?> f.test(f.none)
NativeException: java.util.NoSuchElementException: None.get
object Finder {
def test(t: Option[Int]) { println(t.get) }
}
>> SpaceMule::PfO.Finder.test(Some(3))
3
=> nil
>> SpaceMule::PfO.Finder.test(None)
NameError: no method 'test' for arguments (org.jruby.RubyClass) on Java::SpacemuleModulesPathfinderObjects::Finder
@arturaz
arturaz / gist:1214967
Created September 13, 2011 20:05
Call args
[#<Java::SpacemuleModulesPathfinderObjects::GalaxyPoint:0x46c34>, #<Java::ScalaCollectionImmutable::HashSet:0x838d2a>, Java::Scala::None, Java::Scala::None, #<Java::SpacemuleModulesPathfinderObjects::GalaxyPoint:0x1af2cc0>, #<Java::ScalaCollectionImmutable::HashSet:0x166d133>, Java::Scala::None, Java::Scala::None, Java::Scala::None]