gemwarrior 0.10.5 → 0.10.6

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
  SHA1:
3
- metadata.gz: 4e003f1c361b29e19bf92a5d6041cdf41625ffee
4
- data.tar.gz: 1aa44590aa8d6d79460d64910509519482dffc03
3
+ metadata.gz: 4a63dbf4d7fa1730e5bb7504020b668e54cb0a95
4
+ data.tar.gz: 4ed06ecc25c511622ef4730e7bbc5d9b2c2d1dcb
5
5
  SHA512:
6
- metadata.gz: 27726ab0025e81e5a9b1863f772ff2cd5d99bb468ce1609414c4c4bf97ad1e1cac906e04923cda45183680b7e737ec96490ca1ed0fe0f48671a78a2e5b37da63
7
- data.tar.gz: 9f6f72ad094d442b8064ab21c3c22ef186563a88958b9ae363e3322f52ca69de6b458a88078a5c002e0c12fdb8c737a238ccb4b15c03c610698d160516fec87f
6
+ metadata.gz: fa9c14bded730f4ae0f9693094e8893bb7f5f133be99422e90baabe10da96c92f04461d47a4f94e21e2af4557b08261db405c5f064c6c89f5ecd9654b42d53fe
7
+ data.tar.gz: d75e3ab4f36c04a6946ee6104858f91a7f6d303e92380f193d39741230fe26d02e0a226a9dfd25735db19b85b4fbadd723d0e025f0aab206197471cd1cc86977
data/bin/gemwarrior CHANGED
@@ -17,6 +17,7 @@ GW_OPTS_FILE = "#{GW_HOME}/gw_opts"
17
17
  GW_LOG_FILE = "#{GW_HOME}/gw_log"
18
18
  GW_DEFAULT_WORLD_YAML = File.expand_path('../../data/default_world.yaml', __FILE__)
19
19
  GW_DEFAULT_WORLD_BIN = File.expand_path('../../data/default_world.bin', __FILE__)
20
+ GW_WRAP_WIDTH = 80
20
21
 
21
22
  def parse_options_cli
22
23
  options = {
@@ -124,6 +125,7 @@ def init_config
124
125
  GameOptions.add 'save_file_bin_path', GW_SAVE_FILE_BIN
125
126
  GameOptions.add 'log_file_path', GW_LOG_FILE
126
127
  GameOptions.add 'options_file_path', GW_OPTS_FILE
128
+ GameOptions.add 'wrap_width', GW_WRAP_WIDTH
127
129
  end
128
130
 
129
131
  begin
@@ -9,7 +9,7 @@ module Gemwarrior
9
9
  # CONSTANTS
10
10
  ERROR_ATTACK_OPTION_INVALID = 'That will not do anything against the monster.'
11
11
  BEAST_MODE_ATTACK = 100
12
- ESCAPE_TEXT = '** POOF **'
12
+ ESCAPE_TEXT = ' ** POOF **'
13
13
 
14
14
  attr_accessor :world, :player, :monster, :player_is_defending
15
15
 
@@ -30,23 +30,24 @@ module Gemwarrior
30
30
  { frequencies: 'G#4', duration: 50 }
31
31
  ])
32
32
 
33
- print_battle_line
33
+ # begin battle!
34
+ print_battle_header unless is_arena
34
35
 
35
36
  if is_arena
36
- print 'Your opponent is now...'
37
+ print ' Your opponent is now...'
37
38
  Animation::run(phrase: "#{monster.name.upcase}!", speed: :slow)
38
39
  elsif is_event
39
- puts "You are attacked by #{monster.name}!"
40
+ puts " You are ambushed by #{monster.name}!".colorize(:yellow)
40
41
  else
41
- puts "You decide to attack #{monster.name}!"
42
+ puts " You decide to attack #{monster.name}!"
42
43
  end
43
44
 
44
- puts "#{monster.name} cries out: \"#{monster.battlecry}\"".colorize(:yellow)
45
+ puts " #{monster.name} cries out: \"#{monster.battlecry}\""
45
46
 
46
47
  # first strike!
47
48
  unless is_arena
48
49
  if monster_strikes_first?(is_event)
