rocas_studio_game 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (C) <year> <copyright holders>
2
+
3
+ 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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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 @@
1
+ This gem contains the code examples I did in the Pragmatic Studio ruby class. Its also demonstrates my first attempt at publishing a gem
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,54 @@
1
+ #!/usr/bin/env ruby
2
+
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
+ # player1 = Player.new("moe")
8
+ # player2 = Player.new("larry", 60)
9
+ # player3 = Player.new("curly", 125)
10
+
11
+ knuckleheads = StudioGame::Game.new("Knuckleheads")
12
+ default_player_file = File.join(File.dirname(__FILE__), 'players.csv')
13
+ knuckleheads.load_players(ARGV.shift || default_player_file)
14
+
15
+ klutz = StudioGame::ClumsyPlayer.new("klutz", 105,3)
16
+ knuckleheads.add_player(klutz)
17
+
18
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
19
+ knuckleheads.add_player(berserker)
20
+
21
+
22
+ loop do
23
+ puts "\nHow many game rounds? ('quit' to exit)"
24
+ answer = gets.chomp.downcase
25
+ case answer
26
+ when /^\d+$/
27
+ knuckleheads.play(answer.to_i) do
28
+ knuckleheads.total_points >= 2000
29
+ end
30
+ when "quit", "exit"
31
+ knuckleheads.print_stats
32
+ break
33
+ else
34
+ puts "Please enter a number or 'quit'"
35
+ end
36
+
37
+ end
38
+
39
+
40
+ knuckleheads.save_high_scores
41
+
42
+
43
+ # player4 = Player.new("Alvin", 100)
44
+ # player5 = Player.new("Simon", 60)
45
+ # player6 = Player.new("Theo", 125)
46
+
47
+ # chipmunks = Game.new("Chipmunks")
48
+ # chipmunks.add_player(player4)
49
+ # chipmunks.add_player(player5)
50
+ # chipmunks.add_player(player6)
51
+ # chipmunks.play(10) do
52
+ # knuckleheads.total_points >= 2000
53
+ # end
54
+ # chipmunks.print_stats
@@ -0,0 +1,7 @@
1
+ module StudioGame
2
+ module Auditable
3
+ def audit
4
+ puts "Rolled a #{number} (Die)"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,33 @@
1
+ require_relative 'player'
2
+
3
+ module StudioGame
4
+ class BerserkPlayer < Player
5
+
6
+ def initialize(name,health=100)
7
+ super(name,health)
8
+ @w00t_count = 0
9
+ end
10
+
11
+ def berserk?
12
+ @w00t_count > 5
13
+ end
14
+
15
+ def w00t
16
+ super
17
+ @w00t_count += 1
18
+ puts "#{@name} is berserk!" if berserk?
19
+ end
20
+
21
+ def blam
22
+ berserk? ? w00t : super
23
+ end
24
+ end
25
+
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
+ end
@@ -0,0 +1,43 @@
1
+ require_relative 'player'
2
+
3
+ module StudioGame
4
+
5
+ class ClumsyPlayer < Player
6
+ attr_reader :boost_factor
7
+
8
+ def initialize(name, health=100, boost_factor=1)
9
+ super(name, health)
10
+ @boost_factor = boost_factor
11
+ end
12
+
13
+ def w00t
14
+ @boost_factor.times { super }
15
+ end
16
+
17
+ def found_treasure(treasure)
18
+ damaged_treasure = Treasure.new(treasure.name, treasure.points / 2.0)
19
+ super damaged_treasure
20
+ end
21
+
22
+
23
+ end
24
+
25
+
26
+ if __FILE__ == $0
27
+ clumsy = ClumsyPlayer.new("klutz")
28
+
29
+ hammer = Treasure.new(:hammer, 50)
30
+ clumsy.found_treasure(hammer)
31
+ clumsy.found_treasure(hammer)
32
+ clumsy.found_treasure(hammer)
33
+
34
+ crowbar = Treasure.new(:crowbar, 400)
35
+ clumsy.found_treasure(crowbar)
36
+
37
+ clumsy.each_found_treasure do |treasure|
38
+ puts "#{treasure.points} total #{treasure.name} points"
39
+ end
40
+ puts "#{clumsy.points} grand total points"
41
+ end
42
+
43
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class Die
5
+ include Auditable
6
+ attr_reader :number
7
+
8
+ def initialize
9
+ roll
10
+ end
11
+ def roll
12
+ @number = rand(1..6)
13
+ audit
14
+ @number
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,114 @@
1
+ require_relative 'player'
2
+ require_relative 'game_turn'
3
+ require_relative 'treasure_trove'
4
+ require 'csv'
5
+
6
+ module StudioGame
7
+ class Game
8
+ def initialize(title,players=[])
9
+ @title = title
10
+ @players = players
11
+ end
12
+
13
+ def save_high_scores(to_file="high_scores.txt")
14
+ File.open(to_file, "w") do |file|
15
+ file.puts text_for_highscores
16
+ end
17
+ end
18
+
19
+ def load_players(from_file)
20
+ CSV.foreach(from_file) do |row|
21
+ player = Player.new(row[0], row[1].to_i)
22
+ add_player(player)
23
+ end
24
+ end
25
+ def add_player(player)
26
+ @players << player
27
+ end
28
+ def play(rounds)
29
+ puts "There are #{@players.size} players in #{@title}: "
30
+
31
+ @players.each do |player|
32
+ puts player
33
+ end
34
+
35
+ treasures = TreasureTrove::TREASURES
36
+ puts "\nThere are #{treasures.size} treasures to be found:"
37
+ treasures.each do |treasure|
38
+ puts "A #{treasure.name} is worth #{treasure.points} points"
39
+ end
40
+
41
+ 1.upto(rounds) do |round|
42
+ if block_given?
43
+ break if yield
44
+ end
45
+ puts "\nRound #{round}:"
46
+ @players.each do |player|
47
+ GameTurn.take_turn(player)
48
+ end
49
+ end
50
+ end
51
+
52
+ def text_for_highscores
53
+ text = "\n#{@title} High Scores:"
54
+ @players.sort.each do |player|
55
+ formatted_name = player.name.ljust(20, '.')
56
+ text += "\n#{formatted_name} #{player.score}"
57
+ end
58
+ text
59
+ end
60
+
61
+
62
+ def print_stats
63
+ strong_players, wimpy_players = @players.partition { |player| player.strong? }
64
+
65
+ puts "\n#{@title} Statistics:"
66
+
67
+ print_name_and_health(strong_players,'strong')
68
+ print_name_and_health(wimpy_players,'wimpy')
69
+
70
+ puts text_for_highscores
71
+
72
+ @players.each do |player|
73
+ puts "\n#{player.name}'s point totals:"
74
+ player.each_found_treasure do |treasure|
75
+ puts "#{treasure.points} total #{treasure.name} points"
76
+ end
77
+
78
+ puts "#{player.points} grand total points"
79
+ end
80
+
81
+ puts "#{total_points} total points from treasures found"
82
+
83
+ end
84
+
85
+ def print_name_and_health(players,fraze)
86
+ puts "\n#{players.size} #{fraze} players:"
87
+ block = lambda { |player|
88
+ puts "#{player.name} (#{player.health})"
89
+ }
90
+ players.each { |player| block.call(player)}
91
+
92
+ end
93
+
94
+ def total_points
95
+ @players.reduce(0) { |sum, player| sum + player.points }
96
+ end
97
+
98
+ end
99
+
100
+
101
+ if __FILE__ == $0
102
+ player1 = Player.new("moe")
103
+ player2 = Player.new("larry", 60)
104
+ player3 = Player.new("curly", 125)
105
+
106
+
107
+ knuckleheads = Game.new("Knuckleheads")
108
+ knuckleheads.add_player(player1)
109
+ knuckleheads.add_player(player2)
110
+ knuckleheads.add_player(player3)
111
+ knuckleheads.play
112
+ end
113
+
114
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'loaded_die'
4
+ require_relative 'treasure_trove'
5
+
6
+ module StudioGame
7
+
8
+ module GameTurn
9
+
10
+ def self.take_turn(player)
11
+ die = Die.new
12
+ #die = LoadedDie.new
13
+ case die.roll
14
+ when 1..2
15
+ player.blam
16
+ when 3..4
17
+ puts "#{player.name} was skipped."
18
+ else
19
+ player.w00t
20
+ end
21
+
22
+ treasure = TreasureTrove.random
23
+ player.found_treasure treasure
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'auditable'
2
+ module StudioGame
3
+
4
+ class LoadedDie < Die
5
+ include Auditable
6
+
7
+
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,18 @@
1
+ module StudioGame
2
+ module Playable
3
+ def blam
4
+ puts "#{name} got blammed!"
5
+ self.health -= 10
6
+ end
7
+
8
+ def w00t
9
+ puts "#{name} got w00ted!"
10
+ self.health += 15
11
+ end
12
+
13
+ def strong?
14
+ health > 100
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,74 @@
1
+ require_relative 'treasure_trove'
2
+ require_relative 'Playable'
3
+
4
+ module StudioGame
5
+ class Player
6
+
7
+ include Playable
8
+
9
+
10
+ attr_accessor :name
11
+ attr_accessor :health
12
+
13
+ def initialize(name,health=100)
14
+ @name = name.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 each_found_treasure
31
+ @found_treasures.each do |name,value|
32
+ yield Treasure.new(name,value)
33
+ end
34
+ end
35
+
36
+ def points
37
+ @found_treasures.values.reduce(0,:+)
38
+ end
39
+
40
+ def to_s
41
+ "I'm #{@name} with health = #{@health}, points = #{points}, and score = #{score}."
42
+ end
43
+ def time
44
+ Time.new().strftime("%I:%M:%S")
45
+ end
46
+
47
+
48
+ def score
49
+ @health + points
50
+ end
51
+
52
+ def name=(new_name)
53
+ @name = new_name.capitalize
54
+ end
55
+
56
+
57
+ def <=>(other_player)
58
+ other_player.score <=> score
59
+ end
60
+ end
61
+
62
+
63
+
64
+ if __FILE__ == $0
65
+ player = Player.new("moe")
66
+ puts player.name
67
+ puts player.health
68
+ player.w00t
69
+ puts player.health
70
+ player.blam
71
+ puts player.health
72
+ end
73
+
74
+ end
@@ -0,0 +1,21 @@
1
+ module StudioGame
2
+ Treasure = Struct.new(:name,:points)
3
+
4
+ module TreasureTrove
5
+
6
+ TREASURES = [
7
+ Treasure.new(:pie,5),
8
+ Treasure.new(:bottle, 25),
9
+ Treasure.new(:hammer, 50),
10
+ Treasure.new(:skillet, 100),
11
+ Treasure.new(:broomstick, 200),
12
+ Treasure.new(:crowbar, 400)
13
+
14
+ ]
15
+
16
+
17
+ def self.random
18
+ TREASURES.sample
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,31 @@
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
+
30
+ end
31
+ end
@@ -0,0 +1,52 @@
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
+ yielded = []
25
+ @player.each_found_treasure do |treasure|
26
+ yielded << treasure
27
+ end
28
+
29
+ yielded.should == [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
30
+ end
31
+
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
+ end
52
+ end
@@ -0,0 +1,21 @@
1
+
2
+ require 'studio_game/die'
3
+
4
+ module StudioGame
5
+ describe Die do
6
+
7
+ before do
8
+ @die = Die.new
9
+ end
10
+
11
+ it "should have a initial number bewteen 1..6" do
12
+ @die.number.should <= 6 and @die.number.should >= 1
13
+ end
14
+
15
+ it "rolls" do
16
+ @die.roll.should <= 6 and @die.roll.should >= 1
17
+ end
18
+
19
+
20
+ end
21
+ end
@@ -0,0 +1,65 @@
1
+
2
+ require 'studio_game/game'
3
+
4
+ module StudioGame
5
+ describe Game do
6
+
7
+ before do
8
+ @game = Game.new("Knuckleheads")
9
+
10
+ @initial_health = 100
11
+ @player = Player.new("moe", @initial_health)
12
+
13
+ @game.add_player(@player)
14
+ end
15
+
16
+
17
+
18
+
19
+ it "w00ts the player if a high number is rolled" do
20
+ Die.any_instance.stub(:roll).and_return(5)
21
+ @game.play 2
22
+ @player.health.should == @initial_health + (15 * 2)
23
+ end
24
+
25
+
26
+ it "skips the player if a medium number is rolled" do
27
+ Die.any_instance.stub(:roll).and_return(3)
28
+ @game.play 2
29
+ @player.health.should == @initial_health
30
+ end
31
+
32
+ it "blam the player if a low number is rolled" do
33
+ Die.any_instance.stub(:roll).and_return(1)
34
+ @game.play 2
35
+ @player.health.should == @initial_health - (10 * 2)
36
+ end
37
+
38
+ it "assigns a treasure for points during a player's turn" do
39
+ game = Game.new("Knuckleheads")
40
+ player = Player.new("moe")
41
+
42
+ game.add_player(player)
43
+
44
+ game.play(1)
45
+
46
+ player.points.should_not be_zero
47
+ end
48
+
49
+ it "computes total points as the sum of all player points" do
50
+ game = Game.new("Knuckleheads")
51
+
52
+ player1 = Player.new("moe")
53
+ player2 = Player.new("larry")
54
+
55
+ game.add_player(player1)
56
+ game.add_player(player2)
57
+
58
+ player1.found_treasure(Treasure.new(:hammer, 50))
59
+ player1.found_treasure(Treasure.new(:hammer, 50))
60
+ player2.found_treasure(Treasure.new(:crowbar, 400))
61
+
62
+ game.total_points.should == 500
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,127 @@
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 "can be created from a CSV string" do
13
+ player = Player.from_csv("larry,150")
14
+
15
+ player.name.should == "Larry"
16
+ player.health.should == 150
17
+ end
18
+
19
+ it "has a capitalized name" do
20
+ @player.name.should == "Larry"
21
+ end
22
+
23
+ it "has an initial health" do
24
+ @player.health.should == @initial_health
25
+ end
26
+
27
+ it "has a string representation" do
28
+ @player.found_treasure(Treasure.new(:hammer, 50))
29
+ @player.found_treasure(Treasure.new(:hammer, 50))
30
+
31
+ @player.to_s.should == "I'm Larry with health = 150, points = 100, and score = 250."
32
+ end
33
+
34
+ it "computes a score as the sum of its health and points" do
35
+ @player.found_treasure(Treasure.new(:hammer, 50))
36
+ @player.found_treasure(Treasure.new(:hammer, 50))
37
+
38
+ @player.score.should == 250
39
+ end
40
+
41
+ it "increases health by 15 when w00ted" do
42
+ @player.w00t
43
+
44
+ @player.health.should == (@initial_health + 15)
45
+ end
46
+
47
+ it "decreases health by 10 when blammed" do
48
+ @player.blam
49
+
50
+ @player.health.should == (@initial_health - 10)
51
+ end
52
+
53
+ it "computes points as the sum of all treasure points" do
54
+ @player.points.should == 0
55
+
56
+ @player.found_treasure(Treasure.new(:hammer, 50))
57
+
58
+ @player.points.should == 50
59
+
60
+ @player.found_treasure(Treasure.new(:crowbar, 400))
61
+
62
+ @player.points.should == 450
63
+
64
+ @player.found_treasure(Treasure.new(:hammer, 50))
65
+
66
+ @player.points.should == 500
67
+ end
68
+
69
+ it "yields each found treasure and its total points" do
70
+ @player.found_treasure(Treasure.new(:skillet, 100))
71
+ @player.found_treasure(Treasure.new(:skillet, 100))
72
+ @player.found_treasure(Treasure.new(:hammer, 50))
73
+ @player.found_treasure(Treasure.new(:bottle, 5))
74
+ @player.found_treasure(Treasure.new(:bottle, 5))
75
+ @player.found_treasure(Treasure.new(:bottle, 5))
76
+ @player.found_treasure(Treasure.new(:bottle, 5))
77
+ @player.found_treasure(Treasure.new(:bottle, 5))
78
+
79
+ yielded = []
80
+ @player.each_found_treasure do |treasure|
81
+ yielded << treasure
82
+ end
83
+
84
+ yielded.should == [
85
+ Treasure.new(:skillet, 200),
86
+ Treasure.new(:hammer, 50),
87
+ Treasure.new(:bottle, 25)
88
+ ]
89
+ end
90
+
91
+ context "with a health greater than 100" do
92
+ before do
93
+ @initial_health = 150
94
+ @player = Player.new("larry", @initial_health)
95
+ end
96
+
97
+ it "is strong" do
98
+ @player.should be_strong
99
+ end
100
+ end
101
+
102
+ context "with a health of 100 or less" do
103
+ before do
104
+ @initial_health = 100
105
+ @player = Player.new("larry", @initial_health)
106
+ end
107
+
108
+ it "is strong" do
109
+ @player.should_not be_strong
110
+ end
111
+ end
112
+
113
+ context "in a collection of players" do
114
+ before do
115
+ @player1 = Player.new("moe", 100)
116
+ @player2 = Player.new("larry", 200)
117
+ @player3 = Player.new("curly", 300)
118
+
119
+ @players = [@player1, @player2, @player3]
120
+ end
121
+
122
+ it "is sorted by decreasing score" do
123
+ @players.sort.should == [@player3, @player2, @player1]
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,57 @@
1
+ require 'studio_game/treasure_trove'
2
+
3
+ module StudioGame
4
+ describe Treasure do
5
+
6
+ before do
7
+ @treasure = Treasure.new(:hammer, 50)
8
+ end
9
+
10
+ it "has a name attribute" do
11
+ @treasure.name.should == :hammer
12
+ end
13
+
14
+ it "has a points attribute" do
15
+ @treasure.points.should == 50
16
+ end
17
+
18
+ end
19
+
20
+ describe TreasureTrove do
21
+
22
+ it "has six treasures" do
23
+ TreasureTrove::TREASURES.size.should == 6
24
+ end
25
+
26
+ it "has a pie worth 5 points" do
27
+ TreasureTrove::TREASURES[0].should == Treasure.new(:pie, 5)
28
+ end
29
+
30
+ it "has a bottle worth 25 points" do
31
+ TreasureTrove::TREASURES[1].should == Treasure.new(:bottle, 25)
32
+ end
33
+
34
+ it "has a hammer worth 50 points" do
35
+ TreasureTrove::TREASURES[2].should == Treasure.new(:hammer, 50)
36
+ end
37
+
38
+ it "has a skillet worth 100 points" do
39
+ TreasureTrove::TREASURES[3].should == Treasure.new(:skillet, 100)
40
+ end
41
+
42
+ it "has a broomstick worth 200 points" do
43
+ TreasureTrove::TREASURES[4].should == Treasure.new(:broomstick, 200)
44
+ end
45
+
46
+ it "has a crowbar worth 400 points" do
47
+ TreasureTrove::TREASURES[5].should == Treasure.new(:crowbar, 400)
48
+ end
49
+
50
+ it "returns a random treasure" do
51
+ treasure = TreasureTrove.random
52
+
53
+ TreasureTrove::TREASURES.should include(treasure)
54
+ end
55
+
56
+ end
57
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rocas_studio_game
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Romel Campbell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-11-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: This gem contains the code examples I did in the Pragmatic Studio ruby
31
+ class. Its also demonstrates my first attempt at publishing a gem
32
+ email: romelcampbell@gmail.com
33
+ executables:
34
+ - studio_game
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - bin/players.csv
39
+ - bin/studio_game
40
+ - lib/studio_game/auditable.rb
41
+ - lib/studio_game/berserk_player.rb
42
+ - lib/studio_game/clumsy_player.rb
43
+ - lib/studio_game/die.rb
44
+ - lib/studio_game/game.rb
45
+ - lib/studio_game/game_turn.rb
46
+ - lib/studio_game/loaded_die.rb
47
+ - lib/studio_game/playable.rb
48
+ - lib/studio_game/player.rb
49
+ - lib/studio_game/treasure_trove.rb
50
+ - spec/studio_game/berserk_player_spec.rb
51
+ - spec/studio_game/clumsy_player_spec.rb
52
+ - spec/studio_game/die_spec.rb
53
+ - spec/studio_game/game_spec.rb
54
+ - spec/studio_game/player_spec.rb
55
+ - spec/studio_game/treasure_trove_spec.rb
56
+ - LICENSE
57
+ - README
58
+ homepage: http://online.pragmaticstudio.com/
59
+ licenses: []
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '1.9'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.24
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: Game from online ruby course
82
+ test_files:
83
+ - spec/studio_game/berserk_player_spec.rb
84
+ - spec/studio_game/clumsy_player_spec.rb
85
+ - spec/studio_game/die_spec.rb
86
+ - spec/studio_game/game_spec.rb
87
+ - spec/studio_game/player_spec.rb
88
+ - spec/studio_game/treasure_trove_spec.rb