gemwarrior 0.3.2 → 0.3.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: 9d9fbe46192891851f0b80f4be5c0488423ac649
4
- data.tar.gz: 0ed5b2c8a5056a4e7ad7e384da03128f5584d5c7
3
+ metadata.gz: 47d78c5c7f253648b1a60c476360477a02c301ac
4
+ data.tar.gz: 3e3a6d4bf69a3d9e97326a5e9436233fc4211a09
5
5
  SHA512:
6
- metadata.gz: b881e6754a51e72f2f76ceb7504841fb3284cb4fc7699292b830d3309e45978c6391a1b8ac46181306b618b441e97fffaaffae9d8fd6b511c863b95485d04ecf
7
- data.tar.gz: f413966728db827f7afda8102a065e1d05726830902a0876e32f0384ab68a358c0be25b9eff172aa187d17e8e8f74d36a73879c0c6c9d950c601b8e742770d6a
6
+ metadata.gz: 37567688543f4b502781c1e8178269428031240afb4a9217b50e6f68c4475838a8b6b81c3f7365bbee5170aafc2f78d7c3986af6b7229137ffb267c99707808d
7
+ data.tar.gz: fc5d9729554cb7464e68e159c81e2cf288438949d43d20271d8ff9dc8086ec1d09be5a62a9a2baa43616d19e7f4ed1c6cbcf1bd3eab03249b327ed6399e50dfb
data/gemwarrior.gemspec CHANGED
@@ -1,33 +1,35 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'gemwarrior/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'gemwarrior'
8
- spec.version = Gemwarrior::VERSION
9
- spec.platform = Gem::Platform::RUBY
10
- spec.authors = ['Michael Chadwick']
11
- spec.email = 'mike@codana.me'
12
- spec.homepage = 'http://rubygems.org/gems/gemwarrior'
13
- spec.summary = 'RPG as RubyGem'
14
- spec.description = 'A fun role-playing game in the form of a RubyGem!'
15
-
16
- spec.files = `git ls-files`.split("\n")
17
- spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
- spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
- spec.require_paths = ['lib']
20
- spec.license = 'MIT'
21
-
22
- spec.add_runtime_dependency 'os', '~> 0.9', '>= 0.9.6'
23
- spec.add_runtime_dependency 'matrext', '~> 0.2'
24
-
25
- #spec.add_runtime_dependency 'feep', '~> 0.0.9'
26
- #spec.add_runtime_dependency 'wordnik', '~> 4.12'
27
-
28
- spec.add_development_dependency 'pry-byebug', '~> 3.0'
29
- spec.add_development_dependency 'bundler', '~> 1.8'
30
- spec.add_development_dependency 'rake', '~> 10.0'
31
- spec.add_development_dependency 'rspec', '~> 3.0'
32
- spec.add_development_dependency 'rubocop', '~> 0.29'
33
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gemwarrior/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gemwarrior'
8
+ spec.version = Gemwarrior::VERSION
9
+ spec.platform = Gem::Platform::RUBY
10
+ spec.authors = ['Michael Chadwick']
11
+ spec.email = 'mike@codana.me'
12
+ spec.homepage = 'http://rubygems.org/gems/gemwarrior'
13
+ spec.summary = 'RPG as RubyGem'
14
+ spec.description = 'A fun role-playing game in the form of a RubyGem!'
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ spec.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+ spec.license = 'MIT'
21
+
22
+ spec.add_runtime_dependency 'os', '~> 0.9', '>= 0.9.6'
23
+ spec.add_runtime_dependency 'matrext', '~> 0.2'
24
+ spec.add_runtime_dependency 'http', '~> 0.8.10'
25
+ spec.add_runtime_dependency 'json', '~> 1.8.2'
26
+
27
+ #spec.add_runtime_dependency 'feep', '~> 0.0.9'
28
+ #spec.add_runtime_dependency 'wordnik', '~> 4.12'
29
+
30
+ spec.add_development_dependency 'pry-byebug', '~> 3.0'
31
+ spec.add_development_dependency 'bundler', '~> 1.8'
32
+ spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.0'
34
+ spec.add_development_dependency 'rubocop', '~> 0.29'
35
+ end
@@ -70,7 +70,7 @@ module Gemwarrior
70
70
  ITEM_DESC_FEATHER = 'Soft and tender, unlike the craven bird that probably shed it.'
71
71
  ITEM_ID_GUN = 4
72
72
  ITEM_NAME_GUN = 'gun'
73
- ITEM_DESC_GUN = 'Pew pew goes this firearm you wield, ifn\'t it weren\'t unloaded.'
73
+ ITEM_DESC_GUN = 'Pew pew goes this firearm, you suspect.'
74
74
  end
75
75
 
76
76
  module Locations
@@ -57,7 +57,7 @@ module Gemwarrior
57
57
  return ERROR_COMMAND_INVALID