49
- puts "#{monster.name} strikes first!".colorize(:yellow)
50
+ puts " #{monster.name} strikes first!".colorize(:yellow)
50
51
  monster_attacks_player
51
52
  end
52
53
  end
@@ -63,20 +64,20 @@ module Gemwarrior
63
64
 
64
65
  # check for near death
65
66
  if player_near_death?
66
- puts "You are almost dead!\n".colorize(:yellow)
67
+ puts " You are almost dead!\n".colorize(:yellow)
67
68
  end
68
69
  if monster_near_death?
69
- puts "#{monster.name} is almost dead!\n".colorize(:yellow)
70
+ puts " #{monster.name} is almost dead!\n".colorize(:yellow)
70
71
  end
71
72
 
72
73
  puts
73
74
 
74
75
  # print health info
75
- print "#{player.name.upcase.ljust(12)} :: #{player.hp_cur.to_s.rjust(3)} HP"
76
+ print " #{player.name.upcase.ljust(12)} :: #{player.hp_cur.to_s.rjust(3)} HP"
76
77
  print " (LVL: #{player.level})" if GameOptions.data['debug_mode']
77
78
  print "\n"
78
79
 
79
- print "#{monster.name.upcase.ljust(12)} :: "
80
+ print " #{monster.name.upcase.ljust(12)} :: "
80
81
  if GameOptions.data['debug_mode'] || player.special_abilities.include?(:rocking_vision)
81
82
  print "#{monster.hp_cur.to_s.rjust(3)}"
82
83
  else
@@ -90,8 +91,8 @@ module Gemwarrior
90
91
  self.player_is_defending = false
91
92
 
92
93
  # battle options prompt
93
- puts 'What do you do?'
94
- print '['.colorize(:yellow)
94
+ puts ' What do you do?'
95
+ print ' ['.colorize(:yellow)
95
96
  print 'F'.colorize(:green)
96
97
  print 'ight/'.colorize(:yellow)
97
98
  print 'A'.colorize(:green)
@@ -105,13 +106,13 @@ module Gemwarrior
105
106
  print 'R'.colorize(:green)
106
107
  print 'un]'.colorize(:yellow)
107
108
  print "\n"
108
-
109
+ print ' [BATTLE]> '
109
110
  player_action = STDIN.gets.chomp.downcase
110
111
 
111
112
  # player action
112
113
  case player_action
113
114
  when 'fight', 'f', 'attack', 'a'
114
- puts "You attack #{monster.name}#{player.cur_weapon_name}!"
115
+ puts " You attack #{monster.name}#{player.cur_weapon_name}!"
115
116
  dmg = calculate_damage_to(monster)
116
117
  if dmg > 0
117
118
  Music::cue([{ frequencies: 'A4,E4,B5', duration: 75 }])
@@ -124,32 +125,33 @@ module Gemwarrior
124
125
  else
125
126
  Music::cue([{ frequencies: 'A4', duration: 75 }])
126
127
 
127
- puts 'You miss entirely!'.colorize(:yellow)
128
+ puts ' You miss entirely!'.colorize(:yellow)
128
129
  end
129
130
  when 'defend', 'd'
130
- puts 'You dig in and defend this round.'
131
+ puts ' You dig in and defend this round.'
131
132
  self.player_is_defending = true
132
133
  when 'pass', 'p'
133
- puts 'You decide to pass your turn for some reason. Brave!'
134
+ puts ' You decide to pass your turn for some reason. Brave!'
134
135
  when 'look', 'l'
135
- print "#{monster.name}".colorize(:white)
136
+ print " #{monster.name}".colorize(:white)
136
137
  print " (#{monster.hp_cur}/#{monster.hp_max} HP): #{monster.description}\n"
137
- puts "It has some distinguishing features, too: face is #{monster.face}, hands are #{monster.hands}, and general mood is #{monster.mood}."
138
+ puts " It has some distinguishing features, too: face is #{monster.face}, hands are #{monster.hands}, and general mood is #{monster.mood}."
138
139
  if GameOptions.data['debug_mode']
