studio_game_xyz 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7ed352b68173ad820ccc700ac4779d9fd85b0d27
4
+ data.tar.gz: 3c73468bd22f8d7302a63dda23d1f731d9ad094f
5
+ SHA512:
6
+ metadata.gz: 499660f4421a51c8106dae0b580e531d6f49e4732947057fdf3bebfeb6780662cb052d96c7e647e81dabfc305d903cb0e3acc524f5d95e126326fab1e76a80b7
7
+ data.tar.gz: 88ec68877bc9f3544ef9dc052b0cca86d9a10e38682a313caedc8cc3f1c333934f715d66da83d9b80abc95ff1cd9abfc53807bc924dee268ec257dda2b918ddc
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2015 Vladislav Belogrudov <vlad.belogrudov@gmail.com>
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 is a fantastic game created with help of online course at Pragmatic Programmers. Check out their Ruby course.
data/bin/myplayers.csv ADDED
@@ -0,0 +1,4 @@
1
+ Misha,100
2
+ Foma,20
3
+ Anna,30
4
+ Gosha,40
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,29 @@
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
+ players_file = File.join(File.dirname(__FILE__), 'players.csv')
9
+ knuckleheads.load_players(ARGV.shift || players_file)
10
+ klutz = StudioGame::ClumsyPlayer.new("klutz", 105, 10)
11
+ knuckleheads.add_player(klutz)
12
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
13
+ knuckleheads.add_player(berserker)
14
+
15
+ loop do
16
+ puts "How many game rounds ('quit' or 'exit' to finish)"
17
+ answer = gets.chomp.downcase
18
+
19
+ case answer
20
+ when /^\d+$/
21
+ knuckleheads.play(answer.to_i)
22
+ when "exit", "quit"
23
+ knuckleheads.print_stats
24
+ knuckleheads.save_high_scores
25
+ break
26
+ else
27
+ puts "Please enter a number or 'quit' or 'exit'"
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ module StudioGame
2
+ module Auditable
3
+
4
+ def audit
5
+ puts "Rolled a #{self.number} (#{self.class.name})"
6
+ end
7
+
8
+ end
9
+ 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
+ @w00t_count = 0
8
+ super(name, health)
9
+ end
10
+
11
+ def berserk?
12
+ @w00t_count > 5
13
+ end
14
+
15
+ def w00t
16
+ @w00t_count += 1
17
+ puts "#{@name} is berserk!" if berserk?
18
+ super
19
+ end
20
+
21
+ def blam
22
+ berserk? ? w00t : super
23
+ end
24
+
25
+ end
26
+ end
27
+ if __FILE__ == $0
28
+ berserker = StudioGame::BerserkPlayer.new("berserker", 50)
29
+ 6.times { berserker.w00t }
30
+ 2.times { berserker.blam }
31
+ puts berserker
32
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'player'
2
+ require_relative 'treasure_trove'
3
+
4
+ module StudioGame
5
+ class ClumsyPlayer < Player
6
+
7
+ attr_reader :boost_factor
8
+
9
+ def initialize(name, health=100, boost_factor=1)
10
+ super(name, health)
11
+ @boost_factor = boost_factor
12
+ end
13
+
14
+ def w00t
15
+ @boost_factor.times { super }
16
+ end
17
+
18
+ def found_treasure(treasure)
19
+ super(Treasure.new(treasure.name, treasure.points / 2))
20
+ end
21
+ end
22
+ end
23
+
24
+ if __FILE__ == $0
25
+ clumsy = StudioGame::ClumsyPlayer.new("klutz", 105, 3)
26
+
27
+ hammer = StudioGame::Treasure.new(:hammer, 50)
28
+ clumsy.found_treasure(hammer)
29
+ clumsy.found_treasure(hammer)
30
+ clumsy.found_treasure(hammer)
31
+
32
+ crowbar = StudioGame::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
+
39
+ puts "#{clumsy.points} grand total points"
40
+
41
+ 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,92 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'csv'
4
+ require_relative 'player'
5
+ require_relative 'game_turn'
6
+ require_relative 'treasure_trove'
7
+
8
+ module StudioGame
9
+ class Game
10
+ def initialize(name)
11
+ @title = name
12
+ @players = []
13
+ end
14
+
15
+ def add_player(player)
16
+ @players << player
17
+ end
18
+
19
+ def load_players(from_file)
20
+ CSV.foreach(from_file) do |row|
21
+ add_player(Player.new(row[0], Integer(row[1])))
22
+ end
23
+ end
24
+
25
+ def play(rounds)
26
+ puts "There are #{@players.size} players in #{@title}:"
27
+ puts @players
28
+ treasures = TreasureTrove::TREASURES
29
+ puts "There are #{treasures.size} treasures to be found:"
30
+ treasures.each do |treasure|
31
+ puts "A #{treasure.name} is worth #{treasure.points} points"
32
+ end
33
+ 1.upto(rounds) do |round|
34
+ break if block_given? and yield
35
+ puts "\nRound #{round}"
36
+ @players.each do |player|
37
+ GameTurn.take_turn(player)
38
+ end
39
+ end
40
+ end
41
+
42
+ def total_points
43
+ @players.reduce(0) do |sum, player|
44
+ sum + player.points
45
+ end
46
+ end
47
+
48
+ def high_scores
49
+ scores = "#{@title} High Scores:"
50
+ @players.sort.each do |player|
51
+ scores += "\n#{player.name.ljust(20, ".")} #{player.score}"
52
+ end
53
+ scores
54
+ end
55
+
56
+ def print_stats
57
+ puts "#{@title} Statistics:"
58
+ strong, whimpy = @players.partition { |player| player.strong? }
59
+ strong_sorted_by_health = strong.sort { |a, b| b.health <=> a.health }
60
+ whimpy_sorted_by_health = whimpy.sort { |a, b| b.health <=> a.health }
61
+
62
+ puts "\n#{strong.size} strong players:"
63
+ strong_sorted_by_health.each do |player|
64
+ puts "#{player.name} (#{player.health})"
65
+ end
66
+
67
+ puts "\n#{whimpy.size} whimpy players:"
68
+ whimpy_sorted_by_health.sort.each do |player|
69
+ puts "#{player.name} (#{player.health})"
70
+ end
71
+
72
+ puts "\n" + high_scores
73
+
74
+ @players.each do |player|
75
+ puts "\n#{player.name}'s point totals:"
76
+ player.each_found_treasure do |treasure|
77
+ puts "#{treasure.points} total #{treasure.name} points"
78
+ end
79
+ puts "#{player.points} grand total points"
80
+ end
81
+
82
+ puts "\n#{total_points} total points from treasures found"
83
+ end
84
+
85
+ def save_high_scores(to_file="high_scores.txt")
86
+ File.open(to_file, "w") do |file|
87
+ file.puts high_scores
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,24 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'treasure_trove'
4
+
5
+ module StudioGame
6
+
7
+ module GameTurn
8
+ def self.take_turn(player)
9
+ die = Die.new
10
+ case die.roll
11
+ when 5..6
12
+ player.w00t
13
+ when 3..4
14
+ puts "skipping player #{player.name}"
15
+ else
16
+ player.blam
17
+ end
18
+
19
+ treasure = TreasureTrove::random
20
+ player.found_treasure(treasure)
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+
5
+ class LoadedDie
6
+ include Auditable
7
+
8
+ attr_reader :number
9
+
10
+ def roll
11
+ numbers = [1, 1, 2, 5, 6, 6]
12
+ @number = numbers.sample
13
+ audit
14
+ @number
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,21 @@
1
+ module StudioGame
2
+
3
+ module Playable
4
+
5
+ def blam
6
+ self.health -=10
7
+ puts "#{self.name} got blammed!"
8
+ end
9
+
10
+ def w00t
11
+ self.health +=15
12
+ puts "#{self.name} got w00ted!"
13
+ end
14
+
15
+ def strong?
16
+ self.health > 100
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative 'playable'
4
+
5
+ module StudioGame
6
+
7
+ class Player
8
+ include Playable
9
+
10
+ attr_accessor :health
11
+ attr_accessor :name
12
+
13
+ def name=(new_name)
14
+ @name = new_name.capitalize
15
+ end
16
+
17
+ def initialize(name, health=100)
18
+ @name = name.capitalize
19
+ @health = health
20
+ @found_treasures = Hash.new(0)
21
+ end
22
+
23
+ def self.from_csv(line)
24
+ name, health = line.split(',')
25
+ Player.new(name, Integer(health))
26
+ end
27
+
28
+ def found_treasure(treasure)
29
+ @found_treasures[treasure.name] += treasure.points
30
+ puts "#{@name} found #{treasure.name} worth of #{treasure.points}"
31
+ puts "#{@name}'s treasures: #{@found_treasures}"
32
+ end
33
+
34
+ def points
35
+ @found_treasures.values.reduce(0, :+)
36
+ end
37
+
38
+ def to_s
39
+ "I'm #{@name} with health = #{@health}, points = #{points} and score = #{score}"
40
+ end
41
+
42
+ def score
43
+ @health + points
44
+ end
45
+
46
+ def <=>(player)
47
+ player.score <=> score
48
+ end
49
+
50
+ def each_found_treasure
51
+ @found_treasures.each do |name, points|
52
+ yield(Treasure.new(name, points))
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ end
59
+
60
+ if __FILE__ == $0
61
+ player = StudioGame::Player.new("moe")
62
+ puts player.name
63
+ puts player.health
64
+ player.w00t
65
+ puts player.health
66
+ player.blam
67
+ puts player.health
68
+ end
69
+
@@ -0,0 +1,21 @@
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
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,32 @@
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
+ end
17
+
18
+ it "goes berserk when w00ted more than 5 times" do
19
+ 1.upto(6) { @player.w00t }
20
+
21
+ @player.berserk?.should be_true
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
+ @player.health.should == @initial_health + (8 * 15)
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,46 @@
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 == [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
32
+ end
33
+
34
+ context "Boosted by 10 clumsy player"
35
+ before do
36
+ @initial_health = 100
37
+ @boost_factor = 10
38
+ @player = ClumsyPlayer.new("booster", 100, 10)
39
+ end
40
+
41
+ it "gets boosted 10 times when w00ted" do
42
+ @player.w00t
43
+ @player.health.should == @initial_health + 15 * @boost_factor
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,127 @@
1
+ require 'studio_game/game'
2
+ require 'studio_game/die'
3
+
4
+ module StudioGame
5
+
6
+ describe Game do
7
+
8
+ before do
9
+ $stdout = StringIO.new
10
+ @game = Game.new("Knuckleheads")
11
+ @initial_health = 100
12
+ @rounds = 5
13
+ @player = Player.new("moe", @initial_health)
14
+ @game.add_player(@player)
15
+ end
16
+
17
+ it "w00ts player if high number rolled" do
18
+ Die.any_instance.stub(:roll).and_return(5)
19
+ @game.play(@rounds)
20
+ @player.health.should == @initial_health + 15 * @rounds
21
+ end
22
+
23
+ it "skips player if medium number rolled" do
24
+ Die.any_instance.stub(:roll).and_return(3)
25
+ @game.play(@rounds)
26
+ @player.health.should == @initial_health
27
+ end
28
+
29
+ it "blams player if low number rolled" do
30
+ Die.any_instance.stub(:roll).and_return(2)
31
+ @game.play(@rounds)
32
+ @player.health.should == @initial_health - 10 * @rounds
33
+ end
34
+
35
+ it "assigns a treasure for points during a player's turn" do
36
+ game = Game.new("Knuckleheads")
37
+ player = Player.new("moe")
38
+ game.add_player(player)
39
+ game.play(1)
40
+ player.points.should_not be_zero
41
+ end
42
+
43
+ it "computes total points as the sum of all player points" do
44
+ game = Game.new("Knuckleheads")
45
+
46
+ player1 = Player.new("moe")
47
+ player2 = Player.new("larry")
48
+
49
+ game.add_player(player1)
50
+ game.add_player(player2)
51
+
52
+ player1.found_treasure(Treasure.new(:hammer, 50))
53
+ player1.found_treasure(Treasure.new(:hammer, 50))
54
+ player2.found_treasure(Treasure.new(:crowbar, 400))
55
+
56
+ game.total_points.should == 500
57
+ end
58
+
59
+ it "yields each found treasure and its total points" do
60
+ @player.found_treasure(Treasure.new(:skillet, 100))
61
+ @player.found_treasure(Treasure.new(:skillet, 100))
62
+ @player.found_treasure(Treasure.new(:hammer, 50))
63
+ @player.found_treasure(Treasure.new(:bottle, 5))
64
+ @player.found_treasure(Treasure.new(:bottle, 5))
65
+ @player.found_treasure(Treasure.new(:bottle, 5))
66
+ @player.found_treasure(Treasure.new(:bottle, 5))
67
+ @player.found_treasure(Treasure.new(:bottle, 5))
68
+
69
+ yielded = []
70
+ @player.each_found_treasure do |treasure|
71
+ yielded << treasure
72
+ end
73
+
74
+ yielded.should == [
75
+ Treasure.new(:skillet, 200),
76
+ Treasure.new(:hammer, 50),
77
+ Treasure.new(:bottle, 25)
78
+ ]
79
+ end
80
+
81
+ context "1 strong and two whimpy players" do
82
+ before do
83
+ @player1 = Player.new("joe", 30)
84
+ @player2 = Player.new("kate", 120)
85
+ @player2.found_treasure(Treasure.new(:hammer, 100))
86
+ @player3 = Player.new("pete", 90)
87
+ @game = Game.new("Knuckleheads")
88
+ @game.add_player(@player1)
89
+ @game.add_player(@player2)
90
+ @game.add_player(@player3)
91
+ $stdout = StringIO.new
92
+ end
93
+
94
+ it "shows 1 strong and two whimpy players" do
95
+ @game.print_stats
96
+ $stdout.string.should == <<EOS
97
+ Knuckleheads Statistics:
98
+
99
+ 1 strong players:
100
+ Kate (120)
101
+
102
+ 2 whimpy players:
103
+ Pete (90)
104
+ Joe (30)
105
+
106
+ Knuckleheads High Scores:
107
+ Kate................ 220
108
+ Pete................ 90
109
+ Joe................. 30
110
+
111
+ Joe's point totals:
112
+ 0 grand total points
113
+
114
+ Kate's point totals:
115
+ 100 total hammer points
116
+ 100 grand total points
117
+
118
+ Pete's point totals:
119
+ 0 grand total points
120
+
121
+ 100 total points from treasures found
122
+ EOS
123
+ end
124
+
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,103 @@
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
+ $stdout = StringIO.new
10
+ @initial_health = 150
11
+ @player = Player.new("vlad", @initial_health)
12
+ end
13
+
14
+ it "has a capitalized name" do
15
+ @player.name.should == "Vlad"
16
+ end
17
+
18
+ it "has an initial health" do
19
+ @player.health.should == @initial_health
20
+ end
21
+
22
+ it "has a string representation" do
23
+ @player.found_treasure(Treasure.new(:hammer, 50))
24
+ @player.found_treasure(Treasure.new(:hammer, 50))
25
+ @player.to_s.should == "I'm Vlad 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
+ @player.score.should == 250
32
+ end
33
+
34
+ it "increases health by 15 when w00ted" do
35
+ @player.w00t
36
+ @player.health.should == @initial_health + 15
37
+ end
38
+
39
+ it "decreases health by 10 when blammed" do
40
+ @player.blam
41
+ @player.health.should == @initial_health - 10
42
+ end
43
+
44
+ it "computes points as the sum of all treasure points" do
45
+ @player.points.should == 0
46
+
47
+ @player.found_treasure(Treasure.new(:hammer, 50))
48
+ @player.points.should == 50
49
+
50
+ @player.found_treasure(Treasure.new(:crowbar, 400))
51
+ @player.points.should == 450
52
+
53
+ @player.found_treasure(Treasure.new(:hammer, 50))
54
+ @player.points.should == 500
55
+ end
56
+
57
+ it "intantiates from csv line" do
58
+ line = "Andrew,123"
59
+ player = Player.from_csv(line)
60
+ player.health.should == 123
61
+ player.name.should == "Andrew"
62
+ player.points.should == 0
63
+ end
64
+
65
+ context "with health greater than 100" do
66
+ before do
67
+ @player = Player.new("vlad", 150)
68
+ end
69
+
70
+ it "is strong" do
71
+ @player.should be_strong
72
+ end
73
+ end
74
+
75
+ context "with health less or equal 100" do
76
+ before do
77
+ @player = Player.new("vlad", 100)
78
+ end
79
+
80
+ it "is not strong" do
81
+ @player.should_not be_strong
82
+ end
83
+ end
84
+
85
+ context "in a collection of players" do
86
+ before do
87
+ @player1 = Player.new("moe", 300)
88
+ @player2 = Player.new("larry", 250)
89
+ @player3 = Player.new("curly", 200)
90
+
91
+ @player2.found_treasure(Treasure.new(:skillet, 100))
92
+ @player3.found_treasure(Treasure.new(:broomstick, 400))
93
+
94
+ @players = [@player1, @player2, @player3]
95
+ end
96
+
97
+ it "is sorted by decreasing score" do
98
+ @players.sort.should == [@player3, @player2, @player1]
99
+ end
100
+ end
101
+ end
102
+
103
+ 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,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: studio_game_xyz
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Vladislav Belogrudov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-24 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
+ This is a fantastic game created with help of online course at Pragmatic Programmers. Check out their Ruby course.
29
+ email: vlad.belogrudov@gmail.com
30
+ executables:
31
+ - studio_game
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README
37
+ - bin/myplayers.csv
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://www.google.com
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '1.9'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.4.5
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Simple game with die and blammed / w00ted players
79
+ test_files:
80
+ - spec/studio_game/berserk_player_spec.rb
81
+ - spec/studio_game/clumsy_player_spec.rb
82
+ - spec/studio_game/game_spec.rb
83
+ - spec/studio_game/player_spec.rb
84
+ - spec/studio_game/treasure_trove_spec.rb