rubyplay_framework 1.6.4 → 1.6.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c77d7b777232da3f802d9d9159e08562e3c105d
4
- data.tar.gz: f3cd748d4c311ae2c5e7a16be17ad9bbe6bf33f3
3
+ metadata.gz: 4ffde0f9a94ffc46604e5fbcf531397362930d1a
4
+ data.tar.gz: 44c4fe0fc5a5f6f6eb753361c091193c60961992
5
5
  SHA512:
6
- metadata.gz: 9a7e262d96c1601a4cb2683c3bb7cda23ba156a878dcb0fdf46782b39118f6b82978f6a1f691c8e97c0ba9688181f3bf31f5714bbdc166ec16fcb73eafbe6c8f
7
- data.tar.gz: 8f267960659b72c214d951bf99b11bf6bfc5f74c90e4346c8fbbca990344de579ddb8fa7be3fa067c8851e5391b97eb37f41179824867baaea5b65bf5ef6c120
6
+ metadata.gz: d44d04e753525ccf9927b467ccd03d2e7a3cfa3089f7d124d9ffe8a0f9da2e798f69ef7053af90418a93399fb252425c7f4a8516118dcd6957ced2e40935f29d
7
+ data.tar.gz: 65a7db2dbfe59f1867b6b88088633ba7275257f22beeacdd68e758c077ccada68802a23615fb0c0ebf06f863e2fe3b8eea3cf026f7afebdcfb1de8dbb85e37fb
@@ -1,94 +1,94 @@
1
- #--
2
- # DO NOT MODIFY!!!!
3
- # This file is automatically generated by rex 1.0.5
4
- # from lexical definition file "lib/interpreter/gameLexer.rex".
5
- #++
6
-
7
- require 'racc/parser'
8
- class GameLanguage < Racc::Parser
9
- require 'strscan'
10
-
11
- class ScanError < StandardError ; end
12
-
13
- attr_reader :lineno
14
- attr_reader :filename
15
- attr_accessor :state
16
-
17
- def scan_setup(str)
18
- @ss = StringScanner.new(str)
19
- @lineno = 1
20
- @state = nil
21
- end
22
-
23
- def action
24
- yield
25
- end
26
-
27
- def scan_str(str)
28
- scan_setup(str)
29
- do_parse
30
- end
31
- alias :scan :scan_str
32
-
33
- def load_file( filename )
34
- @filename = filename
35
- open(filename, "r") do |f|
36
- scan_setup(f.read)
37
- end
38
- end
39
-
40
- def scan_file( filename )
41
- load_file(filename)
42
- do_parse
43
- end
44
-
45
-
46
- def next_token
47
- return if @ss.eos?
48
-
49
- # skips empty actions
50
- until token = _next_token or @ss.eos?; end
51
- token
52
- end
53
-
54
- def _next_token
55
- text = @ss.peek(1)
56
- @lineno += 1 if text == "\n"
57
- token = case @state
58
- when nil
59
- case
60
- when (text = @ss.scan(/[ \t]+[a-z]+|[ \t]+[A-Z][a-z]+|[ \t]+[a-z]+\d+|[ \t]+[A-Z][a-z]+\d+/))
61
- action { [:WORD, text.gsub!(/[\ \t]+/,'')] }
62
-
63
- when (text = @ss.scan(/[ \t]+/))
64
- ;
65
-
66
- when (text = @ss.scan(/\d+|-\d+/))
67
- action {[:NUMBER, text.to_i]}
68
-
69
- when (text = @ss.scan(/\d+\.\d+|-\d+\.\d+/))
70
- action {[:FLOAT, test.to_f]}
71
-
72
- when (text = @ss.scan(/\w+/))
73
- action {[:FUNCTION, text]}
74
-
75
- else
76
- text = @ss.string[@ss.pos .. -1]
77
- raise ScanError, "can not match: '" + text + "'"
78
- end # if
79
-
80
- else
81
- raise ScanError, "undefined state: '" + state.to_s + "'"
82
- end # case state
83
- token
84
- end # def _next_token
85
-
86
- def tokenize(code)
87
- scan_setup(code)
88
- tokens = []
89
- while token = next_token
90
- tokens << token
91
- end
92
- tokens
93
- end
94
- end # class
1
+ #--
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by rex 1.0.5
4
+ # from lexical definition file "lib/interpreter/gameLexer.rex".
5
+ #++
6
+
7
+ require 'racc/parser'
8
+ class GameLanguage < Racc::Parser
9
+ require 'strscan'
10
+
11
+ class ScanError < StandardError ; end
12
+
13
+ attr_reader :lineno
14
+ attr_reader :filename
15
+ attr_accessor :state
16
+
17
+ def scan_setup(str)
18
+ @ss = StringScanner.new(str)
19
+ @lineno = 1
20
+ @state = nil
21
+ end
22
+
23
+ def action
24
+ yield
25
+ end
26
+
27
+ def scan_str(str)
28
+ scan_setup(str)
29
+ do_parse
30
+ end
31
+ alias :scan :scan_str
32
+
33
+ def load_file( filename )
34
+ @filename = filename
35
+ open(filename, "r") do |f|
36
+ scan_setup(f.read)
37
+ end
38
+ end
39
+
40
+ def scan_file( filename )
41
+ load_file(filename)
42
+ do_parse
43
+ end
44
+
45
+
46
+ def next_token
47
+ return if @ss.eos?
48
+
49
+ # skips empty actions
50
+ until token = _next_token or @ss.eos?; end
51
+ token
52
+ end
53
+
54
+ def _next_token
55
+ text = @ss.peek(1)
56
+ @lineno += 1 if text == "\n"
57
+ token = case @state
58
+ when nil
59
+ case
60
+ when (text = @ss.scan(/[ \t]+[a-z]+|[ \t]+[A-Z][a-z]+|[ \t]+[a-z]+\d+|[ \t]+[A-Z][a-z]+\d+/))
61
+ action { [:WORD, text.gsub!(/[\ \t]+/,'')] }
62
+
63
+ when (text = @ss.scan(/[ \t]+/))
64
+ ;
65
+
66
+ when (text = @ss.scan(/\d+|-\d+/))
67
+ action {[:NUMBER, text.to_i]}
68
+
69
+ when (text = @ss.scan(/\d+\.\d+|-\d+\.\d+/))
70
+ action {[:FLOAT, test.to_f]}
71
+
72
+ when (text = @ss.scan(/\w+/))
73
+ action {[:FUNCTION, text]}
74
+
75
+ else
76
+ text = @ss.string[@ss.pos .. -1]
77
+ raise ScanError, "can not match: '" + text + "'"
78
+ end # if
79
+
80
+ else
81
+ raise ScanError, "undefined state: '" + state.to_s + "'"
82
+ end # case state
83
+ token
84
+ end # def _next_token
85
+
86
+ def tokenize(code)
87
+ scan_setup(code)
88
+ tokens = []
89
+ while token = next_token
90
+ tokens << token
91
+ end
92
+ tokens
93
+ end
94
+ end # class
@@ -1,24 +1,24 @@
1
- class GameLanguage
2
- macro
3
- BLANK [\ \t]+ #only works on macro
4
- NUMBER \d+|-\d+
5
- FLOAT \d+\.\d+|-\d+\.\d+
6
- WORD [\ \t]+[a-z]+|[\ \t]+[A-Z][a-z]+|[\ \t]+[a-z]+\d+|[\ \t]+[A-Z][a-z]+\d+
7
- FUNCTION \w+
8
- rule
9
- {WORD} { [:WORD, text.gsub!(/[\ \t]+/,'')] }
10
- {BLANK} #do nothing
11
- {NUMBER} {[:NUMBER, text.to_i]}
12
- {FLOAT} {[:FLOAT, test.to_f]}
13
- {FUNCTION} {[:FUNCTION, text]}
14
-
15
- inner
16
- def tokenize(code)
17
- scan_setup(code)
18
- tokens = []
19
- while token = next_token
20
- tokens << token
21
- end
22
- tokens
23
- end
1
+ class GameLanguage
2
+ macro
3
+ BLANK [\ \t]+ #only works on macro
4
+ NUMBER \d+|-\d+
5
+ FLOAT \d+\.\d+|-\d+\.\d+
6
+ WORD [\ \t]+[a-z]+|[\ \t]+[A-Z][a-z]+|[\ \t]+[a-z]+\d+|[\ \t]+[A-Z][a-z]+\d+
7
+ FUNCTION \w+
8
+ rule
9
+ {WORD} { [:WORD, text.gsub!(/[\ \t]+/,'')] }
10
+ {BLANK} #do nothing
11
+ {NUMBER} {[:NUMBER, text.to_i]}
12
+ {FLOAT} {[:FLOAT, test.to_f]}
13
+ {FUNCTION} {[:FUNCTION, text]}
14
+
15
+ inner
16
+ def tokenize(code)
17
+ scan_setup(code)
18
+ tokens = []
19
+ while token = next_token
20
+ tokens << token
21
+ end
22
+ tokens
23
+ end
24
24
  end