139
- puts 'If defeated, will receive:'
140
- puts " >> XP : #{monster.xp}"
141
- puts " >> ROX : #{monster.rox}"
142
- puts " >> ITEMS: #{monster.inventory.list_contents}"
140
+ puts ' If defeated, will receive:'
141
+ puts " >> XP : #{monster.xp}"
142
+ puts " >> ROX : #{monster.rox}"
143
+ puts " >> ITEMS: #{monster.inventory.list_contents}"
143
144
  next
144
145
  end
145
146
  when 'run', 'r'
146
147
  if player_escape?(is_arena)
147
148
  monster.hp_cur = monster.hp_max
148
- puts "You successfully elude #{monster.name}!".colorize(:green)
149
+ puts " You successfully elude #{monster.name}!".colorize(:green)
149
150
  print_escape_text
151
+ print_battle_line
150
152
  return 'escaped'
151
153
  else
152
- puts 'You were not able to run away! :-('.colorize(:yellow)
154
+ puts ' You were not able to run away! :-('.colorize(:yellow)
153
155
  end
154
156
  else
155
157
  puts ERROR_ATTACK_OPTION_INVALID
@@ -207,17 +209,19 @@ module Gemwarrior
207
209
 
208
210
  def take_damage(entity, dmg)
209
211
  entity.hp_cur = entity.hp_cur.to_i - dmg.to_i
210
- who_gets_wounded = ''
212
+ who_gets_wounded_start = ''
211
213
 
212
214
  if entity.eql?(monster)
213
- who_gets_wounded = "> You wound #{monster.name} for "
215
+ who_gets_wounded_start = " > You wound #{monster.name} for "
216
+ who_gets_wounded_end = " point(s)!\n".colorize(:green)
214
217
  else
215
- who_gets_wounded = '> You are wounded for '
218
+ who_gets_wounded_start = ' > You are wounded for '.colorize(:red)
219
+ who_gets_wounded_end = " point(s)!\n".colorize(:red)
216
220
  end
217
221
 
218
- print who_gets_wounded
222
+ print who_gets_wounded_start
219
223
  Animation::run(phrase: dmg.to_s, speed: :slow, oneline: true, alpha: false, random: false)
220
- print " point(s)!\n"
224
+ print who_gets_wounded_end
221
225
  end
222
226
 
223
227
  # MONSTER
@@ -236,7 +240,7 @@ module Gemwarrior
236
240
  end
237
241
 
238
242
  def monster_attacks_player
239
- puts "#{monster.name} attacks you!"
243
+ puts " #{monster.name} attacks you!".colorize(:yellow)
240
244
 
241
245
  dmg = calculate_damage_to(player)
242
246
  if dmg > 0
@@ -246,7 +250,7 @@ module Gemwarrior
246
250
  else
247
251
  Music::cue([{ frequencies: 'B4', duration: 75 }])
248
252
 
249
- puts "#{monster.name} misses entirely!".colorize(:yellow)
253
+ puts " #{monster.name} misses entirely!".colorize(:yellow)
250
254
  end
251
255
  end
252
256
 
@@ -259,7 +263,7 @@ module Gemwarrior
259
263
  end
260
264
 
261
265
  def monster_death
262
- puts "You have defeated #{monster.name}!\n".colorize(:green)
266
+ puts " YOU HAVE DEFEATED #{monster.name.upcase}!\n".colorize(:green)
263
267
 
264
268
  # stats
265
269
  world.player.monsters_killed += 1
@@ -289,19 +293,19 @@ module Gemwarrior
289
293
  gets
290
294
  return 'exit'
291
295
  else
292
- puts 'You just beat a boss monster. Way to go!'
293
- puts " XP : #{monster.xp}".colorize(:green)
294
- puts " ROX: #{monster.rox}".colorize(:green)
296
+ puts ' You just beat a boss monster. Way to go!'
297
+ puts " XP : #{monster.xp}".colorize(:green)
298
+ puts " ROX: #{monster.rox}".colorize(:green)
295
299
  print_battle_line
296
300
  player.update_stats(reason: :monster, value: monster)
297
301
  world.location_by_coords(player.cur_coords).remove_monster(monster.name)
298
302
  end
299
303
  else
