scoreboard_rubywarrior 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ffd8c5ff5887961d03ddd80c9fd5a0b2fb8b0fe
4
+ data.tar.gz: cd1a8d8be5f2740a61a53f2411f3969c4a9abac0
5
+ SHA512:
6
+ metadata.gz: e4decc5944b7780dfdb3b9039cba04d89c41a2cc05a110fd12229995f93d90206f3b02259a0ec83a8c103c817c17677b560aa561457fad91c20eb3f525b3ab83
7
+ data.tar.gz: 57a5c17f8e7fa6fe4d5fdd83d7f7926f9933f53e27d43481e6a99084814bc5fe28b865753a747307077b841d729a49db7b7747d7fa42ce6a721a944ba24ab83c
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in scoreboard_rubywarrior.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard :rspec, cmd: 'bundle exec rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Patrick Davey
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # ScoreboardRubywarrior
2
+
3
+ This gem monkey patches ruby-warrior to allow scores to be
4
+ automatically posted to a webserver (currently https://chchruby-warrior.herokuapp.com/)
5
+
6
+ There is plenty of scope for improving the metrics etc, so please
7
+ feel free to add your (tested?! ;) patches and send them our way.
8
+
9
+ The website code is also open sourced at https://github.com/patrickdavey/rubywarrior_scoreboard
10
+
11
+ ## Installation
12
+
13
+ $ gem install scoreboard_rubywarrior
14
+
15
+ ## Usage
16
+
17
+ Please see Ryan Bates' instructions [on the original ruby-warrior](https://github.com/ryanb/ruby-warrior/)
18
+
19
+
20
+ ## Contributing
21
+
22
+ 1. Fork it ( https://github.com/patrickdavey/scoreboard_rubywarrior/fork )
23
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
24
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
25
+ 4. Push to the branch (`git push origin my-new-feature`)
26
+ 5. Create a new Pull Request
27
+
28
+
29
+ # Thanks
30
+
31
+ Many many thanks to Ryan Bates for creating the ruby-warrior gem.
32
+
33
+ If you feel like saying more.. click the image below ;)
34
+
35
+ [![Thank the developer](https://raw.githubusercontent.com/thankadeveloper/thankadeveloper/master/app/assets/images/badge.png)](http:/thankadeveloper.org?repo=patrickdavey/scoreboard_rubywarrior)
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'bundler/gem_tasks'
3
+
4
+ # Default directory to look in is `/specs`
5
+ # Run with `rake spec`
6
+ RSpec::Core::RakeTask.new(:spec) do |task|
7
+ task.rspec_opts = ['--color', '--format', 'documentation']
8
+ end
9
+
10
+ task :default => :spec
11
+
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require 'scoreboard_rubywarrior'
3
+ runner = RubyWarrior::Runner.new(ARGV, STDIN, STDOUT)
4
+ runner.run
@@ -0,0 +1,38 @@
1
+ # here we patch the level.rb class to add our reporting
2
+ module RubyWarrior
3
+ class Level
4
+ def tally_points
5
+ score = 0
6
+ report = { level_score: warrior.score }
7
+ UI.puts "Level Score: #{warrior.score}"
8
+
9
+ score += warrior.score
10
+
11
+ UI.puts "Time Bonus: #{time_bonus}"
12
+ report[:time_bonus] = time_bonus
13
+
14
+ score += @time_bonus
15
+
16
+ if floor.other_units.empty?
17
+ UI.puts "Clear Bonus: #{clear_bonus}"
18
+ report[:clear_bonus] = clear_bonus
19
+ score += clear_bonus
20
+ end
21
+
22
+ if @profile.epic?
23
+ UI.puts "Total Score: " + score_calculation(@profile.current_epic_score, score)
24
+ @profile.current_epic_grades[@number] = (score / ace_score.to_f) if ace_score
25
+ @profile.current_epic_score += score
26
+ else
27
+ total_score = score_calculation(@profile.score, score)
28
+ report[:total_score] = total_score
29
+ UI.puts "Total Score: " + total_score
30
+ @profile.score += score
31
+ @profile.abilities = warrior.abilities.keys
32
+ report[:warrior_name] = @profile.warrior_name
33
+ report[:level_number] = @number
34
+ ::ScoreboardRubywarrior::Reporter.send_level_update(report)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,13 @@
1
+ module ScoreboardRubywarrior
2
+ class Reporter
3
+ REPORTER_API_ENDPOINT_BASE_URI = 'http://chchruby-warrior.herokuapp.com/'
4
+
5
+ include HTTParty
6
+ base_uri REPORTER_API_ENDPOINT_BASE_URI
7
+
8
+ def self.send_level_update(report)
9
+ post('/scores', body: report.to_json,
10
+ headers: { 'Content-Type' => 'application/json' })
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module ScoreboardRubywarrior
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,57 @@
1
+ require "scoreboard_rubywarrior/version"
2
+ $: << File.dirname(__FILE__)
3
+
4
+ require 'set'
5
+ require 'httparty'
6
+
7
+ require 'ruby_warrior/core_additions'
8
+
9
+ require 'ruby_warrior/runner'
10
+ require 'ruby_warrior/game'
11
+ require 'ruby_warrior/profile'
12
+ require 'ruby_warrior/ui'
13
+ require 'ruby_warrior/config'
14
+ require 'ruby_warrior/player_generator'
15
+ require 'ruby_warrior/level_loader'
16
+ require 'ruby_warrior/tower'
17
+ require 'ruby_warrior/level'
18
+ require 'ruby_warrior/turn'
19
+ require 'ruby_warrior/floor'
20
+ require 'ruby_warrior/space'
21
+ require 'ruby_warrior/position'
22
+
23
+ require 'ruby_warrior/units/base'
24
+ require 'ruby_warrior/units/warrior'
25
+ require 'ruby_warrior/units/sludge'
26
+ require 'ruby_warrior/units/archer'
27
+ require 'ruby_warrior/units/thick_sludge'
28
+ require 'ruby_warrior/units/captive'
29
+ require 'ruby_warrior/units/wizard'
30
+ require 'ruby_warrior/units/golem'
31
+
32
+ require 'ruby_warrior/abilities/base'
33
+ require 'ruby_warrior/abilities/walk'
34
+ require 'ruby_warrior/abilities/attack'
35
+ require 'ruby_warrior/abilities/feel'
36
+ require 'ruby_warrior/abilities/rest'
37
+ require 'ruby_warrior/abilities/health'
38
+ require 'ruby_warrior/abilities/look'
39
+ require 'ruby_warrior/abilities/shoot'
40
+ require 'ruby_warrior/abilities/rescue'
41
+ require 'ruby_warrior/abilities/pivot'
42
+ require 'ruby_warrior/abilities/distance_of'
43
+ require 'ruby_warrior/abilities/bind'
44
+ require 'ruby_warrior/abilities/listen'
45
+ require 'ruby_warrior/abilities/direction_of_stairs'
46
+ require 'ruby_warrior/abilities/direction_of'
47
+ require 'ruby_warrior/abilities/explode'
48
+ require 'ruby_warrior/abilities/detonate'
49
+ require 'ruby_warrior/abilities/form'
50
+
51
+ require 'scoreboard_rubywarrior/reporter.rb'
52
+ require 'scoreboard_rubywarrior/monkeys/level.rb'
53
+
54
+ module ScoreboardRubywarrior
55
+
56
+ end
57
+
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'scoreboard_rubywarrior/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scoreboard_rubywarrior"
8
+ spec.version = ScoreboardRubywarrior::VERSION
9
+ spec.authors = ["Patrick Davey"]
10
+ spec.email = ["patrick.davey@gmail.com"]
11
+ spec.summary = %q{Adds the ability for rubywarrior to publish results to a webserver}
12
+ spec.description = %q{With the utmost thanks to Ryan Bates for his excellent rubywarrior, this
13
+ small addition adds the ability for the rubywarrior to publish level results
14
+ out to a webserver. We wanted this ability to add a small competitive aspect
15
+ for the Christchurch Ruby group. We hope that others will come to enjoy the
16
+ wonderful fun that battling monsters with ruby can be.
17
+
18
+ Pull requests very welcome :)}
19
+ spec.homepage = ""
20
+ spec.license = "MIT"
21
+
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.6"
28
+ spec.add_development_dependency "rake"
29
+ spec.add_development_dependency "pry", ">= 0.9.12"
30
+ spec.add_development_dependency "rspec", "~> 2.14"
31
+ spec.add_development_dependency "guard-rspec", "~> 4.3"
32
+ spec.add_development_dependency "webmock"
33
+
34
+ spec.add_runtime_dependency "httparty", "~> 0.13"
35
+ spec.add_runtime_dependency "rubywarrior", "~> 0.1.3"
36
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe ScoreboardRubywarrior::Reporter do
4
+ let(:report_hash) { {
5
+ warrior_name: 'Trogdor',
6
+ level_score: 10,
7
+ time_bonus: 20,
8
+ clear_bonus: 30,
9
+ total_score: 60
10
+ }
11
+ }
12
+
13
+ before do
14
+ stub_request(:post, ScoreboardRubywarrior::Reporter::REPORTER_API_ENDPOINT_BASE_URI).
15
+ with(:body => "{\"level_score\":0,\"time_bonus\":0,\"total_score\":\"0\",\"warrior_name\":null}",
16
+ :headers => {'Content-Type'=>'application/json'}).
17
+ to_return(:status => 200, :body => "", :headers => {})
18
+ end
19
+
20
+ it "should post the details of a level" do
21
+ ScoreboardRubywarrior::Reporter.should_receive(:post)
22
+ ScoreboardRubywarrior::Reporter.send_level_update(report_hash)
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'rspec'
3
+ require 'pry'
4
+ require 'webmock/rspec'
5
+
6
+ require File.dirname(__FILE__) + '/../lib/scoreboard_rubywarrior'
7
+
8
+ RSpec.configure do |config|
9
+ config.before(:each) do
10
+ RubyWarrior::Config.reset
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,180 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scoreboard_rubywarrior
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Davey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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.9.12
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.12
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: httparty
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.13'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.13'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubywarrior
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.3
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.3
125
+ description: |-
126
+ With the utmost thanks to Ryan Bates for his excellent rubywarrior, this
127
+ small addition adds the ability for the rubywarrior to publish level results
128
+ out to a webserver. We wanted this ability to add a small competitive aspect
129
+ for the Christchurch Ruby group. We hope that others will come to enjoy the
130
+ wonderful fun that battling monsters with ruby can be.
131
+
132
+ Pull requests very welcome :)
133
+ email:
134
+ - patrick.davey@gmail.com
135
+ executables:
136
+ - scoreboard_rubywarrior
137
+ extensions: []
138
+ extra_rdoc_files: []
139
+ files:
140
+ - ".gitignore"
141
+ - Gemfile
142
+ - Guardfile
143
+ - LICENSE.txt
144
+ - README.md
145
+ - Rakefile
146
+ - bin/scoreboard_rubywarrior
147
+ - lib/scoreboard_rubywarrior.rb
148
+ - lib/scoreboard_rubywarrior/monkeys/level.rb
149
+ - lib/scoreboard_rubywarrior/reporter.rb
150
+ - lib/scoreboard_rubywarrior/version.rb
151
+ - scoreboard_rubywarrior.gemspec
152
+ - spec/lib/scoreboard_rubywarrior/reporter_spec.rb
153
+ - spec/spec_helper.rb
154
+ homepage: ''
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.2.2
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: Adds the ability for rubywarrior to publish results to a webserver
178
+ test_files:
179
+ - spec/lib/scoreboard_rubywarrior/reporter_spec.rb
180
+ - spec/spec_helper.rb