ifmapper 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,7 +61,7 @@ class Room
61
61
  end
62
62
 
63
63
  #
64
- # Given to 'adjacent' rooms, return the most direct exit from this
64
+ # Given an 'adjacent' room, return the most direct exit from this
65
65
  # room to room b.
66
66
  #
67
67
  def exit_to(b)
@@ -86,6 +86,16 @@ class Room
86
86
  return vector_to_dir(dx, dy)
87
87
  end
88
88
 
89
+ #
90
+ # Copy a room to another
91
+ #
92
+ def copy(b)
93
+ @name = b.name
94
+ @objects = b.objects
95
+ @tasks = b.tasks
96
+ @darkness = b.darkness
97
+ end
98
+
89
99
 
90
100
  def initialize(x, y, name = 'Room')
91
101
  @exits = Array.new( DIRECTIONS.size )
@@ -3,11 +3,13 @@
3
3
  require 'IFMapper/Connection'
4
4
  require 'IFMapper/Room'
5
5
 
6
- class Page
6
+ class Section
7
7
  attr_accessor :rooms
8
8
  attr_accessor :connections
9
9
  attr_accessor :name
10
10
 
11
+ class ConnectionError < StandardError; end
12
+
11
13
  def marshal_load(v)
12
14
  @rooms = v[0]
13
15
  @connections = v[1]
@@ -46,7 +48,9 @@ class Page
46
48
  return [ minXY, maxXY ]
47
49
  end
48
50
 
49
-
51
+ #
52
+ # Delete a connection from section
53
+ #
50
54
  def delete_connection(c)
51
55
  a = c.roomA
52
56
  if a
@@ -61,6 +65,9 @@ class Page
61
65
  @connections.delete(c)
62
66
  end
63
67
 
68
+ #
69
+ # Delete a connection at a certain index location
70
+ #
64
71
  def delete_connection_at( idx )
65
72
  c = @connections[idx]
66
73
 
@@ -77,6 +84,58 @@ class Page
77
84
  @connections.delete_at(idx)
78
85
  end
79
86
 
87
+ #
88
+ # Create a new connection among two rooms thru their exits
89
+ #
90
+ def new_connection( roomA, exitA, roomB, exitB = nil )
91
+ c = Connection.new( roomA, roomB )
92
+ _new_connection( c, roomA, exitA, roomB, exitB )
93
+ end
94
+
95
+ #
96
+ # Delete a room at a certain index
97
+ #
98
+ def delete_room_at(idx)
99
+ r = @rooms[idx]
100
+ r.exits.each { |e|
101
+ next if not e
102
+ delete_connection(e)
103
+ }
104
+ @rooms.delete_at(idx)
105
+ end
106
+
107
+ #
108
+ # Delete a room
109
+ #
110
+ def delete_room(r)
111
+ r.exits.each { |e|
112
+ next if not e
113
+ delete_connection(e)
114
+ }
115
+ @rooms.delete(r)
116
+ end
117
+
118
+ #
119
+ # Create a new room (note: FXSection overrides this creating an
120
+ # FXRoom instead).
121
+ #
122
+ def new_room( x, y )
123
+ r = Room.new( x, y, 'New Location' )
124
+ return _new_room(r, x, y)
125
+ end
126
+
127
+ def initialize()
128
+ @rooms = []
129
+ @connections = []
130
+ end
131
+
132
+ protected
133
+
134
+ def _new_room( r, x, y )
135
+ @rooms.push(r)
136
+ return r
137
+ end
138
+
80
139
  def _new_connection(c, roomA, exitA, roomB, exitB)
81
140
  exitA = roomA.exit_to(roomB) if not exitA
82
141
  if not exitA
@@ -85,14 +144,14 @@ No exit given or guessed to connect:
85
144
  Room #{roomA} (#{roomA.x}, #{roomA.y})
86
145
  Room #{roomB} (#{roomB.x}, #{roomB.y})
87
146
  EOF
88
- raise err
147
+ raise ConnectionError, err
89
148
  end
90
149
 
91
150
  if roomA[exitA]
92
151
  if not @connections.include?(roomA[exitA])
93
- raise "room exit filled but not in page"
152
+ raise ConnectionError, "room exit filled but not in page"
94
153
  end
95
- raise "room exit #{exitA} for #{roomA} is filled"
154
+ raise ConnectionError, "room exit #{exitA} for #{roomA} is filled"
96
155
  end
97
156
 
98
157
  roomA[exitA] = c
@@ -111,7 +170,7 @@ EOF
111
170
  end
112
171
 
113
172
  if roomB and roomB[exitB] and roomB[exitB] != c
114
- raise "room exit #{exitB} for #{roomB} is filled"
173
+ raise ConnectionError, "room exit #{exitB} for #{roomB} is filled"
115
174
  end
116
175
  roomB[exitB] = c if roomB
