gemwarrior 0.15.13 → 0.15.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gemwarrior +85 -65
- data/data/minimal1.yaml +67 -0
- data/data/minimal2.yaml +25 -0
- data/data/minimal3.yaml +1 -0
- data/gemwarrior.gemspec +1 -1
- data/lib/gemwarrior/game.rb +70 -61
- data/lib/gemwarrior/repl.rb +2 -2
- data/lib/gemwarrior/version.rb +1 -1
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c996dc01e73e72519d15b88e1501ac75c3e532c0bdba8cac30a3f92fa0f95436
|
4
|
+
data.tar.gz: db73dd1235537fe9bda964205b803ebb6a8c84aaec171cba53f93e25e0342c81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59921e22525ab8b60f00a6c63a02ca916d4d5b38b7ac4d08e41da45ebfbabc1ae2ac6b98c945ba7896a4746c581077ec85d2edfbf8dc8dbc667b966156e7b829
|
7
|
+
data.tar.gz: f11c5b5b659d488a4a6eb3e8ad9115a97723ed38c10547bb906f0809031f8e0e7f2b53a5a3db9241fb94e18648fc17f79f44207997b4b41f6a3e06e65798ab32
|
data/bin/gemwarrior
CHANGED
@@ -9,21 +9,72 @@ require_relative '../lib/gemwarrior/version'
|
|
9
9
|
|
10
10
|
include Gemwarrior
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
GW_NAME = 'Gem Warrior'
|
13
|
+
GW_HOME_PATH = "#{Dir.home}/.gemwarrior"
|
14
|
+
GW_SAVE_FILE_YAML_PATH = "#{GW_HOME_PATH}/gw_sav.yaml"
|
15
|
+
GW_SAVE_FILE_BIN_PATH = "#{GW_HOME_PATH}/gw_sav.dat"
|
16
|
+
GW_SAVE_FILE_MODE_DEFAULT = 'Y' # YAML
|
17
|
+
GW_OPTS_FILE_PATH = "#{GW_HOME_PATH}/gw_opts"
|
18
|
+
GW_LOG_FILE_PATH = "#{GW_HOME_PATH}/gw_log"
|
19
|
+
GW_WRAP_WIDTH_DEFAULT = 80
|
20
|
+
|
21
|
+
def print_error(error)
|
22
|
+
case error
|
23
|
+
when OptionParser::InvalidOption
|
24
|
+
puts "#{GW_NAME}: illegal option #{error.args.join(' ')}"
|
25
|
+
else
|
26
|
+
puts "An unexpected error occurred while running #{GW_NAME}:"
|
27
|
+
puts " #{error}\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def init_config(world)
|
32
|
+
Dir.mkdir(GW_HOME_PATH) unless Dir.exist?(GW_HOME_PATH)
|
33
|
+
|
34
|
+
log_file_path = GW_LOG_FILE_PATH
|
35
|
+
options_file_path = GW_OPTS_FILE_PATH
|
36
|
+
save_file_mode_default = GW_SAVE_FILE_MODE_DEFAULT
|
37
|
+
save_file_bin_path = GW_SAVE_FILE_BIN_PATH
|
38
|
+
save_file_yaml_path = GW_SAVE_FILE_YAML_PATH
|
39
|
+
sound_system_default = OS.windows? ? 'win32-sound' : 'bloops'
|
40
|
+
world_yaml_path = File.expand_path("../../data/#{world}.yaml", __FILE__)
|
41
|
+
world_bin_path = File.expand_path("../../data/#{world}.bin", __FILE__)
|
42
|
+
wrap_width = GW_WRAP_WIDTH_DEFAULT
|
43
|
+
|
44
|
+
GameOptions.add 'log_file_path', log_file_path
|
45
|
+
GameOptions.add 'options_file_path', options_file_path
|
46
|
+
GameOptions.add 'save_file_bin_path', save_file_bin_path
|
47
|
+
GameOptions.add 'save_file_mode', save_file_mode_default
|
48
|
+
GameOptions.add 'save_file_yaml_path', save_file_yaml_path
|
49
|
+
GameOptions.add 'sound_system', sound_system_default
|
50
|
+
GameOptions.add 'world_bin_path', world_bin_path
|
51
|
+
GameOptions.add 'world_yaml_path', world_yaml_path
|
52
|
+
GameOptions.add 'wrap_width', wrap_width
|
53
|
+
end
|
54
|
+
|
55
|
+
def read_options_file
|
56
|
+
if !File.exist?(GW_OPTS_FILE_PATH)
|
57
|
+
File.write(GW_OPTS_FILE_PATH, "")
|
58
|
+
end
|
59
|
+
|
60
|
+
options = {}
|
61
|
+
|
62
|
+
File.open(GW_OPTS_FILE_PATH).readlines.each do |line|
|
63
|
+
kv = line.chomp.split(':')
|
64
|
+
options[kv[0].to_sym] = kv[1]
|
65
|
+
end
|
66
|
+
|
67
|
+
# check for null
|
68
|
+
return options[:sound_enabled] ? options : nil
|
69
|
+
end
|
21
70
|
|
22
71
|
def parse_options_cli
|
23
72
|
# default options
|
24
73
|
options = {
|
25
74
|
beast_mode: false,
|
26
75
|
debug_mode: false,
|
76
|
+
extra_command: nil,
|
77
|
+
fight_completion: false,
|
27
78
|
god_mode: false,
|
28
79
|
new_skip: false,
|
29
80
|
resume_skip: false,
|
@@ -31,17 +82,22 @@ def parse_options_cli
|
|
31
82
|
sound_system: 'bloops',
|
32
83
|
sound_volume: 0.3,
|
33
84
|
use_wordnik: false,
|
34
|
-
|
35
|
-
extra_command: nil
|
85
|
+
world_name: 'default_world'
|
36
86
|
}
|
37
87
|
|
38
88
|
# options file has next precedence
|
39
89
|
unless (opts_file = read_options_file).nil?
|
90
|
+
options[:fight_completion] = (opts_file[:fight_completion].eql?('false') ? false : true) if opts_file[:fight_completion]
|
91
|
+
|
40
92
|
options[:sound_enabled] = (opts_file[:sound_enabled].eql?('false') ? false : true) if opts_file[:sound_enabled]
|
93
|
+
|
41
94
|
options[:sound_system] = (opts_file[:sound_system]) if opts_file[:sound_system]
|
95
|
+
|
42
96
|
options[:sound_volume] = (opts_file[:sound_volume].to_f) if opts_file[:sound_volume]
|
97
|
+
|
43
98
|
options[:use_wordnik] = (opts_file[:use_wordnik].eql?('false') ? false : true) if opts_file[:use_wordnik]
|
44
|
-
|
99
|
+
|
100
|
+
opts_file[:world_name] = (opts_file[:world_name]) if opts_file[:world_name]
|
45
101
|
end
|
46
102
|
|
47
103
|
# command line has next precedence
|
@@ -54,10 +110,18 @@ def parse_options_cli
|
|
54
110
|
options[:debug_mode] = true
|
55
111
|
end
|
56
112
|
|
113
|
+
opts.on('-f', '--fight-completion', 'Fighting without specifying an enemy will attack first one it finds') do
|
114
|
+
options[:fight_completion] = false
|
115
|
+
end
|
116
|
+
|
57
117
|
opts.on('-g', '--god', 'Enable debug[godmode]') do
|
58
118
|
options[:god_mode] = true
|
59
119
|
end
|
60
120
|
|
121
|
+
opts.on('-k', '--wordnik', 'Enable Wordnik to generate more diverse, dynamic descriptors of entities') do
|
122
|
+
options[:use_wordnik] = true
|
123
|
+
end
|
124
|
+
|
61
125
|
opts.on('-n', '--new', 'Immediately start a new game, skipping main menu') do
|
62
126
|
options[:new_skip] = true
|
63
127
|
end
|
@@ -71,19 +135,15 @@ def parse_options_cli
|
|
71
135
|
end
|
72
136
|
|
73
137
|
opts.on('-v', '--version', 'Display version number and exit') do
|
74
|
-
puts "#{
|
138
|
+
puts "#{GW_NAME} v#{Gemwarrior::VERSION}"
|
75
139
|
exit
|
76
140
|
end
|
77
141
|
|
78
|
-
opts.on('-w', '--
|
79
|
-
options[:
|
142
|
+
opts.on('-w', '--world WORLD_NAME', String, 'Build Gemwarrior with alternate world data file') do |world_name|
|
143
|
+
options[:world_name] = world_name
|
80
144
|
end
|
81
145
|
|
82
|
-
opts.on('-
|
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|
|
146
|
+
opts.on('-x', '--xtra COMMAND,PARAMS', String, 'Run a command, with optional params, immediately upon beginning the game') do |xc|
|
87
147
|
options[:extra_command] = xc.gsub(',',' ')
|
88
148
|
end
|
89
149
|
end
|
@@ -93,54 +153,14 @@ def parse_options_cli
|
|
93
153
|
return options
|
94
154
|
end
|
95
155
|
|
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
156
|
begin
|
138
|
-
init_config
|
139
|
-
|
140
157
|
options = parse_options_cli
|
141
158
|
|
159
|
+
init_config(options[:world_name])
|
160
|
+
|
142
161
|
Gemwarrior::Game.new(options)
|
143
|
-
rescue =>
|
144
|
-
print_error(
|
162
|
+
rescue => e
|
163
|
+
print_error(e)
|
164
|
+
puts ("#{self.class} - #{e.class}: #{e.message}" + e.backtrace).join("\n")
|
145
165
|
exit(false)
|
146
166
|
end
|
data/data/minimal1.yaml
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gemwarrior::World
|
2
|
+
locations:
|
3
|
+
- !ruby/object:Gemwarrior::Location
|
4
|
+
name: home
|
5
|
+
name_display: Home
|
6
|
+
visited: true
|
7
|
+
description: The little, unimportant, decrepit shack that you live in. What the place lacks in decisive magnanimity is made up for in cozy squalidness. Your bed covers much of the northern corner. Your beloved family chest sits at the foot of the bed.
|
8
|
+
coords: &2
|
9
|
+
:x: 5
|
10
|
+
:y: 0
|
11
|
+
:z: 0
|
12
|
+
paths:
|
13
|
+
:north: true
|
14
|
+
:east: true
|
15
|
+
:south: false
|
16
|
+
:west: true
|
17
|
+
danger_level: :none
|
18
|
+
monster_level_range:
|
19
|
+
items:
|
20
|
+
- !ruby/object:Gemwarrior::Bed
|
21
|
+
equipped: false
|
22
|
+
consumable: false
|
23
|
+
used: false
|
24
|
+
used_again: false
|
25
|
+
number_of_uses:
|
26
|
+
name: bed
|
27
|
+
name_display: Bed
|
28
|
+
description: The place where you sleep when you are not adventuring.
|
29
|
+
takeable: false
|
30
|
+
talkable: false
|
31
|
+
useable: true
|
32
|
+
equippable: false
|
33
|
+
monsters_abounding: []
|
34
|
+
bosses_abounding: []
|
35
|
+
checked_for_monsters: false
|
36
|
+
player: !ruby/object:Gemwarrior::Player
|
37
|
+
name: Player
|
38
|
+
description: |-
|
39
|
+
Picked to do battle against a wizened madman for a shiny something or other for world-saving purposes.
|
40
|
+
face: facey
|
41
|
+
hands: handsy
|
42
|
+
mood: moody
|
43
|
+
level: 1
|
44
|
+
xp: 0
|
45
|
+
hp_cur: 30
|
46
|
+
hp_max: 30
|
47
|
+
atk_lo: 1
|
48
|
+
atk_hi: 2
|
49
|
+
defense: 1
|
50
|
+
dexterity: 3
|
51
|
+
inventory: !ruby/object:Gemwarrior::Inventory
|
52
|
+
armor:
|
53
|
+
items: []
|
54
|
+
weapon:
|
55
|
+
rox: 0
|
56
|
+
cur_coords: *2
|
57
|
+
special_abilities: []
|
58
|
+
monsters_killed: 0
|
59
|
+
bosses_killed: 0
|
60
|
+
items_taken: 0
|
61
|
+
movements_made: 0
|
62
|
+
rests_taken: 0
|
63
|
+
deaths: 0
|
64
|
+
emerald_beaten: false
|
65
|
+
shifty_jeweled: false
|
66
|
+
shifty_to_jewel: false
|
67
|
+
duration:
|
data/data/minimal2.yaml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
--- !ruby/object:Gemwarrior::World
|
2
|
+
locations:
|
3
|
+
- !ruby/object:Gemwarrior::Location
|
4
|
+
name: home
|
5
|
+
name_display: Home
|
6
|
+
visited: true
|
7
|
+
description: The little, unimportant, decrepit shack that you live in. What the place lacks in decisive magnanimity is made up for in cozy squalidness. Your bed covers much of the northern corner. Your beloved family chest sits at the foot of the bed.
|
8
|
+
coords: &2
|
9
|
+
:x: 5
|
10
|
+
:y: 0
|
11
|
+
:z: 0
|
12
|
+
paths:
|
13
|
+
:north: true
|
14
|
+
:east: true
|
15
|
+
:south: false
|
16
|
+
:west: true
|
17
|
+
danger_level: :none
|
18
|
+
monster_level_range:
|
19
|
+
monsters_abounding: []
|
20
|
+
bosses_abounding: []
|
21
|
+
checked_for_monsters: false
|
22
|
+
emerald_beaten: false
|
23
|
+
shifty_jeweled: false
|
24
|
+
shifty_to_jewel: false
|
25
|
+
duration:
|
data/data/minimal3.yaml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--- !ruby/object:Gemwarrior::World
|
data/gemwarrior.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
# additional
|
28
28
|
## runtime deps
|
29
29
|
spec.add_runtime_dependency 'clocker', '~> 0.1.6'
|
30
|
-
spec.add_runtime_dependency 'colorize', '~> 0
|
30
|
+
spec.add_runtime_dependency 'colorize', '~> 1.0'
|
31
31
|
spec.add_runtime_dependency 'gems', '~> 1.2'
|
32
32
|
spec.add_runtime_dependency 'http', '~> 5.1'
|
33
33
|
spec.add_runtime_dependency 'json', '~> 2.6'
|
data/lib/gemwarrior/game.rb
CHANGED
@@ -7,6 +7,7 @@ require 'matrext'
|
|
7
7
|
require_relative 'entities/armor/iron_helmet'
|
8
8
|
require_relative 'entities/items/herb'
|
9
9
|
require_relative 'entities/weapons/dagger'
|
10
|
+
require_relative 'entities/player'
|
10
11
|
require_relative 'misc/animation'
|
11
12
|
require_relative 'misc/audio'
|
12
13
|
require_relative 'misc/formatting'
|
@@ -21,10 +22,10 @@ require_relative 'world'
|
|
21
22
|
module Gemwarrior
|
22
23
|
class Game
|
23
24
|
# CONSTANTS
|
24
|
-
INVENTORY_DEFAULT
|
25
|
-
INVENTORY_DEBUG
|
26
|
-
ROX_DEFAULT
|
27
|
-
ROX_DEBUG
|
25
|
+
INVENTORY_DEFAULT = Inventory.new
|
26
|
+
INVENTORY_DEBUG = Inventory.new([Herb.new, Herb.new, Herb.new])
|
27
|
+
ROX_DEFAULT = 0
|
28
|
+
ROX_DEBUG = 300
|
28
29
|
|
29
30
|
attr_accessor :world,
|
30
31
|
:evaluator,
|
@@ -34,81 +35,58 @@ module Gemwarrior
|
|
34
35
|
|
35
36
|
def initialize(options)
|
36
37
|
# set game options
|
37
|
-
|
38
|
-
GameOptions.add 'debug_mode', options.fetch(:debug_mode)
|
39
|
-
GameOptions.add 'god_mode', options.fetch(:god_mode)
|
40
|
-
GameOptions.add 'sound_enabled', options.fetch(:sound_enabled)
|
41
|
-
GameOptions.add 'sound_system', options.fetch(:sound_system)
|
42
|
-
GameOptions.add 'sound_volume', options.fetch(:sound_volume)
|
43
|
-
GameOptions.add 'use_wordnik', options.fetch(:use_wordnik)
|
44
|
-
GameOptions.add 'fight_completion', options.fetch(:fight_completion)
|
38
|
+
self.init_game_options(options)
|
45
39
|
|
46
40
|
# add classes for creatures, monsters, people, items, weapons, and armor to game
|
47
41
|
# also add them to the global GameAssets
|
48
|
-
init_creatures
|
49
|
-
init_monsters
|
50
|
-
init_people
|
51
|
-
init_items
|
52
|
-
init_weapons
|
53
|
-
init_armor
|
42
|
+
self.init_creatures
|
43
|
+
self.init_monsters
|
44
|
+
self.init_people
|
45
|
+
self.init_items
|
46
|
+
self.init_weapons
|
47
|
+
self.init_armor
|
54
48
|
|
55
|
-
# create new world based on
|
56
|
-
self.world
|
49
|
+
# create new world based on yaml/marshall data
|
50
|
+
self.world = init_world
|
57
51
|
|
58
52
|
# update some player aspects to make more dynamic
|
59
|
-
world.player.name = world.player.generate_name
|
60
|
-
world.player.face = world.player.generate_face
|
61
|
-
world.player.hands = world.player.generate_hands
|
62
|
-
world.player.mood = world.player.generate_mood
|
63
|
-
world.player.inventory = GameOptions.data['debug_mode'] ? INVENTORY_DEBUG : INVENTORY_DEFAULT
|
64
|
-
world.player.rox = GameOptions.data['debug_mode'] ? ROX_DEBUG : ROX_DEFAULT
|
53
|
+
self.world.player.name = world.player.generate_name
|
54
|
+
self.world.player.face = world.player.generate_face
|
55
|
+
self.world.player.hands = world.player.generate_hands
|
56
|
+
self.world.player.mood = world.player.generate_mood
|
57
|
+
self.world.player.inventory = GameOptions.data['debug_mode'] ? INVENTORY_DEBUG : INVENTORY_DEFAULT
|
58
|
+
self.world.player.rox = GameOptions.data['debug_mode'] ? ROX_DEBUG : ROX_DEFAULT
|
65
59
|
|
66
60
|
# set some global variables
|
67
|
-
world.duration = { mins: 0, secs: 0, ms: 0 }
|
68
|
-
world.emerald_beaten = false
|
69
|
-
world.shifty_to_jewel = false
|
70
|
-
world.shifty_has_jeweled = false
|
61
|
+
self.world.duration = { mins: 0, secs: 0, ms: 0 }
|
62
|
+
self.world.emerald_beaten = false
|
63
|
+
self.world.shifty_to_jewel = false
|
64
|
+
self.world.shifty_has_jeweled = false
|
71
65
|
|
72
|
-
# spawn bosses
|
73
|
-
|
74
|
-
world.location_by_name('pain_quarry-southeast').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
75
|
-
world.location_by_name('pain_quarry-east').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
76
|
-
world.location_by_name('pain_quarry-central').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
77
|
-
world.location_by_name('pain_quarry-south').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
78
|
-
world.location_by_name('pain_quarry-west').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
79
|
-
world.location_by_name('pain_quarry-northwest').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
80
|
-
world.location_by_name('pain_quarry-north').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
81
|
-
## River Bridge
|
82
|
-
world.location_by_name('river_bridge').bosses_abounding.push(Gemwarrior.const_get('Jaspern').new)
|
83
|
-
## Throne Room
|
84
|
-
world.location_by_name('sky_tower-throne_room').bosses_abounding.push(Gemwarrior.const_get('Emerald').new)
|
66
|
+
# # spawn bosses
|
67
|
+
self.init_bosses
|
85
68
|
|
86
69
|
# mark home as visited
|
87
|
-
world.location_by_name('home').visited = true
|
70
|
+
self.world.location_by_name('home').visited = true
|
88
71
|
|
89
72
|
# create options file if not existing
|
90
|
-
update_options_file
|
91
|
-
|
92
|
-
# require needed files for selected sound_system if sound_enabled
|
93
|
-
if GameOptions.data['sound_enabled']
|
94
|
-
Audio.init
|
95
|
-
end
|
73
|
+
self.update_options_file
|
96
74
|
|
97
75
|
# create the console
|
98
|
-
self.evaluator
|
99
|
-
self.repl
|
76
|
+
self.evaluator = Evaluator.new(world)
|
77
|
+
self.repl = Repl.new(self, world, evaluator)
|
100
78
|
|
101
79
|
# enter Jool!
|
102
|
-
repl.start('look', options.fetch(:extra_command), options.fetch(:new_skip), options.fetch(:resume_skip))
|
80
|
+
self.repl.start('look', options.fetch(:extra_command), options.fetch(:new_skip), options.fetch(:resume_skip))
|
103
81
|
end
|
104
82
|
|
105
83
|
def update_options_file
|
106
84
|
File.open(GameOptions.data['options_file_path'], 'w') do |f|
|
85
|
+
f.puts "fight_completion:#{GameOptions.data['fight_completion']}"
|
107
86
|
f.puts "sound_enabled:#{GameOptions.data['sound_enabled']}"
|
108
87
|
f.puts "sound_system:#{GameOptions.data['sound_system']}"
|
109
88
|
f.puts "sound_volume:#{GameOptions.data['sound_volume']}"
|
110
89
|
f.puts "use_wordnik:#{GameOptions.data['use_wordnik']}"
|
111
|
-
f.puts "fight_completion:#{GameOptions.data['fight_completion']}"
|
112
90
|
end
|
113
91
|
end
|
114
92
|
|
@@ -120,6 +98,37 @@ module Gemwarrior
|
|
120
98
|
Gemwarrior.const_get(filename_to_string).new
|
121
99
|
end
|
122
100
|
|
101
|
+
def init_game_options(options)
|
102
|
+
GameOptions.add 'beast_mode', options.fetch(:beast_mode)
|
103
|
+
GameOptions.add 'debug_mode', options.fetch(:debug_mode)
|
104
|
+
GameOptions.add 'fight_completion', options.fetch(:fight_completion)
|
105
|
+
GameOptions.add 'god_mode', options.fetch(:god_mode)
|
106
|
+
GameOptions.add 'sound_enabled', options.fetch(:sound_enabled)
|
107
|
+
GameOptions.add 'sound_system', options.fetch(:sound_system)
|
108
|
+
GameOptions.add 'sound_volume', options.fetch(:sound_volume)
|
109
|
+
GameOptions.add 'use_wordnik', options.fetch(:use_wordnik)
|
110
|
+
|
111
|
+
# require needed files for selected sound_system if sound_enabled
|
112
|
+
if GameOptions.data['sound_enabled']
|
113
|
+
Audio.init
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def init_bosses
|
118
|
+
## Pain Quarry
|
119
|
+
world.location_by_name('pain_quarry-southeast').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
120
|
+
world.location_by_name('pain_quarry-east').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
121
|
+
world.location_by_name('pain_quarry-central').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
122
|
+
world.location_by_name('pain_quarry-south').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
123
|
+
world.location_by_name('pain_quarry-west').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
124
|
+
world.location_by_name('pain_quarry-northwest').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
125
|
+
world.location_by_name('pain_quarry-north').bosses_abounding.push(Gemwarrior.const_get('Garynetty').new)
|
126
|
+
## River Bridge
|
127
|
+
world.location_by_name('river_bridge').bosses_abounding.push(Gemwarrior.const_get('Jaspern').new)
|
128
|
+
## Throne Room
|
129
|
+
world.location_by_name('sky_tower-throne_room').bosses_abounding.push(Gemwarrior.const_get('Emerald').new)
|
130
|
+
end
|
131
|
+
|
123
132
|
def init_creatures
|
124
133
|
Dir.glob(File.expand_path('../entities/creatures/*.rb', __FILE__)).each do |creature|
|
125
134
|
require_relative creature
|
@@ -170,20 +179,20 @@ module Gemwarrior
|
|
170
179
|
mode = GameOptions.data['save_file_mode']
|
171
180
|
|
172
181
|
if mode.eql?('Y')
|
173
|
-
if File.exist?(GameOptions.data['
|
174
|
-
File.open(GameOptions.data['
|
175
|
-
return YAML.
|
182
|
+
if File.exist?(GameOptions.data['world_yaml_path'])
|
183
|
+
File.open(GameOptions.data['world_yaml_path'], 'r') do |f|
|
184
|
+
return YAML.unsafe_load(f)
|
176
185
|
end
|
177
186
|
else
|
178
|
-
puts "Error: cannot load #{GameOptions.data['
|
187
|
+
puts "Error: cannot load #{GameOptions.data['world_yaml_path']}."
|
179
188
|
end
|
180
189
|
else
|
181
|
-
if File.exist?(GameOptions.data['
|
182
|
-
File.open(GameOptions.data['
|
190
|
+
if File.exist?(GameOptions.data['world_bin_path'])
|
191
|
+
File.open(GameOptions.data['world_bin_path'], 'r') do |f|
|
183
192
|
return Marshal.load(f)
|
184
193
|
end
|
185
194
|
else
|
186
|
-
puts "Error: cannot load #{GameOptions.data['
|
195
|
+
puts "Error: cannot load #{GameOptions.data['world_bin_path']}."
|
187
196
|
end
|
188
197
|
end
|
189
198
|
end
|
data/lib/gemwarrior/repl.rb
CHANGED
@@ -120,7 +120,7 @@ module Gemwarrior
|
|
120
120
|
def get_save_file_name
|
121
121
|
if save_file_exist?
|
122
122
|
File.open(GameOptions.data['save_file_yaml_path'], 'r') do |f|
|
123
|
-
return YAML.
|
123
|
+
return YAML.unsafe_load(f)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -551,7 +551,7 @@ module Gemwarrior
|
|
551
551
|
if mode.eql? 'Y'
|
552
552
|
if File.exist?(GameOptions.data['save_file_yaml_path'])
|
553
553
|
File.open(GameOptions.data['save_file_yaml_path'], 'r') do |f|
|
554
|
-
return YAML.
|
554
|
+
return YAML.unsafe_load(f)
|
555
555
|
end
|
556
556
|
else
|
557
557
|
puts 'No save file exists.'
|
data/lib/gemwarrior/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemwarrior
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Chadwick
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clocker
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: gems
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -284,6 +284,9 @@ files:
|
|
284
284
|
- bin/gemwarrior
|
285
285
|
- data/default_world.yaml
|
286
286
|
- data/fantasy_names.yaml
|
287
|
+
- data/minimal1.yaml
|
288
|
+
- data/minimal2.yaml
|
289
|
+
- data/minimal3.yaml
|
287
290
|
- gemwarrior.gemspec
|
288
291
|
- lib/gemwarrior/arena.rb
|
289
292
|
- lib/gemwarrior/battle.rb
|
@@ -418,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
418
421
|
- !ruby/object:Gem::Version
|
419
422
|
version: '0'
|
420
423
|
requirements: []
|
421
|
-
rubygems_version: 3.4.
|
424
|
+
rubygems_version: 3.4.19
|
422
425
|
signing_key:
|
423
426
|
specification_version: 4
|
424
427
|
summary: RubyGem text adventure
|