text_adventure 0.1.1
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 +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/bin/text_adventure +3 -0
- data/lib/text_adventure.rb +60 -0
- data/lib/text_adventure/version.rb +3 -0
- data/questions/bar.yml +9 -0
- data/questions/death.yml +7 -0
- data/questions/first_floor.yml +8 -0
- data/questions/ground_floor.yml +9 -0
- data/questions/meetup.yml +11 -0
- data/questions/pay.yml +12 -0
- data/questions/toilet.yml +10 -0
- data/questions/win.yml +5 -0
- data/text_adventure.gemspec +22 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0283bacff35c891a90ebd1c251784c08b7a236a0
|
4
|
+
data.tar.gz: 4135e0e3907ad21e189dc98fce182e71864cad14
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b483d5afe3d4b96f6c0a6ff16b1a3d6abdd93df9e51e6f4deaf0f58cf24d62fdc0bc11372058c4dbb647aece2ad294cf840a4eaaefbc887027d53c689ccc709e
|
7
|
+
data.tar.gz: d8476dbfdde29a1d2d7a6719603c06c1bbe6c6a80ededf16728908d1145bb3e2c489b2a8d526d737f2f0c27260b0c7ba4b38a7b31bbeeac615143ae18eec99be
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# TextAdventure
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/text_adventure`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'text_adventure'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install text_adventure
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/text_adventure/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/text_adventure
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module TextAdventure
|
4
|
+
class World
|
5
|
+
def read_questions
|
6
|
+
questions = {}
|
7
|
+
Dir.glob(
|
8
|
+
File.join(
|
9
|
+
File.dirname(__FILE__),
|
10
|
+
'..',
|
11
|
+
'questions',
|
12
|
+
'*.yml'
|
13
|
+
)
|
14
|
+
).each do |file|
|
15
|
+
key = File.basename(file, '.yml')
|
16
|
+
questions[key] = Question.new YAML.load_file(file)
|
17
|
+
end
|
18
|
+
@questions = questions
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
read_questions
|
23
|
+
key = 'ground_floor'
|
24
|
+
while true do
|
25
|
+
if key == 'win'
|
26
|
+
puts @questions[key].question
|
27
|
+
break
|
28
|
+
end
|
29
|
+
if key == 'death'
|
30
|
+
puts @questions[key].question
|
31
|
+
break
|
32
|
+
end
|
33
|
+
key = @questions[key].ask
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Question
|
39
|
+
attr_accessor :question
|
40
|
+
|
41
|
+
def initialize(data)
|
42
|
+
@question = data['question']
|
43
|
+
@answer = data['answers']
|
44
|
+
end
|
45
|
+
def ask
|
46
|
+
begin
|
47
|
+
puts @question
|
48
|
+
@answer.each do |key,value|
|
49
|
+
puts " (#{key}) #{value['text']}"
|
50
|
+
end
|
51
|
+
input = gets
|
52
|
+
return @answer[input.strip]['key']
|
53
|
+
rescue
|
54
|
+
puts 'No valid option'
|
55
|
+
retry
|
56
|
+
end
|
57
|
+
return 'death'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/questions/bar.yml
ADDED
data/questions/death.yml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
|
2
|
+
question: >
|
3
|
+
You feel very tired. Very very tired. Your eyes feel heavy. You sit on the floor for a moment.
|
4
|
+
HELLO PLAYER
|
5
|
+
you turn back, and a tall, dark figure is staring at you.
|
6
|
+
COME WITH ME
|
7
|
+
well. From this point onwards you can imagine what happends. Your bloody dead.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
question: You are in the first floor of this world. Are you just staying idle?
|
2
|
+
answers:
|
3
|
+
a:
|
4
|
+
text: There is an interesting door to your right. It says "toilet" in the door.
|
5
|
+
key: toilet
|
6
|
+
b:
|
7
|
+
text: And you can also hear some noisy talk. it looks like a meetup.
|
8
|
+
key: meetup
|
data/questions/pay.yml
ADDED
data/questions/win.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'text_adventure/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "text_adventure"
|
8
|
+
spec.version = TextAdventure::VERSION
|
9
|
+
spec.authors = ["Christian Simon"]
|
10
|
+
spec.email = ["simon@swine.de"]
|
11
|
+
|
12
|
+
spec.summary = %q{A new text adventure}
|
13
|
+
spec.description = %q{A new text adventure}
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "bin"
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: text_adventure
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Christian Simon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: A new text adventure
|
42
|
+
email:
|
43
|
+
- simon@swine.de
|
44
|
+
executables:
|
45
|
+
- text_adventure
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/text_adventure
|
55
|
+
- lib/text_adventure.rb
|
56
|
+
- lib/text_adventure/version.rb
|
57
|
+
- questions/bar.yml
|
58
|
+
- questions/death.yml
|
59
|
+
- questions/first_floor.yml
|
60
|
+
- questions/ground_floor.yml
|
61
|
+
- questions/meetup.yml
|
62
|
+
- questions/pay.yml
|
63
|
+
- questions/toilet.yml
|
64
|
+
- questions/win.yml
|
65
|
+
- text_adventure.gemspec
|
66
|
+
homepage:
|
67
|
+
licenses: []
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.4.6
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: A new text adventure
|
89
|
+
test_files: []
|