58
58
  end
59
59
 
60
- command = tokens.first
60
+ command = tokens.first.downcase
61
61
  param = tokens[1]
62
62
 
63
63
  case command
@@ -79,7 +79,7 @@ module Gemwarrior
79
79
  world.player.rest
80
80
  when 'look', 'l'
81
81
  if param
82
- world.player.cur_loc.describe_item(param)
82
+ world.player.cur_loc.describe_entity(param)
83
83
  else
84
84
  world.player.cur_loc.describe
85
85
  end
@@ -117,8 +117,8 @@ module Gemwarrior
117
117
  list_commands
118
118
  when 'quit', 'exit', 'q', 'x'
119
119
  puts "You sure you want to quit? (y/n): "
120
- response = gets.chomp
121
- if (response.downcase.eql?("y") || response.downcase.eql?("yes"))
120
+ response = gets.chomp.downcase
121
+ if (response.eql?("y") || response.eql?("yes"))
122
122
  puts QUIT_MESSAGE
123
123
  exit(0)
124
124
  else
@@ -151,7 +151,7 @@ module Gemwarrior
151
151
  def input_valid?(input)
152
152
  tokens = input.split
153
153
  commands_and_aliases = commands | aliases
154
- if commands_and_aliases.include?(tokens.first)
154
+ if commands_and_aliases.include?(tokens.first.downcase)
155
155
  if tokens.size.between?(1,2)
156
156
  return true
157
157
  end
@@ -11,7 +11,7 @@ module Gemwarrior
11
11
 
12
12
  ## ERRORS
13
13
  ERROR_LOCATION_ITEM_REMOVE_INVALID = 'That item cannot be removed as it doesn\'t exist here.'
14
- ERROR_LOCATION_DESCRIBE_ITEM_INVALID = 'You don\'t see that here.'
14
+ ERROR_LOCATION_DESCRIBE_ENTITY_INVALID = 'You don\'t see that here.'
15
15
 
16
16
  attr_accessor :id, :name, :description, :locs_connected, :danger_level,
17
17
  :items, :monsters_available, :monsters_abounding, :checked_for_monsters
@@ -41,19 +41,28 @@ module Gemwarrior
41
41
  unless list_monsters.nil?
42
42
  desc_text << list_monsters
43
43
  end
44
+ desc_text << list_paths
44
45
 
45
46
  return desc_text
46
47
  end
47
48
 
48
- def describe_item(item_name)
49
- if items.map(&:name).include?(item_name)
49
+ def describe_entity(entity_name)
50
+ if items.map(&:name).include?(entity_name)
50
51
  items.each do |i|
51
- if i.name.eql?(item_name)
52
+ if i.name.eql?(entity_name)
52
53
  return "#{i.description}"
53
54
  end
54
55
  end
56
+ elsif
57
+ if monsters_abounding.map(&:name).include?(entity_name)
58
+ monsters_abounding.each do |m|
59
+ if m.name.eql?(entity_name)
60
+ return "#{m.description}"
61
+ end
62
+ end
63
+ end
55
64
  else
56
- ERROR_LOCATION_DESCRIBE_ITEM_INVALID
65
+ ERROR_LOCATION_DESCRIBE_ENTITY_INVALID
57
66
  end
58
67
  end
59
68
 
@@ -83,6 +92,16 @@ module Gemwarrior
83
92
  return "\n >> Monster(s) abound: #{monsters_abounding.map(&:name).join(', ')}" if monsters_abounding.length > 0
84
93
  end
85
94
 
95
+ def list_paths
96
+ valid_paths = []
97
+ locs_connected.each do |key, value|
98
+ unless value.nil?
99
+ valid_paths.push(key.to_s)
100
+ end
101
+ end
102
+ return "\n >> Paths: #{valid_paths.join(', ')}"
103
+ end
104
+
86
105
  def has_monster?
87
106
  found = false
88
107
  unless danger_level.eql?(:none)
@@ -122,7 +122,7 @@ module Gemwarrior
122
122
  unless direction.nil?
123
123
  if can_move?(direction)
124
124
  new_loc_id = cur_loc.locs_connected[direction.to_sym]
125
- cur_loc = loc_by_id(locations, new_loc_id)
125
+ self.cur_loc = loc_by_id(locations, new_loc_id)
126
126
  print_traveling_text
127
127
  cur_loc.checked_for_monsters = false
128
128
  cur_loc.describe
@@ -6,11 +6,13 @@ require 'os'
6
6
 
7
7
  require_relative 'version'
8
8
  require_relative 'evaluator'
9
+ require_relative 'wordlist'
9
10
 
10
11
  module Gemwarrior
11
12
  class Repl
12
13
  # CONSTANTS
13
14
  ## MESSAGES
