ifmapper 0.9.5 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ class TranscriptReader
14
14
 
15
15
  TRANSCRIPT = /^(?:Start of a transcript of|Here begins a transcript of interation with (.*)|Here begins a transcript of interation with)/
16
16
 
17
- PROMPT = /^>\s*/
17
+ # PROMPT = /^>\s*/
18
18
  LOOK = /^l(ook)?/i
19
19
  UNDO = /^undo$/i
20
20
  RESTART = /^restart$/i
@@ -52,6 +52,7 @@ class TranscriptReader
52
52
  # No exit replies
53
53
  NO_EXIT = [
54
54
  /\byou\scan't\sgo\sthat\sway\b/i,
55
+ /\byou\scan't\sgo\sin\sthat\sdirection\b/i,
55
56
  /\bdoorways\slead\s/i,
56
57
  /\bthat's\sa\swall\b/i,
57
58
  /\bno\sexit\b/i,
@@ -68,35 +69,38 @@ class TranscriptReader
68
69
 
69
70
  # remove things like (on the bed)
70
71
  NAME_REMOVE = /(\s+\(.+\)|,\s+[io]n\s+[^\,\.]+)/
71
- NAME_INVALID = /[:;\*\[\]\|\+\=!\.\?\000]/
72
- SALUTATIONS = /\b(Mr|Mr?s|Miss|Jr|Sr|St)\./
72
+ NAME_INVALID = /--|[:;\*\[\]\|\+\=!\.\?\000]/
73
+ SALUT = '(Mr|Mr?s|Miss|Jr|Sr|St|Dr|Ave|Inc)'
74
+ SALUTATIONS = /\b#{SALUT}\./
73
75
  NAME_MAXWORDS = 20
74
76
  NAME_MAXUNCAP = 4 # so that lowercase "room" "end" "of" will be accepted
75
77
 
76
78
  # Default room description recognition parameters.
77
- DESC_MINWORDS = 10
79
+ DESC_MINWORDS = 20
78
80
 
79
81
  # Ignore these words when matching words in description
80
82
  # To avoid cases, like: An open gate vs. A closed gate
81
83
  DESC_IGNORE = /(?:an|a|open(ed)?|closed?)/i
82
84
 
83
85
 
84
- RESTORE_OK = /\b(Ok|completed?|Okay)\b/
86
+ RESTORE_OK = /\b(Okay|Ok|completed?|Restored)\b/
85
87
 
86
88
  ##
87
- THE = '(?:the|a|your|some of the|some)\s+'
89
+ THE = '(?:the|an|a|your|some of the|some)\s+'
88
90
 
89
91
  ## Regex to eliminate articles from get/take replies.
90
92
  ARTICLE = /^#{THE}/i
91
93
 
92
94
  ## Possible nessages indicating get/take succeeded
93
95
  TAKE_OBJ = '([\w\d\-\'\s]+)'
94
- TAKE_FROM = '(?:\s+(up|from|out)\s+.*)?'
96
+ TAKE_FROM = '(?:\s+(?:up|from|out)\s+.*)$'
95
97
  TAKE_ALIAS = '(?:grab|pick\s+up|pick|pilfer|take(?:\s+up)?)'
96
98
  TAKE_OK = [
97
99
  /\btaken\b/i,
98
100
  /you\s+have\s+now\s+(?:got\s+)?(?:#{THE})?#{TAKE_OBJ}#{TAKE_FROM}/i,
101
+ /you\s+have\s+now\s+(?:got\s+)?(?:#{THE})?#{TAKE_OBJ}/i,
99
102
  /you\s+#{TAKE_ALIAS}\s+(?:#{THE})?#{TAKE_OBJ}#{TAKE_FROM}/i,
103
+ /you\s+#{TAKE_ALIAS}\s+(?:#{THE})?#{TAKE_OBJ}/i,
100
104
  /you\s+now\s+have\s+(?:got\s+)?(?:#{THE})?#{TAKE_OBJ}/i,
101
105
  /you\s+pick\s+up\s+(?:#{THE})?#{TAKE_OBJ}/i,
102
106
  /you\s+are\s+now\s+holding\s+(?:#{THE})?#{TAKE_OBJ}/i,
@@ -119,11 +123,21 @@ class TranscriptReader
119
123
  IDENTIFY_BY_SHORTNAME = 1
120
124
 
121
125
  SHORTNAME_CLASSIC = 0
122
- SHORTNAME_MOONMIST = 1
123
- SHORTNAME_WITNESS = 2
126
+ SHORTNAME_CAPITALIZED = 1
127
+ SHORTNAME_MOONMIST = 2
128
+ SHORTNAME_WITNESS = 3
129
+ SHORTNAME_ADRIFT = 4
124
130
 
125
131
  attr_accessor :identify, :shortName, :map
126
132
 
133
+ def shortName=(x)
134
+ @shortName = x
135
+ if x == SHORTNAME_ADRIFT
136
+ @prompt = /^[a-z]/
137
+ else
138
+ @prompt = /^>\s*/
139
+ end
140
+ end
127
141
 
128
142
 
129
143
  #
@@ -244,7 +258,7 @@ class TranscriptReader
244
258
  # Directly north
245
259
  /\bDirectly\s+#{DIR}/i,
246
260
  # continues|lies|etc... east
247
- /(runs|bears|leads|heads|opens|winds|continues|branches|lies|wanders|bends|curves)\s+#{DIR}\b/i,
261
+ /(runs|bears|leads|heads|opens|winds|continues\s+on|continues|branches|lies|wanders|bends|curves)\s+#{DIR}\b/i,
248
262
  /(running|leading|heading|opening|branching|lying|wandering|looking|bending)\s+#{DIR}\b/i,
249
263
  ]
250
264
 
@@ -312,7 +326,6 @@ class TranscriptReader
312
326
  @here.selected = true if @here
313
327
  @map.create_pathmap
314
328
  @map.zoom = @map.zoom
315
- puts 'transcript zoom done'
316
329
  @map.center_view_on_room(@here) if @here
317
330
  @map.draw
318
331
  end
@@ -325,7 +338,7 @@ class TranscriptReader
325
338
  # Read all commands
326
339
  #
327
340
  loop do
328
- line.sub!(PROMPT, '')
341
+ line.sub!(@prompt, '') if @prompt.to_s =~ />/
329
342
  line.chop!
330
343
  line.sub!(/\s+$/, '')
331
344
  cmd = line
@@ -333,14 +346,12 @@ class TranscriptReader
333
346
  # Read reply
334
347
  reply = []
335
348
  while line = @f.gets
336
- break if line =~ PROMPT
349
+ break if line =~ @prompt
337
350
  line.chop!
338
351
  line.sub!(/\s+$/,'')
339
352
  reply << line
340
353
  end
341
354
 
342
- break if not line
343
-
344
355
  if cmd =~ UNDO
345
356
  @moves.pop
346
357
  else
@@ -358,6 +369,8 @@ class TranscriptReader
358
369
  @moves << move
359
370
  end
360
371
 
372
+ break if not line
373
+
361
374
  end
362
375
 
363
376
 
@@ -677,10 +690,10 @@ class TranscriptReader
677
690
  if score == 1 and desc and room.desc
678
691
  # We have a description...
679
692
  # Try exact description match first
680
- score += 10 if room.desc == desc
693
+ score += 100 if room.desc == desc
681
694
 
682
695
  # Try substring match
683
- score += 5 if room.desc.index(desc)
696
+ score += 50 if room.desc.index(desc)
684
697
 
685
698
  # If we have a room where both name and desc match,
686
699
  # we get a better score than just description only.
@@ -693,18 +706,24 @@ class TranscriptReader
693
706
  dwords = room.desc.split(' ')
694
707
  words = desc.split(' ')
695
708
  match = true
696
- 0.upto(DESC_MINWORDS) { |i|
709
+ count = 0
710
+ 0.upto(desc.size) { |i|
697
711
  # Ignore some words (like open/close, which may just mean
698
712
  # some doors changed state)
699
713
  next if words[i] =~ DESC_IGNORE
700
714
 
701
715
  if words[i] != dwords[i]
702
- match = false
703
- break
716
+ if count < DESC_MINWORDS
717
+ match = false
718
+ break
719
+ else
720
+ next
721
+ end
704
722
  end
723
+ count += 1
705
724
  }
706
725
 
707
- score += 1 if match
726
+ score += count if match
708
727
  end
709
728
  end
710
729
  next if score <= bestscore
@@ -737,10 +756,10 @@ class TranscriptReader
737
756
  if desc and room.desc
738
757
  # We have a description...
739
758
  # Try exact description match first
740
- score += 10 if room.desc == desc
759
+ score += 100 if room.desc == desc
741
760
 
742
761
  # Try substring match
743
- score += 5 if room.desc.index(desc)
762
+ score += 50 if room.desc.index(desc)
744
763
 
745
764
  # If we have a room where both name and desc match,
746
765
  # we get a better score than just description only.
@@ -753,18 +772,24 @@ class TranscriptReader
753
772
  dwords = room.desc.split(' ')
754
773
  words = desc.split(' ')
755
774
  match = true
756
- 0.upto(DESC_MINWORDS) { |i|
775
+ count = 0
776
+ 0.upto(desc.size) { |i|
757
777
  # Ignore some words (like open/close, which may just mean
758
778
  # some doors changed state)
759
779
  next if words[i] =~ DESC_IGNORE
760
780
 
761
781
  if words[i] != dwords[i]
762
- match = false
763
- break
782
+ if count < DESC_MINWORDS
783
+ match = false
784
+ break
785
+ else
786
+ next
787
+ end
764
788
  end
789
+ count += 1
765
790
  }
766
791
 
767
- score += 2 if match and room.name == name
792
+ score += count if match and room.name == name
768
793
  end
769
794
  else
770
795
  # Just the name, not so good
@@ -791,12 +816,14 @@ class TranscriptReader
791
816
 
792
817
  def room_name(line)
793
818
  case @shortName
794
- when SHORTNAME_CLASSIC
795
- return room_name_classic(line)
819
+ when SHORTNAME_CAPITALIZED
820
+ return room_name_classic(line, false)
796
821
  when SHORTNAME_MOONMIST
797
822
  return room_name_moonmist(line)
798
823
  when SHORTNAME_WITNESS
799
824
  return room_name_witness(line)
825
+ else
826
+ return room_name_classic(line, true)
800
827
  end
801
828
  end
802
829
 
@@ -812,6 +839,12 @@ class TranscriptReader
812
839
  return words.join(' ')
813
840
  end
814
841
 
842
+ def room_name_alan(line)
843
+ return false if line !~ /^[^.]+\.$/
844
+ line.sub!(/\.$/, '')
845
+ return room_name_classic(line, true)
846
+ end
847
+
815
848
  def room_name_witness(line)
816
849
  if line =~ /^You\sare\s(?:now\s)?(?:[io]n\s)?(?:#{THE})?([\w'\d\s\-_]+)\.$/
817
850
  return false if $1 =~ /own feet/
@@ -835,7 +868,7 @@ class TranscriptReader
835
868
  #
836
869
  # Determine if line corresponds to a room name
837
870
  #
838
- def room_name_classic(line)
871
+ def room_name_classic(line, all_capitals = true)
839
872
  # Check if user/game has created a room with that name already
840
873
  return line if find_room(line, nil)
841
874
 
@@ -869,12 +902,14 @@ class TranscriptReader
869
902
  return false if line =~ /^[A-Z\d,\.\/\-"'\s]+$/ or line =~ /\s\s/ or
870
903
  line =~ /^".*"$/ or line =~ /^"[^"]+$/ or line =~ /^\d+\)/
871
904
 
905
+ return false if not all_capitals and words.size > 6
906
+
872
907
  # If not, check all words of 4 chars or more are capitalized
873
908
  # and that there are no 3 or more short letter words together
874
909
  # (which means a diagram)
875
910
  num = 0
876
911
  words.each { |w|
877
- return false if w =~ /^[a-z]/ and w.size > NAME_MAXUNCAP
912
+ return false if all_capitals and w =~ /^[a-z]/ and w.size > NAME_MAXUNCAP
878
913
  if w.size <= 2
879
914
  num += 1
880
915
  return false if num > 2
@@ -883,6 +918,9 @@ class TranscriptReader
883
918
  end
884
919
  }
885
920
 
921
+ # Restore period to salutations
922
+ line.sub!(/\b#{SALUT}\b/, '\1.')
923
+
886
924
  # Okay, it is a room.
887
925
  return line
888
926
  end
@@ -1212,7 +1250,7 @@ class TranscriptReader
1212
1250
 
1213
1251
  def destroy
1214
1252
  @t.kill if @t
1215
- @f.close
1253
+ @f.close if @f
1216
1254
  GC.start
1217
1255
  end
1218
1256
 
@@ -1230,7 +1268,8 @@ class TranscriptReader
1230
1268
  end
1231
1269
 
1232
1270
  def initialize(map, file)
1233
- @shortName = 0
1271
+ @shortName = 0
1272
+ @prompt = /^>\s*/
1234
1273
  @identify = 0
1235
1274
 
1236
1275
  @file = file
@@ -1264,7 +1303,7 @@ class TranscriptReader
1264
1303
  end
1265
1304
  @map.name = capitalize_room(@map.name)
1266
1305
  end
1267
- break if PROMPT =~ line
1306
+ break if @prompt =~ line
1268
1307
  end
1269
1308
  parse_line(line)
1270
1309
  end
data/maps/AMFV.map ADDED
Binary file
data/maps/AllRoads.map CHANGED
Binary file
Binary file
data/maps/Janitor.map ADDED
Binary file
data/maps/Tangle.map CHANGED
Binary file
data/maps/balances.map ADDED
Binary file
data/maps/bear.map ADDED
Binary file
data/maps/break_in.map CHANGED
Binary file
data/maps/deadline.map CHANGED
Binary file
data/maps/delusions.map CHANGED
Binary file
data/maps/dreamhold.map CHANGED
Binary file
data/maps/drift3.map ADDED
Binary file
data/maps/eas.map CHANGED
Binary file
data/maps/eas2.map CHANGED
Binary file
data/maps/eas3.map CHANGED
Binary file
data/maps/fallacy.map ADDED
Binary file
data/maps/heist.map ADDED
Binary file
data/maps/heroes.map ADDED
Binary file
Binary file
data/maps/moonmist.map CHANGED
Binary file
Binary file
data/maps/pkgirl.map ADDED
Binary file
Binary file
data/maps/sherbet.map CHANGED
Binary file
data/maps/slouch.map CHANGED
Binary file
data/maps/wasp.map ADDED
Binary file
data/maps/zerosum.map ADDED
Binary file
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.9.5
7
- date: 2005-09-09
6
+ version: 0.9.6
7
+ date: 2005-09-19
8
8
  summary: Interactive Fiction Mapping Tool.
9
9
  require_paths:
10
10
  - lib
@@ -21,42 +21,42 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
21
21
  -
22
22
  - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 1.6.8
24
+ version: 1.8.0
25
25
  version:
26
26
  platform: ruby
27
27
  authors:
28
28
  - Gonzalo Garramuno
29
29
  files:
30
30
  - IFMapper.rbw
31
+ - lib/IFMapper/FXMap.rb
31
32
  - lib/IFMapper/Map.rb
32
33
  - lib/IFMapper/FXRoom.rb
33
34
  - lib/IFMapper/FXSectionDialogBox.rb
34
- - lib/IFMapper/Room.rb
35
+ - lib/IFMapper/FXMapperWindow.rb
35
36
  - lib/IFMapper/Section.rb
37
+ - lib/IFMapper/FXConnection.rb
36
38
  - lib/IFMapper/FXMapColorBox.rb
37
39
  - lib/IFMapper/IFMReader.rb
38
40
  - lib/IFMapper/IFMWriter.rb
39
41
  - lib/IFMapper/FXWarningBox.rb
40
- - lib/IFMapper/FXMap.rb
41
42
  - lib/IFMapper/FXMapperSettings.rb
42
- - lib/IFMapper/FXConnection.rb
43
- - lib/IFMapper/FXMapperWindow.rb
44
43
  - lib/IFMapper/Connection.rb
45
44
  - lib/IFMapper/MapPrinting.rb
46
45
  - lib/IFMapper/FXDCPostscript.rb
47
46
  - lib/IFMapper/FXDCPrint.rb
47
+ - lib/IFMapper/Room.rb
48
48
  - lib/IFMapper/PDFMapExporter.rb
49
49
  - lib/IFMapper/TranscriptReader.rb
50
50
  - lib/IFMapper/FXMapDialogBox.rb
51
51
  - lib/IFMapper/FXSpline.rb
52
52
  - lib/IFMapper/InformReader.rb
53
- - lib/IFMapper/FXRoomDialogBox.rb
53
+ - lib/IFMapper/FXMapFileDialog.rb
54
54
  - lib/IFMapper/InformWriter.rb
55
55
  - lib/IFMapper/FXSection.rb
56
56
  - lib/IFMapper/TADSReader.rb
57
57
  - lib/IFMapper/InformReaderOld.rb
58
- - lib/IFMapper/FXMapFileDialog.rb
59
58
  - lib/IFMapper/TADSWriter.rb
59
+ - lib/IFMapper/FXRoomDialogBox.rb
60
60
  - lib/IFMapper/FXConnectionDialogBox.rb
61
61
  - lib/IFMapper/AStar.rb
62
62
  - lib/IFMapper/TranscriptDialogBox.rb
@@ -140,6 +140,18 @@ files:
140
140
  - maps/break_in.map
141
141
  - maps/moonmist.map
142
142
  - maps/dreamhold.map
143
+ - maps/AMFV.map
144
+ - maps/wasp.map
145
+ - maps/Janitor.map
146
+ - maps/bear.map
147
+ - maps/zerosum.map
148
+ - maps/balances.map
149
+ - maps/fallacy.map
150
+ - maps/heist.map
151
+ - maps/pkgirl.map
152
+ - maps/heroes.map
153
+ - maps/photograph.map
154
+ - maps/drift3.map
143
155
  - icons/filenew.png
144
156
  - icons/fileopen.png
145
157
  - icons/filesave.png