gemwarrior 0.12.3 → 0.12.4

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
2
  SHA1:
3
- metadata.gz: 1697e1d764121074f811ef07f649cc4420f13cc6
4
- data.tar.gz: 556ea5a82a3d6fc851fc0fcf31d763e5614b6502
3
+ metadata.gz: bea60182b8599a491537d816df34ed5d590bbe07
4
+ data.tar.gz: fac354917d7dd23fec734909ecdd2ec842874f59
5
5
  SHA512:
6
- metadata.gz: 68d56bd71a1a8b4f37ba352d3074fedbec91a1e10e559f490675064d0cc0ff2c0928138c0847350a83cf421c131df4520040c985043c97d068ceb0226ae5dc31
7
- data.tar.gz: 5131706a624149a4e61b370d7372248605be282eb293fecd8472aad8a49881090309c9fd05ba9121b1b9e0207205f2634afd04b332e5e34fbcc3b8fe9bef3c6e
6
+ metadata.gz: 59175723350eca718f71c27d823a53d3cb45fae16e470bd477d09e08ab5eb39a4924d821c9461cb177d677b501d817b1cd05c32b25356a800268b2321785ec57
7
+ data.tar.gz: de53018e24010e6390f72ff32d644f1211a5d847fef28684280997ebeb8bb358ae187b44429228acb7e84ade2e9e75f38bae32c42b61e1563ec040e554bbc2db
data/bin/gemwarrior CHANGED
@@ -17,7 +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
+ GW_DEFAULT_WRAP_WIDTH = 80
21
21
 
22
22
  def parse_options_cli
23
23
  options = {
@@ -127,7 +127,7 @@ def init_config
127
127
  GameOptions.add 'save_file_bin_path', GW_SAVE_FILE_BIN
128
128
  GameOptions.add 'log_file_path', GW_LOG_FILE
129
129
  GameOptions.add 'options_file_path', GW_OPTS_FILE
130
- GameOptions.add 'wrap_width', GW_WRAP_WIDTH
130
+ GameOptions.add 'wrap_width', GW_DEFAULT_WRAP_WIDTH
131
131
  end
132
132
 
133
133
  begin
@@ -2,6 +2,8 @@
2
2
  # Standardized, cross-platform horizontal rule
3
3
  # Cribbed extensively from https://github.com/ivantsepp/hr
4
4
 
5
+ require_relative '../game_options'
6
+
5
7
  module Gemwarrior
6
8
  module Hr
7
9
  extend self
@@ -12,43 +14,19 @@ module Gemwarrior
12
14
 
13
15
  def string(*patterns)
14
16
  options = patterns.last.is_a?(Hash) ? patterns.pop : {}
15
- column_width = get_column_width
17
+ screen_width = GameOptions.data['wrap_width']
16
18
  output = patterns.map do |pattern|
17
19
  pattern = pattern.to_s
18
- times = (column_width / pattern.length) + 1
19
- (pattern * times)[0..column_width - 1]
20
+ times = (screen_width / pattern.length) + 1
21
+ (pattern * times)[0..screen_width - 1]
20
22
  end.join
23
+ output << "\n"
21
24
  options = options.inject({}){|tmp,(k,v)| tmp[k.to_sym] = v.to_sym; tmp}
22
25
  options.any? ? output.colorize(options) : output
23
26
  end
24
-
25
- private
26
-
27
- def get_column_width
28
- column_width = 0
29
27
 
30
- begin
31
- require 'io/console'
32
- column_width = IO.console.winsize[1]
33
- rescue
34
- if command_exists?('tput')
35
- column_width = `tput cols`.to_i
36
- elsif command_exists?('stty')
37
- column_width = `stty size`.split.last.to_i
38
- elsif command_exists?('mode')
39
- mode_output = `mode`.split
40
- column_width = mode_output[mode_output.index('Columns:')+1].to_i
41
- end
42
- end
28
+ private
43
29
 
44
- case
45
- when column_width.nil?, column_width <= 0
46
- return 80
47
- else
48
- return column_width
49
- end
50
- end
51
-
52
30
  def command_exists?(command)
53
31
  ENV['PATH'].split(File::PATH_SEPARATOR).any? { |path|
54
32
  (File.exist? File.join(path, "#{command}")) || (File.exist? File.join(path, "#{command}.com")) || (File.exist? File.join(path, "#{command}.exe"))
@@ -16,6 +16,8 @@ require_relative 'version'
16
16
  module Gemwarrior
17
17
  class Repl
18
18
  # CONSTANTS
19
+ SCREEN_WIDTH_MIN = 80
20
+ SCREEN_WIDTH_MAX = 120
19
21
  QUIT_MESSAGE = 'Temporal flux detected. Shutting down...'.colorize(:red)
20
22
  MAIN_MENU_QUIT_MESSAGE = 'Giving up so soon? Jool will be waiting...'.colorize(:red)
21
23
  SPLASH_MESSAGE = 'Welcome to *Jool*, where randomized fortune is just as likely as mayhem.'
@@ -28,8 +30,35 @@ module Gemwarrior
28
30
  self.game = game
29
31
  self.world = world
30
32
  self.evaluator = evaluator
33
+
34
+ GameOptions.data['wrap_width'] = get_screen_width
31
35
  end
32
36
 
37
+ def get_screen_width
38
+ screen_width = SCREEN_WIDTH_MIN
39
+
40
+ begin
41
+ require 'io/console'
42
+ screen_width = IO.console.winsize[1]
43
+ rescue
44
+ if command_exists?('tput')
45
+ screen_width = `tput cols`.to_i
46
+ elsif command_exists?('stty')
47
+ screen_width = `stty size`.split.last.to_i
48
+ elsif command_exists?('mode')
49
+ mode_output = `mode`.split
50
+ screen_width = mode_output[mode_output.index('Columns:')+1].to_i
51
+ end
52
+ end
53
+
54
+ case
55
+ when screen_width.nil?, screen_width <= 0
56
+ return SCREEN_WIDTH_MIN
57
+ else
58
+ return [screen_width, SCREEN_WIDTH_MAX].min
59
+ end
60
+ end
61
+
33
62
  def start(initial_command, extra_command, new_skip, resume_skip)
34
63
  setup_screen(initial_command, extra_command, new_skip, resume_skip)
35
64
 
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.12.3'
5
+ VERSION = '0.12.4'
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.12.3
4
+ version: 0.12.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick