studio_game_rc 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,8 @@
1
+ Copyright (c) 2012 Aaron Penner
2
+
3
+
4
+ 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:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ 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,6 @@
1
+ This is an application created during The Pragmatic Studio's
2
+ Ruby Programming course, as described at
3
+
4
+ http://pragmaticstudio.com
5
+
6
+ This code is Copyright 2012 Aaron Penner. See the LICENSE file.
@@ -0,0 +1,4 @@
1
+ Matthew,82
2
+ Mark,101
3
+ Luke, 85
4
+ John,90
@@ -0,0 +1,7 @@
1
+ Knuckleheads High Scores:
2
+ John................ 3485
3
+ Berserker........... 2180
4
+ Mark................ 2121
5
+ Luke................ 1135
6
+ Klutz............... 1007
7
+ Matthew............. 872
@@ -0,0 +1,3 @@
1
+ Alvin,100
2
+ Simon,60
3
+ Theo,125
@@ -0,0 +1,43 @@
1
+ #!D:/Ruby193/bin/ruby.exe
2
+ #
3
+ # This file was generated by RubyGems.
4
+ #
5
+ # The application 'rspec-core' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+ require_relative '../lib/studio_game/game'
9
+ require_relative '../lib/studio_game/clumsy_player'
10
+ require_relative '../lib/studio_game/berserk_player'
11
+
12
+ knuckleheads = StudioGame::Game.new("Knuckleheads")
13
+ knuckleheads.load_players(ARGV.shift || File.join(File.dirname(__FILE__),"players.csv"))
14
+
15
+ klutz = StudioGame::ClumsyPlayer.new("klutz", 105)
16
+ knuckleheads.add_player(klutz)
17
+
18
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
19
+ knuckleheads.add_player(berserker)
20
+
21
+ loop do
22
+ puts "How many game rounds? ('quit' to exit)"
23
+ answer = gets.chomp.downcase
24
+
25
+ case answer
26
+ when /^\d+$/
27
+ knuckleheads.play(answer.to_i)
28
+ when 'quit', 'exit'
29
+ knuckleheads.print_stats
30
+ break
31
+ else
32
+ "Please enter number of Rounds? ('quit' to exit)"
33
+ end
34
+ end
35
+
36
+ knuckleheads.save_high_scores
37
+
38
+
39
+ # knuckleheads.play(10) do
40
+ # knuckleheads.total_points >= 2000
41
+ # end
42
+
43
+
@@ -0,0 +1,6 @@
1
+ @ECHO OFF
2
+ IF NOT "%~f0" == "~f0" GOTO :WinNT
3
+ @"ruby.exe" "studio_game" %1 %2 %3 %4 %5 %6 %7 %8 %9
4
+ GOTO :EOF
5
+ :WinNT
6
+ @"ruby.exe" "%~dpn0" %*
@@ -0,0 +1,8 @@
1
+ module StudioGame
2
+ module Auditable
3
+
4
+ def audit
5
+ puts "Rolled a #{self.number} (#{self.class})"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,37 @@
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 w00t
12
+ super
13
+ @w00t_count += 1
14
+ puts "#{@name} is berserk!" if berserk?
15
+ end
16
+
17
+ def blam
18
+ if berserk?
19
+ w00t
20
+ else
21
+ super
22
+ end
23
+ end
24
+
25
+ def berserk?
26
+ @w00t_count > 5
27
+ end
28
+
29
+ end
30
+
31
+ if __FILE__ == $0
32
+ berserker = BerserkPlayer.new("berserker", 50)
33
+ 6.times { berserker.w00t }
34
+ 2.times { berserker.blam }
35
+ puts berserker.health
36
+ end
37
+ end
@@ -0,0 +1,40 @@
1
+ require_relative 'player'
2
+
3
+ module StudioGame
4
+ class ClumsyPlayer < Player
5
+
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 found_treasure(treasure)
14
+ super(Treasure.new(treasure.name, treasure.points / 2))
15
+ end
16
+
17
+ def w00t
18
+ @boost_factor.times { super }
19
+ end
20
+
21
+ end
22
+
23
+ if __FILE__ == $0
24
+ clumsy = ClumsyPlayer.new("klutz",100,2)
25
+
26
+ hammer = Treasure.new(:hammer, 50)
27
+ clumsy.found_treasure(hammer)
28
+ clumsy.found_treasure(hammer)
29
+ clumsy.found_treasure(hammer)
30
+ clumsy.w00t
31
+
32
+ crowbar = Treasure.new(:crowbar, 400)
33
+ clumsy.found_treasure(crowbar)
34
+
35
+ clumsy.each_found_treasure do |treasure|
36
+ puts "#{treasure.points} total #{treasure.name} points"
37
+ end
38
+ puts "#{clumsy.points} grand total points"
39
+ end
40
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class Die
5
+
6
+ include Auditable
7
+ attr_reader :number
8
+
9
+ def initialize
10
+ roll
11
+ end
12
+
13
+ def roll
14
+ @number = rand(1..6)
15
+ audit
16
+ @number
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,124 @@
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
+
9
+ attr_reader :title
10
+
11
+ def initialize(title)
12
+ @title = title
13
+ @players = []
14
+ end
15
+
16
+ def load_players(from_file)
17
+ File.readlines(from_file).each do |line|
18
+ add_player(Player.from_csv(line))
19
+ end
20
+ end
21
+
22
+ # def load_players(from_file)
23
+ # CSV.foreach(from_file) do |row|
24
+ # player = Player.new(row[0],row[1].to_i)
25
+ # add_player(player)
26
+ # end
27
+ # end
28
+
29
+ def save_high_scores(to_file="high_scores.txt")
30
+ File.open(to_file,"w") do |file|
31
+ file.puts "#{@title} High Scores:\n"
32
+ @players.sort.each do |p|
33
+ file.puts player_score(p)
34
+ end
35
+ end
36
+ end
37
+
38
+ def add_player(player)
39
+ @players.push(player)
40
+ end
41
+
42
+ def play(rounds)
43
+ puts "There are #{@players.size} players in #{@title}:"
44
+
45
+ @players.each do |player|
46
+ puts player
47
+ end
48
+
49
+ treasures = TreasureTrove::TREASURES
50
+ puts "\nThere are #{treasures.size} treaures to be found:"
51
+ treasures.each do |treasure|
52
+ puts "A #{treasure.name} is worth #{treasure.points} poitns"
53
+ end
54
+
55
+ puts "\n"
56
+
57
+ 1.upto(rounds) do |round|
58
+
59
+ if block_given?
60
+ break if yield
61
+ end
62
+
63
+ puts "Round #{round}:"
64
+
65
+ @players.each do |player|
66
+ GameTurn.take_turn(player)
67
+ #puts player
68
+ end
69
+ puts "\n"
70
+ end
71
+ end
72
+
73
+ def total_points
74
+ @players.reduce(0) do |sum, player|
75
+ sum + player.points
76
+ end
77
+ end
78
+
79
+ def player_score(player)
80
+ "#{player.name.ljust(20,'.')} #{player.score}"
81
+ end
82
+
83
+ def player_stats(player)
84
+ puts "#{player.name} (#{player.score})"
85
+ end
86
+
87
+ def print_stats
88
+ puts "#{@title} Statistics:\n"
89
+
90
+
91
+ @players.sort.each do |player|
92
+ puts "\n#{player.name}'s point totals:"
93
+
94
+ player.each_found_treasure do |treasure|
95
+ puts "#{treasure.points} total #{treasure.name} points"
96
+ end
97
+
98
+ puts "#{player.points} grand total points"
99
+ end
100
+ puts "\n#{total_points} total points from treasures found"
101
+
102
+ strong,wimp = @players.partition{|n| n.strong?}
103
+
104
+ puts "\n#{strong.size} strong players:"
105
+ strong.each do |p|
106
+ player_stats(p)
107
+ end
108
+
109
+ puts "\n#{wimp.size} wimpy players:"
110
+ wimp.each do |p|
111
+ player_stats(p)
112
+ end
113
+
114
+ puts "\n"
115
+
116
+ puts "#{@title} High Scores:\n"
117
+ @players.sort.each do |p|
118
+ puts player_score(p)
119
+ end
120
+
121
+ end
122
+
123
+ end
124
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'loaded_die'
4
+ require_relative 'treasure_trove'
5
+
6
+ module StudioGame
7
+ module GameTurn
8
+
9
+ def self.take_turn(player)
10
+ roll_number = Die.new.roll
11
+ #roll_number = LoadedDie.new.roll
12
+
13
+ case (roll_number)
14
+
15
+ when 1..2
16
+ player.blam
17
+ when 3..4
18
+ #do nothing
19
+ puts "#{player.name} was skipped."
20
+ else
21
+ player.w00t
22
+ end
23
+
24
+ player.found_treasure(TreasureTrove.random)
25
+ #puts "#{player.name} found a #{found.name} worth #{found.points} points."
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class LoadedDie
5
+
6
+ include Auditable
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,19 @@
1
+ module StudioGame
2
+ module Playable
3
+
4
+ def strong?
5
+ self.health > 100
6
+ end
7
+
8
+ def w00t
9
+ self.health += 15
10
+ puts "#{name} got w00ted!"
11
+ end
12
+
13
+ def blam
14
+ self.health -= 10
15
+ puts "#{name} got blammed!"
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,63 @@
1
+ require_relative 'treasure_trove'
2
+ require_relative 'playable'
3
+
4
+ module StudioGame
5
+ class Player
6
+
7
+ include Playable
8
+ attr_accessor :health
9
+ attr_accessor :name
10
+
11
+
12
+ def initialize(name, health=100)
13
+ @name = name.capitalize
14
+ @health = health
15
+ @found_treasure = Hash.new(0)
16
+ end
17
+
18
+ def found_treasure(treasure)
19
+ @found_treasure[treasure.name] += treasure.points
20
+ puts "#{@name} found a #{treasure.name} worth #{treasure.points} points."
21
+ puts "#{@name}'s treasures: #{@found_treasure}"
22
+ end
23
+
24
+ def each_found_treasure
25
+ @found_treasure.each do |name, points|
26
+ treasure = Treasure.new(name, points)
27
+ yield(treasure)
28
+ end
29
+ end
30
+
31
+ def points
32
+ @found_treasure.values.reduce(0,:+)
33
+ end
34
+
35
+ def score
36
+ @health + points
37
+ end
38
+
39
+ def <=>(other)
40
+ other.score <=> score
41
+ end
42
+
43
+ def self.from_csv(string)
44
+ name, health = string.split(",")
45
+ new(name, Integer(health))
46
+ end
47
+
48
+ def to_s
49
+ "I\'m #{@name} with a health = #{@health}, points = #{points}, and score = #{score}."
50
+ end
51
+
52
+ end
53
+
54
+ if __FILE__ == $0
55
+ player = Player.new("moe")
56
+ puts player.name
57
+ puts player.health
58
+ player.w00t
59
+ puts player.health
60
+ player.blam
61
+ puts player.health
62
+ end
63
+ end
@@ -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
+
18
+ end
19
+ 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,51 @@
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
+ context "with a boost factor" do
33
+ before do
34
+ @initial_health = 100
35
+ @boost_factor = 5
36
+ @player = ClumsyPlayer.new("klutz", @initial_health, @boost_factor)
37
+ end
38
+
39
+ it "has a boost factor" do
40
+ @player.boost_factor.should == 5
41
+ end
42
+
43
+ it "gets boost factor number of w00ts when w00ted" do
44
+ @player.w00t
45
+
46
+ @player.health.should == @initial_health + (15 * @boost_factor)
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,87 @@
1
+ require 'studio_game/game'
2
+
3
+ module StudioGame
4
+ describe Game do
5
+ before do
6
+ @game = Game.new("Blam the Wumpus")
7
+
8
+ @initial_health = 100
9
+ @player = Player.new("Hunter", @initial_health)
10
+
11
+ @game.add_player(@player)
12
+
13
+ $stdout = StringIO.new
14
+ end
15
+
16
+ it "call play with w00ted outcome" do
17
+ Die.any_instance.stub(:roll).and_return(5)
18
+ @game.play(1)
19
+ @player.health.should == @initial_health + 15
20
+ end
21
+
22
+ it "call play with w00ted outcome twice" do
23
+ Die.any_instance.stub(:roll).and_return(5)
24
+ @game.play(2)
25
+ @player.health.should == @initial_health + (15 * 2)
26
+ end
27
+
28
+ it "call play with skipped outcome" do
29
+ Die.any_instance.stub(:roll).and_return(3)
30
+ @game.play(4)
31
+ @player.health.should == @initial_health
32
+ end
33
+
34
+ it "call play with blammed outcome" do
35
+ Die.any_instance.stub(:roll).and_return(1)
36
+ @game.play(1)
37
+ @player.health.should == @initial_health - 10
38
+ end
39
+
40
+ it "call play with blammed outcome three times" do
41
+ Die.any_instance.stub(:roll).and_return(1)
42
+ @game.play(3)
43
+ @player.health.should == @initial_health - (10 * 3)
44
+ end
45
+
46
+ context "in a collection of players" do
47
+ before do
48
+ @player1 = Player.new("moe", 100)
49
+ @player2 = Player.new("larry", 200)
50
+ @player3 = Player.new("curly", 300)
51
+
52
+ @players = [@player1, @player2, @player3]
53
+ end
54
+
55
+ it "is sorted by decreasing score" do
56
+ @players.sort.should == [@player3, @player2, @player1]
57
+ end
58
+ end
59
+
60
+ it "assigns a treasure for points during a player's turn" do
61
+ game = Game.new("Knuckleheads")
62
+ player = Player.new("moe")
63
+
64
+ game.add_player(player)
65
+
66
+ game.play(1)
67
+
68
+ player.points.should_not be_zero
69
+ end
70
+
71
+ it "computes total points as the sum of all player points" do
72
+ game = Game.new("Knuckleheads")
73
+
74
+ player1 = Player.new("moe")
75
+ player2 = Player.new("larry")
76
+
77
+ game.add_player(player1)
78
+ game.add_player(player2)
79
+
80
+ player1.found_treasure(Treasure.new(:hammer, 50))
81
+ player1.found_treasure(Treasure.new(:hammer, 50))
82
+ player2.found_treasure(Treasure.new(:crowbar, 400))
83
+
84
+ game.total_points.should == 500
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,124 @@
1
+ require 'studio_game/player'
2
+ require 'studio_game/treasure_trove'
3
+
4
+ module StudioGame
5
+ describe Player do
6
+
7
+ before do
8
+ @health = 150
9
+ @player = Player.new("larry", @health)
10
+ $stdout = StringIO.new
11
+ end
12
+
13
+ it "has a capitalized name" do
14
+ @player.name.should == "Larry"
15
+ end
16
+
17
+ it "has an initial health" do
18
+ @player.health.should == 150
19
+ end
20
+
21
+ it "has a string representation" do
22
+ @player.found_treasure(Treasure.new(:hammer, 50))
23
+ @player.found_treasure(Treasure.new(:hammer, 50))
24
+ @player.to_s.should == "I'm Larry with a health = 150, points = 100, and score = 250."
25
+ end
26
+
27
+ it "computes a score as the sum of its health and points" do
28
+ @player.found_treasure(Treasure.new(:hammer, 50))
29
+ @player.found_treasure(Treasure.new(:hammer, 50))
30
+
31
+ @player.score.should == 250
32
+ end
33
+
34
+ it "increases health by 15 when w00ted" do
35
+ @player.w00t
36
+
37
+ @player.health.should == @health + 15
38
+ end
39
+
40
+
41
+ it "decreases health by 10 when blammed" do
42
+ @player.blam
43
+
44
+ @player.health.should == @health - 10
45
+ end
46
+
47
+ context "default health initalization" do
48
+ before do
49
+ @player = Player.new("larry")
50
+ end
51
+
52
+ it "default health is 100" do
53
+ @player.health.should == 100
54
+ end
55
+
56
+ end
57
+
58
+ context "health of 150" do
59
+ before do
60
+ @player = Player.new("Arnold", 150)
61
+ end
62
+
63
+ it "is Strong" do
64
+ @player.should be_strong
65
+ end
66
+ end
67
+
68
+ context "health of 100" do
69
+ before do
70
+ @player = Player.new("Arnold", 100)
71
+ end
72
+
73
+ it "is not Strong" do
74
+ @player.should_not be_strong
75
+ end
76
+ end
77
+
78
+ it "computes points as the sum of all treasure points" do
79
+ @player.points.should == 0
80
+
81
+ @player.found_treasure(Treasure.new(:hammer, 50))
82
+
83
+ @player.points.should == 50
84
+
85
+ @player.found_treasure(Treasure.new(:crowbar, 400))
86
+
87
+ @player.points.should == 450
88
+
89
+ @player.found_treasure(Treasure.new(:hammer, 50))
90
+
91
+ @player.points.should == 500
92
+ end
93
+
94
+ it "yields each found treasure and its total points" do
95
+ @player.found_treasure(Treasure.new(:skillet, 100))
96
+ @player.found_treasure(Treasure.new(:skillet, 100))
97
+ @player.found_treasure(Treasure.new(:hammer, 50))
98
+ @player.found_treasure(Treasure.new(:bottle, 5))
99
+ @player.found_treasure(Treasure.new(:bottle, 5))
100
+ @player.found_treasure(Treasure.new(:bottle, 5))
101
+ @player.found_treasure(Treasure.new(:bottle, 5))
102
+ @player.found_treasure(Treasure.new(:bottle, 5))
103
+
104
+ yielded = []
105
+ @player.each_found_treasure do |treasure|
106
+ yielded << treasure
107
+ end
108
+
109
+ yielded.should == [
110
+ Treasure.new(:skillet, 200),
111
+ Treasure.new(:hammer, 50),
112
+ Treasure.new(:bottle, 25)
113
+ ]
114
+ end
115
+
116
+ it "can be created from a CSV string" do
117
+ player = Player.from_csv("larry,150")
118
+
119
+ player.name.should == "Larry"
120
+ player.health.should == 150
121
+ end
122
+
123
+ end
124
+ 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,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: studio_game_rc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aaron Penner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &21272220 !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: *21272220
25
+ description: ! "This is an application created during The Pragmatic Studio's \nRuby
26
+ Programming course, as described at\n\n http://pragmaticstudio.com\n\nThis code
27
+ is Copyright 2012 Aaron Penner. See the LICENSE file."
28
+ email: apenner@rockcairn.com
29
+ executables:
30
+ - studio_game
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/bible_players.csv
35
+ - bin/high_scores.txt
36
+ - bin/players.csv
37
+ - bin/studio_game
38
+ - bin/studio_game.bat
39
+ - lib/studio_game/auditable.rb
40
+ - lib/studio_game/berserk_player.rb
41
+ - lib/studio_game/clumsy_player.rb
42
+ - lib/studio_game/die.rb
43
+ - lib/studio_game/game.rb
44
+ - lib/studio_game/game_turn.rb
45
+ - lib/studio_game/loaded_die.rb
46
+ - lib/studio_game/playable.rb
47
+ - lib/studio_game/player.rb
48
+ - lib/studio_game/treasure_trove.rb
49
+ - spec/studio_game/berserk_player_spec.rb
50
+ - spec/studio_game/clumsy_player_spec.rb
51
+ - spec/studio_game/game_spec.rb
52
+ - spec/studio_game/player_spec.rb
53
+ - spec/studio_game/treasure_trove_spec.rb
54
+ - LICENSE
55
+ - README
56
+ homepage: http://rockcairn.com
57
+ licenses: []
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '1.9'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 1.8.16
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Simple game created during ruby course
80
+ test_files:
81
+ - spec/studio_game/berserk_player_spec.rb
82
+ - spec/studio_game/clumsy_player_spec.rb
83
+ - spec/studio_game/game_spec.rb
84
+ - spec/studio_game/player_spec.rb
85
+ - spec/studio_game/treasure_trove_spec.rb