15
+ QUIT_MESSAGE = 'Temporal flux detected. Shutting down...'
14
16
  SPLASH_MESSAGE = 'Welcome to Gem Warrior, where randomized fortune is just as likely as mayhem.'
15
17
 
16
18
  attr_accessor :world, :eval
@@ -56,11 +58,11 @@ module Gemwarrior
56
58
  end
57
59
 
58
60
  def print_fortune
59
- noun1_vals = ["abutments", "bains", "crocuses", "chapes", "civility", "fingering", "gabardines", "nooks", "scalawags", "squiggles"]
60
- noun2_vals = ["asterisms", "deniers", "diastoles", "extremities", "payments", "specters", "splats", "thalamuses", "wallets", "xylophones"]
61
- noun3_vals = ["blebs", "blowholes", "dancers", "dinges", "dualism", "ebullitions", "gullets", "knops", "phaetons", "snickers"]
62
-
63
- puts "* Remember: #{noun1_vals[rand(0..9)]} and #{noun2_vals[rand(0..9)]} are the key to #{noun3_vals[rand(0..9)]} *\n\n"
61
+ noun1_values = WordList.new('noun-plural')
62
+ noun2_values = WordList.new('noun-plural')
63
+ noun3_values = WordList.new('noun-plural')
64
+
65
+ puts "* Remember: #{noun1_values.get_random_value} and #{noun2_values.get_random_value} are the key to #{noun3_values.get_random_value} *\n\n"
64
66
  end
65
67
 
66
68
  def setup_screen(initialCommand = nil)
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = "0.3.2"
5
+ VERSION = "0.3.3"
6
6
  end
@@ -0,0 +1,84 @@
1
+ # lib/gemwarrior/wordlist.rb
2
+ # List of words for flavor text, hopefully randomized from Wordnik
3
+
4
+ require 'http'
5
+ require 'json'
6
+
7
+ module Gemwarrior
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"]
10
+
11
+ attr_accessor :type, :limit, :words, :error
12
+
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
18
+ end
19
+
20
+ def get_random_value
21
+ words[rand(0..limit)]
22
+ end
23
+
24
+ def list_words
25
+ words.join(',')
26
+ end
27
+
28
+ private
29
+
30
+ def populate_words(type, limit = 10)
31
+ url = 'http://api.wordnik.com:80/v4/words.json/randomWords'
32
+ api_key = ENV['WORDNIK_API_KEY']
33
+
34
+ case type
35
+ when 'noun', 'noun-plural', 'adjective', 'verb'
36
+ else
37
+ return get_static_values
38
+ end
39
+
40
+ json_return = HTTP.get(
41
+ url,
42
+ :params => {
43
+ :hasDictionaryDef => true,
44
+ :includePartOfSpeech => type,
45
+ :minCorpusCount => 1,
46
+ :maxCorpusCount => -1,
47
+ :minDictionaryCount => 1,
48
+ :maxDictionaryCount => -1,
49
+ :minLength => 5,
50
+ :maxLength => 12,
51
+ :sortBy => 'alpha',
52
+ :sortOrder => 'asc',
53
+ :limit => limit,
54
+ :api_key => api_key
55
+ }
56
+ )
57
+
58
+ json_data = JSON.parse(json_return.to_s)
59
+
60
+ if json_data.include?('type') && json_data.include?('message')
61
+ error = "wordnik #{json_data['type']}: #{json_data['message']}"
62
+ return get_static_values
63
+ else
64
+ word_list = []
65
+ json_data.map {|j| word_list.push(j['word'])}
66
+ if word_list.length > 0
67
+ return word_list
68
+ else
69
+ error = 'Empty array from Wordnik'
70
+ return get_static_values
71
+ end
72
+ end
73
+ end
74
+
75
+ def get_static_values
76
+ static_values = []
77
+ 0.upto(10) do
78
+ static_values.push(STATIC_NOUN_VALUES[rand(0..STATIC_NOUN_VALUES.length-1)])
79
+ end
80
+ return static_values
81
+ end
82
+
83
+ end
84
+ end
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.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -44,6 +44,34 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0.2'
47
+ - !ruby/object:Gem::Dependency
48
+ name: http
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.8.10
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.8.10
61
+ - !ruby/object:Gem::Dependency
62
+ name: json
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 1.8.2
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 1.8.2
47
75
  - !ruby/object:Gem::Dependency
48
76
  name: pry-byebug
49
77
  requirement: !ruby/object:Gem::Requirement
@@ -141,6 +169,7 @@ files:
141
169
  - lib/gemwarrior/player.rb
142
170
  - lib/gemwarrior/repl.rb
143
171
  - lib/gemwarrior/version.rb
172
+ - lib/gemwarrior/wordlist.rb
144
173
  - lib/gemwarrior/world.rb
145
174
  - spec/rubywarrior_spec.rb
146
175
  - spec/spec_helper.rb