studio_game_francisco 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
+ SHA512:
3
+ data.tar.gz: fe2157a5b0ea547d67e91d5ce5e6d6f6929cd76025eaeed045ea0e14693c170d79b56f5dbb39b6206fa29aedfe06425695897ec95349366285d0d6e90c01c19c
4
+ metadata.gz: 001005f1708874663383e6286350d7d123bc5b07012428b5bb06bab933d3cbc75d8825d929420a96ec2f31a235dfea96e8d0bd4da7b968b7e8f92be7c587319b
5
+ SHA1:
6
+ data.tar.gz: feaa0b5b961771e9143c8364ca6c274976a87d72
7
+ metadata.gz: 826b60368e06ee155eabe5f8a732d5f6b691df66
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2013 Francisco De La Cruz
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 application from an exercise in The Pragmatic Studio's
2
+ Ruby Programming course, as described at
3
+
4
+ http://pragmaticstudio.com
5
+
6
+ This code is Copyright 2013 Francisco De La Cruz. 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,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/studio_game/player'
4
+ require_relative '../lib/studio_game/game'
5
+ require_relative '../lib/studio_game/clumsy_player'
6
+ require_relative '../lib/studio_game/berserk_player'
7
+
8
+ knuckleheads = StudioGame::Game.new("Knuckleheads")
9
+
10
+ default_player_file = File.join(File.dirname(__FILE__), 'players.csv')
11
+ knuckleheads.load_players(ARGV.shift || default_player_file)
12
+
13
+ klutz = StudioGame::ClumsyPlayer.new('klutz', 105)
14
+ knuckleheads.add_player(klutz)
15
+
16
+ berserker = StudioGame::BerserkPlayer.new('berserker', 50)
17
+ knuckleheads.add_player(berserker)
18
+
19
+ loop do
20
+ puts "\nHow many game rounds? ('quit' to exit)"
21
+ answer = gets.chomp.downcase
22
+ case answer
23
+ when /^\d+$/
24
+ knuckleheads.play(answer.to_i)
25
+ when 'quit', 'exit'
26
+ knuckleheads.print_stats
27
+ break
28
+ else
29
+ puts "Please enter a number or 'quit'"
30
+ end
31
+ end
32
+
33
+ knuckleheads.save_high_scores
@@ -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,32 @@
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
+ 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
@@ -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
+ damaged_treasure = Treasure.new(treasure.name, treasure.points / 2)
15
+ super(damaged_treasure)
16
+ end
17
+
18
+ def w00t
19
+ @boost_factor.times { super }
20
+ end
21
+ end
22
+
23
+
24
+ if __FILE__ == $0
25
+ clumsy = ClumsyPlayer.new("klutz", 105, 3)
26
+
27
+ hammer = Treasure.new(:hammer, 50)
28
+ clumsy.found_treasure(hammer)
29
+ clumsy.found_treasure(hammer)
30
+ clumsy.found_treasure(hammer)
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
+ include Auditable
6
+
7
+ attr_reader :number
8
+
9
+ # def initialize # commented to stop the "double rolling" of the dice
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,101 @@
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 add_player(a_player)
17
+ @players << a_player
18
+ end
19
+
20
+ def play(rounds)
21
+ puts "\nThere are #{@players.size} players in #{@title}:\n"
22
+
23
+ @players.each do |player|
24
+ puts player
25
+ end
26
+
27
+ 1.upto(rounds) do |round|
28
+ puts "\nRound: #{round}"
29
+ @players.each do |player|
30
+ GameTurn.take_turn(player)
31
+ end
32
+ end
33
+
34
+ treasures = TreasureTrove::TREASURES
35
+ puts "\nThere are #{treasures.size} treasures to be found:"
36
+ treasures.each do |treasure|
37
+ puts "A #{treasure.name} is worth #{treasure.points} points"
38
+ end
39
+ end
40
+
41
+ def total_points
42
+ @players.reduce(0) { |sum, player| sum + player.points }
43
+ end
44
+
45
+ def print_name_and_health(player)
46
+ puts "#{player.name} (#{player.health})"
47
+ end
48
+
49
+ def high_score_entry(player)
50
+ formatted_name = player.name.ljust(20, '.')
51
+ "#{formatted_name} #{player.score}"
52
+ end
53
+
54
+ def print_stats
55
+ puts "\n#{@title} Statistics:"
56
+
57
+ strong_players, wimpy_players = @players.partition { |player| player.strong? }
58
+
59
+ puts "\n#{strong_players.size} strong players:"
60
+ strong_players.each do |player|
61
+ print_name_and_health(player)
62
+ end
63
+
64
+ puts "\n#{wimpy_players.size} wimpy players:"
65
+ wimpy_players.each do |player|
66
+ print_name_and_health(player)
67
+ end
68
+
69
+ puts "\n#{total_points} total points from treasures found"
70
+ @players.sort.each do |player|
71
+ puts "\n#{player.name}'s point totals:"
72
+ player.each_found_treasure do |treasure|
73
+ puts "#{treasure.points} total #{treasure.name} points"
74
+ end
75
+ puts "#{player.points} grand total points"
76
+ end
77
+
78
+ puts "\n#{@title} High Scores:"
79
+ @players.sort.each do |player|
80
+ puts high_score_entry(player)
81
+ end
82
+ end
83
+
84
+ def load_players(from_file)
85
+ # File.readlines(from_file).each do |line|
86
+ CSV.foreach(from_file) do |row| #BONUS: Ruby Standard Library
87
+ # add_player(Player.from_csv(line))
88
+ add_player(Player.new(row[0], row[1].to_i))
89
+ end
90
+ end
91
+
92
+ def save_high_scores(to_file="high_scores.txt")
93
+ File.open(to_file, "w") do |file|
94
+ file.puts "#{@title} High Scores:"
95
+ @players.sort.each do |player|
96
+ file.puts high_score_entry(player)
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,24 @@
1
+ require_relative 'die'
2
+ require_relative 'player'
3
+ require_relative 'treasure_trove'
4
+ require_relative 'loaded_die'
5
+
6
+ module StudioGame
7
+ module GameTurn
8
+ def self.take_turn(player)
9
+ die = Die.new
10
+ # die = LoadedDie.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
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ def conversation
2
+ puts "Hello"
3
+ yield
4
+ puts "Goodbye"
5
+ end
6
+
7
+ def five_times
8
+ 1.upto(5) do |count|
9
+ yield count
10
+ end
11
+ end
12
+
13
+ def n_times(number)
14
+ 1.upto(number) do |count|
15
+ yield count
16
+ end
17
+ end
18
+
19
+ conversation { puts "Good to meet you!" }
20
+
21
+ five_times do |n|
22
+ puts "#{n} situps"
23
+ puts "#{n} pushups"
24
+ puts "#{n} chinups"
25
+ end
26
+
27
+ n_times(10) do |n|
28
+ puts "#{n} situps"
29
+ puts "#{n} pushups"
30
+ puts "#{n} chinups"
31
+ end
32
+
@@ -0,0 +1,17 @@
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
+ @number = [1, 1, 2, 5, 6, 6].sample
13
+ audit
14
+ @number
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module StudioGame
2
+ module Playable
3
+ def w00t
4
+ self.health += 15
5
+ puts "#{self.name} got w00ted!"
6
+ end
7
+
8
+ def blam
9
+ self.health -= 10
10
+ puts "#{self.name} got blammed!"
11
+ end
12
+
13
+ def strong?
14
+ self.health > 100
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,65 @@
1
+ require_relative 'treasure_trove'
2
+ require_relative 'playable'
3
+
4
+ module StudioGame
5
+ class Player
6
+ include Playable
7
+
8
+ attr_accessor :health
9
+ attr_accessor :name
10
+
11
+ def initialize(name, health=100)
12
+ @name = name.capitalize
13
+ @health = health
14
+ @found_treasures = Hash.new(0)
15
+ end
16
+
17
+ def name=(name)
18
+ @name = name.capitalize
19
+ end
20
+
21
+ def score
22
+ @health + points
23
+ end
24
+
25
+ def <=>(other)
26
+ other.score <=> score
27
+ end
28
+
29
+ def to_s
30
+ "I'm #{@name} with health = #{@health}, points = #{points}, and a score of #{score}."
31
+ end
32
+
33
+ def found_treasure(treasure)
34
+ @found_treasures[treasure.name] += treasure.points
35
+ puts "#{@name} found a #{treasure.name} worth #{treasure.points} points."
36
+ puts "#{@name}'s treasures: #{@found_treasures}"
37
+ end
38
+
39
+ def points
40
+ @found_treasures.values.reduce(0, :+)
41
+ end
42
+
43
+ def each_found_treasure
44
+ @found_treasures.each do |name, points|
45
+ yield Treasure.new(name, points)
46
+ end
47
+ end
48
+
49
+ def self.from_csv(str)
50
+ name, health = str.split(",")
51
+ new(name, Integer(health)) #CLEVER, just new(...) instead of Player.new(...) which is already calling the method inside Game
52
+ end
53
+ end
54
+ end
55
+
56
+
57
+ if __FILE__ == $0
58
+ player = Player.new("moe")
59
+ puts player.name
60
+ puts player.health
61
+ player.w00t
62
+ puts player.health
63
+ player.blam
64
+ puts player.health
65
+ end
@@ -0,0 +1,18 @@
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
+ end
@@ -0,0 +1,34 @@
1
+ require 'studio_game/berserk_player'
2
+
3
+ module StudioGame
4
+ describe BerserkPlayer do
5
+
6
+ before do
7
+ $stdout = StringIO.new
8
+ end
9
+
10
+ before do
11
+ @initial_health = 50
12
+ @player = BerserkPlayer.new("berserker", @initial_health)
13
+ end
14
+
15
+ it "does not go berserk when w00ted up to 5 times" do
16
+ 1.upto(5) { @player.w00t }
17
+
18
+ @player.berserk?.should be_false
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
+ end
26
+
27
+ it "gets w00ted instead of blammed when it's gone berserk" do
28
+ 1.upto(6) { @player.w00t }
29
+ 1.upto(2) { @player.blam }
30
+
31
+ @player.health.should == @initial_health + (8 * 15)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,55 @@
1
+ require 'studio_game/clumsy_player'
2
+
3
+ module StudioGame
4
+ describe ClumsyPlayer do
5
+
6
+ before do
7
+ $stdout = StringIO.new
8
+ end
9
+
10
+ before do
11
+ @player = ClumsyPlayer.new("klutz")
12
+ end
13
+
14
+ it "only gets half the point value for each treasure" do
15
+ @player.points.should == 0
16
+
17
+ hammer = Treasure.new(:hammer, 50)
18
+ @player.found_treasure(hammer)
19
+ @player.found_treasure(hammer)
20
+ @player.found_treasure(hammer)
21
+
22
+ @player.points.should == 75
23
+
24
+ crowbar = Treasure.new(:crowbar, 400)
25
+ @player.found_treasure(crowbar)
26
+
27
+ @player.points.should == 275
28
+
29
+ yielded = []
30
+ @player.each_found_treasure do |treasure|
31
+ yielded << treasure
32
+ end
33
+
34
+ yielded.should == [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
35
+ end
36
+
37
+ context "with a boost factor" do
38
+ before do
39
+ @initial_health = 100
40
+ @boost_factor = 5
41
+ @player = ClumsyPlayer.new("klutz", @initial_health, @boost_factor)
42
+ end
43
+
44
+ it "has a boost factor" do
45
+ @player.boost_factor.should == 5
46
+ end
47
+
48
+ it "gets a boost everytime he is w00ted" do
49
+ @player.w00t
50
+
51
+ @player.health.should == @initial_health + (15 * @boost_factor)
52
+ end
53
+ end
54
+ end
55
+ 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 the 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 "nothing happens if a medium number is rolled" do
24
+ Die.any_instance.stub(:roll).and_return(3)
25
+
26
+ @game.play(2)
27
+
28
+ @player.health.should == @initial_health
29
+ end
30
+
31
+ it "blams the player if a low number is rolled" do
32
+ Die.any_instance.stub(:roll).and_return(1)
33
+
34
+ @game.play(2)
35
+
36
+ @player.health.should == @initial_health - (10 * 2)
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,128 @@
1
+ require "studio_game/player"
2
+
3
+ module StudioGame
4
+ describe Player do
5
+
6
+ before do
7
+ $stdout = StringIO.new
8
+ end
9
+
10
+ before do
11
+ @initial_health = 150
12
+ @player = Player.new("larry", @initial_health)
13
+ end
14
+
15
+ it "has a capitalized name" do
16
+ @player.name.should == "Larry"
17
+ end
18
+
19
+ it "has an initial health" do
20
+ @player.health.should == 150
21
+ end
22
+
23
+ it "has a string representation" do
24
+ @player.found_treasure(Treasure.new(:hammer, 50))
25
+ @player.found_treasure(Treasure.new(:hammer, 50))
26
+
27
+ @player.to_s.should == "I'm Larry with health = 150, points = 100, and a score of 250."
28
+ end
29
+
30
+ it "computes a score as the sum of its health and points" do
31
+ @player.found_treasure(Treasure.new(:hammer, 50))
32
+ @player.found_treasure(Treasure.new(:hammer, 50))
33
+
34
+ @player.score.should == 250
35
+ end
36
+
37
+ it "increases health by 15 when w00ted" do
38
+ @player.w00t
39
+
40
+ @player.health.should == @initial_health + 15
41
+ end
42
+
43
+ it "decreases health by 10 when blammed" do
44
+ @player.blam
45
+
46
+ @player.health.should == @initial_health - 10
47
+ end
48
+
49
+ context "with a health greater than 100" do
50
+ before do
51
+ @player = Player.new("larry", 150)
52
+ end
53
+
54
+ it "is strong" do
55
+ @player.should be_strong
56
+ end
57
+ end
58
+
59
+ context "with a health of 100 or less" do
60
+ before do
61
+ @player = Player.new("larry", 100)
62
+ end
63
+
64
+ it "is wimpy" do
65
+ @player.should_not be_strong
66
+ end
67
+ end
68
+
69
+ context "in a collection of players" do
70
+ before do
71
+ @player1 = Player.new("moe", 100)
72
+ @player2 = Player.new("larry", 200)
73
+ @player3 = Player.new("curly", 300)
74
+
75
+ @players = [@player1, @player2, @player3]
76
+ end
77
+
78
+ it "is sorted by decreasing score" do
79
+ @players.sort.should == [@player3, @player2, @player1]
80
+ end
81
+ end
82
+
83
+ it "computes points as the sum of all treasure points" do
84
+ @player.points.should == 0
85
+
86
+ @player.found_treasure(Treasure.new(:hammer, 50))
87
+
88
+ @player.points.should == 50
89
+
90
+ @player.found_treasure(Treasure.new(:crowbar, 400))
91
+
92
+ @player.points.should == 450
93
+
94
+ @player.found_treasure(Treasure.new(:hammer, 50))
95
+
96
+ @player.points.should == 500
97
+ end
98
+
99
+ it "yields each found treasure and its total points" do
100
+ @player.found_treasure(Treasure.new(:skillet, 100))
101
+ @player.found_treasure(Treasure.new(:skillet, 100))
102
+ @player.found_treasure(Treasure.new(:hammer, 50))
103
+ @player.found_treasure(Treasure.new(:bottle, 5))
104
+ @player.found_treasure(Treasure.new(:bottle, 5))
105
+ @player.found_treasure(Treasure.new(:bottle, 5))
106
+ @player.found_treasure(Treasure.new(:bottle, 5))
107
+ @player.found_treasure(Treasure.new(:bottle, 5))
108
+
109
+ yielded = []
110
+ @player.each_found_treasure do |treasure|
111
+ yielded << treasure
112
+ end
113
+
114
+ yielded.should == [
115
+ Treasure.new(:skillet, 200),
116
+ Treasure.new(:hammer, 50),
117
+ Treasure.new(:bottle, 25)
118
+ ]
119
+ end
120
+
121
+ it "it creates a Player from a CSV" do
122
+ player = Player.from_csv("larry, 100")
123
+
124
+ player.name.should == "Larry"
125
+ player.health.should == 100
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,56 @@
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
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: studio_game_francisco
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - francisco de la cruz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2013-09-02 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ prerelease: false
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - &id002
20
+ - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ type: :development
24
+ version_requirements: *id001
25
+ description: |
26
+ This is an application from an exercise in The Pragmatic Studio's
27
+ Ruby Programming course, as described at
28
+
29
+ http://pragmaticstudio.com
30
+
31
+ This code is Copyright 2013 Francisco De La Cruz. See the LICENSE file
32
+
33
+ email: helloquico@gmail.com
34
+ executables:
35
+ - studio_game
36
+ extensions: []
37
+
38
+ extra_rdoc_files: []
39
+
40
+ files:
41
+ - bin/players.csv
42
+ - bin/studio_game
43
+ - lib/studio_game/auditable.rb
44
+ - lib/studio_game/berserk_player.rb
45
+ - lib/studio_game/clumsy_player.rb
46
+ - lib/studio_game/die.rb
47
+ - lib/studio_game/game.rb
48
+ - lib/studio_game/game_turn.rb
49
+ - lib/studio_game/iterators.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
+ - LICENSE
60
+ - README
61
+ homepage: http://slocate.tumblr.com/
62
+ licenses: []
63
+
64
+ metadata: {}
65
+
66
+ post_install_message:
67
+ rdoc_options: []
68
+
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: "1.8"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - *id002
79
+ requirements: []
80
+
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.7
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: A fun, and entirely random, text-based game
86
+ test_files:
87
+ - spec/studio_game/berserk_player_spec.rb
88
+ - spec/studio_game/clumsy_player_spec.rb
89
+ - spec/studio_game/game_spec.rb
90
+ - spec/studio_game/player_spec.rb
91
+ - spec/studio_game/treasure_trove_spec.rb