gemwarrior 0.15.10 → 0.15.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8592466ba7744b7af20d77a5dfb3ab4da57e5c12763d50b5362f062e80047cc5
4
- data.tar.gz: a64e7d954caa398e2bed569e7579e3f6981ad5ff3f24aaafa1dbf4f8fa6457e0
3
+ metadata.gz: 994ca3f7d106260f639e8cac066623c6222b509b0bdea5c42fbe53c96a85e97a
4
+ data.tar.gz: '05638ad1416e4da010f1fad072bec2be6695d7a1eca1d6fc03517dfcac8f1c2b'
5
5
  SHA512:
6
- metadata.gz: cbfda0a7ed5922ba2b53aa34a553e923304c4c460e9e3e3597759e046cd13281a4ccdb6c2f40ca9df67cb0096fe986674c2c88e6adad84acd45808f1a6346c1a
7
- data.tar.gz: f015e5cab9d6837ed4fc1adbbec78b2cb80e5a5bd0c8186264e6c1c4c4fe18917c3e8508640d5f49cb227dc16322601f951080f96abd96fd003310719cc2b100
6
+ metadata.gz: a4802863c09897f4731a4594aaf36ead9c7b77c85d64c4648e09309b6761842bada17e090b46f1e072e62aa75e60b9f378284bd46f9e2a46d6edc0f4e8b2ca94
7
+ data.tar.gz: 9032c9afd863ab9c14bd287a0efae3be4d308183df8b3c298665c0971a7e6a20ffcfa61b8f4cff9e4dfd6f752ab7a23b59d6e4e9fe79d34cb5701f5b31bcaa75
data/bin/gemwarrior CHANGED
@@ -1,146 +1,146 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
- require 'os'
5
-
6
- require_relative '../lib/gemwarrior/game'
7
- require_relative '../lib/gemwarrior/game_options'
8
- require_relative '../lib/gemwarrior/version'
9
-
10
- include Gemwarrior
11
-
12
- GAME_NAME = 'Gem Warrior'
13
- GW_HOME = "#{Dir.home}/.gemwarrior"
14
- GW_SAVE_FILE_YAML = "#{GW_HOME}/gw_sav.yaml"
15
- GW_SAVE_FILE_BIN = "#{GW_HOME}/gw_sav.dat"
16
- GW_OPTS_FILE = "#{GW_HOME}/gw_opts"
17
- GW_LOG_FILE = "#{GW_HOME}/gw_log"
18
- GW_DEFAULT_WORLD_YAML = File.expand_path('../../data/default_world.yaml', __FILE__)
19
- GW_DEFAULT_WORLD_BIN = File.expand_path('../../data/default_world.bin', __FILE__)
20
- GW_DEFAULT_WRAP_WIDTH = 80
21
-
22
- def parse_options_cli
23
- # default options
24
- options = {
25
- beast_mode: false,
26
- debug_mode: false,
27
- god_mode: false,
28
- new_skip: false,
29
- resume_skip: false,
30
- sound_enabled: false,
31
- sound_system: 'bloops',
32
- sound_volume: 0.3,
33
- use_wordnik: false,
34
- fight_completion: false,
35
- extra_command: nil
36
- }
37
-
38
- # options file has next precedence
39
- unless (opts_file = read_options_file).nil?
40
- options[:sound_enabled] = (opts_file[:sound_enabled].eql?('false') ? false : true) if opts_file[:sound_enabled]
41
- options[:sound_system] = (opts_file[:sound_system]) if opts_file[:sound_system]
42
- options[:sound_volume] = (opts_file[:sound_volume].to_f) if opts_file[:sound_volume]
43
- options[:use_wordnik] = (opts_file[:use_wordnik].eql?('false') ? false : true) if opts_file[:use_wordnik]
44
- options[:fight_completion] = (opts_file[:fight_completion].eql?('false') ? false : true) if opts_file[:fight_completion]
45
- end
46
-
47
- # command line has next precedence
48
- optparse = OptionParser.new do |opts|
49
- opts.on('-b', '--beast', 'Enable debug[beastmode]') do
50
- options[:beast_mode] = true
51
- end
52
-
53
- opts.on('-d', '--debug', 'Enable debug commands in-game') do
54
- options[:debug_mode] = true
55
- end
56
-
57
- opts.on('-g', '--god', 'Enable debug[godmode]') do
58
- options[:god_mode] = true
59
- end
60
-
61
- opts.on('-n', '--new', 'Immediately start a new game, skipping main menu') do
62
- options[:new_skip] = true
63
- end
64
-
65
- opts.on('-r', '--resume', 'Immediately resume the saved game, skipping main menu') do
66
- options[:resume_skip] = true
67
- end
68
-
69
- opts.on('-s', '--sound', 'Enable sound (experimental)') do
70
- options[:sound_enabled] = true
71
- end
72
-
73
- opts.on('-v', '--version', 'Display version number and exit') do
74
- puts "#{GAME_NAME} v#{Gemwarrior::VERSION}"
75
- exit
76
- end
77
-
78
- opts.on('-w', '--wordnik', 'Enable Wordnik to generate more diverse, dynamic descriptors of entities') do
79
- options[:use_wordnik] = true
80
- end
81
-
82
- opts.on('-f', '--fight-completion', 'Fighting without specifying an enemy will attack first one it finds') do
83
- options[:fight_completion] = false
84
- end
85
-
86
- opts.on('-x', '--extra COMMAND,PARAM1,PARAM2,PARAM3', String, 'Run a command, with optional params, immediately upon beginning the game') do |xc|
87
- options[:extra_command] = xc.gsub(',',' ')
88
- end
89
- end
90
-
91
- optparse.parse!()
92
-
93
- return options
94
- end
95
-
96
- def print_error(error)
97
- case error
98
- when OptionParser::InvalidOption
99
- puts "#{GAME_NAME}: illegal option #{error.args.join(' ')}"
100
- else
101
- puts "An unexpected error occurred while running #{GAME_NAME}:"
102
- puts " #{error}\n"
103
- end
104
- end
105
-
106
- def read_options_file
107
- if File.exist?(GameOptions.data['options_file_path'])
108
- options = {}
109
- File.open(GameOptions.data['options_file_path']).readlines.each do |line|
110
- kv = line.chomp.split(':')
111
- options[kv[0].to_sym] = kv[1]
112
- end
113
-
114
- # check for null
115
- return options[:sound_enabled] ? options : nil
116
- end
117
- nil
118
- end
119
-
120
- def init_config
121
- Dir.mkdir(GW_HOME) unless Dir.exist?(GW_HOME)
122
-
123
- sound_system_default = OS.windows? ? 'win32-sound' : 'bloops'
124
- save_file_mode_default = 'Y' # YAML
125
-
126
- GameOptions.add 'sound_system', sound_system_default
127
- GameOptions.add 'save_file_mode', save_file_mode_default
128
- GameOptions.add 'default_world_path_yaml', GW_DEFAULT_WORLD_YAML
129
- GameOptions.add 'default_world_path_bin', GW_DEFAULT_WORLD_BIN
130
- GameOptions.add 'save_file_yaml_path', GW_SAVE_FILE_YAML
131
- GameOptions.add 'save_file_bin_path', GW_SAVE_FILE_BIN
132
- GameOptions.add 'log_file_path', GW_LOG_FILE
133
- GameOptions.add 'options_file_path', GW_OPTS_FILE
134
- GameOptions.add 'wrap_width', GW_DEFAULT_WRAP_WIDTH
135
- end
136
-
137
- begin
138
- init_config
139
-
140
- options = parse_options_cli
141
-
142
- Gemwarrior::Game.new(options)
143
- rescue => error
144
- print_error(error)
145
- exit(false)
146
- end
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'os'
5
+
6
+ require_relative '../lib/gemwarrior/game'
7
+ require_relative '../lib/gemwarrior/game_options'
8
+ require_relative '../lib/gemwarrior/version'
9
+
10
+ include Gemwarrior
11
+
12
+ GAME_NAME = 'Gem Warrior'
13
+ GW_HOME = "#{Dir.home}/.gemwarrior"
14
+ GW_SAVE_FILE_YAML = "#{GW_HOME}/gw_sav.yaml"
15
+ GW_SAVE_FILE_BIN = "#{GW_HOME}/gw_sav.dat"
16
+ GW_OPTS_FILE = "#{GW_HOME}/gw_opts"
17
+ GW_LOG_FILE = "#{GW_HOME}/gw_log"
18
+ GW_DEFAULT_WORLD_YAML = File.expand_path('../../data/default_world.yaml', __FILE__)
19
+ GW_DEFAULT_WORLD_BIN = File.expand_path('../../data/default_world.bin', __FILE__)
20
+ GW_DEFAULT_WRAP_WIDTH = 80
21
+
22
+ def parse_options_cli
23
+ # default options
24
+ options = {
25
+ beast_mode: false,
26
+ debug_mode: false,
27
+ god_mode: false,
28
+ new_skip: false,
29
+ resume_skip: false,
30
+ sound_enabled: false,
31
+ sound_system: 'bloops',
32
+ sound_volume: 0.3,
33
+ use_wordnik: false,
34
+ fight_completion: false,
35
+ extra_command: nil
36
+ }
37
+
38
+ # options file has next precedence
39
+ unless (opts_file = read_options_file).nil?
40
+ options[:sound_enabled] = (opts_file[:sound_enabled].eql?('false') ? false : true) if opts_file[:sound_enabled]
41
+ options[:sound_system] = (opts_file[:sound_system]) if opts_file[:sound_system]
42
+ options[:sound_volume] = (opts_file[:sound_volume].to_f) if opts_file[:sound_volume]
43
+ options[:use_wordnik] = (opts_file[:use_wordnik].eql?('false') ? false : true) if opts_file[:use_wordnik]
44
+ options[:fight_completion] = (opts_file[:fight_completion].eql?('false') ? false : true) if opts_file[:fight_completion]
45
+ end
46
+
47
+ # command line has next precedence
48
+ optparse = OptionParser.new do |opts|
49
+ opts.on('-b', '--beast', 'Enable debug[beastmode]') do
50
+ options[:beast_mode] = true
51
+ end
52
+
53
+ opts.on('-d', '--debug', 'Enable debug commands in-game') do
54
+ options[:debug_mode] = true
55
+ end
56
+
57
+ opts.on('-g', '--god', 'Enable debug[godmode]') do
58
+ options[:god_mode] = true
59
+ end
60
+
61
+ opts.on('-n', '--new', 'Immediately start a new game, skipping main menu') do
62
+ options[:new_skip] = true
63
+ end
64
+
65
+ opts.on('-r', '--resume', 'Immediately resume the saved game, skipping main menu') do
66
+ options[:resume_skip] = true
67
+ end
68
+
69
+ opts.on('-s', '--sound', 'Enable sound (experimental)') do
70
+ options[:sound_enabled] = true
71
+ end
72
+
73
+ opts.on('-v', '--version', 'Display version number and exit') do
74
+ puts "#{GAME_NAME} v#{Gemwarrior::VERSION}"
75
+ exit
76
+ end
77
+
78
+ opts.on('-w', '--wordnik', 'Enable Wordnik to generate more diverse, dynamic descriptors of entities') do
79
+ options[:use_wordnik] = true
80
+ end
81
+
82
+ opts.on('-f', '--fight-completion', 'Fighting without specifying an enemy will attack first one it finds') do
83
+ options[:fight_completion] = false
84
+ end
85
+
86
+ opts.on('-x', '--extra COMMAND,PARAM1,PARAM2,PARAM3', String, 'Run a command, with optional params, immediately upon beginning the game') do |xc|
87
+ options[:extra_command] = xc.gsub(',',' ')
88
+ end
89
+ end
90
+
91
+ optparse.parse!()
92
+
93
+ return options
94
+ end
95
+
96
+ def print_error(error)
97
+ case error
98
+ when OptionParser::InvalidOption
99
+ puts "#{GAME_NAME}: illegal option #{error.args.join(' ')}"
100
+ else
101
+ puts "An unexpected error occurred while running #{GAME_NAME}:"
102
+ puts " #{error}\n"
103
+ end
104
+ end
105
+
106
+ def read_options_file
107
+ if File.exist?(GameOptions.data['options_file_path'])
108
+ options = {}
109
+ File.open(GameOptions.data['options_file_path']).readlines.each do |line|
110
+ kv = line.chomp.split(':')
111
+ options[kv[0].to_sym] = kv[1]
112
+ end
113
+
114
+ # check for null
115
+ return options[:sound_enabled] ? options : nil
116
+ end
117
+ nil
118
+ end
119
+
120
+ def init_config
121
+ Dir.mkdir(GW_HOME) unless Dir.exist?(GW_HOME)
122
+
123
+ sound_system_default = OS.windows? ? 'win32-sound' : 'bloops'
124
+ save_file_mode_default = 'Y' # YAML
125
+
126
+ GameOptions.add 'sound_system', sound_system_default
127
+ GameOptions.add 'save_file_mode', save_file_mode_default
128
+ GameOptions.add 'default_world_path_yaml', GW_DEFAULT_WORLD_YAML
129
+ GameOptions.add 'default_world_path_bin', GW_DEFAULT_WORLD_BIN
130
+ GameOptions.add 'save_file_yaml_path', GW_SAVE_FILE_YAML
131
+ GameOptions.add 'save_file_bin_path', GW_SAVE_FILE_BIN
132
+ GameOptions.add 'log_file_path', GW_LOG_FILE
133
+ GameOptions.add 'options_file_path', GW_OPTS_FILE
134
+ GameOptions.add 'wrap_width', GW_DEFAULT_WRAP_WIDTH
135
+ end
136
+
137
+ begin
138
+ init_config
139
+
140
+ options = parse_options_cli
141
+
142
+ Gemwarrior::Game.new(options)
143
+ rescue => error
144
+ print_error(error)
145
+ exit(false)
146
+ end
data/gemwarrior.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Gemwarrior::VERSION
9
9
  spec.platform = Gem::Platform::RUBY
