gruesome 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -15,13 +15,12 @@
15
15
 
16
16
  # Gruesome
17
17
 
18
- The Ruby Z-Code Emulator and IF Manager (Currently in progress). It current can
18
+ The Ruby Z-Code Emulator and IF Manager (Currently in progress). It currently can
19
19
  play version 3 games such as the ZORK trilogy.
20
20
 
21
21
  ## Currently implemented
22
22
 
23
23
  * Majority of version 3 Z-Machine (Enough to play most games)
24
- * WARNING: Save and Restore are not implemented!!!!! Don't get eaten by a grue!
25
24
 
26
25
  ## To play
27
26
 
data/lib/gruesome/cli.rb CHANGED
@@ -5,66 +5,66 @@ require_relative 'machine'
5
5
  require_relative 'logo'
6
6
 
7
7
  module Gruesome
8
- class CLI
9
- BANNER = <<-USAGE
10
- Usage:
11
- gruesome play STORY_FILE
12
-
13
- Description:
14
- The 'play' command will start a session of the story given as STORY_FILE
15
-
16
- Example:
17
- gruesome play zork1.z3
18
-
19
- USAGE
20
-
21
- class << self
22
- def parse_options
23
- @opts = OptionParser.new do |opts|
24
- opts.banner = BANNER.gsub(/^\t{2}/, '')
25
-
26
- opts.separator ''
27
- opts.separator 'Options:'
28
-
29
- opts.on('-h', '--help', 'Display this help') do
30
- puts opts
31
- exit
32
- end
33
- end
34
-
35
- @opts.parse!
36
- end
37
-
38
- def CLI.run
39
- begin
40
- parse_options
41
- rescue OptionParser::InvalidOption => e
42
- warn e
43
- exit -1
44
- end
45
-
46
- def fail
47
- puts @opts
48
- exit -1
49
- end
50
-
51
- if ARGV.empty?
52
- fail
53
- end
54
-
55
- case ARGV.first
56
- when 'play'
57
- fail unless ARGV[1]
58
-
59
- Gruesome::Logo.print
60
-
61
- puts
62
- puts "--------------------------------------------------------------------------------"
63
- puts
64
-
65
- Gruesome::Machine.new(ARGV[1]).execute
66
- end
67
- end
68
- end
69
- end
8
+ class CLI
9
+ BANNER = <<-USAGE
10
+ Usage:
11
+ gruesome play STORY_FILE
12
+
13
+ Description:
14
+ The 'play' command will start a session of the story given as STORY_FILE
15
+
16
+ Example:
17
+ gruesome play zork1.z3
18
+
19
+ USAGE
20
+
21
+ class << self
22
+ def parse_options
23
+ @opts = OptionParser.new do |opts|
24
+ opts.banner = BANNER.gsub(/^ /, '')
25
+
26
+ opts.separator ''
27
+ opts.separator 'Options:'
28
+
29
+ opts.on('-h', '--help', 'Display this help') do
30
+ puts opts
31
+ exit
32
+ end
33
+ end
34
+
35
+ @opts.parse!
36
+ end
37
+
38
+ def CLI.run
39
+ begin
40
+ parse_options
41
+ rescue OptionParser::InvalidOption => e
42
+ warn e
43
+ exit -1
44
+ end
45
+
46
+ def fail
47
+ puts @opts
48
+ exit -1
49
+ end
50
+
51
+ if ARGV.empty?
52
+ fail
53
+ end
54
+
55
+ case ARGV.first
56
+ when 'play'
57
+ fail unless ARGV[1]
58
+
59
+ Gruesome::Logo.print
60
+
61
+ puts
62
+ puts "--------------------------------------------------------------------------------"
63
+ puts
64
+
65
+ Gruesome::Machine.new(ARGV[1]).execute
66
+ end
67
+ end
68
+ end
69
+ end
70
70
  end
data/lib/gruesome/logo.rb CHANGED
@@ -3,10 +3,10 @@
3
3
  # DO NOT REMOVE ABOVE COMMENT! IT IS MAGIC!
4
4
 
5
5
  module Gruesome
6
- module Logo
7
- # I'm just making sure this works regardless of the unicode format this
8
- # source file is saved as...
9
- LOGO = <<ENDLOGO
6
+ module Logo
7
+ # I'm just making sure this works regardless of the unicode format this
8
+ # source file is saved as...
9
+ LOGO = <<ENDLOGO
10
10
  ▄▄▄▄▄ ▄▄▄▄▄
11
11
  ▀████▄ ▄████▀
12
12
  ▀████▄ ▄████▀
@@ -21,8 +21,8 @@ module Gruesome
21
21
  ▀▀▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀▀▀ ▀▀▀▀▀▀ ▀▀▀▀▀▀ ▀▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀▀▀▀
22
22
  ENDLOGO
23
23
 
24
- def Logo.print
25
- puts LOGO
26
- end
27
- end
24
+ def Logo.print
25
+ puts LOGO
26
+ end
27
+ end
28
28
  end
@@ -1,17 +1,17 @@
1
1
  require_relative 'z/machine'
2
2
 
3
3
  module Gruesome
4
- class Machine
5
- def initialize(story_file)
6
- # Later, detect the type
7
- #
8
- # For now, assume Z-Machine
4
+ class Machine
5
+ def initialize(story_file)
6
+ # Later, detect the type
7
+ #
8
+ # For now, assume Z-Machine
9
9
 
10
- @machine = Z::Machine.new(story_file)
11
- end
10
+ @machine = Z::Machine.new(story_file)
11
+ end
12
12
 
13
- def execute
14
- @machine.execute
15
- end
16
- end
13
+ def execute
14
+ @machine.execute
15
+ end
16
+ end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Grue
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -7,24 +7,24 @@ require_relative 'header'
7
7
  require_relative 'zscii'
8
8
 
9
9
  module Gruesome
10
- module Z
11
- class AbbreviationTable
12
- def initialize(memory)
13
- @memory = memory
14
- @header = Header.new(@memory.contents)
15
- end
10
+ module Z
11
+ class AbbreviationTable
12
+ def initialize(memory)
13
+ @memory = memory
14
+ @header = Header.new(@memory.contents)
15
+ end
16
16
 
17
- def lookup(alphabet, index, translation_alphabet)
18
- abbrev_index = (32 * (alphabet)) + index
19
- addr = @header.abbrev_tbl_addr + abbrev_index*2
17
+ def lookup(alphabet, index, translation_alphabet)
18
+ abbrev_index = (32 * (alphabet)) + index
19
+ addr = @header.abbrev_tbl_addr + abbrev_index*2
20
20
 
21
- # this will yield a word address, which we multiply by 2
22
- # to get into a byte address
23
- str_addr = @memory.force_readw(addr)
24
- str_addr *= 2
21
+ # this will yield a word address, which we multiply by 2
22
+ # to get into a byte address
23
+ str_addr = @memory.force_readw(addr)
24
+ str_addr *= 2
25
25
 
26
- ZSCII.translate(translation_alphabet, @header.version, @memory.force_readzstr(str_addr)[1], nil)
27
- end
28
- end
29
- end
26
+ ZSCII.translate(translation_alphabet, @header.version, @memory.force_readzstr(str_addr)[1], nil)
27
+ end
28
+ end
29
+ end
30
30
  end