irbthbound 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +8 -0
- data/bin/console +12 -0
- data/bin/setup +7 -0
- data/exe/irbthbound +5 -0
- data/irbthbound.gemspec +24 -0
- data/lib/irbthbound/cli.rb +5 -0
- data/lib/irbthbound/game.rb +33 -0
- data/lib/irbthbound/player.rb +11 -0
- data/lib/irbthbound/version.rb +3 -0
- data/lib/irbthbound.rb +5 -0
- data/lib/main.rb +10 -0
- data/lib/naming.rb +218 -0
- data/lib/player_stats.rb +67 -0
- data/lib/random.rb +31 -0
- data/lib/text.rb +37 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 359b2a0c8af6c56de5b79f87aa400ee6d60c7738
|
4
|
+
data.tar.gz: 782f1ca34ca58521d67da7cae31d4c052845e8fe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eb060f92bcf6bacbf2ab078d5f59c391246aeb736c01c7651d7c724ec41a76d2fed32da89797e13c28e65c61a582986a495d4eabf0ea64bf6a5842d2903ef044
|
7
|
+
data.tar.gz: 51381049d0ded892792c03bcbbfb4b139231afb2c0b8a948313a132ccb063cda8158818021a2493f893f87da5d9b7c1a8646b45abbfe590979e29ab9f6fa009e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Dave Yarwood
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# irbthbound
|
2
|
+
|
3
|
+
For reasons I don't fully comprehend, I've always been mega-obsessed with [EarthBound](https://en.wikipedia.org/wiki/EarthBound), a quirky RPG for the Super NES, released in 1995. I also greatly enjoy text adventure games in the vein of [Zork](https://en.wikipedia.org/wiki/Zork).
|
4
|
+
|
5
|
+
In 2012, I decided it would be fun to write a port of EarthBound as a text adventure game. I worked on it for a little bit and then promptly got bored and moved onto something else.
|
6
|
+
|
7
|
+
In 2016, I stumbled upon the code I had written and decided to play around with it a little more. In the course of refactoring the (admittedly terrible) Ruby code I had hacked up several years prior, I came upon the realization that, in lieu of writing my own interactive text adventure environment from scratch, I could hijack Ruby's interactive shell, [irb](https://en.wikipedia.org/wiki/Interactive_Ruby_Shell) and re-purpose it to do my bidding. Thanks to the open-ness
|
8
|
+
and extensibility of irb and the Ruby language itself, this actually turned out to be pretty doable. Commands like `look`, `attack`, and `inventory` could be implemented as functions in the context of the shell environment. Thus, **IRBTHBOUND** was born.
|
9
|
+
|
10
|
+
(I actually ended up using [Pry](http://pryrepl.org/) for the extra flexibility it provides over `irb`, like being able to redefine the prompt dynamically, etc. Perhaps it's a bit of a stretch to still call this **irb**thbound, but hey -- close enough, right!?)
|
11
|
+
|
12
|
+
I've tried to remain as true to the spirit of EarthBound as possible with this port. In the interest of making the game mechanics as similar to the SNES game as possible, I have researched and translated known formulas for things like the probability of events happening during battle, damage calculation, level-up curves for each character, etc.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Pre-requisites: Ruby, Bundler
|
17
|
+
|
18
|
+
Run `gem install irbthbound` to grab the latest release.
|
19
|
+
|
20
|
+
## How to Play
|
21
|
+
|
22
|
+
Running `irbthbound` with no arguments will start a new game.
|
23
|
+
|
24
|
+
As you're playing, you'll be able to save the game, which will write some slightly encrypted game data to a file on your hard drive. To pick back up where you left off, run `irbthbound /path/to/the/file.sav`.
|
25
|
+
|
26
|
+
## Development
|
27
|
+
|
28
|
+
Clone this repo and run `bundle install` to install dependencies.
|
29
|
+
|
30
|
+
`bin/console` will get you into a development REPL.
|
31
|
+
|
32
|
+
`rake run` starts a new game, which means starting a Pry session bound to an `Irbthbound::Player` instance.
|
33
|
+
|
34
|
+
`rake release` to deploy to http://rubygems.org.
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. [Fork this repo](https://github.com/daveyarwood/irbthbound/fork)
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create a new Pull Request
|
43
|
+
|
44
|
+
# License
|
45
|
+
|
46
|
+
*Earthbound: The War Against Giygas!* is copyright 1994-1995 Shigesato Itoi / APE
|
47
|
+
|
48
|
+
This is a totally unofficial port, in no way endorsed by Itoi, APE, or Nintendo. Consider it a work of interactive fan-fiction.
|
49
|
+
|
50
|
+
Programmed by Dave Yarwood, 2012-2016
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/exe/irbthbound
ADDED
data/irbthbound.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'irbthbound/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "irbthbound"
|
8
|
+
spec.version = Irbthbound::VERSION
|
9
|
+
spec.authors = ["Dave Yarwood"]
|
10
|
+
spec.email = ["dave.yarwood@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{An esoteric port of Earthbound/Mother 2 to IRB}
|
13
|
+
spec.homepage = "https://github.com/daveyarwood/irbthbound"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'msgpack'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
require 'irbthbound/player'
|
5
|
+
|
6
|
+
module Irbthbound
|
7
|
+
class Game
|
8
|
+
attr_accessor :characters, :locations
|
9
|
+
|
10
|
+
# NOTE: whoever has this salt has the power to decrypt and fuck with game
|
11
|
+
# save files, but that's OK in my book
|
12
|
+
@@salt = '$2a$10$/uCgVxSVZEHa0p224cHQi.'
|
13
|
+
|
14
|
+
def save_to_file(filename)
|
15
|
+
data = {'characters' => @characters,
|
16
|
+
'locations' => @locations}
|
17
|
+
File.write filename, MessagePack.pack(data)
|
18
|
+
end
|
19
|
+
|
20
|
+
def start
|
21
|
+
Pry.config.prompt = [ proc { "ENTER INPUT> " }, proc { "MORE INPUT REQUIRED!*" }]
|
22
|
+
Pry.start Irbthbound::Player.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def Game.load_from_file(filename)
|
27
|
+
data = MessagePack.unpack File.read(filename)
|
28
|
+
gs = Game.new
|
29
|
+
gs.characters = data['characters']
|
30
|
+
gs.locations = data['locations']
|
31
|
+
gs
|
32
|
+
end
|
33
|
+
end
|
data/lib/irbthbound.rb
ADDED
data/lib/main.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'naming.rb'
|
2
|
+
|
3
|
+
# Start New Game
|
4
|
+
|
5
|
+
# from naming.rb; this method goes through all the naming
|
6
|
+
# stuff and then initializes $ness, $paula, $jeff, $poo, $king,
|
7
|
+
# $steak and $rockin using the names the player has chosen
|
8
|
+
naming
|
9
|
+
|
10
|
+
[$ness, $paula, $jeff, $poo, $king, $steak, $rockin].each {|x| p x}
|
data/lib/naming.rb
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
require_relative 'player_stats'
|
2
|
+
require_relative 'text'
|
3
|
+
|
4
|
+
# When you start the main module, you will see a k3wl
|
5
|
+
# ASCII art Earthbound logo or something, and then you'll
|
6
|
+
# be allowed to start a new game or load an existing one.
|
7
|
+
|
8
|
+
# When you start a new game, this stuff will happen.
|
9
|
+
|
10
|
+
def naming
|
11
|
+
|
12
|
+
intro_p = "You are somewhere. Or rather, you are nowhere in particular. You exist, but you are getting ready to exist, if that makes sense. Let's just say you're sitting in front of your computer terminal (you retro dog, you), just itching to embark upon the text adventure remake of the most poignant SNES RPG of the 90's, which, if you're a Gen X/Y-er, was probably a vital part of your childhood and/or adolescence. Your brain cells twitch with excitement. Before we get started, let's name some stuff."
|
13
|
+
|
14
|
+
ness = {
|
15
|
+
:desc => "You see before you an intrepid young boy in a sporty red baseball cap, a familiar-looking yellow-and-blue T-shirt, a yellow backpack, blue shorts and red-and-white sneakers. You somehow sense that there is something very important about this youngster.",
|
16
|
+
:prompt => "Please name him.",
|
17
|
+
:him_her => "him",
|
18
|
+
:dont_care => ['Ness', 'Alec', 'Roger', 'Will', 'Brian', 'Tyler', 'Lane'],
|
19
|
+
:name => nil
|
20
|
+
}
|
21
|
+
|
22
|
+
paula = {
|
23
|
+
:desc => "Now you see a pretty, happy-go-lucky girl in a pink dress. She exudes energy and life. You can only hope that one day you will meet.",
|
24
|
+
:prompt => "Name her, too.",
|
25
|
+
:him_her => "her",
|
26
|
+
:dont_care => ['Paula', 'Nancy', 'Skye', 'Paige', 'Marie', 'Holly', 'Jane'],
|
27
|
+
:name => nil
|
28
|
+
}
|
29
|
+
|
30
|
+
jeff = {
|
31
|
+
:desc => "Your friend walks up. You're not sure how you know he's your friend, but it's obvious to you that he is. He's dressed in a dapper, olive-colored suit with a black bow-tie and thick specs. Your friend looks like he takes life seriously.",
|
32
|
+
:prompt => "Name your friend.",
|
33
|
+
:him_her => "him",
|
34
|
+
:dont_care => ['Jeff', 'Dan', 'Henry', 'Isaac', 'Ralph', 'Sean', 'Rob'],
|
35
|
+
:name => nil
|
36
|
+
}
|
37
|
+
|
38
|
+
poo = {
|
39
|
+
:desc => "Before you now is a curious-looking fellow you imagine to be from a distant land. He is clad in a black-and-white martial arts outfit, sports a conspicuous hairdo resembling a traditional Chinese top-knot, and appears quite disciplined.",
|
40
|
+
:prompt => "Name another friend.",
|
41
|
+
:him_her => "him",
|
42
|
+
:dont_care => ['Poo', 'Kato', 'Kai', 'Omar', 'Ramin', 'Aziz', 'Lado'],
|
43
|
+
:name => nil
|
44
|
+
}
|
45
|
+
|
46
|
+
king = {
|
47
|
+
:desc => "You recall that you have a dog -- a big, fluffy, white, happy dog.",
|
48
|
+
:prompt => "Name your pet.",
|
49
|
+
:him_her => "him",
|
50
|
+
:dont_care => ['King', 'Peach', 'Sparky', 'Rex', 'Baby', 'Rover', 'Misty'],
|
51
|
+
:name => nil
|
52
|
+
}
|
53
|
+
|
54
|
+
food = {
|
55
|
+
:prompt => "Now, tell me this... what's your favorite homemade food?",
|
56
|
+
:dont_care => ['Steak', 'Pie', 'Pasta', 'Cake', 'Eggs', 'Bread', 'Salmon'],
|
57
|
+
:name => nil
|
58
|
+
}
|
59
|
+
|
60
|
+
fav_thing = {
|
61
|
+
:prompt => "And what is your favorite thing?",
|
62
|
+
:dont_care => ['Rockin', 'Hammer', 'Love', 'Gifts', 'Slime', 'Gaming', 'Boxing'],
|
63
|
+
:name => nil
|
64
|
+
}
|
65
|
+
|
66
|
+
$chars = [ness, paula, jeff, poo, king]
|
67
|
+
$things = [food, fav_thing]
|
68
|
+
|
69
|
+
def name_char(char, i=0)
|
70
|
+
puts "\n#{char[:desc].eighty}\n"
|
71
|
+
catch (:done) do
|
72
|
+
puts "\n#{char[:prompt]}\n"
|
73
|
+
puts "\n(Please enter a name, or type 'dc' if you 'Don't Care,' and then press ENTER.)".eighty
|
74
|
+
print ">> "
|
75
|
+
name = gets.strip
|
76
|
+
if name.downcase == "dc"
|
77
|
+
puts "\nOK, how about '#{char[:dont_care][i]}'? (y/n)"
|
78
|
+
loop do
|
79
|
+
print ">> "
|
80
|
+
answer = gets.strip
|
81
|
+
case answer.downcase[0]
|
82
|
+
when "y"
|
83
|
+
char[:name] = char[:dont_care][i]
|
84
|
+
throw :done
|
85
|
+
when "n"
|
86
|
+
puts "\n" + "OK. Let's start over, then. If you still don't care, then I can come up with something else -- just type 'dc' again and I'll see what I can do.".eighty + "\n"
|
87
|
+
name_char(char, (i + 1) % char[:dont_care].length)
|
88
|
+
return
|
89
|
+
else
|
90
|
+
puts "(Y)es or (N)o, please."
|
91
|
+
end
|
92
|
+
end
|
93
|
+
else
|
94
|
+
puts "\nAre you sure you want to name #{char[:him_her]} '#{name}'? (y/n)"
|
95
|
+
loop do
|
96
|
+
print ">> "
|
97
|
+
answer = gets.strip
|
98
|
+
case answer.downcase[0]
|
99
|
+
when "y"
|
100
|
+
char[:name] = name
|
101
|
+
throw :done
|
102
|
+
when "n"
|
103
|
+
puts "\nOK. Let's start over.\n"
|
104
|
+
name_char(char)
|
105
|
+
return
|
106
|
+
else
|
107
|
+
puts "(Y)es or (N)o, please."
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
puts "\nOK desu ka! You watch #{char[:name]} walk away.\n"
|
114
|
+
end
|
115
|
+
|
116
|
+
def name_thing(thing, i=0)
|
117
|
+
catch (:done) do
|
118
|
+
puts "\n#{thing[:prompt]}\n"
|
119
|
+
puts "\n(Please enter your answer, or type 'dc' if you 'Don't Care,' and then press ENTER.)".eighty
|
120
|
+
print ">> "
|
121
|
+
name = gets.strip
|
122
|
+
if name.downcase.strip == "dc"
|
123
|
+
puts "\nHmm... how about '#{thing[:dont_care][i]}'? (y/n)"
|
124
|
+
loop do
|
125
|
+
print ">> "
|
126
|
+
answer = gets.strip
|
127
|
+
case answer.downcase[0]
|
128
|
+
when "y"
|
129
|
+
thing[:name] = thing[:dont_care][i]
|
130
|
+
throw :done
|
131
|
+
when "n"
|
132
|
+
puts "\n" + "OK. Let's start over, then. If you still don't care, then I can come up with something else -- just type 'dc' again and I'll see what I can do.".eighty + "\n"
|
133
|
+
name_thing(thing, (i + 1) % thing[:dont_care].length)
|
134
|
+
return
|
135
|
+
else
|
136
|
+
puts "(Y)es or (N)o, please."
|
137
|
+
end
|
138
|
+
end
|
139
|
+
else
|
140
|
+
puts "\nAre you sure it's '#{name}'? (y/n)"
|
141
|
+
loop do
|
142
|
+
print ">> "
|
143
|
+
answer = gets.strip
|
144
|
+
case answer.downcase[0]
|
145
|
+
when "y"
|
146
|
+
thing[:name] = name
|
147
|
+
throw :done
|
148
|
+
when "n"
|
149
|
+
puts "\nOK. Let's start over.\n"
|
150
|
+
name_thing(thing)
|
151
|
+
return
|
152
|
+
else
|
153
|
+
puts "(Y)es or (N)o, please."
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
puts "\nOK desu ka!\n"
|
160
|
+
end
|
161
|
+
|
162
|
+
def name_stuff
|
163
|
+
$chars.each {|char| name_char(char) }
|
164
|
+
$things.each {|thing| name_thing(thing) }
|
165
|
+
end
|
166
|
+
|
167
|
+
def confirm_choices
|
168
|
+
puts "\nAlright, so to sum up your choices...\n"
|
169
|
+
|
170
|
+
puts "\nBoy 1: #{$chars[0][:name]}"
|
171
|
+
puts "Girl: #{$chars[1][:name]}"
|
172
|
+
puts "Boy 2: #{$chars[2][:name]}"
|
173
|
+
puts "Boy 3: #{$chars[3][:name]}"
|
174
|
+
|
175
|
+
puts "\nDog: #{$chars[4][:name]}"
|
176
|
+
|
177
|
+
puts "\nFavorite food: #{$things[0][:name]}"
|
178
|
+
puts "Coolest thing: #{$things[1][:name]}"
|
179
|
+
|
180
|
+
puts "\nAre you happy with this? (y/n)"
|
181
|
+
loop do
|
182
|
+
print ">> "
|
183
|
+
answer = gets.strip
|
184
|
+
case answer.downcase[0]
|
185
|
+
when "y"
|
186
|
+
return true
|
187
|
+
when "n"
|
188
|
+
puts "\n" + "OK. Then let's start all over."
|
189
|
+
return false
|
190
|
+
else
|
191
|
+
puts "(Y)es or (N)o, please."
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
puts "\n#{intro_p.eighty}\n"
|
197
|
+
|
198
|
+
loop do
|
199
|
+
name_stuff
|
200
|
+
break if confirm_choices
|
201
|
+
end
|
202
|
+
|
203
|
+
puts "\nOK, let's do this! Waaow!!\n"
|
204
|
+
|
205
|
+
# initializes all 4 characters with the
|
206
|
+
# starting 'level 1' stats, and the names
|
207
|
+
# the player has chosen
|
208
|
+
$ness = Ness.new; $ness.name = ness[:name]
|
209
|
+
$paula = Paula.new; $paula.name = paula[:name]
|
210
|
+
$jeff = Jeff.new; $jeff.name = jeff[:name]
|
211
|
+
$poo = Poo.new; $poo.name = poo[:name]
|
212
|
+
|
213
|
+
# sets global variables i.e. Rockin and Steak
|
214
|
+
$king = king[:name]
|
215
|
+
$steak = food[:name]
|
216
|
+
$rockin = fav_thing[:name]
|
217
|
+
|
218
|
+
end
|
data/lib/player_stats.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
class Playable
|
2
|
+
|
3
|
+
def self.metaclass; class << self; self; end; end
|
4
|
+
|
5
|
+
def self.traits(*arr)
|
6
|
+
return @traits if arr.empty?
|
7
|
+
attr_accessor *arr
|
8
|
+
arr.each do |a|
|
9
|
+
metaclass.instance_eval do
|
10
|
+
define_method(a) do |val|
|
11
|
+
@traits ||= {}
|
12
|
+
@traits[a] = val
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class_eval do
|
18
|
+
define_method(:initialize) do
|
19
|
+
self.class.traits.each do |k,v|
|
20
|
+
instance_variable_set("@#{k}", v)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
traits :exp, :level, :max_hp, :hp, :max_pp, :pp, :offense,
|
28
|
+
:defense, :speed, :guts, :luck, :vitality, :iq,
|
29
|
+
:status, :name
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
class Ness < Playable
|
34
|
+
name "Ness"
|
35
|
+
exp 0; level 1
|
36
|
+
hp 30; max_hp 30
|
37
|
+
pp 10; max_pp 10
|
38
|
+
offense 2; defense 2; speed 2; guts 2
|
39
|
+
vitality 2; iq 2; luck 2
|
40
|
+
end
|
41
|
+
|
42
|
+
class Paula < Playable
|
43
|
+
name "Paula"
|
44
|
+
exp 0; level 1
|
45
|
+
hp 30; max_hp 30
|
46
|
+
pp 10; max_pp 10
|
47
|
+
offense 2; defense 2; speed 2; guts 2
|
48
|
+
vitality 2; iq 2; luck 2
|
49
|
+
end
|
50
|
+
|
51
|
+
class Jeff < Playable
|
52
|
+
name "Jeff"
|
53
|
+
exp 0; level 1
|
54
|
+
hp 30; max_hp 30
|
55
|
+
pp 0; max_pp 0
|
56
|
+
offense 2; defense 2; speed 2; guts 2
|
57
|
+
vitality 2; iq 2; luck 2
|
58
|
+
end
|
59
|
+
|
60
|
+
class Poo < Playable
|
61
|
+
name "Poo"
|
62
|
+
exp 0; level 1
|
63
|
+
hp 30; max_hp 30
|
64
|
+
pp 10; max_pp 10
|
65
|
+
offense 2; defense 2; speed 2; guts 2
|
66
|
+
vitality 2; iq 2; luck 2
|
67
|
+
end
|
data/lib/random.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
=begin
|
2
|
+
This file contains some helpful methods used by the
|
3
|
+
battle equations and so on, to provide weighted random
|
4
|
+
values for things like generating a percentage in the
|
5
|
+
range of +/- 50%, where the value is more likely to be
|
6
|
+
closer to 0%, à la a pyramid-shaped distribution.
|
7
|
+
=end
|
8
|
+
|
9
|
+
def plus_or_minus(p) # +/- "n" percent (50, 25, etc.)
|
10
|
+
|
11
|
+
q = 1
|
12
|
+
lower = 1
|
13
|
+
upper = 1
|
14
|
+
table = Hash.new
|
15
|
+
|
16
|
+
(-p..p).to_a.each do |prob|
|
17
|
+
upper = lower + (q - 1)
|
18
|
+
|
19
|
+
(lower..upper).to_a.each do |k|
|
20
|
+
table[k] = prob
|
21
|
+
end
|
22
|
+
|
23
|
+
q += 1 if prob < 0
|
24
|
+
q -= 1 if prob >= 0
|
25
|
+
|
26
|
+
lower = upper + 1
|
27
|
+
end
|
28
|
+
|
29
|
+
table[rand(1..upper)].to_f / 100
|
30
|
+
|
31
|
+
end
|
data/lib/text.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
# Divides a string up into n-character lines. Pushes a word down onto the
|
4
|
+
# next line if it doesn't fit, like on a page in a book.
|
5
|
+
def line_divide(n)
|
6
|
+
answer = []
|
7
|
+
src = self.chars
|
8
|
+
|
9
|
+
loop do # for each line...
|
10
|
+
# remove any leading space from the line
|
11
|
+
src = src.join.strip.split('')
|
12
|
+
|
13
|
+
case src[n-1] # checks the nth character
|
14
|
+
when ' ', '-'
|
15
|
+
answer << src.shift(n).join
|
16
|
+
when nil # if line < n characters
|
17
|
+
answer << src.shift(n).join
|
18
|
+
break
|
19
|
+
else # if n+1th character is not ' ' or '-'
|
20
|
+
if src[n] == ' '
|
21
|
+
answer << src.shift(n).join
|
22
|
+
else # if nth character is mid-word
|
23
|
+
i = (/[ -]/ =~ src[0,n].join.reverse)
|
24
|
+
answer << src.shift(n - i).join
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
answer.join("\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Divides a string up into 80-character lines.
|
32
|
+
def eighty
|
33
|
+
self.line_divide(80)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: irbthbound
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Yarwood
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-16 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.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
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:
|
42
|
+
email:
|
43
|
+
- dave.yarwood@gmail.com
|
44
|
+
executables:
|
45
|
+
- irbthbound
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- .gitignore
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- exe/irbthbound
|
57
|
+
- irbthbound.gemspec
|
58
|
+
- lib/irbthbound.rb
|
59
|
+
- lib/irbthbound/cli.rb
|
60
|
+
- lib/irbthbound/game.rb
|
61
|
+
- lib/irbthbound/player.rb
|
62
|
+
- lib/irbthbound/version.rb
|
63
|
+
- lib/main.rb
|
64
|
+
- lib/naming.rb
|
65
|
+
- lib/player_stats.rb
|
66
|
+
- lib/random.rb
|
67
|
+
- lib/text.rb
|
68
|
+
homepage: https://github.com/daveyarwood/irbthbound
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 2.4.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: An esoteric port of Earthbound/Mother 2 to IRB
|
92
|
+
test_files: []
|