gemwarrior 0.7.2 → 0.7.3

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: b3e02eb07b6d2f5d85c69bff99e23d580e61326b
4
- data.tar.gz: 8cc5438f267d75b010f7645d8da54d3dafa4a9c6
3
+ metadata.gz: d91e48c65260ba5b61f52b93ad8eea2b45fe8c18
4
+ data.tar.gz: cb95d7af28130ed0b74ad1f5f36d2c8d010f7244
5
5
  SHA512:
6
- metadata.gz: 5736f18ee87c888f5a0f41ede0fbb6f5246735d6da39c6282e5649568de3d33cb0aa8d3470b0505c214af997ff0f542382dc016be5f169e6547cbf63536ad15b
7
- data.tar.gz: d3d2fa237f23270f92bfaa0f73529708d9d755646dee38a1199952b7be1296a888c377a412f96073cb7fb04cfc23f2e427bb80ea73db0bb421f05e52c905d645
6
+ metadata.gz: 76d5776994978dbd5a4bd076ec5adb99e05f0ef1a6c047d570a0da16e8291e4483ad7577b4740c9ee6d68bb9aa5f4220526d49bc0cc2ab8e6c1455efb1063bda
7
+ data.tar.gz: 7d42296d573a9d911a8a49a6485c95b24cf0e8648899264c391d6394369a43f4042000a93c9f00a61d9f7cdbcdb221b197d468603686db1eccb3b20cf3ba0d40
@@ -8,7 +8,7 @@ require_relative '../lib/gemwarrior/game'
8
8
  GAME_NAME = "Gem Warrior"
9
9
 
10
10
  def parse_options
11
- options = {:debug_mode => false, :god_mode => false, :beast_mode => false}
11
+ options = {:debug_mode => false, :god_mode => false, :beast_mode => false, :use_wordnik => false}
12
12
 
13
13
  optparse = OptionParser.new do |opts|
14
14
  opts.on('-v', '--version', 'Display version number and exit') do
@@ -27,6 +27,10 @@ def parse_options
27
27
  opts.on('-b', '--beast', 'Set beastmode to true on load') do
28
28
  options[:beast_mode] = true
29
29
  end
30
+
31
+ opts.on('-w', '--wordnik', 'Use Wordnik to generate more diverse, dynamic descriptors of entities') do
32
+ options[:use_wordnik] = true
33
+ end
30
34
  end
31
35
 
32
36
  optparse.parse!()
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_runtime_dependency 'json', '~> 1.8.2'
26
26
  spec.add_runtime_dependency 'colorize', '~> 0.7.7'
27
27
 
28
- #spec.add_runtime_dependency 'feep', '~> 0.0.9'
28
+ #spec.add_runtime_dependency 'feep', '~> 0.1.0'
29
29
  #spec.add_runtime_dependency 'wordnik', '~> 4.12'
30
30
 
31
31
  spec.add_development_dependency 'pry-byebug', '~> 3.0'
@@ -31,6 +31,8 @@ module Gemwarrior
31
31
  start_stats = PlayerLevels::get_level_stats(1)
32
32
 
33
33
  world.debug_mode = options.fetch(:debug_mode)