10
10
  spec.authors = ['Michael Chadwick']
11
- spec.email = 'mike@codana.me'
11
+ spec.email = 'mike@neb.host'
12
12
  spec.homepage = 'http://rubygems.org/gems/gemwarrior'
13
13
  spec.summary = 'RubyGem text adventure'
14
14
  spec.description = 'A fun text adventure in the form of a RubyGem!'
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
  spec.license = 'MIT'
21
21
 
22
+ spec.required_ruby_version = '~> 2.0'
23
+
22
24
  spec.add_runtime_dependency 'os', '~> 0.9', '>= 0.9.6'
23
25
  spec.add_runtime_dependency 'http', '~> 0.8.10'
24
26
  spec.add_runtime_dependency 'json', '~> 2.3.0'
@@ -1,81 +1,81 @@
1
- # lib/gemwarrior/arena.rb
2
- # Arena series of battles
3
-
4
- require_relative 'battle'
5
-
6
- module Gemwarrior
7
- class Arena
8
- # CONSTANTS
9
- BONUS_ROX_MULTIPLIER = 25
10
- BONUS_XP_MULTIPLIER = 10
11
-
12
- attr_accessor :world, :player
13
-
14
- def initialize(options)
15
- self.world = options.fetch(:world)
16
- self.player = options.fetch(:player)
17
- end
18
-
19
- def start
20
- print_arena_intro
21
-
22
- arena_monsters_vanquished = 0
23
-
24
- loop do
25
- monster = generate_monster
26
- battle = Battle.new(world: world, player: player, monster: monster)
27
- result = battle.start(is_arena: true)
28
-
29
- return 'death' if result.eql?('death')
30
-
31
- arena_monsters_vanquished += 1
32
-
33
- print ' Do you wish to continue fighting in the Arena? (y/n) '
34
- answer = gets.chomp.downcase
35
-
36
- case answer
37
- when 'y', 'yes'
38
- puts
39
- next
40
- else
41
- bonus_rox = arena_monsters_vanquished * BONUS_ROX_MULTIPLIER
42
- bonus_xp = arena_monsters_vanquished * BONUS_XP_MULTIPLIER
43
- player.rox = player.rox + bonus_rox
44
- player.xp = player.xp + bonus_xp
45
- puts
46
- puts ' You decided you\'ve had enough of the exhausting Arena for one day and exit the main stage.'
47
- puts " You defeated #{arena_monsters_vanquished} monsters!"
48
- puts " You have gained #{bonus_rox} rox and #{bonus_xp} XP!"
49
-
50
- return print_arena_outro
51
- end
52
- end
53
- end
54
-
55
- private
56
-
57
- def generate_monster
58
- random_monster = nil
59
-
60
- loop do
61
- random_monster = GameMonsters.data[rand(0..GameMonsters.data.length - 1)].clone
62
-
63
- break unless random_monster.is_boss
64
- end
65
-
66
- random_monster.clone
67
- end
68
-
69
- def print_arena_intro
70
- puts '**************************'.colorize(:red)
71
- puts '* YOU ENTER THE ARENA!!! *'.colorize(:red)
72
- puts '**************************'.colorize(:red)
73
- end
74
-
75
- def print_arena_outro
76
- puts '**************************'.colorize(:red)
77
- puts '* YOU LEAVE THE ARENA!!! *'.colorize(:red)
78
- puts '**************************'.colorize(:red)
79
- end
80
- end
81
- end
1
+ # lib/gemwarrior/arena.rb
2
+ # Arena series of battles
3
+
4
+ require_relative 'battle'
5
+
6
+ module Gemwarrior
7
+ class Arena
8
+ # CONSTANTS
9
+ BONUS_ROX_MULTIPLIER = 25
10
+ BONUS_XP_MULTIPLIER = 10
11
+
12
+ attr_accessor :world, :player
13
+
14
+ def initialize(options)
15
+ self.world = options.fetch(:world)
16
+ self.player = options.fetch(:player)
17
+ end
18
+
19
+ def start
20
+ print_arena_intro
21
+
22
+ arena_monsters_vanquished = 0
23
+
24
+ loop do
25
+ monster = generate_monster
26
+ battle = Battle.new(world: world, player: player, monster: monster)
27
+ result = battle.start(is_arena: true)
28
+
29
+ return 'death' if result.eql?('death')
30
+
31
+ arena_monsters_vanquished += 1
32
+
33
+ print ' Do you wish to continue fighting in the Arena? (y/n) '
34
+ answer = gets.chomp.downcase
35
+
36
+ case answer
37
+ when 'y', 'yes'
38
+ puts
39
+ next
40
+ else
41
+ bonus_rox = arena_monsters_vanquished * BONUS_ROX_MULTIPLIER
42
+ bonus_xp = arena_monsters_vanquished * BONUS_XP_MULTIPLIER
43
+ player.rox = player.rox + bonus_rox
44
+ player.xp = player.xp + bonus_xp
45
+ puts
46
+ puts ' You decided you\'ve had enough of the exhausting Arena for one day and exit the main stage.'
47
+ puts " You defeated #{arena_monsters_vanquished} monsters!"
48
+ puts " You have gained #{bonus_rox} rox and #{bonus_xp} XP!"
49
+
50
+ return print_arena_outro
51
+ end
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def generate_monster
58
+ random_monster = nil
59
+
60
+ loop do
61
+ random_monster = GameMonsters.data[rand(0..GameMonsters.data.length - 1)].clone
62
+
63
+ break unless random_monster.is_boss
64
+ end
65
+
66
+ random_monster.clone
67
+ end
68
+
69
+ def print_arena_intro
70
+ puts '**************************'.colorize(:red)
71
+ puts '* YOU ENTER THE ARENA!!! *'.colorize(:red)
72
+ puts '**************************'.colorize(:red)
73
+ end
74
+
75
+ def print_arena_outro
76
+ puts '**************************'.colorize(:red)
77
+ puts '* YOU LEAVE THE ARENA!!! *'.colorize(:red)
78
+ puts '**************************'.colorize(:red)
79
+ end
80
+ end
81
+ end