falling 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 +9 -0
- data/.rubocop.yml +151 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/README.md +37 -0
- data/Rakefile +10 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/exe/falling +5 -0
- data/falling.gemspec +29 -0
- data/lib/falling.rb +47 -0
- data/lib/falling/area.rb +19 -0
- data/lib/falling/cli.rb +11 -0
- data/lib/falling/interface.rb +55 -0
- data/lib/falling/map_view.rb +56 -0
- data/lib/falling/messages_view.rb +81 -0
- data/lib/falling/messaging/message.rb +23 -0
- data/lib/falling/player.rb +4 -0
- data/lib/falling/universe.rb +9 -0
- data/lib/falling/version.rb +4 -0
- data/lib/falling/view.rb +26 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7c4c330227e6b46532ccf806108ad464a69946c1
|
4
|
+
data.tar.gz: 57679ac0840ac958d13f37fd8be6daa7a1622b2d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f19a03e156a9c59db3dc55ec5816cf42e4ce5651246c9905b96c63134b34b9e26f09724290277002693fc3d1f736f5d579b0a11c4f71201408ea2965369f5c4d
|
7
|
+
data.tar.gz: 263ae772dc2090102dde4550888e4b65848cad721a1c789021020cf8621f88b4d80a45c0950bd48b4c7b3df08d2a3fb89e554525023cd7debfb2943503337eb8
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
|
4
|
+
Style/TrailingCommaInLiteral:
|
5
|
+
EnforcedStyleForMultiline: comma
|
6
|
+
|
7
|
+
# Relaxed.Ruby.Style
|
8
|
+
|
9
|
+
Style/Alias:
|
10
|
+
Enabled: false
|
11
|
+
StyleGuide: http://relaxed.ruby.style/#stylealias
|
12
|
+
|
13
|
+
Style/BeginBlock:
|
14
|
+
Enabled: false
|
15
|
+
StyleGuide: http://relaxed.ruby.style/#stylebeginblock
|
16
|
+
|
17
|
+
Style/BlockDelimiters:
|
18
|
+
Enabled: false
|
19
|
+
StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
|
20
|
+
|
21
|
+
Style/Documentation:
|
22
|
+
Enabled: false
|
23
|
+
StyleGuide: http://relaxed.ruby.style/#styledocumentation
|
24
|
+
|
25
|
+
Style/DotPosition:
|
26
|
+
Enabled: false
|
27
|
+
StyleGuide: http://relaxed.ruby.style/#styledotposition
|
28
|
+
|
29
|
+
Style/DoubleNegation:
|
30
|
+
Enabled: false
|
31
|
+
StyleGuide: http://relaxed.ruby.style/#styledoublenegation
|
32
|
+
|
33
|
+
Style/EndBlock:
|
34
|
+
Enabled: false
|
35
|
+
StyleGuide: http://relaxed.ruby.style/#styleendblock
|
36
|
+
|
37
|
+
Style/FormatString:
|
38
|
+
Enabled: false
|
39
|
+
StyleGuide: http://relaxed.ruby.style/#styleformatstring
|
40
|
+
|
41
|
+
Style/IfUnlessModifier:
|
42
|
+
Enabled: false
|
43
|
+
StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
|
44
|
+
|
45
|
+
Style/Lambda:
|
46
|
+
Enabled: false
|
47
|
+
StyleGuide: http://relaxed.ruby.style/#stylelambda
|
48
|
+
|
49
|
+
Style/ModuleFunction:
|
50
|
+
Enabled: false
|
51
|
+
StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
|
52
|
+
|
53
|
+
Style/MultilineBlockChain:
|
54
|
+
Enabled: false
|
55
|
+
StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
|
56
|
+
|
57
|
+
Style/NegatedIf:
|
58
|
+
Enabled: false
|
59
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedif
|
60
|
+
|
61
|
+
Style/NegatedWhile:
|
62
|
+
Enabled: false
|
63
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
|
64
|
+
|
65
|
+
Style/ParallelAssignment:
|
66
|
+
Enabled: false
|
67
|
+
StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
|
68
|
+
|
69
|
+
Style/PercentLiteralDelimiters:
|
70
|
+
Enabled: false
|
71
|
+
StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
|
72
|
+
|
73
|
+
Style/PerlBackrefs:
|
74
|
+
Enabled: false
|
75
|
+
StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
|
76
|
+
|
77
|
+
Style/Semicolon:
|
78
|
+
Enabled: false
|
79
|
+
StyleGuide: http://relaxed.ruby.style/#stylesemicolon
|
80
|
+
|
81
|
+
Style/SignalException:
|
82
|
+
Enabled: false
|
83
|
+
StyleGuide: http://relaxed.ruby.style/#stylesignalexception
|
84
|
+
|
85
|
+
Style/SingleLineBlockParams:
|
86
|
+
Enabled: false
|
87
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
|
88
|
+
|
89
|
+
Style/SingleLineMethods:
|
90
|
+
Enabled: false
|
91
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
|
92
|
+
|
93
|
+
Style/SpaceBeforeBlockBraces:
|
94
|
+
Enabled: false
|
95
|
+
StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
|
96
|
+
|
97
|
+
Style/SpaceInsideParens:
|
98
|
+
Enabled: false
|
99
|
+
StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
|
100
|
+
|
101
|
+
Style/SpecialGlobalVars:
|
102
|
+
Enabled: false
|
103
|
+
StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
|
104
|
+
|
105
|
+
Style/StringLiterals:
|
106
|
+
Enabled: false
|
107
|
+
StyleGuide: http://relaxed.ruby.style/#stylestringliterals
|
108
|
+
|
109
|
+
# Style/TrailingComma:
|
110
|
+
# Enabled: false
|
111
|
+
# StyleGuide: http://relaxed.ruby.style/#styletrailingcomma
|
112
|
+
|
113
|
+
Style/WhileUntilModifier:
|
114
|
+
Enabled: false
|
115
|
+
StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
|
116
|
+
|
117
|
+
Lint/AmbiguousRegexpLiteral:
|
118
|
+
Enabled: false
|
119
|
+
StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
|
120
|
+
|
121
|
+
Lint/AssignmentInCondition:
|
122
|
+
Enabled: false
|
123
|
+
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
|
124
|
+
|
125
|
+
Metrics/AbcSize:
|
126
|
+
Enabled: false
|
127
|
+
|
128
|
+
Metrics/BlockNesting:
|
129
|
+
Enabled: false
|
130
|
+
|
131
|
+
Metrics/ClassLength:
|
132
|
+
Enabled: false
|
133
|
+
|
134
|
+
Metrics/ModuleLength:
|
135
|
+
Enabled: false
|
136
|
+
|
137
|
+
Metrics/CyclomaticComplexity:
|
138
|
+
Enabled: false
|
139
|
+
|
140
|
+
Metrics/LineLength:
|
141
|
+
Enabled: false
|
142
|
+
|
143
|
+
Metrics/MethodLength:
|
144
|
+
Enabled: false
|
145
|
+
|
146
|
+
Metrics/ParameterLists:
|
147
|
+
Enabled: false
|
148
|
+
|
149
|
+
Metrics/PerceivedComplexity:
|
150
|
+
Enabled: false
|
151
|
+
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at jared@creepywizard.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Falling [![Build Status](https://travis-ci.org/porkchopclub/porkchop.svg?branch=master)](https://travis-ci.org/porkchopclub/porkchop)
|
2
|
+
|
3
|
+
Nothing to see here. Just some exploratory programming.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install it like any other gem.
|
8
|
+
|
9
|
+
$ gem install falling
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
To start a new game.
|
14
|
+
|
15
|
+
$ falling start_game
|
16
|
+
|
17
|
+
## Development
|
18
|
+
|
19
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
20
|
+
`rake test` to run the tests. You can also run `bin/console` for an interactive
|
21
|
+
prompt that will allow you to experiment.
|
22
|
+
|
23
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
24
|
+
release a new version, update the version number in `version.rb`, and then run
|
25
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
26
|
+
git commits and tags, and push the `.gem` file to
|
27
|
+
[rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
_This project is not currently seeking contributions._
|
32
|
+
|
33
|
+
Bug reports are welcome on GitHub at https://github.com/jarednorman/falling.
|
34
|
+
This project is intended to be a safe, welcoming space for collaboration, and
|
35
|
+
contributors are expected to adhere to the [Contributor
|
36
|
+
Covenant](http://contributor-covenant.org) code of conduct.
|
37
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/exe/falling
ADDED
data/falling.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'falling/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "falling"
|
8
|
+
spec.version = Falling::VERSION
|
9
|
+
spec.authors = ["Jared Norman"]
|
10
|
+
spec.email = ["jared@creepywizard.com"]
|
11
|
+
|
12
|
+
spec.summary = 'A simple roguelike game.'
|
13
|
+
spec.description = 'A simple roguelike game.'
|
14
|
+
spec.homepage = "http://www.creepywizard.com"
|
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_dependency "thor", "~> 0.19.1"
|
22
|
+
spec.add_dependency "curses", "~> 1.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
28
|
+
spec.add_development_dependency "rubocop", "~> 0.36"
|
29
|
+
end
|
data/lib/falling.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'curses'
|
2
|
+
require 'logger'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
require 'falling/version'
|
6
|
+
require 'falling/universe'
|
7
|
+
require 'falling/interface'
|
8
|
+
|
9
|
+
module Falling
|
10
|
+
class << self
|
11
|
+
def start_game
|
12
|
+
logger.info 'Booting up.'
|
13
|
+
Interface.new(universe: Falling::Universe.new).run!
|
14
|
+
logger.info 'Quitting.'
|
15
|
+
ensure
|
16
|
+
log_file.close
|
17
|
+
log_file.unlink if log_file.is_a? Tempfile
|
18
|
+
end
|
19
|
+
|
20
|
+
def logger
|
21
|
+
@logger ||=
|
22
|
+
Logger.new(log_file).tap do |logger|
|
23
|
+
logger.level =
|
24
|
+
if development?
|
25
|
+
Logger::DEBUG
|
26
|
+
else
|
27
|
+
Logger::WARN
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def log_file
|
35
|
+
@log_file ||=
|
36
|
+
if development?
|
37
|
+
File.open('./development.log', File::WRONLY | File::APPEND | File::CREAT)
|
38
|
+
else
|
39
|
+
Tempfile.new('falling.log')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def development?
|
44
|
+
ENV['FALLING_ENV'] == 'development'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/falling/area.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Falling
|
2
|
+
class Area
|
3
|
+
attr_reader :width,
|
4
|
+
:height
|
5
|
+
|
6
|
+
def initialize(width:,
|
7
|
+
height:)
|
8
|
+
@width = width
|
9
|
+
@height = height
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_a
|
13
|
+
@garbage ||=
|
14
|
+
(1..height).map do
|
15
|
+
(1..width).map { %w(# . . .).sample }.join
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/falling/cli.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'falling/map_view'
|
2
|
+
require 'falling/messages_view'
|
3
|
+
require 'falling/player'
|
4
|
+
|
5
|
+
module Falling
|
6
|
+
class Interface
|
7
|
+
attr_reader :player
|
8
|
+
|
9
|
+
def initialize(universe:,
|
10
|
+
player: true)
|
11
|
+
create_player! if player
|
12
|
+
@universe = universe
|
13
|
+
end
|
14
|
+
|
15
|
+
def run!
|
16
|
+
with_screen do
|
17
|
+
loop do
|
18
|
+
map_view.refresh
|
19
|
+
messages_view.refresh
|
20
|
+
Curses.doupdate
|
21
|
+
break unless messages_view.step!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_reader :universe
|
29
|
+
|
30
|
+
def map_view
|
31
|
+
@map_view ||= MapView.new(universe: universe)
|
32
|
+
end
|
33
|
+
|
34
|
+
def messages_view
|
35
|
+
@messages_view ||= MessagesView.new(universe: universe)
|
36
|
+
end
|
37
|
+
|
38
|
+
def with_screen
|
39
|
+
Falling.logger.info "Initializing screen."
|
40
|
+
Curses.init_screen
|
41
|
+
begin
|
42
|
+
Curses.crmode
|
43
|
+
Curses.noecho
|
44
|
+
yield
|
45
|
+
ensure
|
46
|
+
Falling.logger.info "Closing screen."
|
47
|
+
Curses.close_screen
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_player!
|
52
|
+
@player = Player.new
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'curses'
|
2
|
+
|
3
|
+
require 'falling/view'
|
4
|
+
|
5
|
+
module Falling
|
6
|
+
class MapView < View
|
7
|
+
def initialize(universe:)
|
8
|
+
Falling.logger.info "Initializing MapView."
|
9
|
+
@universe = universe
|
10
|
+
super()
|
11
|
+
end
|
12
|
+
|
13
|
+
# FIXME: Add smart camera centering.
|
14
|
+
def refresh
|
15
|
+
active_area.
|
16
|
+
to_a[0, height].
|
17
|
+
each_with_index do |row_string, row_index|
|
18
|
+
window.setpos row_offset + row_index, column_offset
|
19
|
+
window.addstr row_string[0, width]
|
20
|
+
end
|
21
|
+
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :universe
|
28
|
+
|
29
|
+
def active_area
|
30
|
+
universe.active_area
|
31
|
+
end
|
32
|
+
|
33
|
+
def column_offset
|
34
|
+
if active_area.width <= width
|
35
|
+
(width - active_area.width) / 2
|
36
|
+
else
|
37
|
+
0
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def row_offset
|
42
|
+
if active_area.height <= height
|
43
|
+
(height - active_area.height) / 2
|
44
|
+
else
|
45
|
+
0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def calculate_geometry!
|
50
|
+
@width = Curses.cols * 3 / 5
|
51
|
+
@height = Curses.lines
|
52
|
+
@row = 0
|
53
|
+
@column = 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'curses'
|
2
|
+
|
3
|
+
require 'falling/view'
|
4
|
+
require 'falling/messaging/message'
|
5
|
+
|
6
|
+
module Falling
|
7
|
+
class MessagesView < View
|
8
|
+
MAX_MESSAGES = 64
|
9
|
+
|
10
|
+
def initialize(universe:)
|
11
|
+
Falling.logger.info "Initializing MapView."
|
12
|
+
@universe = universe
|
13
|
+
add_message(Messaging::Message.new("Welcome to Falling."))
|
14
|
+
add_message(Messaging::Message.new("Press ? for help."))
|
15
|
+
super()
|
16
|
+
end
|
17
|
+
|
18
|
+
def step!
|
19
|
+
character = window.getch
|
20
|
+
Falling.logger.debug "User input: #{character.inspect}."
|
21
|
+
|
22
|
+
case character
|
23
|
+
when "q"
|
24
|
+
return false
|
25
|
+
when "?"
|
26
|
+
add_message(Messaging::Message.new(
|
27
|
+
"Controls:\n - q to quit\n - literally nothing else"
|
28
|
+
))
|
29
|
+
end
|
30
|
+
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_message(message)
|
35
|
+
messages.insert(0, message)
|
36
|
+
messages.slice(0, MAX_MESSAGES)
|
37
|
+
end
|
38
|
+
|
39
|
+
def refresh
|
40
|
+
window.clear
|
41
|
+
window.box(0, 0)
|
42
|
+
draw_messages
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def draw_messages
|
49
|
+
offset = text_height
|
50
|
+
messages.each do |message|
|
51
|
+
message_height = message.height(at_width: text_width)
|
52
|
+
offset -= message_height
|
53
|
+
break if offset < 1
|
54
|
+
message.format(for_width: text_width).each_with_index do |text, index|
|
55
|
+
window.setpos offset + index, 1
|
56
|
+
window.addstr text
|
57
|
+
end
|
58
|
+
end
|
59
|
+
window.setpos text_height, 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def calculate_geometry!
|
63
|
+
@width = Curses.cols - Curses.cols * 3 / 5
|
64
|
+
@height = Curses.lines
|
65
|
+
@row = 0
|
66
|
+
@column = Curses.cols * 3 / 5
|
67
|
+
end
|
68
|
+
|
69
|
+
def text_width
|
70
|
+
width - 2
|
71
|
+
end
|
72
|
+
|
73
|
+
def text_height
|
74
|
+
height - 2
|
75
|
+
end
|
76
|
+
|
77
|
+
def messages
|
78
|
+
@messages ||= []
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Falling
|
2
|
+
module Messaging
|
3
|
+
class Message
|
4
|
+
def initialize(text)
|
5
|
+
@text = text
|
6
|
+
end
|
7
|
+
|
8
|
+
def height(at_width:)
|
9
|
+
raise "not enough screen space" if at_width < 24
|
10
|
+
format(for_width: at_width).length
|
11
|
+
end
|
12
|
+
|
13
|
+
# FIXME: One day we will properly break words.
|
14
|
+
def format(for_width:)
|
15
|
+
text.scan(/.{1,#{for_width}}/)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
attr_reader :text
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/falling/view.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'curses'
|
2
|
+
|
3
|
+
module Falling
|
4
|
+
class View
|
5
|
+
def initialize
|
6
|
+
calculate_geometry!
|
7
|
+
@window = Curses::Window.new(height, width, row, column)
|
8
|
+
end
|
9
|
+
|
10
|
+
def refresh
|
11
|
+
window.noutrefresh
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
attr_reader :window,
|
17
|
+
:width,
|
18
|
+
:height,
|
19
|
+
:column,
|
20
|
+
:row
|
21
|
+
|
22
|
+
def calculate_geometry!
|
23
|
+
raise NotImplementedError
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: falling
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jared Norman
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.19.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: curses
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.36'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.36'
|
111
|
+
description: A simple roguelike game.
|
112
|
+
email:
|
113
|
+
- jared@creepywizard.com
|
114
|
+
executables:
|
115
|
+
- falling
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rubocop.yml"
|
121
|
+
- ".travis.yml"
|
122
|
+
- CODE_OF_CONDUCT.md
|
123
|
+
- Gemfile
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/setup
|
128
|
+
- exe/falling
|
129
|
+
- falling.gemspec
|
130
|
+
- lib/falling.rb
|
131
|
+
- lib/falling/area.rb
|
132
|
+
- lib/falling/cli.rb
|
133
|
+
- lib/falling/interface.rb
|
134
|
+
- lib/falling/map_view.rb
|
135
|
+
- lib/falling/messages_view.rb
|
136
|
+
- lib/falling/messaging/message.rb
|
137
|
+
- lib/falling/player.rb
|
138
|
+
- lib/falling/universe.rb
|
139
|
+
- lib/falling/version.rb
|
140
|
+
- lib/falling/view.rb
|
141
|
+
homepage: http://www.creepywizard.com
|
142
|
+
licenses: []
|
143
|
+
metadata: {}
|
144
|
+
post_install_message:
|
145
|
+
rdoc_options: []
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 2.5.1
|
161
|
+
signing_key:
|
162
|
+
specification_version: 4
|
163
|
+
summary: A simple roguelike game.
|
164
|
+
test_files: []
|