brawl 0.0.0.alpha → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.gitignore +1 -0
  2. data/.rspec +0 -0
  3. data/README.md +43 -0
  4. data/_design/ClassDescriptions.txt +98 -0
  5. data/_design/Psudo_Program.rb +113 -0
  6. data/_design/array.rb +4 -0
  7. data/_design/threads.rb +71 -0
  8. data/_spike/Communications/communications.rb +2 -0
  9. data/_spike/Communications/lib/communications/com_linker.rb +11 -0
  10. data/_spike/Communications/lib/communications/null_modem.rb +11 -0
  11. data/_spike/Communications/spec/communications/com_linker_spec.rb +37 -0
  12. data/_spike/DRb/arena.rb +32 -0
  13. data/_spike/DRb/battle_controller.rb +54 -0
  14. data/_spike/DRb/bot.rb +23 -0
  15. data/_spike/DRb/bot_runner.rb +110 -0
  16. data/_spike/DRb/comment.txt +11 -0
  17. data/_spike/DRb/server.rb +28 -0
  18. data/_spike/DRb/test_bot.rb +6 -0
  19. data/_spike/array.rb +7 -0
  20. data/_spike/atan2.rb +39 -0
  21. data/_spike/battle.rb +202 -0
  22. data/_spike/break.rb +10 -0
  23. data/_spike/circles.rb +29 -0
  24. data/_spike/cleaner_attribs.rb +13 -0
  25. data/_spike/comlink.rb +61 -0
  26. data/_spike/concat.rb +27 -0
  27. data/_spike/example_bot.rb +42 -0
  28. data/_spike/forwarding_instance.rb +32 -0
  29. data/_spike/hash_loop.rb +17 -0
  30. data/_spike/hashing.rb +7 -0
  31. data/_spike/hook.rb +19 -0
  32. data/_spike/mod.rb +10 -0
  33. data/_spike/point_in_cone.rb +20 -0
  34. data/_spike/runner.rb +44 -0
  35. data/_spike/safe.rb +28 -0
  36. data/brawl.gemspec +4 -3
  37. data/example/example_battle.rb +173 -0
  38. data/example/logview.txt +6394 -0
  39. data/lib/brawl.rb +14 -3
  40. data/lib/brawl/_helper.rb +65 -0
  41. data/lib/brawl/arena.rb +118 -0
  42. data/lib/brawl/basic_arena_object.rb +35 -0
  43. data/lib/brawl/basic_bot.rb +69 -0
  44. data/lib/brawl/battle_controller.rb +97 -0
  45. data/lib/brawl/bot_proxy.rb +60 -0
  46. data/lib/brawl/clock.rb +36 -0
  47. data/lib/brawl/parts.rb +3 -0
  48. data/lib/brawl/parts/basic_motor.rb +55 -0
  49. data/lib/brawl/parts/basic_scanner.rb +33 -0
  50. data/lib/brawl/parts/basic_weapon.rb +47 -0
  51. data/lib/brawl/version.rb +1 -1
  52. data/lib/brawl/wall.rb +9 -0
  53. data/spec/brawl/arena_spec.rb +163 -0
  54. data/spec/brawl/basic_arena_object_spec.rb +40 -0
  55. data/spec/brawl/basic_bot_spec.rb +84 -0
  56. data/spec/brawl/battle_controller_spec.rb +138 -0
  57. data/spec/brawl/clock_spec.rb +28 -0
  58. data/spec/brawl/helper_spec.rb +23 -0
  59. data/spec/brawl/parts/basic_motor_spec.rb +220 -0
  60. data/spec/brawl/parts/basic_scanner_spec.rb +101 -0
  61. data/spec/brawl/parts/basic_weapon_spec.rb +146 -0
  62. data/spec/spec_helper.rb +5 -0
  63. metadata +101 -10
@@ -0,0 +1,146 @@
1
+ require 'spec_helper'
2
+
3
+ describe Brawl::BasicWeapon do
4
+
5
+ let(:clock){clock = Brawl::Clock.new(0.1)}
6
+ let(:arena){Brawl::Arena.new(size: {width: 10, length: 10}, clock: clock)}
7
+ let(:bot) do
8
+ Brawl::BasicBot.new(
9
+ arena: arena,
10
+ location: {x: 5.0, y: 5.0},
11
+ parts: {Brawl::BasicWeapon=>{range: 3, power: 1}}
12
+ )
13
+ end
14
+
15
+ context "when firing" do
16
+
17
+ it "should return enemy properties on a hit" do
18
+ bot = Brawl::BasicBot.new(
19
+ arena: arena,
20
+ location: {x: 1, y: 0},
21
+ parts: {Brawl::BasicWeapon=>{range: 20, power: 1}}
22
+ )
23
+ enemy = Brawl::BasicBot.new(
24
+ arena: arena,
25
+ location: {x: 8, y: 1},
26
+ parts: {Brawl::BasicWeapon=>{range: 20, power: 1}}
27
+ )
28
+ bot.shoot(82).should_not be_nil
29
+ end
30
+
31
+ it "should return enemy properties on a hit" do
32
+ bot = Brawl::BasicBot.new(
33
+ arena: arena,
34
+ location: {x: 6, y: 1},
35
+ parts: {Brawl::BasicWeapon=>{range: 20, power: 1}}
36
+ )
37
+ enemy = Brawl::BasicBot.new(
38
+ arena: arena,
39
+ location: {x: 1, y: 4},
40
+ parts: {Brawl::BasicWeapon=>{range: 20, power: 1}}
41
+ )
42
+ bot.shoot(301).should_not be_nil
43
+ end
44
+
45
+ it "should return enemy properties on a hit" do
46
+ enemy = Brawl::BasicBot.new(
47
+ arena: arena,
48
+ location: {x: 6, y: 6},
49
+ parts: {Brawl::BasicWeapon=>{range: 50, power: 1}}
50
+ )
51
+ bot.shoot(45).should ==
52
+ enemy.properties.merge(distance:1.4, bearing:45.0, health: 1)
53
+ end
54
+
55
+ it "should return wall properites on a hit" do
56
+ bot = Brawl::BasicBot.new(
57
+ arena: arena,
58
+ location: {x: 9.0, y: 5.0},
59
+ parts: {Brawl::BasicWeapon=>{range: 3, power: 1}}
60
+ )
61
+ bot.shoot(90)[:class].should == Brawl::Wall
62
+ end
63
+
64
+ it "should return nothing on a miss" do
65
+ bot = Brawl::BasicBot.new(
66
+ arena: arena,
67
+ location: {x: 5.0, y: 5.0},
68
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1}}
69
+ )
70
+ bot.shoot(90).should be_nil
71
+ end
72
+
73
+ it "should hit the closest object" do
74
+ enemy1 = Brawl::BasicBot.new(
75
+ arena: arena,
76
+ location: {x: 5.0, y: 6.0},
77
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1}}
78
+ )
79
+ enemy2 = Brawl::BasicBot.new(
80
+ arena: arena,
81
+ location: {x: 5.0, y: 7.0},
82
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1}}
83
+ )
84
+ bot = Brawl::BasicBot.new(
85
+ arena: arena,
86
+ location: {x: 5.0, y: 5.0},
87
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1}}
88
+ )
89
+ bot.shoot(0).should == enemy1.properties.merge(
90
+ distance:1.0, bearing:0.0, health: 1
91
+ )
92
+
93
+ end
94
+
95
+ it "should damage an enemy" do
96
+ enemy = Brawl::BasicBot.new(
97
+ arena: arena,
98
+ location: {x: 5.0, y: 6.0},
99
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1}}
100
+ )
101
+ expect{bot.shoot}.should change(enemy, :health).by(-1)
102
+ end
103
+
104
+ end
105
+
106
+ context "when reloading" do
107
+
108
+ it "should start the reload_countdown when firing" do
109
+ expect{bot.shoot}.should change(bot, :reload_countdown).from(0)
110
+ end
111
+
112
+ it "should set the countdown based on the #reload_time" do
113
+ bot = Brawl::BasicBot.new(
114
+ arena: arena,
115
+ location: {x: 9.0, y: 5.0},
116
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1, reload_time: 10}}
117
+ )
118
+ expect{bot.shoot}.should change(bot, :reload_countdown).to(10)
119
+ end
120
+
121
+ it "should count down based on clock ticks since last shot" do
122
+ bot = Brawl::BasicBot.new(
123
+ arena: arena,
124
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1, reload_time: 10}}
125
+ )
126
+ clock.start
127
+ bot.shoot
128
+ sleep(0.3)
129
+ clock.stop
130
+ bot.reload_countdown.should be_within(5.1).of(bot.reload_time)
131
+ end
132
+
133
+ it "should not fire when the reload countdown is still going" do
134
+ bot.shoot 90
135
+ enemy = Brawl::BasicBot.new(
136
+ arena: arena,
137
+ location: {x: 6.0, y: 6.0},
138
+ parts: {Brawl::BasicWeapon=>{range: 2, power: 1}}
139
+ )
140
+ bot.shoot(45).should == false
141
+
142
+ end
143
+
144
+ end
145
+
146
+ end
@@ -0,0 +1,5 @@
1
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "/../lib"))
2
+ $: << '.'
3
+
4
+ require 'brawl'
5
+
metadata CHANGED
@@ -1,17 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brawl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.alpha
5
- prerelease: 6
4
+ version: 0.0.3
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mike Bethany
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-30 00:00:00.000000000Z
13
- dependencies: []
14
- description: nothing to see here, move along
12
+ date: 2011-08-01 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: uuidtools
16
+ requirement: &2161579400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2161579400
25
+ - !ruby/object:Gem::Dependency
26
+ name: eventable
27
+ requirement: &2161578860 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2161578860
36
+ description: Write robotic assassins using Ruby and watch them as they do your evil
37
+ bidding.
15
38
  email:
16
39
  - mikbe.tk@gmail.com
17
40
  executables: []
@@ -19,11 +42,69 @@ extensions: []
19
42
  extra_rdoc_files: []
20
43
  files:
21
44
  - .gitignore
45
+ - .rspec
22
46
  - Gemfile
47
+ - README.md
23
48
  - Rakefile
49
+ - _design/ClassDescriptions.txt
50
+ - _design/Psudo_Program.rb
51
+ - _design/array.rb
52
+ - _design/threads.rb
53
+ - _spike/Communications/communications.rb
54
+ - _spike/Communications/lib/communications/com_linker.rb
55
+ - _spike/Communications/lib/communications/null_modem.rb
56
+ - _spike/Communications/spec/communications/com_linker_spec.rb
57
+ - _spike/DRb/arena.rb
58
+ - _spike/DRb/battle_controller.rb
59
+ - _spike/DRb/bot.rb
60
+ - _spike/DRb/bot_runner.rb
61
+ - _spike/DRb/comment.txt
62
+ - _spike/DRb/server.rb
63
+ - _spike/DRb/test_bot.rb
64
+ - _spike/array.rb
65
+ - _spike/atan2.rb
66
+ - _spike/battle.rb
67
+ - _spike/break.rb
68
+ - _spike/circles.rb
69
+ - _spike/cleaner_attribs.rb
70
+ - _spike/comlink.rb
71
+ - _spike/concat.rb
72
+ - _spike/example_bot.rb
73
+ - _spike/forwarding_instance.rb
74
+ - _spike/hash_loop.rb
75
+ - _spike/hashing.rb
76
+ - _spike/hook.rb
77
+ - _spike/mod.rb
78
+ - _spike/point_in_cone.rb
79
+ - _spike/runner.rb
80
+ - _spike/safe.rb
24
81
  - brawl.gemspec
82
+ - example/example_battle.rb
83
+ - example/logview.txt
25
84
  - lib/brawl.rb
85
+ - lib/brawl/_helper.rb
86
+ - lib/brawl/arena.rb
87
+ - lib/brawl/basic_arena_object.rb
88
+ - lib/brawl/basic_bot.rb
89
+ - lib/brawl/battle_controller.rb
90
+ - lib/brawl/bot_proxy.rb
91
+ - lib/brawl/clock.rb
92
+ - lib/brawl/parts.rb
93
+ - lib/brawl/parts/basic_motor.rb
94
+ - lib/brawl/parts/basic_scanner.rb
95
+ - lib/brawl/parts/basic_weapon.rb
26
96
  - lib/brawl/version.rb
97
+ - lib/brawl/wall.rb
98
+ - spec/brawl/arena_spec.rb
99
+ - spec/brawl/basic_arena_object_spec.rb
100
+ - spec/brawl/basic_bot_spec.rb
101
+ - spec/brawl/battle_controller_spec.rb
102
+ - spec/brawl/clock_spec.rb
103
+ - spec/brawl/helper_spec.rb
104
+ - spec/brawl/parts/basic_motor_spec.rb
105
+ - spec/brawl/parts/basic_scanner_spec.rb
106
+ - spec/brawl/parts/basic_weapon_spec.rb
107
+ - spec/spec_helper.rb
27
108
  homepage: http://mikbe.tk
28
109
  licenses: []
29
110
  post_install_message:
@@ -39,13 +120,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
39
120
  required_rubygems_version: !ruby/object:Gem::Requirement
40
121
  none: false
41
122
  requirements:
42
- - - ! '>'
123
+ - - ! '>='
43
124
  - !ruby/object:Gem::Version
44
- version: 1.3.1
125
+ version: '0'
45
126
  requirements: []
46
- rubyforge_project: brawl
127
+ rubyforge_project:
47
128
  rubygems_version: 1.8.5
48
129
  signing_key:
49
130
  specification_version: 3
50
- summary: A work in progress
51
- test_files: []
131
+ summary: A robot combat game where you write Ruby programs to control your robots.
132
+ test_files:
133
+ - spec/brawl/arena_spec.rb
134
+ - spec/brawl/basic_arena_object_spec.rb
135
+ - spec/brawl/basic_bot_spec.rb
136
+ - spec/brawl/battle_controller_spec.rb
137
+ - spec/brawl/clock_spec.rb
138
+ - spec/brawl/helper_spec.rb
139
+ - spec/brawl/parts/basic_motor_spec.rb
140
+ - spec/brawl/parts/basic_scanner_spec.rb
141
+ - spec/brawl/parts/basic_weapon_spec.rb
142
+ - spec/spec_helper.rb