@@ -1,40 +1,40 @@
1
- class GameLanguage
2
- rule
3
- function : FUNCTION
4
- | FUNCTION WORD { return val }
5
- | FUNCTION WORD WORD { return val }
6
- | FUNCTION WORD WORD WORD { return val }
7
- | FUNCTION WORD WORD WORD WORD { return val }
8
- | FUNCTION NUMBER NUMBER { return val }
9
- | FUNCTION NUMBER NUMBER NUMBER { return val }
10
- end
11
-
12
- ---- header
13
- require_relative 'gameLexer'
14
-
15
- ---- inner
16
- @@functions = []
17
-
18
- def parse(object, input)
19
- output = scan_str(input)
20
- if(output.kind_of?(Array))
21
- if(@@functions.find { |f| (f[0] == output[0]) && (f.length == output.length) })
22
- object.public_send(output[0].to_sym, *(output.drop(1)))
23
- else
24
- raise RuntimeError, "No such function #{output[0]}"
25
- end
26
- else
27
- if(@@functions.find { |f| (f[0] == output) })
28
- object.public_send(output.to_sym)
29
- else
30
- raise RuntimeError, "No such function #{output}"
31
- end
32
- end
33
- end
34
-
35
- def intialize_functions(filename)
36
- file = File.open(filename).read
37
- file.each_line { |line|
38
- @@functions << line.gsub(/\s+/, ' ').strip.split(" ")
39
- }
1
+ class GameLanguage
2
+ rule
3
+ function : FUNCTION
4
+ | FUNCTION WORD { return val }
5
+ | FUNCTION WORD WORD { return val }
6
+ | FUNCTION WORD WORD WORD { return val }
7
+ | FUNCTION WORD WORD WORD WORD { return val }
8
+ | FUNCTION NUMBER NUMBER { return val }
9
+ | FUNCTION NUMBER NUMBER NUMBER { return val }
10
+ end
11
+
12
+ ---- header
13
+ require_relative 'gameLexer'
14
+
15
+ ---- inner
16
+ @@functions = []
17
+
18
+ def parse(object, input)
19
+ output = scan_str(input)
20
+ if(output.kind_of?(Array))
21
+ if(@@functions.find { |f| (f[0] == output[0]) && (f.length == output.length) })
22
+ object.public_send(output[0].to_sym, *(output.drop(1)))
23
+ else
24
+ raise RuntimeError, "No such function #{output[0]}"
25
+ end
26
+ else
27
+ if(@@functions.find { |f| (f[0] == output) })
28
+ object.public_send(output.to_sym)
29
+ else
30
+ raise RuntimeError, "No such function #{output}"
31
+ end
32
+ end
33
+ end
34
+
35
+ def intialize_functions(filename)
36
+ file = File.open(filename).read
37
+ file.each_line { |line|
38
+ @@functions << line.gsub(/\s+/, ' ').strip.split(" ")
39
+ }
40
40
  end
@@ -1,172 +1,172 @@
1
- #
2
- # DO NOT MODIFY!!!!
3
- # This file is automatically generated by Racc 1.4.14
4
- # from Racc grammer file "".
5
- #
6
-
7
- require 'racc/parser.rb'
8
-
9
- require_relative 'gameLexer'
10
-
11
- class GameLanguage < Racc::Parser
12
-
13
- module_eval(<<'...end gameParser.racc/module_eval...', 'gameParser.racc', 16)
14
- @@functions = []
15
-
16
- def parse(object, input)
17
- output = scan_str(input)
18
- if(output.kind_of?(Array))
19
- if(@@functions.find { |f| (f[0] == output[0]) && (f.length == output.length) })
20
- object.public_send(output[0].to_sym, *(output.drop(1)))
21
- else
22
- raise RuntimeError, "No such function #{output[0]}"
23
- end
24
- else
25
- if(@@functions.find { |f| (f[0] == output) })
26
- object.public_send(output.to_sym)
27
- else
28
- raise RuntimeError, "No such function #{output}"
29
- end
30
- end
31
- end
32
-
33
- def intialize_functions(filename)
34
- file = File.open(filename).read
35
- file.each_line { |line|
36
- @@functions << line.gsub(/\s+/, ' ').strip.split(" ")
37
- }
38
- end
39
- ...end gameParser.racc/module_eval...
40
- ##### State transition tables begin ###
41
-
42
- racc_action_table = [
43
- 4, 5, 7, 2, 6, 3, 8, 9, 10, 11 ]
44
-
45
- racc_action_check = [
46
- 2, 2, 4, 0, 3, 1, 5, 7, 8, 9 ]
47
-
48
- racc_action_pointer = [
49
- 1, 5, -3, 4, -1, 2, nil, 4, 4, 6,
50
- nil, nil ]
51
-
52
- racc_action_default = [
53
- -8, -8, -1, -8, -2, -8, 12, -3, -6, -4,
54
- -7, -5 ]
55
-
56
- racc_goto_table = [
57
- 1 ]
58
-
59
- racc_goto_check = [
60
- 1 ]
61
-
62
- racc_goto_pointer = [
63
- nil, 0 ]
64
-
65
- racc_goto_default = [
66
- nil, nil ]
67
-
68
- racc_reduce_table = [
69
- 0, 0, :racc_error,
70
- 1, 6, :_reduce_none,
71
- 2, 6, :_reduce_2,
72
- 3, 6, :_reduce_3,
73
- 4, 6, :_reduce_4,
74
- 5, 6, :_reduce_5,
75
- 3, 6, :_reduce_6,
76
- 4, 6, :_reduce_7 ]
77
-
78
- racc_reduce_n = 8
79
-
80
- racc_shift_n = 12
81
-
82
- racc_token_table = {
83
- false => 0,
84
- :error => 1,
85
- :FUNCTION => 2,
86
- :WORD => 3,
87
- :NUMBER => 4 }
88
-
89
- racc_nt_base = 5
90
-
91
- racc_use_result_var = true
92
-
93
- Racc_arg = [
94
- racc_action_table,
95
- racc_action_check,
96
- racc_action_default,
97
- racc_action_pointer,
98
- racc_goto_table,
99
- racc_goto_check,
100
- racc_goto_default,
101
- racc_goto_pointer,
102
- racc_nt_base,
103
- racc_reduce_table,
104
- racc_token_table,
105
- racc_shift_n,
106
- racc_reduce_n,
107
- racc_use_result_var ]
108
-
109
- Racc_token_to_s_table = [
110
- "$end",
111
- "error",
112
- "FUNCTION",
113
- "WORD",
114
- "NUMBER",
115
- "$start",
116
- "function" ]
117
-
118
- Racc_debug_parser = false
119
-
120
- ##### State transition tables end #####
121
-
122
- # reduce 0 omitted
123
-
124
- # reduce 1 omitted
125
-
126
- module_eval(<<'.,.,', 'gameParser.racc', 3)
127
- def _reduce_2(val, _values, result)
128
- return val
129
- result
130
- end
131
- .,.,
132
-
133
- module_eval(<<'.,.,', 'gameParser.racc', 4)
134
- def _reduce_3(val, _values, result)
135
- return val
136
- result
137
- end
138
- .,.,
139
-
140
- module_eval(<<'.,.,', 'gameParser.racc', 5)
141
- def _reduce_4(val, _values, result)
142
- return val
143
- result
144
- end
145
- .,.,
146
-
147
- module_eval(<<'.,.,', 'gameParser.racc', 6)
148
- def _reduce_5(val, _values, result)
149
- return val
150
- result
151
- end
152
- .,.,
153
-
154
- module_eval(<<'.,.,', 'gameParser.racc', 7)
155
- def _reduce_6(val, _values, result)
156
- return val
157
- result
158
- end
159
- .,.,
160
-
161
- module_eval(<<'.,.,', 'gameParser.racc', 8)
162
- def _reduce_7(val, _values, result)
163
- return val
164
- result
165
- end
166
- .,.,
167
-
168
- def _reduce_none(val, _values, result)
169
- val[0]
170
- end
171
-
172
- end # class GameLanguage
1
+ #
2
+ # DO NOT MODIFY!!!!
3
+ # This file is automatically generated by Racc 1.4.14
4
+ # from Racc grammer file "".
5
+ #
6
+
7
+ require 'racc/parser.rb'
8
+
9
+ require_relative 'gameLexer'
10
+
11
+ class GameLanguage < Racc::Parser
12
+
13
+ module_eval(<<'...end gameParser.racc/module_eval...', 'gameParser.racc', 16)
14
+ @@functions = []
15
+
16
+ def parse(object, input)
17
+ output = scan_str(input)
18
+ if(output.kind_of?(Array))
19
+ if(@@functions.find { |f| (f[0] == output[0]) && (f.length == output.length) })
20
+ object.public_send(output[0].to_sym, *(output.drop(1)))
21
+ else
22
+ raise RuntimeError, "No such function #{output[0]}"
23
+ end
24
+ else
25
+ if(@@functions.find { |f| (f[0] == output) })
26
+ object.public_send(output.to_sym)
27
+ else
28
+ raise RuntimeError, "No such function #{output}"
29
+ end
30
+ end
31
+ end
32
+
33
+ def intialize_functions(filename)
34
+ file = File.open(filename).read
35
+ file.each_line { |line|
36
+ @@functions << line.gsub(/\s+/, ' ').strip.split(" ")
37
+ }
38
+ end
39
+ ...end gameParser.racc/module_eval...
40
+ ##### State transition tables begin ###
41
+
42
+ racc_action_table = [
43
+ 4, 5, 7, 2, 6, 3, 8, 9, 10, 11 ]
44
+
45
+ racc_action_check = [
46
+ 2, 2, 4, 0, 3, 1, 5, 7, 8, 9 ]
47
+
48
+ racc_action_pointer = [
49
+ 1, 5, -3, 4, -1, 2, nil, 4, 4, 6,
50
+ nil, nil ]
51
+
52
+ racc_action_default = [
53
+ -8, -8, -1, -8, -2, -8, 12, -3, -6, -4,
54
+ -7, -5 ]
55
+
56
+ racc_goto_table = [
57
+ 1 ]
58
+
59
+ racc_goto_check = [
60
+ 1 ]
61
+
62
+ racc_goto_pointer = [
63
+ nil, 0 ]
64
+
65
+ racc_goto_default = [
66
+ nil, nil ]
67
+
68
+ racc_reduce_table = [
69
+ 0, 0, :racc_error,
70
+ 1, 6, :_reduce_none,
71
+ 2, 6, :_reduce_2,
72
+ 3, 6, :_reduce_3,
73
+ 4, 6, :_reduce_4,
74
+ 5, 6, :_reduce_5,
75
+ 3, 6, :_reduce_6,
76
+ 4, 6, :_reduce_7 ]
77
+
78
+ racc_reduce_n = 8
79
+
80
+ racc_shift_n = 12
81
+
82
+ racc_token_table = {
83
+ false => 0,
84
+ :error => 1,
85
+ :FUNCTION => 2,
86
+ :WORD => 3,
87
+ :NUMBER => 4 }
88
+
89
+ racc_nt_base = 5
90
+
91
+ racc_use_result_var = true
92
+
93
+ Racc_arg = [
94
+ racc_action_table,
95
+ racc_action_check,
96
+ racc_action_default,
97
+ racc_action_pointer,
98
+ racc_goto_table,
99
+ racc_goto_check,
100
+ racc_goto_default,
101
+ racc_goto_pointer,
102
+ racc_nt_base,
103
+ racc_reduce_table,
104
+ racc_token_table,
105
+ racc_shift_n,
106
+ racc_reduce_n,
107
+ racc_use_result_var ]
108
+
109
+ Racc_token_to_s_table = [
110
+ "$end",
111
+ "error",
112
+ "FUNCTION",
113
+ "WORD",
114
+ "NUMBER",
115
+ "$start",
116
+ "function" ]
117
+
118
+ Racc_debug_parser = false
119
+
120
+ ##### State transition tables end #####
121
+
122
+ # reduce 0 omitted
123
+
124
+ # reduce 1 omitted
125
+
126
+ module_eval(<<'.,.,', 'gameParser.racc', 3)
127
+ def _reduce_2(val, _values, result)
128
+ return val
129
+ result
130
+ end
131
+ .,.,
132
+
133
+ module_eval(<<'.,.,', 'gameParser.racc', 4)
134
+ def _reduce_3(val, _values, result)
135
+ return val
136
+ result
137
+ end
138
+ .,.,
139
+
140
+ module_eval(<<'.,.,', 'gameParser.racc', 5)
141
+ def _reduce_4(val, _values, result)
142
+ return val
143
+ result
144
+ end
145
+ .,.,
146
+
147
+ module_eval(<<'.,.,', 'gameParser.racc', 6)
148
+ def _reduce_5(val, _values, result)
149
+ return val
150
+ result
151
+ end
152
+ .,.,
153
+
154
+ module_eval(<<'.,.,', 'gameParser.racc', 7)
155
+ def _reduce_6(val, _values, result)
156
+ return val
157
+ result
158
+ end
159
+ .,.,
160
+
161
+ module_eval(<<'.,.,', 'gameParser.racc', 8)
162
+ def _reduce_7(val, _values, result)
163
+ return val
164
+ result
165
+ end
166
+ .,.,
167
+
168
+ def _reduce_none(val, _values, result)
169
+ val[0]
170
+ end
171
+
172
+ end # class GameLanguage
data/lib/map/dungeon.rb CHANGED
@@ -52,7 +52,7 @@ module MapDungeon
52
52
  end
53
53
 
54
54
  #Dungeon builder class
55
- class DungeonXPathBuilder
55
+ class DungeonBuilder
56
56
  include MapEntity
57
57
 
58
58
  def initialize()
@@ -61,22 +61,22 @@ module MapDungeon
61
61
 
62
62
  attr_reader :dungeon
63
63
 
64
- def build_XML_dungeon(name, description, node = nil, entityBuilder = "")
64
+ def build_dungeon(name, description, node = nil, entityBuilder = "")
65
65
  add_name(name)
66
66
  add_description(description)
67
67
  if(node != nil)
68
- node.each() { |entity|
68
+ node.each() do |entity|
69
69
  args = []
70
70
  if(entityBuilder.length > 0)
71
71
  builder = Object::const_get(entityBuilder).new()
72
72
  else
73
- builder = EntityXPathBuilder.new()
73
+ builder = EntityBuilder.new()
74
74
  end
75
75
  nodeSet = entity.xpath("*")
76
76
  nodeSet.each { |n| args << n.content }
77
- builder.build_XML_entity(*(args))
77
+ builder.build_entity(*(args))
78
78
  @dungeon.add_entity(builder.entity, builder.entity.type)
79
- }
79
+ end
80
80
  end
81
81
  end
82
82
 
data/lib/map/entity.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'nokogiri'
2
-
3
1
  module MapEntity
4
2
 
5
3
  class Entity
@@ -32,7 +30,7 @@ module MapEntity
32
30
  end
33
31
 
34
32
  #Entity builder class
35
- class EntityXPathBuilder
33
+ class EntityBuilder
36
34
 
37
35
  def initialize()
38
36
  @entity = Entity.new()
@@ -41,7 +39,7 @@ module MapEntity
41
39
  attr_reader :entity
42
40
 
43
41
  #Builds the entity of a dungeon
44
- def build_XML_entity(type, nametag)
42
+ def build_entity(type, nametag)
45
43
  add_type(type)
46
44
  add_nametag(nametag)
47
45
  end
data/lib/map/map.rb CHANGED
@@ -24,20 +24,26 @@ include MapPoint, MapDungeon, MapEntity
24
24
  doc = parse_from_XML(filePath)
25
25
  end
26
26
  doc.remove_namespaces!
27
- doc.xpath("//node").each() { |node|
27
+ doc.xpath("//node").each() do |node|
28
28
  coords = node.xpath("point//*")
29
29
  point = build_point(coords, pointBuilder)
30
30
  dungeonElements = node.xpath("dungeon//*[not(name()='entity') and not(ancestor-or-self::entity)]")
31
31
  dungeon = build_dungeon(node, dungeonElements, dungeonBuilder, entityBuilder)
32
32
  @map_nodes[point] = dungeon
33
33
  build_adjacent(point, node, pointBuilder)
34
- }
34
+ end
35
35
  p = @map_nodes.keys().sample() #Get random key
36
36
  if(@map_nodes.length() != check_connectivity(p))
37
37
  raise MapExceptions::MalformedMapException.new()
38
38
  end
39
39
  end
40
40
 
41
+ #Allows to make a movement without creating a explicit Point object
42
+ def move(point, entity, movX = 0, movY = 0, movZ = 0)
43
+ toPoint = Point.new(point.x()+movX, point.y()+movY, point.z()+movZ)
44
+ movement(point, toPoint, entity)
45
+ end
46
+
41
47
  #Puts move the entity from one point to an adjacent
42
48
  def movement(fromPoint, toPoint, entity)
43
49
  if(is_adjacent?(fromPoint, toPoint))
@@ -48,12 +54,6 @@ include MapPoint, MapDungeon, MapEntity
48
54
  end
49
55
  end
50
56
 
51
- #Allows to make a movement without creating a explicit Point object
52
- def move(point, entity, movX = 0, movY = 0, movZ = 0)
53
- toPoint = Point.new(point.x()+movX, point.y()+movY, point.z()+movZ)
54
- movement(point, toPoint, entity)
55
- end
56
-
57
57
  #Check if point2 is in the adjacent list of point1
58
58
  def is_adjacent?(point1, point2)
59
59
  @adjacencies[point1].find { |p| point2 == p }
