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