300
- puts 'You get the following spoils of war:'
301
- puts " XP : #{monster.xp}".colorize(:green)
302
- puts " ROX : #{monster.rox}".colorize(:green)
304
+ puts ' You get the following spoils of war:'
305
+ puts " XP : #{monster.xp}".colorize(:green)
306
+ puts " ROX : #{monster.rox}".colorize(:green)
303
307
  unless monster.inventory.nil?
304
- puts " ITEMS: #{monster.inventory.list_contents}".colorize(:green) unless monster.inventory.items.empty?
308
+ puts " ITEMS: #{monster.inventory.list_contents}".colorize(:green) unless monster.inventory.items.empty?
305
309
  end
306
310
  print_battle_line
307
311
  player.update_stats(reason: :monster, value: monster)
@@ -319,7 +323,7 @@ module Gemwarrior
319
323
  end
320
324
 
321
325
  def player_death
322
- puts "You are dead, slain by the #{monster.name}!".colorize(:red)
326
+ puts " You are dead, slain by the #{monster.name}!".colorize(:red)
323
327
  print_battle_line
324
328
  end
325
329
 
@@ -330,6 +334,8 @@ module Gemwarrior
330
334
  else
331
335
  dex_diff = monster.dexterity - player.dexterity
332
336
  rand_dex = rand(0..dex_diff)
337
+ rand_dex += rand(0..1) # slight extra chance modifier
338
+
333
339
  if rand_dex % 2 > 0
334
340
  return true
335
341
  else
@@ -341,13 +347,19 @@ module Gemwarrior
341
347
  end
342
348
 
343
349
  # STATUS TEXT
344
-
345
350
  def print_escape_text
346
- Animation::run(phrase: ESCAPE_TEXT, oneline: true)
351
+ Animation::run(phrase: ESCAPE_TEXT, oneline: false)
347
352
  end
348
353
 
349
354
  def print_battle_line
350
- puts '******************************'
355
+ GameOptions.data['wrap_width'].times { print '*'.colorize(background: :red, color: :white) }
356
+ print "\n"
357
+ end
358
+
359
+ def print_battle_header
360
+ print_battle_line
361
+ puts ' BATTLE BEGINS!'.ljust(GameOptions.data['wrap_width']).colorize(background: :red, color: :white)
362
+ print_battle_line
351
363
  end
352
364
  end
353
365
  end
@@ -1,11 +1,10 @@
1
1
  # lib/gemwarrior/entities/entity.rb
2
2
  # Base class for an interactable object
3
3
 
4
+ require_relative '../game_options'
5
+
4
6
  module Gemwarrior
5
7
  class Entity
6
- # CONSTANTS
7
- WRAP_WIDTH = 80
8
-
9
8
  attr_accessor :name, :description
10
9
 
11
10
  def status
@@ -13,7 +12,7 @@ module Gemwarrior
13
12
  status_text << "#{description}\n".colorize(:white)
14
13
  end
15
14
 
16
- def puts(s = '', width = WRAP_WIDTH)
15
+ def puts(s = '', width = GameOptions.data['wrap_width'])
17
16
  super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
18
17
  end
19
18
  end
@@ -19,7 +19,6 @@ module Gemwarrior
19
19
  QUIT_MESSAGE = 'Temporal flux detected. Shutting down...'.colorize(:red)
20
20
  MAIN_MENU_QUIT_MESSAGE = 'Giving up so soon? Jool will be waiting...'.colorize(:yellow)
21
21
  SPLASH_MESSAGE = 'Welcome to *Jool*, where randomized fortune is just as likely as mayhem.'
22
- WRAP_WIDTH = 80
23
22
  GITHUB_NAME = 'michaelchadwick'
24
23
  GITHUB_PROJECT = 'gemwarrior'
25
24
 
@@ -77,7 +76,7 @@ module Gemwarrior
77
76
  Readline.readline(prompt_text, true).to_s
78
77
  end
79
78
 
80
- def puts(s = '', width = WRAP_WIDTH)
79
+ def puts(s = '', width = GameOptions.data['wrap_width'])
81
80
  super s.gsub(/(.{1,#{width}})(\s+|\Z)/, "\\1\n") unless s.nil?
82
81
  end
83
82
 
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.10.5'
5
+ VERSION = '0.10.6'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemwarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.5
4
+ version: 0.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick