laurynasl / rubyrogue

Currently just a growing skeleton for roguelike game being written in ruby (NCurses interface) and tested with RSpec

This URL has Read+Write access

laurynasl (author)
Mon Dec 15 10:55:47 -0800 2008
commit  3fa432309dc07d4b5e1a5d826dfff20ac25e43f1
tree    7ee05225f09ebebf50dd92d5c0f388f14ee79108
parent  cc0dfa23c018567517a16205001846149573b854
rubyrogue / boot.rb
100644 70 lines (62 sloc) 1.768 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Copyright (C) 2008 Laurynas Liutkus
# All rights reserved. See the file named LICENSE in the distribution
# for more details.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
$: << 'app'
require 'rubygems'
require 'rdoc/ri/ri_paths'
require 'rdoc/usage'
require 'lib/fov/ruby_fov'
require 'lib/vector'
require 'app/array'
 
class String
  def underscore
    self.to_s.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
  end
end
 
class Module
  alias :const_missing_before_rubyrogue :const_missing
  def const_missing(name)
    filename = 'app/' + name.to_s.underscore + '.rb'
    if File.exist?(filename)
      log 'requiring: ' + filename
      require filename
      eval name.to_s
    else
      const_missing_before_rubyrogue(name)
    end
  end
end
 
module Enumerable
  def invoke(method)
    collect{|i| i.send(method)}
  end
end
 
def log(text)
  $logfile ||= File.new('log/stdout.log', 'a')
  $logfile << text.to_s + "\n"
  $logfile.flush
end
 
def min(a, b)
  a < b ? a : b
end
 
def max(a, b)
  a > b ? a : b
end