@@ -121,11 +121,11 @@ include MapPoint, MapDungeon, MapEntity
121
121
  #Checks if the map generated is fully connected
122
122
  def check_connectivity(point, visited = Hash.new())
123
123
  visited[point] = 1
124
- @adjacencies[point].each { |nextPoint|
124
+ @adjacencies[point].each do |nextPoint|
125
125
  if(!visited.has_key?(nextPoint))
126
126
  check_connectivity(nextPoint, visited)
127
127
  end
128
- }
128
+ end
129
129
  return visited.length()
130
130
  end
131
131
 
@@ -133,13 +133,13 @@ include MapPoint, MapDungeon, MapEntity
133
133
  def shortest_path(initial, destination)
134
134
  distance = Hash.new()
135
135
  visited = Hash.new()
136
- @adjacencies.each_key { |point|
136
+ @adjacencies.each_key do |point|
137
137
  if(is_adjacent?(initial, point))
138
138
  distance[point] = 1
139
139
  else
140
140
  distance[point] = (2**(0.size * 8 - 2) - 1)
141
141
  end
142
- }
142
+ end
143
143
  visited[initial] = true
144
144
  distance.delete(initial)
145
145
  until(visited.length == @adjacencies.length) do
@@ -150,12 +150,12 @@ include MapPoint, MapDungeon, MapEntity
150
150
  if(nextNode == destination)
