gemwarrior 0.15.0 → 0.15.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 42b11f28fb910a20ab8c22ad7c97f67403c0ea9b
4
- data.tar.gz: 884e88c0ee09cd7c34cd75b675c09d301750642a
2
+ SHA256:
3
+ metadata.gz: e974792259f0ed169c712e4b93c2848a063cf97490696a7ee7b198b6d52a26eb
4
+ data.tar.gz: 7b7d820704431ad6ac7d03b2a59922b304eeba07d828882a19e4f3363b55d3d7
5
5
  SHA512:
6
- metadata.gz: 59cc678e76ce6dbd0d88fcef353eeef743185f4d78fa27dde69a84b7bc7779b1fc50d35c4ab1a2cb3d0a43588c0b866460838459b6499a7620074cb076922e88
7
- data.tar.gz: 94ef68e78d3e118385b91b26ee3ac71123546a6535b05fbe8baeb3a41b197e5977c10fd4a19c66aad557c2443d5a717fe2c4152343bc03c1618567ab9ea5905f
6
+ metadata.gz: 4e291b78434c5ea2cadbdb6f0b48d03d612fe1f75892ed7f4bb9e4fe08faa2015ff29b566e22a29093eba9f88ed9f52baa85471593742a438373bc3abce4b22d
7
+ data.tar.gz: 30ca5643b4f02e8e1c042e594da3d2de28ea733c4447af5615e591b9dc777d0434ca5ce05743900a3405f700037cde9d12f15bf676174c1fc63410441a31756b
data/README.md CHANGED
@@ -42,11 +42,3 @@ Run the commands above and you'll be whisked away to Jool, ready to start or con
42
42
  `> version` - display current game version
43
43
  `> quit` - quit this nonsense w/ prompt
44
44
  `> quit!` - quit this nonsense w/o prompt
