studio_game_jf 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: 4d273174fb36285282f96098b9291a00749e82c7
4
+ data.tar.gz: 3f457774d1b74698210a658c9b9ceef65bcda721
5
+ SHA512:
6
+ metadata.gz: 095922edf70be18994a4f806e0570739f02a996787904ee4bc8226f92dee481f168a15d8ac663ffd2f6f6a2e4629a7c9ed3ed78f3ab692936d855eafcb830338
7
+ data.tar.gz: ef79184512f9fd539895dcd711e7e21465ff3eb0791a7e04308742141d99fe794136a2605c6a8f6679935318504123235ab4ea95737b359077285ce292e85473
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) <2015> <Julian Feliciano>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README ADDED
File without changes
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
+
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
+
11
+ player4 = StudioGame::ClumsyPlayer.new('klutz', 105, 3)
12
+ player5 = StudioGame::BerserkPlayer.new('berserker', 50)
13
+ knuckleheads.add_player(player4)
14
+ knuckleheads.add_player(player5)
15
+
16
+ loop do
17
+ puts "\nHow many game rounds? ('quit' to exit)"
18
+ answer = gets.chomp.downcase
19
+ case answer
20
+ when /^\d+$/
21
+ knuckleheads.play(answer.to_i)
22
+ when 'quit', 'exit'
23
+ knuckleheads.print_stats
24
+ break
25
+ else
26
+ puts "Please enter a number or 'quit'"
27
+ end
28
+ end
29
+
30
+ 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
+
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
+ if __FILE__ == $0
27
+ berserker = BerserkPlayer.new('berserker', 50)
28
+ 6.times { berserker.w00t }
29
+ 2.times { berserker.blam }
30
+ puts berserker.health
31
+ end
32
+ end
@@ -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)
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,19 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+ class Die
5
+ include Auditable
6
+
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,108 @@
1
+ require 'csv'
2
+ require_relative 'game_turn'
3
+ require_relative 'treasure_trove'
4
+
5
+ module StudioGame
6
+ class Game
7
+ attr_reader :title
8
+
9
+ def initialize(title)
10
+ @title = title
11
+ @players = []
12
+ end
13
+
14
+ def load_players(from_file)
15
+ CSV.foreach(from_file) do |row|
16
+ player = Player.new(row[0], row[1].to_i)
17
+ add_player(player)
18
+ end
19
+ end
20
+
21
+ def save_high_scores(to_file='high_scores.txt')
22
+ File.open(to_file, 'w') do |file|
23
+ file.puts "#{@title} High Scores:"
24
+ @players.sort.each do |player|
25
+ file.puts high_score_entry(player)
26
+ end
27
+ end
28
+ end
29
+
30
+ def add_player(player)
31
+ @players << player
32
+ end
33
+
34
+ def total_points
35
+ @players.reduce(0) { |sum, player| sum += player.points }
36
+ end
37
+
38
+ def play(rounds)
39
+ puts "There are #{@players.size} players in #{@title}:"
40
+ puts @players
41
+
42
+ treasures = TreasureTrove::TREASURES
43
+
44
+ puts "\nThere are #{treasures.size} treasures to be found:"
45
+ treasures.each do |treasure|
46
+ puts "A #{treasure.name} is worth #{treasure.points} points"
47
+ end
48
+
49
+ 1.upto(rounds) do |round|
50
+ if block_given?
51
+ break if yield
52
+ end
53
+ puts "\nRound #{round}:"
54
+ @players.each do |player|
55
+ GameTurn.take_turn(player)
56
+ puts player
57
+ end
58
+ end
59
+ end
60
+
61
+ def print_name_and_health(player)
62
+ puts "#{player.name} (#{player.health})"
63
+ end
64
+
65
+ def high_score_entry(player)
66
+ formatted_name = player.name.ljust(20, '.')
67
+ "#{formatted_name} #{player.score}"
68
+ end
69
+
70
+ def print_stats
71
+ strong_players, wimpy_players = @players.partition { |p| p.strong? }
72
+
73
+ puts "\n#{@title} Statistics:"
74
+
75
+ puts "\n#{total_points} total points from treasures found"
76
+
77
+ @players.sort.each do |player|
78
+ puts "\n#{player.name}'s point totals:"
79
+ player.each_found_treasure do |treasure|
80
+ puts "#{treasure.points} total #{treasure.name} points"
81
+ end
82
+ puts "#{player.points} grand total points"
83
+ end
84
+
85
+ puts "\n#{strong_players.size} strong players:"
86
+ strong_players.each do |player|
87
+ print_name_and_health(player)
88
+ end
89
+
90
+ puts "\n#{wimpy_players.size} wimpy players:"
91
+ wimpy_players.each do |player|
92
+ print_name_and_health(player)
93
+ end
94
+
95
+ puts "\n#{@title} High Scores:"
96
+ @players.sort.each do |player|
97
+ puts high_score_entry(player)
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ if __FILE__ == $0
104
+ player = Player.new('moe')
105
+ game = Game.new('Knuckleheads')
106
+ game.add_player(player)
107
+ game.play(3)
108
+ end
@@ -0,0 +1,25 @@
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
+ # die = LoadedDie.new
11
+
12
+ case die.roll
13
+ when 1..2
14
+ player.blam
15
+ when 3..4
16
+ puts "#{player.name} was skipped."
17
+ else
18
+ player.w00t
19
+ end
20
+
21
+ treasure = TreasureTrove.random
22
+ player.found_treasure(treasure)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ Knuckleheads High Scores:
2
+ Theo................ 750
3
+ Klutz............... 742
4
+ Simon............... 485
5
+ Alvin............... 330
6
+ Berserker........... 260
@@ -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,15 @@
1
+ module Playable
2
+ def blam
3
+ self.health -= 10
4
+ puts "#{name} got blammed!"
5
+ end
6
+
7
+ def w00t
8
+ self.health += 15
9
+ puts "#{name} got w00ted!"
10
+ end
11
+
12
+ def strong?
13
+ health > 100
14
+ end
15
+ end
@@ -0,0 +1,63 @@
1
+ require_relative 'treasure_trove'
2
+ require_relative 'playable'
3
+
4
+ module StudioGame
5
+ class Player
6
+ include Playable
7
+
8
+ attr_accessor :name, :health
9
+
10
+ def initialize(name, health=100)
11
+ @name = name.capitalize
12
+ @health = health
13
+ @found_treasures = Hash.new(0)
14
+ end
15
+
16
+ def self.from_csv(string)
17
+ name, health = string.split(',')
18
+ Player.new(name, Integer(health))
19
+ end
20
+
21
+ def points
22
+ @found_treasures.values.reduce(0, :+)
23
+ end
24
+
25
+ def each_found_treasure
26
+ @found_treasures.each do |name, points|
27
+ yield(Treasure.new(name, points))
28
+ end
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 score
38
+ @health + points
39
+ end
40
+
41
+ def name=(new_name)
42
+ @name = new_name.capitalize
43
+ end
44
+
45
+ def <=>(other_player)
46
+ other_player.score <=> score
47
+ end
48
+
49
+ def to_s
50
+ "I'm #{@name} with health = #{@health}, points = #{points}, and score = #{score}."
51
+ end
52
+ end
53
+ end
54
+
55
+ if __FILE__ == $0
56
+ player = Player.new('moe')
57
+ puts player.name
58
+ puts player.health
59
+ player.w00t
60
+ puts player.health
61
+ player.blam
62
+ puts player.health
63
+ end
@@ -0,0 +1,19 @@
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
+ end
@@ -0,0 +1,31 @@
1
+ require 'studio_game/berserk_player'
2
+
3
+ module StudioGame
4
+ describe BerserkPlayer do
5
+
6
+ before do
7
+ $stdout = StringIO.new
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
+ expect(@player.berserk?).to be_falsey
16
+ end
17
+
18
+ it "goes berserk when w00ted more than 5 times" do
19
+ 1.upto(6) { @player.w00t }
20
+
21
+ expect(@player.berserk?).to be_truthy
22
+ end
23
+
24
+ it "gets w00ted instead of blammed when it's gone berserk" do
25
+ 1.upto(6) { @player.w00t }
26
+ 1.upto(2) { @player.blam }
27
+
28
+ expect(@player.health).to eq(@initial_health + (8 * 15))
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,56 @@
1
+ require 'studio_game/clumsy_player'
2
+
3
+ module StudioGame
4
+ describe ClumsyPlayer do
5
+
6
+ before do
7
+ $stdout = StringIO.new
8
+ @player = ClumsyPlayer.new('klutz')
9
+ end
10
+
11
+ it "only gets half the point value for each treasure" do
12
+ expect(@player.points).to eq(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
+ expect(@player.points).to eq(75)
20
+
21
+ crowbar = Treasure.new(:crowbar, 400)
22
+ @player.found_treasure(crowbar)
23
+
24
+ expect(@player.points).to eq(275)
25
+
26
+ yielded = []
27
+ @player.each_found_treasure do |treasure|
28
+ yielded << treasure
29
+ end
30
+
31
+ expect(yielded).to eq([
32
+ Treasure.new(:hammer, 75),
33
+ Treasure.new(:crowbar, 200)
34
+ ])
35
+ end
36
+
37
+ context "with a boost factor" do
38
+
39
+ before do
40
+ @initial_health = 100
41
+ @boost_factor = 5
42
+ @player = ClumsyPlayer.new('klutz', @initial_health, @boost_factor)
43
+ end
44
+
45
+ it "has a boost factor" do
46
+ expect(@player.boost_factor).to eq(5)
47
+ end
48
+
49
+ it "gets boost factor amount of w00ts when w00ted" do
50
+ @player.w00t
51
+
52
+ expect(@player.health).to eq(@initial_health + (15 * @boost_factor))
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,67 @@
1
+ require 'studio_game/game'
2
+
3
+ module StudioGame
4
+ describe Game do
5
+
6
+ before do
7
+ $stdout = StringIO.new
8
+ @game = Game.new('knucklheads')
9
+
10
+ @initial_health = 100
11
+ @player = Player.new('moe', @initial_health)
12
+
13
+ @game.add_player(@player)
14
+ end
15
+
16
+ it "w00ts the player if a high number is rolled" do
17
+ allow_any_instance_of(Die).to receive(:roll).and_return(5)
18
+
19
+ @game.play(2)
20
+
21
+ expect(@player.health).to eq(@initial_health + (15 * 2))
22
+ end
23
+
24
+ it "skips the player if a medium number is rolled" do
25
+ allow_any_instance_of(Die).to receive(:roll).and_return(3)
26
+
27
+ @game.play(2)
28
+
29
+ expect(@player.health).to eq(@initial_health)
30
+ end
31
+
32
+ it "blams the player if a low number is rolled" do
33
+ allow_any_instance_of(Die).to receive(:roll).and_return(1)
34
+
35
+ @game.play(2)
36
+
37
+ expect(@player.health).to eq(@initial_health - (10 * 2))
38
+ end
39
+
40
+ it "assigns a treasure for points during a player's turn" do
41
+ game = Game.new('Knuckleheads')
42
+ player = Player.new('moe')
43
+
44
+ game.add_player(player)
45
+
46
+ game.play(1)
47
+
48
+ expect(player.points).not_to be_zero
49
+ end
50
+
51
+ it "computes total points as the sum of all player points" do
52
+ game = Game.new('Knuckleheads')
53
+
54
+ player1 = Player.new('moe')
55
+ player2 = Player.new('larry')
56
+
57
+ game.add_player(player1)
58
+ game.add_player(player2)
59
+
60
+ player1.found_treasure(Treasure.new(:hammer, 50))
61
+ player1.found_treasure(Treasure.new(:hammer, 50))
62
+ player2.found_treasure(Treasure.new(:crowbar, 400))
63
+
64
+ expect(game.total_points).to eq(500)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,133 @@
1
+ require 'studio_game/player'
2
+ require 'studio_game/treasure_trove'
3
+
4
+ module StudioGame
5
+ describe Player do
6
+
7
+ before do
8
+ $stdout = StringIO.new
9
+ @initial_health = 150
10
+ @player = Player.new('larry', @initial_health)
11
+ end
12
+
13
+ it "has a capitalized name" do
14
+ expect(@player.name).to eq('Larry')
15
+ end
16
+
17
+ it "has an initial health" do
18
+ expect(@player.health).to eq(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
+ expect(@player.to_s).to eq("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
+ expect(@player.score).to eq(250)
33
+ end
34
+
35
+ it "increases health by 15 when w00ted" do
36
+ @player.w00t
37
+
38
+ expect(@player.health).to eq(@initial_health + 15)
39
+ end
40
+
41
+ it "decreases health by 10 when blammed" do
42
+ @player.blam
43
+
44
+ expect(@player.health).to eq(@initial_health - 10)
45
+ end
46
+
47
+ it "computes points as the sum of all treasure points" do
48
+ expect(@player.points).to eq(0)
49
+
50
+ @player.found_treasure(Treasure.new(:hammer, 50))
51
+
52
+ expect(@player.points).to eq(50)
53
+
54
+ @player.found_treasure(Treasure.new(:crowbar, 400))
55
+
56
+ expect(@player.points).to eq(450)
57
+
58
+ @player.found_treasure(Treasure.new(:hammer, 50))
59
+
60
+ expect(@player.points).to eq(500)
61
+ end
62
+
63
+ it "yields each found treasure and its total points" do
64
+ @player.found_treasure(Treasure.new(:skillet, 100))
65
+ @player.found_treasure(Treasure.new(:skillet, 100))
66
+ @player.found_treasure(Treasure.new(:hammer, 50))
67
+ @player.found_treasure(Treasure.new(:bottle, 5))
68
+ @player.found_treasure(Treasure.new(:bottle, 5))
69
+ @player.found_treasure(Treasure.new(:bottle, 5))
70
+ @player.found_treasure(Treasure.new(:bottle, 5))
71
+ @player.found_treasure(Treasure.new(:bottle, 5))
72
+
73
+ yielded = []
74
+ @player.each_found_treasure do |treasure|
75
+ yielded << treasure
76
+ end
77
+
78
+ expect(yielded).to eq([
79
+ Treasure.new(:skillet, 200),
80
+ Treasure.new(:hammer, 50),
81
+ Treasure.new(:bottle, 25)
82
+ ])
83
+ end
84
+
85
+ it "can be created from a CSV string" do
86
+ player = Player.from_csv("Julian,100")
87
+
88
+ expect(player.name).to eq('Julian')
89
+ expect(player.health).to eq(100)
90
+ end
91
+
92
+ context "with a health greater than 100" do
93
+
94
+ before do
95
+ @player = Player.new('larry', 150)
96
+ end
97
+
98
+ it "is strong" do
99
+ # expect(@player.strong?).to be_truthy
100
+ # expect(@player.strong?).to eq(true)
101
+ expect(@player).to be_strong
102
+ end
103
+ end
104
+
105
+ context "with a health less than or equal to 100" do
106
+
107
+ before do
108
+ @player = Player.new('larry', 100)
109
+ end
110
+
111
+ it "is wimpy" do
112
+ # expect(@player.strong?).to eq(false)
113
+ # expect(@player.strong?).to be_falsey
114
+ expect(@player).not_to be_strong
115
+ end
116
+ end
117
+
118
+ context "in a collection of players" do
119
+
120
+ before do
121
+ @player1 = Player.new('moe', 100)
122
+ @player2 = Player.new('larry', 200)
123
+ @player3 = Player.new('curly', 300)
124
+
125
+ @players = [@player1, @player2, @player3]
126
+ end
127
+
128
+ it "is sorted by decreasing score" do
129
+ expect(@players.sort).to eq([@player3, @player2, @player1])
130
+ end
131
+ end
132
+ end
133
+ end
@@ -0,0 +1,55 @@
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
+ expect(@treasure.name).to eq(:hammer)
12
+ end
13
+
14
+ it "has a points attribute" do
15
+ expect(@treasure.points).to eq(50)
16
+ end
17
+ end
18
+
19
+ describe TreasureTrove do
20
+
21
+ it "has six treasures" do
22
+ expect(TreasureTrove::TREASURES.size).to eq(6)
23
+ end
24
+
25
+ it "has a pie worth 5 points" do
26
+ expect(TreasureTrove::TREASURES[0]).to eq(Treasure.new(:pie, 5))
27
+ end
28
+
29
+ it "has a bottle worth 25 points" do
30
+ expect(TreasureTrove::TREASURES[1]).to eq(Treasure.new(:bottle, 25))
31
+ end
32
+
33
+ it "has a hammer worth 50 points" do
34
+ expect(TreasureTrove::TREASURES[2]).to eq(Treasure.new(:hammer, 50))
35
+ end
36
+
37
+ it "has a skillet worth 100 points" do
38
+ expect(TreasureTrove::TREASURES[3]).to eq(Treasure.new(:skillet, 100))
39
+ end
40
+
41
+ it "has a broomstick worth 200 points" do
42
+ expect(TreasureTrove::TREASURES[4]).to eq(Treasure.new(:broomstick, 200))
43
+ end
44
+
45
+ it "has a crowbar worth 400 points" do
46
+ expect(TreasureTrove::TREASURES[5]).to eq(Treasure.new(:crowbar, 400))
47
+ end
48
+
49
+ it "returns a random treasure" do
50
+ treasure = TreasureTrove.random
51
+
52
+ expect(TreasureTrove::TREASURES).to include(treasure)
53
+ end
54
+ end
55
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: studio_game_jf
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Julian Feliciano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-28 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
+ email: julsfelic@gmail.com
29
+ executables:
30
+ - studio_game
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README
36
+ - bin/players.csv
37
+ - bin/studio_game
38
+ - lib/studio_game/auditable.rb
39
+ - lib/studio_game/berserk_player.rb
40
+ - lib/studio_game/clumsy_player.rb
41
+ - lib/studio_game/die.rb
42
+ - lib/studio_game/game.rb
43
+ - lib/studio_game/game_turn.rb
44
+ - lib/studio_game/high_scores.txt
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
+ homepage: https://www.pragmaticstudio.com
55
+ licenses:
56
+ - MIT
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.4.6
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: A game of luck!
78
+ test_files:
79
+ - spec/studio_game/berserk_player_spec.rb
80
+ - spec/studio_game/clumsy_player_spec.rb
81
+ - spec/studio_game/game_spec.rb
82
+ - spec/studio_game/player_spec.rb
83
+ - spec/studio_game/treasure_trove_spec.rb