117
176
 
@@ -119,40 +178,4 @@ EOF
119
178
  return c
120
179
  end
121
180
 
122
- def new_connection( roomA, exitA, roomB, exitB = nil )
123
- c = Connection.new( roomA, roomB )
124
- _new_connection(c, roomA, exitA, roomB, exitB )
125
- end
126
-
127
- def delete_room_at(idx)
128
- r = @rooms[idx]
129
- r.exits.each { |e|
130
- next if not e
131
- delete_connection(e)
132
- }
133
- @rooms.delete_at(idx)
134
- end
135
-
136
- def delete_room(r)
137
- r.exits.each { |e|
138
- next if not e
139
- delete_connection(e)
140
- }
141
- @rooms.delete(r)
142
- end
143
-
144
- def _new_room( r, x, y )
145
- @rooms.push(r)
146
- return r
147
- end
148
-
149
- def new_room( x, y )
150
- r = Room.new( x, y, 'New Location' )
151
- return _new_room(r, x, y)
152
- end
153
-
154
- def initialize()
155
- @rooms = []
156
- @connections = []
157
- end
158
181
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: ifmapper
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.5"
7
- date: 2005-08-12
6
+ version: "0.6"
7
+ date: 2005-08-14
8
8
  summary: Interactive Fiction Mapping Tool.
9
9
  require_paths:
10
10
  - lib
@@ -28,27 +28,30 @@ authors:
28
28
  - Gonzalo Garramuno
29
29
  files:
30
30
  - IFMapper.rb
31
- - lib/IFMapper/FXWarningBox.rb
31
+ - lib/IFMapper/FXMap.rb
32
32
  - lib/IFMapper/Map.rb
33
- - lib/IFMapper/Connection.rb
34
- - lib/IFMapper/FXMapperSettings.rb
35
33
  - lib/IFMapper/FXSpline.rb
34
+ - lib/IFMapper/FXSection.rb
35
+ - lib/IFMapper/FXRoom.rb
36
36
  - lib/IFMapper/FXMapDialogBox.rb
37
- - lib/IFMapper/FXAboutDialogBox.rb
38
- - lib/IFMapper/FXConnection.rb
39
- - lib/IFMapper/FXPageDialogBox.rb
40
- - lib/IFMapper/FXPage.rb
41
- - lib/IFMapper/FXSearchDialogBox.rb
37
+ - lib/IFMapper/FXSectionDialogBox.rb
42
38
  - lib/IFMapper/FXMapperWindow.rb
43
- - lib/IFMapper/IFMReader.rb
44
- - lib/IFMapper/FXMap.rb
45
- - lib/IFMapper/FXRoom.rb
46
- - lib/IFMapper/Page.rb
47
- - lib/IFMapper/FXMapFileDialog.rb
48
39
  - lib/IFMapper/Room.rb
40
+ - lib/IFMapper/Section.rb
41
+ - lib/IFMapper/FXConnection.rb
42
+ - lib/IFMapper/IFMReader.rb
43
+ - lib/IFMapper/FXWarningBox.rb
44
+ - lib/IFMapper/FXMapColorBox.rb
49
45
  - lib/IFMapper/PDFMapExporter.rb
46
+ - lib/IFMapper/MapPrinting.rb
47
+ - lib/IFMapper/FXMapperSettings.rb
48
+ - lib/IFMapper/Connection.rb
49
+ - lib/IFMapper/FXAboutDialogBox.rb
50
+ - lib/IFMapper/FXSearchDialogBox.rb
51
+ - lib/IFMapper/FXMapFileDialog.rb
50
52
  - lib/IFMapper/FXRoomDialogBox.rb
51
53
  - lib/IFMapper/FXConnectionDialogBox.rb
54
+ - lib/IFMapper/AStar.rb
52
55
  - maps/Zork_Zero.ifm
53
56
  - maps/anchor.ifm
54
57
  - maps/atrox.ifm
@@ -111,6 +114,22 @@ files:
111
114
  - icons/printicon.png
112
115
  - icons/prevpage.png
113
116
  - icons/nextpage.png
117
+ - icons/room_n.xpm
118
+ - icons/room_nw.xpm
119
+ - icons/room_ne.xpm
120
+ - icons/room_se.xpm
121
+ - icons/room_sw.xpm
122
+ - icons/room_s.xpm
123
+ - icons/room_w.xpm
124
+ - icons/room_e.xpm
125
+ - icons/room_n.gif
126
+ - icons/room_s.gif
127
+ - icons/room_sw.gif
128
+ - icons/room_se.gif
129
+ - icons/room_ne.gif
130
+ - icons/room_nw.gif
131
+ - icons/room_e.gif
132
+ - icons/room_w.gif
114
133
  - HISTORY.txt
115
134
  - IFMapper.gemspec
116
135
  test_files: []