151
151
  break;
152
152
  end
153
- @adjacencies[nextNode].each { |a|
153
+ @adjacencies[nextNode].each do |a|
154
154
  alt = distance[nextNode] + 1
155
155
  if(!(visited.has_key?(a)) && alt < distance[a])
156
156
  distance[a] = alt
157
157
  end
158
- }
158
+ end
159
159
  distance.delete(nextNode)
160
160
  end
161
161
  end
@@ -181,10 +181,10 @@ protected
181
181
  if(pointBuilder.length > 0)
182
182
  builder = Object::const_get(pointBuilder).new()
183
183
  else
184
- builder = PointXPathBuilder.new()
184
+ builder = PointBuilder.new()
185
185
  end
186
186
  nodeSet.each { |node| args << node.content }
187
- builder.build_XML_point(*(args))
187
+ builder.build_point(*(args))
188
188
  builder.point()
189
189
  end
190
190
 
@@ -194,15 +194,15 @@ protected
194
194
  if(dungeonBuilder.length > 0)
195
195
  builder = Object::const_get(dungeonBuilder).new()
196
196
  else
197
- builder = DungeonXPathBuilder.new()
197
+ builder = DungeonBuilder.new()
198
198
  end
199
199
  nodeSet.each { |n| args << n.content }
200
200
  if(!(node.xpath("dungeon//entity").empty?))
201
201
  args << node.xpath("dungeon//entity")
202
202
  args << entityBuilder
203
- builder.build_XML_dungeon(*(args))
203
+ builder.build_dungeon(*(args))
204
204
  else
205
- builder.build_XML_dungeon(*(args))
205
+ builder.build_dungeon(*(args))
206
206
  end
207
207
  builder.dungeon()
208
208
  end
data/lib/map/point.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'nokogiri'
2
-
3
1
  module MapPoint
4
2
 
5
3
  class Point
@@ -38,7 +36,7 @@ module MapPoint
38
36
  end
39
37
 
40
38
  #Point builder class
41
- class PointXPathBuilder
39
+ class PointBuilder
42
40
 
43
41
  def initialize()
44
42
  @point = Point.new()
@@ -47,7 +45,7 @@ module MapPoint
47
45
  attr_reader :point
48
46
 
49
47
  #Builds the point of a node
50
- def build_XML_point(x, y, z)
48
+ def build_point(x, y, z)
51
49
  add_x(x.to_i)
52
50
  add_y(y.to_i)
53
51
  add_z(z.to_i)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyplay_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.4
4
+ version: 1.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Pavon Alvarado
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.6.8
110
+ rubygems_version: 2.6.12
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Roleplay games development helper library