34
+ world.use_wordnik = options.fetch(:use_wordnik)
35
+
34
36
  world.player = Player.new({
35
37
  :description => PLAYER_DESC_DEFAULT,
36
38
  :level => start_stats[:level],
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = "0.7.2"
5
+ VERSION = "0.7.3"
6
6
  end
@@ -6,25 +6,33 @@ require 'json'
6
6
 
7
7
  module Gemwarrior
8
8
  class WordList
9
- STATIC_NOUN_VALUES = ["abutments", "asterisms", "bains", "blebs", "blowholes", "chapes", "civility", "crocuses", "dancers", "deniers", "diastoles", "dinges", "dualism", "ebullitions", "extremities", "fingering", "gabardines", "gullets", "knops", "nooks", "payments", "phaetons", "scalawags", "snickers", "specters", "splats", "squiggles", "thalamuses", "wallets", "xylophones"]
9
+ STATIC_ADJECTIVE_VALUES_VALUES = [
10
+ '5 o\'clock-shadowed', 'angry', 'aristocratic', 'calm', 'choice', 'clinical', 'cracked', 'depressed', 'dingy', 'excited', 'ginormous', 'handsome', 'hydrothermal', 'lackadaisical', 'man-sized', 'moist', 'non-venomous', 'picaresque', 'positive', 'relaxed', 'ruddy', 'smooth', 'shocked', 'sticky', 'tense', 'tingly', 'tired', 'toneless', 'unpolished', 'worn'
11
+ ]
12
+ STATIC_NOUN_VALUES = [
13
+ 'arrestor', 'blockhead', 'busker', 'candlestick', 'cigarette', 'clavinet', 'cursor', 'degeneration', 'devotchka', 'drive', 'earthquake', 'genie', 'granddaddy', 'haunter', 'heater', 'locality', 'nitrogen', 'quitter', 'raccoon', 'radish', 'recession', 'sheepdog', 'smorgasbord', 'softener', 'sphere', 'stage-hand', 'tsunami', 'tuber', 'whatsit', 'zillionaire'
14
+ ]
15
+ STATIC_NOUN_PLURAL_VALUES = [
16
+ 'abutments', 'asterisms', 'bains', 'blebs', 'blowholes', 'chapes', 'civility', 'crocuses', 'dancers', 'deniers', 'diastoles', 'dinges', 'dualism', 'ebullitions', 'extremities', 'fingering', 'gabardines', 'gullets', 'knops', 'nooks', 'payments', 'phaetons', 'scalawags', 'snickers', 'specters', 'splats', 'squiggles', 'thalamuses', 'wallets', 'xylophones'
17
+ ]
18
+ STATIC_VERB_VALUES = [
19
+ 'accentuate', 'accompany', 'blatter', 'bully', 'collide', 'crusade', 'disallow', 'entitle', 'infest', 'lateral', 'micturate', 'mourn', 'munge', 'numb', 'outdraw', 'overstep', 'plummet', 'refill', 'refurnish', 'reroute', 'rumple', 'scupper', 'smoosh', 'spifflicate', 'straighten', 'synthesize', 'terrorize', 'unshift', 'vociferate'
20
+ ]
10
21
 
11
- attr_accessor :type, :limit, :words, :error
22
+ attr_accessor :use_wordnik, :type, :limit, :words, :error
12
23
 
13
- def initialize(type, limit = 10)
14
- self.type = type
15
- self.limit = limit
16
- self.words = populate_words(type, limit)
17
- self.error = nil
24
+ def initialize(use_wordnik = false, type = 'noun', limit = 10)
25
+ self.use_wordnik = use_wordnik
26
+ self.type = type
27
+ self.limit = limit
28
+ self.words = populate_words(type, limit)
29
+ self.error = nil
18
30
  end
19
31
 
20
32
  def get_random_value
21
33
  random_value = words[rand(0..limit)]
22
34
 
23
- if random_value.nil?
24
- get_random_value
25
- else
26
- return random_value
27
- end
35
+ return random_value.nil? ? get_random_value : random_value
28
36
  end
29
37
 
30
38
  def list_words
@@ -37,51 +45,68 @@ module Gemwarrior
37
45
  url = 'http://api.wordnik.com:80/v4/words.json/randomWords'
38
46
  api_key = ENV['WORDNIK_API_KEY']
39
47
 
40
- case type
41
- when 'noun', 'noun-plural', 'adjective', 'verb'
42
- else
43
- return get_static_values
44
- end
45
-
46
- json_return = HTTP.get(
47
- url,
48
- :params => {
49
- :hasDictionaryDef => true,
50
- :includePartOfSpeech => type,
51
- :minCorpusCount => 1,
52
- :maxCorpusCount => -1,
53
- :minDictionaryCount => 1,
54
- :maxDictionaryCount => -1,
55
- :minLength => 5,
56
- :maxLength => 12,
57
- :sortBy => 'alpha',
58
- :sortOrder => 'asc',
59
- :limit => limit,
60
- :api_key => api_key
61
- }
62
- )
63
-
64
- json_data = JSON.parse(json_return.to_s)
65
-
66
- if json_data.include?('type') && json_data.include?('message')
67
- error = "wordnik #{json_data['type']}: #{json_data['message']}"
68
- return get_static_values
69
- else
70
- word_list = []
71
- json_data.map {|j| word_list.push(j['word'])}
72
- if word_list.length > 0
73
- return word_list
48
+ unless api_key.nil? || use_wordnik == false
49
+ case type
50
+ when 'noun', 'noun-plural', 'adjective', 'verb'
74
51
  else
75
- error = 'Empty array from Wordnik'
52
+ error = 'invalid wordlist type'
53
+ return
54
+ end
55
+
56
+ json_return = HTTP.get(
57
+ url,
58
+ :params => {
59
+ :hasDictionaryDef => true,
60
+ :includePartOfSpeech => type,
61
+ :minCorpusCount => 1,
62
+ :maxCorpusCount => -1,
63
+ :minDictionaryCount => 1,
64
+ :maxDictionaryCount => -1,
65
+ :minLength => 5,
66
+ :maxLength => 12,
67
+ :sortBy => 'alpha',
68
+ :sortOrder => 'asc',
69
+ :limit => limit,
70
+ :api_key => api_key
71
+ }
72
+ )
73
+
74
+ json_data = JSON.parse(json_return.to_s)
75
+
76
+ if json_data.include?('type') && json_data.include?('message')
77
+ error = "wordnik #{json_data['type']}: #{json_data['message']}"
76
78
  return get_static_values
79
+ else
80
+ word_list = []
81
+ json_data.map {|j| word_list.push(j['word'])}
82
+ if word_list.length > 0
83
+ return word_list
84
+ else
85
+ error = 'Empty array from Wordnik'
86
+ return get_static_values(type)
87
+ end
77
88
  end
78
89
  end
90
+
91
+ return get_static_values(type)
79
92
  end
80
93
 
81
- def get_static_values
94
+ def get_static_values(type = nil)
82
95
  static_values = []
83
96
  0.upto(10) do
84
- static_values.push(STATIC_NOUN_VALUES[rand(0..STATIC_NOUN_VALUES.length-1)])
97
+ case type
98
+ when 'noun'
99
+ static_values.push(STATIC_NOUN_VALUES[rand(0..STATIC_NOUN_VALUES.length-1)])
100
+ when 'noun-plural'
101
+ static_values.push(STATIC_NOUN_PLURAL_VALUES[rand(0..STATIC_NOUN_PLURAL_VALUES.length-1)])
102
+ when 'adjective'
103
+ static_values.push(STATIC_ADJECTIVE_VALUES[rand(0..STATIC_ADJECTIVE_VALUES.length-1)])
104
+ when 'verb'
105
+ static_values.push(STATIC_VERB_VALUES[rand(0..STATIC_VERB_VALUES.length-1)])
106
+ else
107
+ error = 'invalid wordlist type'
108
+ return
109
+ end
85
110
  end
86
111
  return static_values
87
112
  end
@@ -65,9 +65,9 @@ module Gemwarrior
65
65
  end
66
66
 
67
67
  def print_fortune
68
- noun1_values = WordList.new('noun-plural')
69
- noun2_values = WordList.new('noun-plural')
70
- noun3_values = WordList.new('noun-plural')
68
+ noun1_values = WordList.new(world.use_wordnik, 'noun-plural')
69
+ noun2_values = WordList.new(world.use_wordnik, 'noun-plural')
70
+ noun3_values = WordList.new(world.use_wordnik, 'noun-plural')
71
71
 
72
72
  puts "* Remember: #{noun1_values.get_random_value} and #{noun2_values.get_random_value} are the key to #{noun3_values.get_random_value} *\n\n"
73
73
  end
@@ -15,7 +15,7 @@ module Gemwarrior
15
15
  ERROR_LIST_PARAM_INVALID = 'That is not something that can be listed.'
16
16
  ERROR_LOCATION_DESCRIBE_ENTITY_INVALID = 'You do not see that here.'
17
17
 
18
- attr_accessor :monsters, :locations, :player, :debug_mode
18
+ attr_accessor :monsters, :locations, :player, :debug_mode, :use_wordnik
19
19
 
20
20
  def initialize
21
21
  self.monsters = init_monsters
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.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick