bf_studio_game 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 46c77f506e436766e42c4086524c0828be705add
4
+ data.tar.gz: 2fea86b4235334249e6dce9cb055313635749611
5
+ SHA512:
6
+ metadata.gz: 905fc27c90781d98cd41b06b56b7c49f5941bae98034a0bac5aca23b9969268244e7f3e497c61d69dc39e402570c4eafc0baef048f23054f32d41e651f6c7e8d
7
+ data.tar.gz: dc7dd8824f019d1cfbd918fb55a4214b19bddd03944bca987475231b4126157e2492e89dabb8df1d3a446605396d89b43098ca8432fc2e88491595c587774955
data/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+
2
+
3
+ Copyright (C) <2014> <BFITC, LLC>
4
+
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,4 @@
1
+ game
2
+ ====
3
+
4
+ Pragmatic Studio Programming Ruby Course - Game
@@ -0,0 +1,3 @@
1
+ superman,1000
2
+ batman,500
3
+ spiderman,750
data/bin/players.csv ADDED
@@ -0,0 +1,3 @@
1
+ Alvin,100
2
+ Simon,60
3
+ Theo,125
data/bin/studio_game ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/studio_game/player'
3
+ require_relative '../lib/studio_game//game'
4
+ require_relative '../lib/studio_game//clumsy_player'
5
+ require_relative '../lib/studio_game//berserk_player'
6
+
7
+ knuckleheads = StudioGame::Game.new("Knuckleheads")
8
+ default_player_file = File.join(File.dirname(__FILE__), 'players.csv')
9
+ knuckleheads.load_players(ARGV.shift || default_player_file)
10
+ klutz = StudioGame::ClumsyPlayer.new("klutz", 105)
11
+ knuckleheads.add_player(klutz)
12
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
13
+ knuckleheads.add_player(berserker)
14
+
15
+ loop do
16
+ puts "\nHow many game rounds ('quit' to exit)"
17
+ answer = gets.chomp.downcase
18
+ case answer
19
+ when /^\d+$/
20
+ knuckleheads.play(answer.to_i)
21
+ when 'quit', 'exit', 'x', 'q', 'bye'
22
+ knuckleheads.print_stats
23
+ break
24
+ else
25
+ puts "Please enter a number or 'quit'"
26
+ end
27
+ end
28
+
29
+ knuckleheads.save_high_scores
30
+
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/studio_game/player'
3
+ require_relative '../lib/studio_game//game'
4
+ require_relative '../lib/studio_game//clumsy_player'
5
+ require_relative '../lib/studio_game//berserk_player'
6
+
7
+ knuckleheads = StudioGame::Game.new("Knuckleheads")
8
+ knuckleheads.load_players(ARGV.shift || "players.csv")
9
+ klutz = StudioGame::ClumsyPlayer.new("klutz", 105)
10
+ knuckleheads.add_player(klutz)
11
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
12
+ knuckleheads.add_player(berserker)
13
+
14
+ loop do
15
+ puts "\nHow many game rounds ('quit' to exit)"
16
+ answer = gets.chomp.downcase
17
+ case answer
18
+ when /^\d+$/
19
+ knuckleheads.play(answer.to_i)
20
+ when 'quit', 'exit', 'x', 'q', 'bye'
21
+ knuckleheads.print_stats
22
+ break
23
+ else
24
+ puts "Please enter a number or 'quit'"
25
+ end
26
+ end
27
+
28
+ knuckleheads.save_high_scores
29
+
@@ -0,0 +1,7 @@
1
+ module StudioGame
2
+ module Auditable
3
+ def audit
4
+ puts "Rolled a #{self.number} (#{self.class})"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ require_relative 'player'
2
+
3
+ module StudioGame
4
+ class BerserkPlayer < Player
5
+ def initialize(name, health=100)
6
+ super(name, health)
7
+ @w00t_count = 0
8
+ end
9
+
10
+ def berserk?
11
+ @w00t_count > 5
12
+ end
13
+
14
+ def w00t
15
+ super
16
+ @w00t_count += 1
17
+ puts "#{@name} is berserk!" if berserk?
18
+ end
19
+
20
+ def blam
21
+ berserk? ? w00t : super
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ if __FILE__ == $0
28
+ berserker = BerserkPlayer.new("berserker", 50)
29
+ 6.times {berserker.w00t}
30
+ 2.times {berserker.blam}
31
+ puts berserker.health
32
+ end
33
+
@@ -0,0 +1,38 @@
1
+ require_relative 'player'
2
+
3
+ module StudioGame
4
+ class ClumsyPlayer < Player
5
+ attr_reader :boost_factor
6
+
7
+ def initialize(name, health=100, boost_factor=1)
8
+ super(name, health)
9
+ @boost_factor = boost_factor
10
+ end
11
+
12
+ def w00t
13
+ @boost_factor.times {super}
14
+ end
15
+
16
+ def found_treasure(treasure)
17
+ damaged_treasure = Treasure.new(treasure.name, treasure.points / 2.0)
18
+ super(damaged_treasure)
19
+ end
20
+ end
21
+ end
22
+
23
+ if __FILE__ == $0
24
+ clumsy = ClumsyPlayer.new("klutz", 105, 3)
25
+
26
+ hammer = Treasure.new(:hammer, 50)
27
+ clumsy.found_treasure(hammer)
28
+ clumsy.found_treasure(hammer)
29
+ clumsy.found_treasure(hammer)
30
+
31
+ crowbar = Treasure.new(:crowbar, 400)
32
+ clumsy.found_treasure(crowbar)
33
+
34
+ clumsy.each_found_treasure do |treasure|
35
+ puts "#{treasure.points} total #{treasure.name} points"
36
+ end
37
+ puts "#{clumsy.points} grand total points"
38
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class Die
5
+ include Auditable
6
+
7
+ attr_reader :number
8
+
9
+ def roll
10
+ @number = rand(1..6)
11
+ audit
12
+ @number
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,110 @@
1
+ module StudioGame
2
+ class Game
3
+ require_relative 'player'
4
+ require_relative 'die'
5
+ require_relative 'game_turn'
6
+ require 'csv'
7
+
8
+ attr_reader :title
9
+
10
+ def initialize(title)
11
+ @title = title
12
+ @players = []
13
+ end
14
+
15
+ def high_score_entry(player)
16
+ formatted_name = player.name.ljust(20, '.')
17
+ "#{formatted_name} #{player.score}"
18
+ end
19
+
20
+ def save_high_scores(to_file = "high_scores.txt")
21
+ File.open(to_file, "w") do |file|
22
+ file.puts "#{@title} High Scores:"
23
+ @players.sort.each do |player|
24
+ file.puts high_score_entry(player)
25
+ end
26
+ end
27
+ end
28
+
29
+
30
+ def load_players(players_file)
31
+ CSV.foreach(players_file) do |row|
32
+ player = Player.new(row[0], row[1].to_i)
33
+ add_player(player)
34
+ end
35
+ end
36
+
37
+ def add_player(player)
38
+ @players << player
39
+ end
40
+
41
+ def play(rounds)
42
+ puts "There are #{@players.size} players in #{@title}: "
43
+
44
+ @players.each do |player|
45
+ puts player
46
+ end
47
+
48
+ 1.upto(rounds) do |round|
49
+ if block_given?
50
+ break if yield
51
+ end
52
+ puts "\nRound #{round}:"
53
+ @players.each do |player|
54
+ GameTurn.take_turn(player)
55
+ puts player
56
+ end
57
+ end
58
+ end
59
+
60
+ def print_name_and_health(player)
61
+ puts "#{player.name} (#{player.health})"
62
+ end
63
+
64
+ def total_points
65
+ @players.reduce(0) { |sum, player| sum + player.points }
66
+ end
67
+
68
+ def print_stats
69
+ strong_players, wimpy_players = @players.partition {|player| player.strong?}
70
+ puts "\n#{@title} Statistics:"
71
+
72
+ puts "\n#{strong_players.size} strong players:"
73
+ strong_players.each do |player|
74
+ print_name_and_health(player)
75
+ end
76
+
77
+
78
+ puts "\n#{wimpy_players.size} wimpy players:"
79
+ wimpy_players.each do |player|
80
+ print_name_and_health(player)
81
+ end
82
+
83
+ puts "\n#{@title} High Scores:"
84
+ sorted_players = strong_players.sort
85
+ sorted_players.each do |player|
86
+ puts high_score_entry(player)
87
+ end
88
+
89
+ @players.sort.each do |player|
90
+ puts "\n#{player.name}'s point totals:"
91
+ player.each_found_treasure do |treasure|
92
+ puts "#{treasure.points} total #{treasure.name} points"
93
+ end
94
+ puts "#{player.points} grand total points"
95
+ end
96
+
97
+ puts "\n\n#{total_points} total points from treasures found"
98
+ end
99
+ end
100
+ end
101
+
102
+ if __FILE__ == $0
103
+ puts "====================================" "\nSAMPLE GAME CODE:\n"
104
+ player = Player.new("moe")
105
+ puts player.name
106
+ puts player.health
107
+ player.w00t
108
+ player.blam
109
+ puts player.health
110
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'die'
2
+ require_relative 'loaded_die'
3
+ require_relative 'player'
4
+ require_relative 'treasure_trove'
5
+
6
+ module StudioGame
7
+ module GameTurn
8
+ def self.take_turn(player)
9
+ die = Die.new
10
+ case die.roll
11
+ when 1..2
12
+ player.blam
13
+ when 3..4
14
+ puts "#{player.name} was skipped."
15
+ else
16
+ player.w00t
17
+ end
18
+
19
+ treasure = TreasureTrove.random
20
+ player.found_treasure(treasure)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class LoadedDie
5
+ include Auditable
6
+
7
+ attr_reader :number
8
+
9
+ def roll
10
+ numbers = [1, 1, 2, 5, 6, 6]
11
+ @number = numbers.sample
12
+ audit
13
+ @number
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module StudioGame
2
+ module Playable
3
+ def w00t
4
+ self.health += 15
5
+ puts "#{name} got w00ted!"
6
+ end
7
+
8
+ def blam
9
+ self.health -= 10
10
+ puts "#{name} got blammed!"
11
+ end
12
+
13
+ def strong?
14
+ health > 100
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,70 @@
1
+ require_relative 'treasure_trove'
2
+ require_relative 'playable'
3
+
4
+ module StudioGame
5
+ class Player
6
+ include Playable
7
+
8
+
9
+ attr_reader :score
10
+ attr_accessor :name, :health
11
+
12
+
13
+ def initialize(name, health=100)
14
+ @name = name.downcase.capitalize
15
+ @health = health
16
+ @found_treasures = Hash.new(0)
17
+ end
18
+
19
+ def self.from_csv(string)
20
+ name, health = string.split(',')
21
+ Player.new(name, Integer(health))
22
+ end
23
+
24
+ def found_treasure(treasure)
25
+ @found_treasures[treasure.name] += treasure.points
26
+ puts "#{@name} found a #{treasure.name} worth #{treasure.points} points."
27
+ puts "#{@name}'s treasures: #{@found_treasures}."
28
+ end
29
+
30
+ def points
31
+ @found_treasures.values.reduce(0, :+)
32
+ end
33
+
34
+ def each_found_treasure
35
+ @found_treasures.each do |name, points|
36
+ yield Treasure.new(name, points)
37
+ end
38
+ end
39
+
40
+ def score
41
+ @health + points
42
+ end
43
+
44
+ def name=(new_name)
45
+ @name = new_name.capitalize
46
+ end
47
+
48
+
49
+
50
+ def <=>(other_player)
51
+ other_player.score <=> score
52
+ end
53
+
54
+ def to_s
55
+ "I'm #{@name} with health = #{@health}, points = #{points}, and score = #{score}."
56
+ end
57
+ end
58
+ end
59
+
60
+ if __FILE__ == $0
61
+ puts "====================================" "\nSAMPLE PLAYER CODE:\n"
62
+ player = Player.new("moe")
63
+ puts player.name
64
+ puts player.health
65
+ player.w00t
66
+ player.blam
67
+ puts player.health
68
+ end
69
+
70
+
@@ -0,0 +1,19 @@
1
+ module StudioGame
2
+ Treasure = Struct.new(:name, :points)
3
+
4
+ module TreasureTrove
5
+ TREASURES= [
6
+ Treasure.new(:pie, 5),
7
+ Treasure.new(:bottle, 25),
8
+ Treasure.new(:hammer, 50),
9
+ Treasure.new(:skillet, 100),
10
+ Treasure.new(:broomstick, 200),
11
+ Treasure.new(:crowbar, 400)
12
+ ]
13
+
14
+ def self.random
15
+ TREASURES.sample
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,30 @@
1
+ require 'studio_game/berserk_player'
2
+
3
+ module StudioGame
4
+ describe BerserkPlayer do
5
+
6
+ before do
7
+ @initial_health = 50
8
+ @player = BerserkPlayer.new("berserker", @initial_health)
9
+ end
10
+
11
+ it "does not go berserk when w00ted up to 5 times" do
12
+ 1.upto(5) { @player.w00t }
13
+
14
+ @player.berserk?.should be_false
15
+ end
16
+
17
+ it "goes berserk when w00ted more than 5 times" do
18
+ 1.upto(6) { @player.w00t}
19
+
20
+ @player.berserk?.should be_true
21
+ end
22
+
23
+ it "gets w00ted instead of blammed when it's gone berserk" do
24
+ 1.upto(6) { @player.w00t }
25
+ 1.upto(2) { @player.blam }
26
+
27
+ @player.health.should == @initial_health + (8 * 15)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,53 @@
1
+ require 'studio_game/clumsy_player'
2
+
3
+ module StudioGame
4
+ describe ClumsyPlayer do
5
+ before do
6
+ @player = ClumsyPlayer.new("klutz")
7
+ end
8
+
9
+ it "only gets half the point value for each treasure" do
10
+ @player.points.should == 0
11
+
12
+ hammer = Treasure.new(:hammer, 50)
13
+ @player.found_treasure(hammer)
14
+ @player.found_treasure(hammer)
15
+ @player.found_treasure(hammer)
16
+
17
+ @player.points.should == 75
18
+
19
+ crowbar = Treasure.new(:crowbar, 400)
20
+ @player.found_treasure(crowbar)
21
+
22
+ @player.points.should == 275
23
+
24
+
25
+ yielded = []
26
+ @player.each_found_treasure do |treasure|
27
+ yielded << treasure
28
+ end
29
+
30
+ yielded.should == [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
31
+ end
32
+
33
+ context "with a boost factor" do
34
+ before do
35
+ @initial_health = 100
36
+ @boost_factor = 5
37
+ @player = ClumsyPlayer.new("klutz", @initial_health, @boost_factor)
38
+ end
39
+
40
+ it "has a boost factor" do
41
+ @player.boost_factor.should == 5
42
+ end
43
+
44
+ it "gets boost factor number of w00ts when w00ted" do
45
+ @player.w00t
46
+
47
+ @player.health.should == @initial_health + (15 * @boost_factor)
48
+ end
49
+ end
50
+
51
+
52
+ end
53
+ end
@@ -0,0 +1,66 @@
1
+ require 'studio_game/game'
2
+
3
+ module StudioGame
4
+ describe Game do
5
+
6
+ before do
7
+ @game = Game.new("Knuckleheads")
8
+
9
+ @initial_health = 100
10
+ @player = Player.new("moe", @initial_health)
11
+
12
+ @game.add_player(@player)
13
+ end
14
+
15
+ it "w00ts a player if a high number is rolled" do
16
+ Die.any_instance.stub(:roll).and_return(5)
17
+
18
+ @game.play(2)
19
+
20
+ @player.health.should == @initial_health + 15 * 2
21
+ end
22
+
23
+ it "skips the player if a medium number is rolled" do
24
+ Die.any_instance.stub(:roll).and_return(3)
25
+
26
+ @game.play(4)
27
+
28
+ @player.health.should == @initial_health
29
+ end
30
+
31
+ it "blams a player if a low number is rolled" do
32
+ Die.any_instance.stub(:roll).and_return(1)
33
+
34
+ @game.play(7)
35
+
36
+ @player.health.should == @initial_health - 10 * 7
37
+ end
38
+
39
+ it "assigns a treasure for points during a player's turn" do
40
+ game = Game.new("Knuckleheads")
41
+ player = Player.new("moe")
42
+
43
+ game.add_player(player)
44
+
45
+ game.play(1)
46
+
47
+ player.points.should_not be_zero
48
+ end
49
+
50
+ it "computes total points as the sum of all player points" do
51
+ game = Game.new("Knuckleheads")
52
+
53
+ player1 = Player.new("moe")
54
+ player2 = Player.new("larry")
55
+
56
+ game.add_player(player1)
57
+ game.add_player(player2)
58
+
59
+ player1.found_treasure(Treasure.new(:hammer, 50))
60
+ player1.found_treasure(Treasure.new(:hammer, 50))
61
+ player2.found_treasure(Treasure.new(:crowbar, 400))
62
+
63
+ game.total_points.should == 500
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,129 @@
1
+ require 'studio_game/player'
2
+ require 'studio_game/treasure_trove'
3
+
4
+ module StudioGame
5
+ describe Player do
6
+ before do
7
+ $stdout = StringIO.new
8
+ @initial_health = 150
9
+ @player = Player.new("larry", @initial_health)
10
+ end
11
+
12
+ it "has a capitalized name" do
13
+ @player.name.should == "Larry"
14
+ end
15
+
16
+ it "has an initial health" do
17
+ @player.health.should == @initial_health
18
+ end
19
+
20
+ it "has a string representation" do
21
+
22
+ @player.found_treasure(Treasure.new(:hammer, 50))
23
+ @player.found_treasure(Treasure.new(:hammer, 50))
24
+
25
+ @player.to_s.should == "I'm Larry with health = 150, points = 100, and score = 250."
26
+ end
27
+
28
+ it "computes a score as the sum of its health and points" do
29
+ @player.found_treasure(Treasure.new(:hammer, 50))
30
+ @player.found_treasure(Treasure.new(:hammer, 50))
31
+
32
+ @player.score.should == 250
33
+ end
34
+
35
+ it "increases health by 15 when w00ted" do
36
+ @player.w00t
37
+
38
+ @player.health.should == @initial_health + 15
39
+ end
40
+
41
+ it "decreases health by 10 when blammed" do
42
+ @player = Player.new("larry", 150)
43
+ @player.blam
44
+
45
+ @player.health.should == @initial_health - 10
46
+ end
47
+
48
+ context "with a health greater than 100" do
49
+ before do
50
+ @player = Player.new("larry", 150)
51
+ end
52
+
53
+ it "is strong" do
54
+ @player.should be_strong
55
+ end
56
+ end
57
+
58
+ context "with a health 100 or less" do
59
+ before do
60
+ @player = Player.new("larry", 100)
61
+ end
62
+
63
+ it "is wimpy" do
64
+ @player.should_not be_strong
65
+ end
66
+ end
67
+
68
+ context "in a collection of players" do
69
+ before do
70
+ @player1 = Player.new("moe", 100)
71
+ @player2 = Player.new("larry", 200)
72
+ @player3 = Player.new("curly", 300)
73
+
74
+ @players = [@player1, @player2, @player3]
75
+ end
76
+
77
+ it "is sorted by decreasing score" do
78
+ @players.sort.should == [@player3, @player2, @player1]
79
+ end
80
+ end
81
+
82
+ it "yields each found treasure and its total points" do
83
+ @player.found_treasure(Treasure.new(:skillet, 100))
84
+ @player.found_treasure(Treasure.new(:skillet, 100))
85
+ @player.found_treasure(Treasure.new(:hammer, 50))
86
+ @player.found_treasure(Treasure.new(:bottle, 5))
87
+ @player.found_treasure(Treasure.new(:bottle, 5))
88
+ @player.found_treasure(Treasure.new(:bottle, 5))
89
+ @player.found_treasure(Treasure.new(:bottle, 5))
90
+ @player.found_treasure(Treasure.new(:bottle, 5))
91
+
92
+ yielded = []
93
+ @player.each_found_treasure do |treasure|
94
+ yielded << treasure
95
+ end
96
+
97
+ yielded.should == [
98
+ Treasure.new(:skillet, 200),
99
+ Treasure.new(:hammer, 50),
100
+ Treasure.new(:bottle, 25)
101
+ ]
102
+ end
103
+
104
+
105
+ it "computes points as the sum of all treasure points" do
106
+ @player.points.should == 0
107
+
108
+ @player.found_treasure(Treasure.new(:hammer, 50))
109
+
110
+ @player.points.should == 50
111
+
112
+ @player.found_treasure(Treasure.new(:crowbar, 400))
113
+
114
+ @player.points.should == 450
115
+
116
+ @player.found_treasure(Treasure.new(:hammer, 50))
117
+
118
+ @player.points.should == 500
119
+ end
120
+
121
+ it "can be created from a CSV string" do
122
+ player = Player.from_csv("larry,150")
123
+
124
+ player.name.should == "Larry"
125
+ player.health.should == 150
126
+ end
127
+
128
+ end
129
+ end
@@ -0,0 +1,57 @@
1
+ require 'studio_game/treasure_trove'
2
+
3
+ module StudioGame
4
+ describe Treasure do
5
+ before do
6
+ @treasure = Treasure.new(:hammer, 50)
7
+ end
8
+
9
+ it "has a name attribute" do
10
+ @treasure.name.should == :hammer
11
+ end
12
+
13
+ it "has a points attribute" do
14
+ @treasure.points.should == 50
15
+ end
16
+
17
+ end
18
+ end
19
+
20
+ module StudioGame
21
+ describe TreasureTrove do
22
+
23
+ it "has six treasures" do
24
+ TreasureTrove::TREASURES.size.should == 6
25
+ end
26
+
27
+ it "has a pie worth 5 points" do
28
+ TreasureTrove::TREASURES[0].should == Treasure.new(:pie, 5)
29
+ end
30
+
31
+ it "has a bottle worth 25 points" do
32
+ TreasureTrove::TREASURES[1].should == Treasure.new(:bottle, 25)
33
+ end
34
+
35
+ it "has a hammer worth 50 points" do
36
+ TreasureTrove::TREASURES[2].should == Treasure.new(:hammer, 50)
37
+ end
38
+
39
+ it "has a skillet worth 100 points" do
40
+ TreasureTrove::TREASURES[3].should == Treasure.new(:skillet, 100)
41
+ end
42
+
43
+ it "has a broomstick worth 200 points" do
44
+ TreasureTrove::TREASURES[4].should == Treasure.new(:broomstick, 200)
45
+ end
46
+
47
+ it "has a crowbar worth 400 points" do
48
+ TreasureTrove::TREASURES[5].should == Treasure.new(:crowbar, 400)
49
+ end
50
+
51
+ it "returns a random treasure" do
52
+ treasure = TreasureTrove.random
53
+
54
+ TreasureTrove::TREASURES.should include(treasure)
55
+ end
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bf_studio_game
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bob Fried
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: |
28
+ game
29
+ ====
30
+
31
+ Pragmatic Studio Programming Ruby Course - Game
32
+ email: bobfried@centurylink.net
33
+ executables:
34
+ - studio_game
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - LICENSE
39
+ - README
40
+ - bin/my_favorite_players.csv
41
+ - bin/players.csv
42
+ - bin/studio_game
43
+ - bin/studio_game.rb
44
+ - lib/studio_game/auditable.rb
45
+ - lib/studio_game/berserk_player.rb
46
+ - lib/studio_game/clumsy_player.rb
47
+ - lib/studio_game/die.rb
48
+ - lib/studio_game/game.rb
49
+ - lib/studio_game/game_turn.rb
50
+ - lib/studio_game/loaded_die.rb
51
+ - lib/studio_game/playable.rb
52
+ - lib/studio_game/player.rb
53
+ - lib/studio_game/treasure_trove.rb
54
+ - spec/studio_game/berserk_player_spec.rb
55
+ - spec/studio_game/clumsy_player_spec.rb
56
+ - spec/studio_game/game_spec.rb
57
+ - spec/studio_game/player_spec.rb
58
+ - spec/studio_game/treasure_trove_spec.rb
59
+ homepage: http://pragmaticstudio.com
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '1.9'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.2.2
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Plays games and rates players
83
+ test_files:
84
+ - spec/studio_game/clumsy_player_spec.rb
85
+ - spec/studio_game/player_spec.rb
86
+ - spec/studio_game/game_spec.rb
87
+ - spec/studio_game/treasure_trove_spec.rb
88
+ - spec/studio_game/berserk_player_spec.rb