45
-
46
- ## In Progress, Yanno
47
-
48
- Gem Warrior is in heavy beta testing right now, and if you wish to help out in an official way, please visit [the main Gem Warrior homepage](http://gw.codana.me) for more information.
49
-
50
- ## Current Issues/Requests
51
-
52
- The old list of issues/features has been moved to the [Github issues section](https://github.com/michaelchadwick/gemwarrior/issues). Feel free to go there to add any bugs you find while playing or any requests for new features.
File without changes
@@ -1,4 +1,4 @@
1
- # List of fantasy names, taken from a couple sources, as data for NameGeneraor
1
+ # List of fantasy names, taken from a couple sources, as data for NameGenerator
2
2
  # http://www.creative-role-playing.com/fantasy-sounding-names
3
3
  # http://www.angelfire.com/tx/afira/six.html
4
4
  ---
@@ -26,18 +26,18 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'matrext', '~> 0.4.10'
27
27
  spec.add_runtime_dependency 'clocker', '~> 0.1.6'
28
28
  spec.add_runtime_dependency 'gems', '~> 0.8.3'
29
-
29
+
30
30
  # sound systems
31
31
  #spec.add_runtime_dependency 'feep', '~> 0.1.3'
32
32
  #spec.add_runtime_dependency 'win32-sound', '~> 0.6.0'
33
33
  #spec.add_runtime_dependency 'bloopsaphone', '>= 0.4'
34
-
35
- spec.add_development_dependency 'bundler', '~> 1.8'
36
- spec.add_development_dependency 'rake', '~> 10.0'
37
- spec.add_development_dependency 'rubocop', '~> 0.29'
38
- spec.add_development_dependency 'rspec'
39
- spec.add_development_dependency 'rspec-nc'
40
- spec.add_development_dependency 'guard'
41
- spec.add_development_dependency 'guard-rspec'
42
- spec.add_development_dependency 'pry-byebug', '~> 3.0'
34
+
35
+ spec.add_development_dependency 'bundler', '~> 2.1'
36
+ spec.add_development_dependency 'rake', '~> 12.3.3'
37
+ spec.add_development_dependency 'rubocop', '~> 0.52.1'
38
+ spec.add_development_dependency 'rspec', '~> 3.9.0'
39
+ spec.add_development_dependency 'rspec-nc', '~> 0.3'
40
+ spec.add_development_dependency 'guard', '~> 2.16'
41
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
42
+ spec.add_development_dependency 'pry-byebug', '~> 3.9'
43
43
  end
@@ -66,7 +66,7 @@ module Gemwarrior
66
66
  print "\n"
67
67
  end
68
68
  puts
69
- print 'REMAINING GOLD: '
69
+ print 'REMAINING ROX: '
70
70
  Animation.run(phrase: player_rox_remaining.to_s, oneline: true)
71
71
  print "\n"
72
72
  display_shopping_cart(items_purchased)
@@ -76,7 +76,7 @@ module Gemwarrior
76
76
  print "\n"
77
77
  end
78
78
  puts
79
- print 'REMAINING GOLD: '
79
+ print 'REMAINING ROX: '
80
80
  Animation.run(phrase: player_rox_remaining.to_s, oneline: true)
81
81
  print "\n"
82
82
  display_shopping_cart(items_purchased)
@@ -14,7 +14,7 @@ module Gemwarrior
14
14
 
15
15
  GO_PARAMS = 'Options: north, east, south, west'
16
16
  CHANGE_PARAMS = 'Options: name'
17
- DEBUG_LIST_PARAMS = 'Options: players, creatures, items, locations, monsters, weapons'
17
+ DEBUG_LIST_PARAMS = 'Options: players, creatures, items, locations, monsters, weapons, armor'
18
18
  DEBUG_STAT_PARAMS = 'Options: hp_cur, atk_lo, atk_hi, experience, rox, strength, dexterity, defense, inventory'
19
19
 
20
20
  ERROR_COMMAND_INVALID = 'That is not something the game yet understands.'
@@ -6,7 +6,7 @@
6
6
  require 'yaml'
7
7
 
8
8
  class NameGenerator
9
- attr_accessor :name_set, :type, :chain_cache
9
+ attr_accessor :type, :name_set, :chain_cache
10
10
 
11
11
  def initialize(type)
12
12
  self.type = type
@@ -39,9 +39,9 @@ class NameGenerator
39
39
  def generate_names(count = 1)
40
40
  list = []
41
41
 
42
- for i in 1..count
42
+ (1..count).each {
43
43
  list.push(generate_name)
44
- end
44
+ }
45
45
 
46
46
  return list
47
47
  end
@@ -117,11 +117,11 @@ class NameGenerator
117
117
  chain.each do |key, subkey|
118
118
  table_len[key] = 0
119
119
 
120
- subkey.each do |subkey, value|
120
+ subkey.each do |subsubkey, value|
121
121
  count = value
122
122
  weighted = (count ** 1.3).floor
123
123
 
124
- chain[key][subkey] = weighted
124
+ chain[key][subsubkey] = weighted
125
125
  table_len[key] += weighted
126
126
  end
127
127
  end
@@ -136,7 +136,7 @@ class NameGenerator
136
136
  parts = select_link(chain, 'parts')
137
137
  names = []
138
138
 
139
- for i in 0..parts-1
139
+ (0..parts-1).each {
140
140
  name_len = select_link(chain, 'name_len')
141
141
  c = select_link(chain, 'initial')
142
142
  name = c
@@ -148,7 +148,7 @@ class NameGenerator
148
148
  last_c = c
149
149
  end
150
150
  names.push(name)
151
- end
151
+ }
152
152
 
153
153
  return names.join(' ')
154
154
  end
@@ -1,19 +1,24 @@
1
1
  # lib/gemwarrior/misc/timer.rb
2
2
  # Timer
3
3
 
4
+ require 'observer'
5
+
4
6
  module Gemwarrior
5
7
  class Timer
6
- attr_accessor :duration_in_s, :timer_name, :background, :progress, :verbose
8
+ include Observable
9
+
10
+ attr_accessor :duration_in_s, :timer_name, :background, :progress, :verbose, :command
7
11
 
8
12
  DEFAULTS = {
9
- duration_in_s: 1,
10
- timer_name: 'Timer',
11
- background: false,
13
+ duration_in_s: 5,
14
+ timer_name: 'timer',
15
+ background: true,
12
16
  progress: false,
13
- verbose: true
17
+ verbose: false,
18
+ command: nil
14
19
  }
15
20
 
16
- def initialize(options = {})
21
+ def initialize(options = {}, repl)
17
22
  options = DEFAULTS.merge(options)
18
23
 
19
24
  self.duration_in_s = options[:duration_in_s]
@@ -21,6 +26,9 @@ module Gemwarrior
21
26
  self.background = options[:background]
22
27
  self.progress = options[:progress]
23
28
  self.verbose = options[:verbose]
29
+ self.command = options[:command]
30
+
31
+ add_observer(repl)
24
32
  end
25
33
 
26
34
  def start
@@ -40,11 +48,15 @@ module Gemwarrior
40
48
  sleep 1
41
49
  print '.' if progress
42
50
  if Time.now >= end_time
43
- print "\n"
44
- puts "#{timer_name} ended at #{Time.now}" if verbose
45
- return
51
+ return stop
46
52
  end
47
53
  end
48
54
  end
55
+
56
+ def stop
57
+ puts "\n#{timer_name} ended at #{Time.now}" if verbose
58
+ changed
59
+ notify_observers(self.command) unless self.command.nil?
60
+ end
49
61
  end
50
62
  end
@@ -76,15 +76,7 @@ module Gemwarrior
76
76
  loop do
77
77
  prompt
78
78
  begin
79
- input = read_line
80
- result = evaluator.parse(input)
81
- if result.eql?('exit')
82
- exit
83
- elsif result.eql?('checkupdate')
84
- check_for_new_release
85
- else
86
- puts result
87
- end
79
+ main_loop
88
80
  rescue Interrupt
89
81
  puts
90
82
  puts QUIT_MESSAGE
@@ -94,6 +86,23 @@ module Gemwarrior
94
86
  end
95
87
  end
96
88
 
89
+ def main_loop(ext_input = nil)
90
+ input = ext_input.nil? ? read_line : ext_input
91
+ result = evaluator.parse(input)
92
+ if result.eql?('exit')
93
+ exit
94
+ elsif result.eql?('checkupdate')
95
+ check_for_new_release
96
+ else
97
+ puts result
98
+ end
99
+ end
100
+
101
+ # timer observer
102
+ #def update(command)
103
+ # main_loop(command)
104
+ #end
105
+
97
106
  private
98
107
 
99
108
  def clear_screen
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.15.0'
5
+ VERSION = '0.15.5'
6
6
  end
@@ -16,10 +16,8 @@ module Gemwarrior
16
16
  WORLD_DIM_WIDTH = 10
17
17
  WORLD_DIM_HEIGHT = 10
18
18
 
19
- attr_accessor :monsters,
19
+ attr_accessor :player,
20
20
  :locations,
21
- :weapons,
22
- :player,
23
21
  :duration,
24
22
  :emerald_beaten,
25
23
  :shifty_to_jewel,
@@ -197,6 +195,14 @@ module Gemwarrior
197
195
  else
198
196
  ">> weapons: #{GameWeapons.data.map(&:name).join(', ')}"
199
197
  end
198
+ when 'armor'
199
+ puts "[ARMOR](#{GameArmor.data.length})".colorize(:yellow)
200
+ if details
201
+ GameArmor.data.map { |w| print w.describe_detailed }
202
+ return
203
+ else
204
+ ">> armor: #{GameArmor.data.map(&:name).join(', ')}"
205
+ end
200
206
  else
201
207
  ERROR_LIST_PARAM_INVALID
202
208
  end
@@ -210,6 +216,7 @@ module Gemwarrior
210
216
  puts "#{list('creatures', show_details)}\n\n"
211
217
  puts "#{list('monsters', show_details)}\n\n"
212
218
  puts "#{list('items', show_details)}\n\n"
219
+ puts "#{list('armor', show_details)}\n\n"
213
220
  puts "#{list('weapons', show_details)}\n\n"
214
221
  puts "#{list('locations', show_details)}\n"
215
222
  puts
@@ -0,0 +1,18 @@
1
+ new_release_available = false
2
+
3
+ puts 'Checking releases...'
4
+
5
+ remote_release = '0.10.3'
6
+ local_release = '0.10.3'
7
+
8
+ 0.upto(2) do |i|
9
+ if remote_release.split('.')[i].to_i > local_release.split('.')[i].to_i
10
+ new_release_available = true
11
+ end
12
+ end
13
+
14
+ status_text = new_release_available ? "New v#{remote_release} available!" : 'You have the latest version.'
15
+
16
+ puts "local_release: #{local_release}"
17
+ puts "remote_release #{remote_release}"
18
+ puts status_text
@@ -0,0 +1,9 @@
1
+ require 'io/console'
2
+
3
+ puts 'press a key using STDIN.getc'
4
+ c = STDIN.getc
5
+ puts "c: #{c.dump}"
6
+
7
+ puts 'press another key using STDIN.getch'
8
+ ch = STDIN.getch
9
+ puts "ch: #{ch.dump}"
@@ -0,0 +1,16 @@
1
+ s = 'I still can\'t believe I lost at the Arena! I was doing so well, and then a slippery citrinaga got a cheap shot on me.'
2
+ words = s.split(' ')
3
+ words_hooched = []
4
+
5
+ words.each do |w|
6
+ puts "w: #{w}"
7
+ if rand(0..100) > 45 and w.length > 1
8
+ w = w.split('')
9
+ w = w.insert(rand(0..w.length-1), '*HIC*')
10
+ w = w.join('')
11
+ end
12
+ words_hooched << w
13
+ end
14
+
15
+ puts
16
+ puts "Final sentence: #{words_hooched.join(' ')}"
@@ -0,0 +1,7 @@
1
+ class Item
2
+ attr_accessor :name
3
+
4
+ def initialize(name = 'item')
5
+ self.name = name
6
+ end
7
+ end
@@ -0,0 +1,42 @@
1
+ require 'http'
2
+ require 'json'
3
+
4
+ url = 'http://api.wordnik.com:80/v4/words.json/randomWords'
5
+
6
+ json_return = HTTP.get(
7
+ url,
8
+ :params => {
9
+ :hasDictionaryDef => true,
10
+ :includePartOfSpeech => 'noun-plural',
11
+ :minCorpusCount => 10,
12
+ :maxCorpusCount => -1,
13
+ :minDictionaryCount => 1,
14
+ :maxDictionaryCount => -1,
15
+ :minLength => 5,
16
+ :maxLength => 12,
17
+ :sortBy => 'alpha',
18
+ :sortOrder => 'asc',
19
+ :limit => 10,
20
+ :api_key => '63f5001dfacf2d619230e08591702875786da258b471becb6'
21
+ }
22
+ )
23
+
24
+ if json_return
25
+ json_data = JSON.parse(json_return.to_s)
26
+
27
+ if json_data.include?("type") && json_data.include?("message")
28
+ puts "wordnik error: #{json_data["message"]}"
29
+ else
30
+ word_list = []
31
+ json_data.map {|j| word_list.push(j["word"])}
32
+ if word_list.length > 0
33
+ p word_list
34
+ else
35
+ puts 'no words received'
36
+ end
37
+ end
38
+ else
39
+ puts "json error: #{json_return.to_s}"
40
+ end
41
+
42
+
@@ -0,0 +1,90 @@
1
+ module AudioCues
2
+ def self.add key, val
3
+ @@cues ||= {}
4
+ @@cues[key] = val
5
+ end
6
+
7
+ def self.cues
8
+ @@cues ||= {}
9
+ end
10
+
11
+ self.add :battle_start, {
12
+ synth: [
13
+ { frequencies: 'G4', duration: 50 },
14
+ { frequencies: 'G#4', duration: 50 },
15
+ { frequencies: 'G4', duration: 50 },
16
+ { frequencies: 'G#4', duration: 50 },
17
+ { frequencies: 'G4', duration: 50 },
18
+ { frequencies: 'G#4', duration: 50 }
19
+ ],
20
+ sample: 'battle_start.wav'
21
+ }
22
+
23
+ self.add :battle_player_attack, {
24
+ synth: [{ frequencies: 'A4,E4,B5', duration: 75 }],
25
+ sample: 'battle_player_attack.wav'
26
+ }
27
+
28
+ self.add :battle_player_miss, {
29
+ synth: [{ frequencies: 'A4', duration: 75 }],
30
+ sample: 'battle_player_miss.wav'
31
+ }
32
+
33
+ self.add :battle_monster_attack, {
34
+ synth: [{ frequencies: 'B4,E#5,A5', duration: 75 }],
35
+ sample: 'battle_monster_attack.wav'
36
+ }
37
+
38
+ self.add :battle_monster_miss, {
39
+ synth: [{ frequencies: 'B4', duration: 75 }],
40
+ sample: 'battle_monster_miss.wav'
41
+ }
42
+
43
+ self.add :intro, {
44
+ synth: [
45
+ { frequencies: 'A3,E4,C#5,E5', duration: 300 },
46
+ { frequencies: 'A3,E4,C#5,F#5', duration: 600 }
47
+ ],
48
+ sample: 'intro.wav'
49
+ }
50
+
51
+ self.add :player_resurrection, {
52
+ synth: [
53
+ { frequencies: 'D#5', duration: 100 },
54
+ { frequencies: 'A4', duration: 150 },
55
+ { frequencies: 'F#4', duration: 200 },
56
+ { frequencies: 'F4', duration: 1000 }
57
+ ],
58
+ sample: 'player_resurrection.wav'
59
+ }
60
+
61
+ self.add :player_travel, {
62
+ synth: [
63
+ { frequencies: 'C4', duration: 75 },
64
+ { frequencies: 'D4', duration: 75 },
65
+ { frequencies: 'E4', duration: 75 }
66
+ ],
67
+ sample: 'player_travel.wav'
68
+ }
69
+
70
+ self.add :win_game, {
71
+ synth: [
72
+ { frequencies: 'G3', duration: 250 },
73
+ { frequencies: 'A3', duration: 50 },
74
+ { frequencies: 'B3', duration: 50 },
75
+ { frequencies: 'C4', duration: 50 },
76
+ { frequencies: 'D4', duration: 250 },
77
+ { frequencies: 'E4', duration: 50 },
78
+ { frequencies: 'F#4', duration: 50 },
79
+ { frequencies: 'G4', duration: 50 },
80
+ { frequencies: 'A4', duration: 250 },
81
+ { frequencies: 'B4', duration: 50 },
82
+ { frequencies: 'C5', duration: 50 },
83
+ { frequencies: 'D5', duration: 50 },
84
+ { frequencies: 'E5', duration: 50 },
85
+ { frequencies: 'F#5', duration: 50 },
86
+ { frequencies: 'G5', duration: 1000 }
87
+ ],
88
+ sample: 'win_game.wav'
89
+ }
90
+ end
@@ -0,0 +1,50 @@
1
+ class Rat
2
+ attr_accessor :name,
3
+ :level,
4
+ :hp
5
+
6
+ def initialize(name = 'rat')
7
+ self.name = name
8
+ self.level = rand(1..4)
9
+ self.hp = rand((self.level * 3)..(self.level * 5))
10
+ end
11
+ end
12
+
13
+ m = [Rat.new]
14
+
15
+ rat_o = m[0]
16
+ rat_c = m[0].clone
17
+
18
+ puts "[initial]"
19
+ puts "m[0] : #{m[0].inspect}"
20
+ puts "rat_o : #{rat_o.inspect}"
21
+ puts "rat_c : #{rat_c.inspect}"
22
+
23
+ m[0].hp -= 1
24
+
25
+ puts "[m[0] - 1hp]"
26
+ puts "m[0] : #{m[0].inspect}"
27
+ puts "rat_o : #{rat_o.inspect}"
28
+ puts "rat_c : #{rat_c.inspect}"
29
+
30
+ rat_o.hp -= 1
31
+
32
+ puts "[rat_o - 1hp]"
33
+ puts "m[0] : #{m[0].inspect}"
34
+ puts "rat_o : #{rat_o.inspect}"
35
+ puts "rat_c : #{rat_c.inspect}"
36
+
37
+ rat_c.hp -= 1
38
+
39
+ puts "[rat_c - 1hp]"
40
+ puts "m[0] : #{m[0].inspect}"
41
+ puts "rat_o : #{rat_o.inspect}"
42
+ puts "rat_c : #{rat_c.inspect}"
43
+
44
+ rat_c2 = m[0].clone
45
+
46
+ puts "[rat_c2 created from m[0]]"
47
+ puts "m[0] : #{m[0].inspect}"
48
+ puts "rat_o : #{rat_o.inspect}"
49
+ puts "rat_c : #{rat_c.inspect}"
50
+ puts "rat_c2: #{rat_c2.inspect}"
@@ -0,0 +1,35 @@
1
+ require 'feep'
2
+
3
+ sequence = [
4
+ {freq_or_note: 'A3', duration: 80},
5
+ {freq_or_note: 'E4', duration: 80},
6
+ {freq_or_note: 'G4', duration: 80},
7
+ {freq_or_note: 'C#5', duration: 80},
8
+ {freq_or_note: 'G5', duration: 240}
9
+ ]
10
+
11
+ defaults = {
12
+ :freq_or_note => '440',
13
+ :waveform => 'saw',
14
+ :volume => 0.3,
15
+ :duration => 100,
16
+ :notext => true
17
+ }
18
+
19
+ sequence.each do |seq|
20
+ puts "seq before merge: #{seq}"
21
+
22
+ seq = defaults.merge(seq)
23
+
24
+ puts "seq after merge: #{seq}"
25
+
26
+ puts "playing #{seq[:freq_or_note]}"
27
+
28
+ Feep::Base.new({
29
+ :freq_or_note => seq[:freq_or_note],
30
+ :waveform => seq[:waveform],
31
+ :volume => seq[:volume],
32
+ :duration => seq[:duration],
33
+ :notext => seq[:notext]
34
+ })
35
+ end
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env ruby
2
+ require 'io/console'
3
+
4
+ class SaveLoad
5
+ SAVE_DATA_FILE = 'save.conf'
6
+
7
+ attr_accessor :data_changed
8
+
9
+ def initialize
10
+ self.data_changed = false
11
+ end
12
+
13
+ module Config
14
+ def self.add key, value
15
+ @@data ||= {}
16
+ @@data[key] = value
17
+ end
18
+
19
+ def self.data
20
+ @@data ||= {}
21
+ end
22
+ end
23
+
24
+ def show_change_data_menu
25
+ puts 'Change Data'
26
+ puts '-----------'
27
+ puts
28
+ puts " (1) Name: #{Config.data['name']}"
29
+ puts " (2) Age: #{Config.data['age']}"
30
+ puts " (3) Hometown: #{Config.data['hometown']}"
31
+ puts
32
+ puts ' (q) Back to main menu'
33
+ puts
34
+ print 'data> '
35
+ choice = STDIN.getch.downcase
36
+
37
+ case choice
38
+ when '1'
39
+ print 'Name: '
40
+ answer = gets.chomp
41
+
42
+ unless answer.empty?
43
+ if Config.data['name'].nil?
44
+ Config.add 'name', answer
45
+ else
46
+ Config.data['name'] = answer
47
+ end
48
+ self.data_changed = true
49
+ end
50
+ show_change_data_menu
51
+ when '2'
52
+ print 'Age: '
53
+ answer = gets.chomp
54
+
55
+ unless answer.empty?
56
+ if Config.data['age'].nil?
57
+ Config.add 'age', answer
58
+ else
59
+ Config.data['age'] = answer
60
+ end
61
+ self.data_changed = true
62
+ end
63
+ show_change_data_menu
64
+ when '3'
65
+ print 'Hometown: '
66
+ answer = gets.chomp
67
+
68
+ unless answer.empty?
69
+ if Config.data['hometown'].nil?
70
+ Config.add 'hometown', answer
71
+ else
72
+ Config.data['hometown'] = answer
73
+ end
74
+ self.data_changed = true
75
+ end
76
+ show_change_data_menu
77
+ when 'q', 'x'
78
+ puts
79
+ return
80
+ else
81
+ show_change_data_menu
82
+ end
83
+ end
84
+
85
+ def show_main_menu
86
+ puts 'Main Menu'
87
+ puts '---------'
88
+ puts
89
+ puts ' (1) Display loaded data'
90
+ puts ' (2) Change data'
91
+ puts ' (3) Read from save file'
92
+ puts ' (4) Write to save file'
93
+ puts
94
+ puts ' (q) Quit from script'
95
+ puts
96
+ print 'menu> '
97
+ choice = STDIN.getch.downcase
98
+
99
+ case choice
100
+ when '1'
101
+ puts choice
102
+ display_loaded_data
103
+ show_main_menu
104
+ when '2'
105
+ puts choice
106
+ show_change_data_menu
107
+ show_main_menu
108
+ when '3'
109
+ puts choice
110
+ read_from_save
111
+ show_main_menu
112
+ when '4'
113
+ puts choice
114
+ write_to_save
115
+ show_main_menu
116
+ when 'x', 'q'
117
+ puts choice
118
+ if data_changed
119
+ puts 'You changed stuff. Do you want to save before exiting? (y/n)'
120
+ answer = STDIN.getch.downcase
121
+
122
+ case answer
123
+ when 'y'
124
+ write_to_save
125
+ end
126
+ end
127
+ puts "Exiting..."
128
+ exit
129
+ else
130
+ show_main_menu
131
+ end
132
+ end
133
+
134
+ def display_loaded_data
135
+ if Config.data.empty?
136
+ puts 'No loaded data yet.'
137
+ puts
138
+ else
139
+ Config.data.each do |key, val|
140
+ puts "#{key} : #{val}"
141
+ end
142
+ puts
143
+ end
144
+ end
145
+
146
+ def read_from_save
147
+ if File.exist?(SAVE_DATA_FILE)
148
+ #save_data = YAML.load_file(SAVE_DATA_FILE)
149
+
150
+ print 'Overwrite current session with saved data? (y/n) '
151
+ a = STDIN.getch.chomp.downcase
152
+
153
+ case a
154
+ when 'y'
155
+ File.open(SAVE_DATA_FILE).readlines.each do |line|
156
+ l = line.split(':')
157
+ Config.add l[0], l[1]
158
+ end
159
+ puts "Successfully read from #{SAVE_DATA_FILE}"
160
+ puts
161
+ end
162
+ else
163
+ puts 'No save file.'
164
+ end
165
+ end
166
+
167
+ def write_to_save
168
+ File.open(SAVE_DATA_FILE, 'w') do |f|
169
+ Config.data.each do |key, val|
170
+ f.puts "#{key}:#{val}"
171
+ end
172
+ end
173
+ puts "Wrote to #{SAVE_DATA_FILE}"
174
+ puts
175
+ end
176
+ end
177
+
178
+ puts 'Welcome to the Save/Load data test!'
179
+ puts
180
+ sl = SaveLoad.new
181
+ sl.show_main_menu
@@ -0,0 +1,2 @@
1
+ name:mike
2
+ age:34
@@ -0,0 +1,4 @@
1
+ require_relative 'game_options'
2
+
3
+ puts GameOptions.data
4
+ puts GameOptions.data['sound_enabled']
@@ -0,0 +1,15 @@
1
+ module GameOptions
2
+ def self.add key, value
3
+ @@data ||= {}
4
+ @@data[key] = value
5
+ end
6
+
7
+ def self.data
8
+ @@data ||= {}
9
+ end
10
+ end
11
+
12
+ GameOptions.data
13
+
14
+ GameOptions.add 'sound_enabled', true
15
+ GameOptions.add 'sound_volume', 0.3
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.0
4
+ version: 0.15.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -120,112 +120,112 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '1.8'
123
+ version: '2.1'
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '1.8'
130
+ version: '2.1'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: rake
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '10.0'
137
+ version: 12.3.3
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '10.0'
144
+ version: 12.3.3
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: rubocop
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: '0.29'
151
+ version: 0.52.1
152
152
  type: :development
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: '0.29'
158
+ version: 0.52.1
159
159
  - !ruby/object:Gem::Dependency
160
160
  name: rspec
161
161
  requirement: !ruby/object:Gem::Requirement
162
162
  requirements:
163
- - - ">="
163
+ - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: '0'
165
+ version: 3.9.0
166
166
  type: :development
167
167
  prerelease: false
168
168
  version_requirements: !ruby/object:Gem::Requirement
169
169
  requirements:
170
- - - ">="
170
+ - - "~>"
171
171
  - !ruby/object:Gem::Version
172
- version: '0'
172
+ version: 3.9.0
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: rspec-nc
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
- - - ">="
177
+ - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: '0'
179
+ version: '0.3'
180
180
  type: :development
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - ">="
184
+ - - "~>"
185
185
  - !ruby/object:Gem::Version
186
- version: '0'
186
+ version: '0.3'
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: guard
189
189
  requirement: !ruby/object:Gem::Requirement
190
190
  requirements:
191
- - - ">="
191
+ - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: '0'
193
+ version: '2.16'
194
194
  type: :development
195
195
  prerelease: false
196
196
  version_requirements: !ruby/object:Gem::Requirement
197
197
  requirements:
198
- - - ">="
198
+ - - "~>"
199
199
  - !ruby/object:Gem::Version
200
- version: '0'
200
+ version: '2.16'
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: guard-rspec
203
203
  requirement: !ruby/object:Gem::Requirement
204
204
  requirements:
205
- - - ">="
205
+ - - "~>"
206
206
  - !ruby/object:Gem::Version
207
- version: '0'
207
+ version: '4.7'
208
208
  type: :development
209
209
  prerelease: false
210
210
  version_requirements: !ruby/object:Gem::Requirement
211
211
  requirements:
212
- - - ">="
212
+ - - "~>"
213
213
  - !ruby/object:Gem::Version
214
- version: '0'
214
+ version: '4.7'
215
215
  - !ruby/object:Gem::Dependency
216
216
  name: pry-byebug
217
217
  requirement: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - "~>"
220
220
  - !ruby/object:Gem::Version
221
- version: '3.0'
221
+ version: '3.9'
222
222
  type: :development
223
223
  prerelease: false
224
224
  version_requirements: !ruby/object:Gem::Requirement
225
225
  requirements:
226
226
  - - "~>"
227
227
  - !ruby/object:Gem::Version
228
- version: '3.0'
228
+ version: '3.9'
229
229
  description: A fun text adventure in the form of a RubyGem!
230
230
  email: mike@codana.me
231
231
  executables:
@@ -343,11 +343,23 @@ files:
343
343
  - lib/gemwarrior/world.rb
344
344
  - spec/gemwarrior_spec.rb
345
345
  - spec/spec_helper.rb
346
+ - tests/compare_versions.rb
347
+ - tests/getch_test.rb
348
+ - tests/hooch.rb
349
+ - tests/item_hashes.rb
350
+ - tests/json_api_call.rb
351
+ - tests/module_hashes.rb
352
+ - tests/test-class/test-class.rb
353
+ - tests/test-feep/test-feep.rb
354
+ - tests/test-save-load/save-load.rb
355
+ - tests/test-save-load/save.conf
356
+ - tests/test-singleton/game.rb
357
+ - tests/test-singleton/game_options.rb
346
358
  homepage: http://rubygems.org/gems/gemwarrior
347
359
  licenses:
348
360
  - MIT
349
361
  metadata: {}
350
- post_install_message:
362
+ post_install_message:
351
363
  rdoc_options: []
352
364
  require_paths:
353
365
  - lib
@@ -362,9 +374,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
362
374
  - !ruby/object:Gem::Version
363
375
  version: '0'
364
376
  requirements: []
365
- rubyforge_project:
366
- rubygems_version: 2.4.8
367
- signing_key:
377
+ rubygems_version: 3.1.4
378
+ signing_key:
368
379
  specification_version: 4
369
380
  summary: RubyGem text adventure
370
- test_files: []
381
+ test_files:
382
+ - spec/gemwarrior_spec.rb
383
+ - spec/spec_helper.rb