dice_game_koek 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
+ SHA256:
3
+ metadata.gz: ad212cfc6cc489a4fae7cba14a9416905bebec007e63f0bc2d10ce55acdc38e4
4
+ data.tar.gz: 518d8e131420d35aaaebdedd8d2fe02bab81cf63de6acf74ef115b955ddb7b39
5
+ SHA512:
6
+ metadata.gz: 78d2d8d8e7fb990612d47e0be95f23a3ec60fa6d70a414f444ba77c345f86789d5281d2094d108c46b6bc5719d126569938adf5dc9f8fecd8fb65581b24f9470
7
+ data.tar.gz: f5f1c9f217cd63061db194d19ae383fcf61ebcd438ede38c11522edeb8dc8782f722e36914fc604267f6429831d6c36c3d720bd47cfa247b0f320a4e7236372b
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 @@
1
+ Dice game to learn Ruby.
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,40 @@
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
+ module StudioGame
8
+ player1 = Player.new("moe")
9
+ player2 = Player.new("larry", 60)
10
+ player3 = Player.new("curly", 125)
11
+ player4 = Player.new("shemp", 90)
12
+ player5 = ClumsyPlayer.new("klutz", 105, 5)
13
+ player6 = BerserkPlayer.new("berserker", 50)
14
+
15
+ knuckleheads = StudioGame::Game.new("Knuckleheads")
16
+ default_player_file = File.join(File.dirname(__FILE__), 'players.csv')
17
+ knuckleheads.load_player(ARGV.shift || default_player_file)
18
+ knuckleheads.add_player(player5)
19
+ knuckleheads.add_player(player6)
20
+
21
+
22
+
23
+ loop do
24
+ puts "\nHow many game rounds? ('quit' to exit)"
25
+ answer = gets.chomp.downcase
26
+ case answer
27
+ when /^\d+$/
28
+ knuckleheads.play(answer.to_i)
29
+ when 'quit', 'exit'
30
+ knuckleheads.print_stats
31
+ break
32
+ else
33
+ puts "Please enter a number or 'quit'"
34
+ end
35
+ end
36
+
37
+ knuckleheads.save_high_scores
38
+
39
+ end
40
+
@@ -0,0 +1,9 @@
1
+ module StudioGame
2
+
3
+ module Auditable
4
+
5
+ def audit
6
+ puts "Rolled a #{self.number} (#{self.class})"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,40 @@
1
+ require_relative 'player'
2
+ require_relative 'treasure_trove'
3
+
4
+ module StudioGame
5
+
6
+ class BerserkPlayer < Player
7
+
8
+ def initialize(name, health)
9
+ super(name, health)
10
+ @w00t_count = 0
11
+ end
12
+
13
+ def berserk?
14
+ @w00t_count > 5
15
+ end
16
+
17
+ def w00t
18
+ super
19
+ @w00t_count += 1
20
+ puts "#{@name} is berserk!" if berserk?
21
+ end
22
+
23
+ def blam
24
+ if berserk?
25
+ w00t
26
+ else
27
+ super
28
+ end
29
+ end
30
+
31
+
32
+ end
33
+
34
+ if __FILE__ == $0
35
+ berserker = BerserkPlayer.new("berserker", 50)
36
+ 6.times { berserker.w00t }
37
+ 2.times { berserker.blam }
38
+ puts berserker.health
39
+ end
40
+ end
@@ -0,0 +1,42 @@
1
+ require_relative 'player'
2
+ require_relative 'treasure_trove'
3
+
4
+ module StudioGame
5
+
6
+ class ClumsyPlayer < Player
7
+
8
+ attr_reader :boost_factor
9
+
10
+ def initialize(name, health, boost_factor)
11
+ super(name, health)
12
+ @boost_factor = boost_factor
13
+ end
14
+
15
+ def w00t
16
+ @boost_factor.times { super }
17
+ end
18
+
19
+ def found_treasure(treasure)
20
+ damaged_treasure = Treasure.new(treasure.name, treasure.points / 2)
21
+ super(damaged_treasure)
22
+ end
23
+
24
+ end
25
+
26
+ if __FILE__ == $0
27
+ clumsy = ClumsyPlayer.new("klutz")
28
+
29
+ hammer = Treasure.new(:hammer, 50)
30
+ clumsy.found_treasure(hammer)
31
+ clumsy.found_treasure(hammer)
32
+ clumsy.found_treasure(hammer)
33
+
34
+ crowbar = Treasure.new(:crowbar, 400)
35
+ clumsy.found_treasure(crowbar)
36
+
37
+ clumsy.each_found_treasure do |treasure|
38
+ puts "#{treasure.points} total #{treasure.name} points"
39
+ end
40
+ puts "#{clumsy.points} grand total points"
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'auditable'
2
+
3
+ module StudioGame
4
+
5
+ class Die
6
+ include Auditable #make sure its capitalized
7
+
8
+ attr_reader :number #getter
9
+
10
+ def roll #method that rolls the die
11
+ @number = rand(1..6) # gets a random number between 1-6 inclusive
12
+ audit #method from the mixin auditable.rb
13
+ @number #returns number on die
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,111 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'game_turn'
4
+ require_relative 'treasure_trove'
5
+
6
+ module StudioGame
7
+
8
+ class Game
9
+ attr_reader :title
10
+
11
+ def initialize(title)
12
+ @title = title
13
+ @players = []
14
+ end
15
+
16
+ def save_high_scores(to_file = "high_scores.txt")
17
+ File.open(to_file, "w") do |file|
18
+ file.puts "#{@title} High Scores:"
19
+ @players.sort.each do |player|
20
+ file.puts high_score_entry(player)
21
+ end
22
+ end
23
+ end
24
+
25
+ def load_player(from_file)
26
+ File.readlines(from_file).each do |line|
27
+ add_player(Player.from_csv(line))
28
+ end
29
+
30
+ end
31
+
32
+ def high_score_entry(player)
33
+ "#{player.name.ljust(20, ".")}#{player.score}"
34
+
35
+ # formatted_name = player.name.ljust(20, ".")
36
+ # "#{formatted_name} #{player.score}"
37
+
38
+ end
39
+
40
+ def add_player(new_player)
41
+
42
+ @players.push(new_player)
43
+
44
+ end
45
+
46
+ def print_stats
47
+ puts "\n#{@title} Statistics:"
48
+ strong_player, wimpy_player = @players.partition {|player| player.strong?}
49
+
50
+ # another way to do this is below...
51
+ # strong_player = @players.select { |player| player.strong? }
52
+ # wimpy_player = @players.reject { |player| player.strong? }
53
+
54
+
55
+ puts "\n#{strong_player.size} strong players:"
56
+ strong_player.each do |player|
57
+ print_name_and_health(player)
58
+ end
59
+
60
+ puts "\n#{wimpy_player.size} wimpy players:"
61
+ wimpy_player.each do |player|
62
+ print_name_and_health(player)
63
+ end
64
+
65
+ puts "\n#{total_points} total treasure points found."
66
+
67
+ @players.each do |player|
68
+ puts "\n#{player.name} point totals:"
69
+ player.each_found_treasure do |treasure|
70
+ puts "#{treasure.points} total #{treasure.name} points. "
71
+ end
72
+ puts "#{player.points} grand total points"
73
+ end
74
+
75
+ puts "#{title} High Scores:"
76
+ @players.sort.each do |player|
77
+ puts high_score_entry(player)
78
+ end
79
+ end
80
+
81
+ def print_name_and_health(x)
82
+ puts "#{x.name} (#{x.health})"
83
+ end
84
+
85
+ def play(rounds)
86
+ puts "\nThere are #{@players.size} players in #{@title}:"
87
+ @players.each do |x|
88
+ puts x
89
+ end
90
+
91
+ treasures = TreasureTrove::TREASURES
92
+ puts "There are #{treasures.size} treasures to be found:\n"
93
+ treasures.each do |treasure|
94
+ puts "A #{treasure.name} is worth #{treasure.points} points\n"
95
+ end
96
+
97
+ 1.upto(rounds) do |round|
98
+ puts "\n Round #{round}:"
99
+ @players.each do |player|
100
+ GameTurn.take_turn(player)
101
+ end
102
+ end
103
+ end
104
+
105
+ def total_points
106
+ @players.reduce(0) {|sum, player| sum + player.points}
107
+ end
108
+
109
+ end
110
+
111
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'player'
2
+ require_relative 'die'
3
+ require_relative 'loaded_die'
4
+
5
+ module StudioGame
6
+
7
+ module GameTurn
8
+
9
+ def self.take_turn(player)
10
+ dice = Die.new
11
+ treasure = TreasureTrove.random
12
+
13
+ case dice.roll
14
+
15
+ when 5..6
16
+ player.w00t
17
+ when 3..4
18
+ puts "#{player.name} was skipped"
19
+ else
20
+ player.blam
21
+ end
22
+
23
+ player.found_treasure(treasure)
24
+
25
+
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+
@@ -0,0 +1,16 @@
1
+ require_relative 'die'
2
+ require_relative 'auditable'
3
+
4
+ module StudioGame
5
+ class LoadedDie
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,22 @@
1
+
2
+ module StudioGame
3
+ module Playable
4
+
5
+ def strong?
6
+ health > 100
7
+ end
8
+
9
+ def w00t
10
+ self.health += 15
11
+ puts "#{name} got w00ted"
12
+ end
13
+
14
+ def blam
15
+ self.health -= 10
16
+ puts "#{name} got blammed"
17
+ end
18
+
19
+
20
+
21
+ end
22
+ end
@@ -0,0 +1,65 @@
1
+ require_relative 'playable'
2
+
3
+ module StudioGame
4
+
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 <=>(other)
22
+ other.score <=> score
23
+ end
24
+
25
+ def found_treasure(treasure)
26
+ @found_treasures[treasure.name] += treasure.points
27
+ puts "#{@name} found a #{treasure.name} worth #{treasure.points} points."
28
+ end
29
+
30
+ def each_found_treasure
31
+ @found_treasures.each do |name, points|
32
+ yield Treasure.new(name, points)
33
+ end
34
+
35
+ end
36
+
37
+ def points
38
+ @found_treasures.values.reduce(0, :+)
39
+ end
40
+
41
+ def name=(name)
42
+ @name = name.capitalize
43
+ end
44
+
45
+ def score
46
+ @health + points
47
+ end
48
+
49
+ def to_s
50
+ "I'm #{@name} with a health = #{@health}, points = #{points}, and score = #{score}."
51
+ end
52
+ end
53
+
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
64
+
65
+ end
@@ -0,0 +1,24 @@
1
+ module StudioGame
2
+
3
+ Treasure = Struct.new(:name, :points)
4
+
5
+ module TreasureTrove
6
+
7
+ TREASURES = [
8
+ Treasure.new(:pie, 5),
9
+ Treasure.new(:bottle, 25),
10
+ Treasure.new(:hammer, 50),
11
+ Treasure.new(:skillet, 100),
12
+ Treasure.new(:broomstick, 200),
13
+ Treasure.new(:crowbar, 400)
14
+ ]
15
+
16
+ def self.random
17
+ TREASURES.sample
18
+ end
19
+
20
+ end
21
+ end
22
+
23
+
24
+
@@ -0,0 +1,33 @@
1
+ require 'studio_game/berserk_player'
2
+ module StudioGame
3
+
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
+ @player.berserk?.should be_falsey
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
+ @player.berserk?.should be_truthy
23
+ end
24
+
25
+ it "gets w00ted instead of blammed when it's gone berserk" do
26
+ 1.upto(6) { @player.w00t }
27
+ 1.upto(2) { @player.blam }
28
+
29
+ @player.health.should == @initial_health + (8 * 15)
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,56 @@
1
+ require 'studio_game/clumsy_player'
2
+
3
+ module StudioGame
4
+
5
+ describe ClumsyPlayer do
6
+ before do
7
+ @player = ClumsyPlayer.new("klutz", 100, 5)
8
+ end
9
+
10
+ it "only gets half the point value for each treasure" do
11
+ @player.points.should == 0
12
+
13
+ hammer = Treasure.new(:hammer, 50)
14
+ @player.found_treasure(hammer)
15
+ @player.found_treasure(hammer)
16
+ @player.found_treasure(hammer)
17
+
18
+ @player.points.should == 75
19
+
20
+ crowbar = Treasure.new(:crowbar, 400)
21
+ @player.found_treasure(crowbar)
22
+
23
+ @player.points.should == 275
24
+
25
+ yielded = []
26
+ @player.each_found_treasure do |treasure|
27
+ yielded << treasure
28
+ end
29
+
30
+ yielded.should == [Treasure.new(:hammer, 75), Treasure.new(:crowbar, 200)]
31
+ end
32
+
33
+
34
+
35
+
36
+ context "with a boost factor" do
37
+ before do
38
+ @initial_health = 100
39
+ @boost_factor = 5
40
+ @player = ClumsyPlayer.new("klutz", @initial_health, @boost_factor)
41
+ end
42
+
43
+ it "has a boost factor" do
44
+ expect(@player.boost_factor).to eq(5)
45
+ end
46
+
47
+ it "gets boost factor number of w00ts when w00ted" do
48
+ @player.w00t
49
+ expect(@player.health).to eq(@initial_health + (15 * @boost_factor))
50
+ end
51
+ end
52
+
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,68 @@
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 "w00ts the player if a high number is rolled" do
17
+ allow_any_instance_of(Die).to receive(:roll).and_return(5)
18
+ @game.play(2)
19
+
20
+ expect(@player.health).to eq(@initial_health + (15 * 2))
21
+ end
22
+ it "skips the player if a medium number is rolled" do
23
+ allow_any_instance_of(Die).to receive(:roll).and_return(3)
24
+ @game.play(2)
25
+
26
+ expect(@player.health).to eq(@initial_health)
27
+ end
28
+ it "blams the player if a low number is rolled" do
29
+ allow_any_instance_of(Die).to receive(:roll).and_return(1)
30
+ @game.play(2)
31
+
32
+ expect(@player.health).to eq(@initial_health - (10 * 2))
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
+
39
+ game.add_player(player)
40
+
41
+ game.play(1)
42
+
43
+ #player.points.should_not be_zero
44
+ expect(player.points).not_to be_zero
45
+ end
46
+
47
+ it "computes total points as the sum of all player points" do
48
+ game = Game.new("Knuckleheads")
49
+
50
+ player1 = Player.new("moe")
51
+ player2 = Player.new("larry")
52
+
53
+ game.add_player(player1)
54
+ game.add_player(player2)
55
+
56
+ player1.found_treasure(Treasure.new(:hammer, 50))
57
+ player1.found_treasure(Treasure.new(:hammer, 50))
58
+ player2.found_treasure(Treasure.new(:crowbar, 400))
59
+
60
+ #game.total_points.should == 500
61
+ expect(game.total_points).to eq(500)
62
+ end
63
+
64
+
65
+
66
+
67
+ end
68
+ end
@@ -0,0 +1,136 @@
1
+ require 'studio_game/player'
2
+ require 'studio_game/treasure_trove'
3
+
4
+ module StudioGame
5
+
6
+ describe Player do
7
+
8
+
9
+ before do
10
+ @initial_health = 150
11
+ @player = Player.new("larry", @initial_health)
12
+ $stdout = StringIO.new
13
+ end
14
+
15
+ it "has a capitalized name" do
16
+ expect(@player.name).to eq("Larry")
17
+ end
18
+
19
+ it "has an inital health" do
20
+ expect(@player.health).to eq(150)
21
+ end
22
+ it "has a string respresentation" do
23
+ @player.found_treasure(Treasure.new(:hammer, 50))
24
+ @player.found_treasure(Treasure.new(:hammer, 50))
25
+
26
+ expect(@player.to_s).to eq("I'm Larry with a health = 150, points = 100, and score = 250.")
27
+ end
28
+
29
+ it "computes a score as the sum of its health and points" do
30
+ @player.found_treasure(Treasure.new(:hammer, 50))
31
+ @player.found_treasure(Treasure.new(:hammer, 50))
32
+
33
+ @player.score.should == 250
34
+ end
35
+
36
+ it "increases health by 15 when w00ted" do
37
+ @player.w00t
38
+
39
+ expect(@player.health).to eq(@initial_health + 15)
40
+ end
41
+
42
+
43
+ it "decreases health by 10 when blammed" do
44
+ @player.blam
45
+
46
+ expect(@player.health).to eq(@initial_health - 10)
47
+ end
48
+
49
+ context "player has an initial health greater than 100" do
50
+ before do
51
+ @initial_health = 150
52
+ @player = Player.new("larry", @initial_health)
53
+ $stdout = StringIO.new
54
+ end
55
+
56
+ it "player is strong" do
57
+ expect(@player).to be_strong #different syntax use for a boolean.
58
+ end
59
+
60
+ end
61
+
62
+ context "player has an initial health of 100" do
63
+ before do
64
+ @initial_health = 100
65
+ @player = Player.new("larry", @initial_health)
66
+ $stdout = StringIO.new
67
+ end
68
+
69
+ it "player is strong" do
70
+ expect(@player).not_to be_strong #different syntax use for a boolean.
71
+ end
72
+
73
+ end
74
+
75
+ context "in a collection of players" do
76
+ before do
77
+ @player1 = Player.new("moe", 100)
78
+ @player2 = Player.new("larry", 200)
79
+ @player3 = Player.new("curly", 300)
80
+
81
+ @players = [@player1, @player2, @player3]
82
+ end
83
+
84
+ it "is sorted by decreasing score" do
85
+ @players.sort.should == [@player3, @player2, @player1]
86
+ end
87
+ end
88
+
89
+ it "computes points as the sum of all treasure points" do
90
+ @player.points.should == 0
91
+
92
+ @player.found_treasure(Treasure.new(:hammer, 50))
93
+
94
+ @player.points.should == 50
95
+
96
+ @player.found_treasure(Treasure.new(:crowbar, 400))
97
+
98
+ @player.points.should == 450
99
+
100
+ @player.found_treasure(Treasure.new(:hammer, 50))
101
+
102
+ @player.points.should == 500
103
+ end
104
+
105
+ it "yields each found treasure and its total points" do
106
+ @player.found_treasure(Treasure.new(:skillet, 100))
107
+ @player.found_treasure(Treasure.new(:skillet, 100))
108
+ @player.found_treasure(Treasure.new(:hammer, 50))
109
+ @player.found_treasure(Treasure.new(:bottle, 5))
110
+ @player.found_treasure(Treasure.new(:bottle, 5))
111
+ @player.found_treasure(Treasure.new(:bottle, 5))
112
+ @player.found_treasure(Treasure.new(:bottle, 5))
113
+ @player.found_treasure(Treasure.new(:bottle, 5))
114
+
115
+ yielded = []
116
+ @player.each_found_treasure do |treasure|
117
+ yielded << treasure
118
+ end
119
+
120
+ yielded.should == [
121
+ Treasure.new(:skillet, 200),
122
+ Treasure.new(:hammer, 50),
123
+ Treasure.new(:bottle, 25)
124
+ ]
125
+ end
126
+
127
+ it "can be created from a CSV string" do
128
+ player = Player.from_csv("larry,150")
129
+
130
+ player.name.should == "Larry"
131
+ player.health.should == 150
132
+ end
133
+
134
+
135
+ end
136
+ end
@@ -0,0 +1,70 @@
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
+ expect(@treasure.name).to eq(:hammer)
14
+ end
15
+
16
+ it "has a points attribute" do
17
+ #@treasure.points.should == 50
18
+ expect(@treasure.points).to eq(50)
19
+ end
20
+
21
+ end
22
+
23
+
24
+ describe TreasureTrove do
25
+
26
+ it "has six treasures" do
27
+ #TreasureTrove::TREASURES.size.should == 6
28
+ expect(TreasureTrove::TREASURES.size).to eq(6)
29
+ end
30
+
31
+
32
+ it "has a pie worth 5 points" do
33
+ #TreasureTrove::TREASURES[0].should == Treasure.new(:pie, 5)
34
+ expect(TreasureTrove::TREASURES[0]).to eq(Treasure.new(:pie,5))
35
+ end
36
+
37
+ it "has a bottle worth 25 points" do
38
+ #TreasureTrove::TREASURES[1].should == Treasure.new(:bottle, 25)
39
+ expect(TreasureTrove::TREASURES[1]).to eq(Treasure.new(:bottle, 25))
40
+ end
41
+
42
+ it "has a hammer worth 50 points" do
43
+ #TreasureTrove::TREASURES[2].should == Treasure.new(:hammer, 50)
44
+ expect(TreasureTrove::TREASURES[2]).to eq(Treasure.new(:hammer, 50))
45
+ end
46
+
47
+ it "has a skillet worth 100 points" do
48
+ #TreasureTrove::TREASURES[3].should == Treasure.new(:skillet, 100)
49
+ expect(TreasureTrove::TREASURES[3]).to eq(Treasure.new(:skillet, 100))
50
+ end
51
+
52
+ it "has a broomstick worth 200 points" do
53
+ #TreasureTrove::TREASURES[4].should == Treasure.new(:broomstick, 200)
54
+ expect(TreasureTrove::TREASURES[4]).to eq(Treasure.new(:broomstick, 200))
55
+ end
56
+
57
+ it "has a crowbar worth 400 points" do
58
+ #TreasureTrove::TREASURES[5].should == Treasure.new(:crowbar, 400)
59
+ expect(TreasureTrove::TREASURES[5]).to eq(Treasure.new(:crowbar, 400))
60
+ end
61
+
62
+ it "returns a random treasure" do
63
+ treasure = TreasureTrove.random
64
+
65
+ #TreasureTrove::TREASURES.should include(treasure)
66
+ expect(TreasureTrove::TREASURES).to include(treasure)
67
+ end
68
+
69
+ end
70
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dice_game_koek
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Zachary Koekenberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-12-31 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: '2.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.8.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.8.0
33
+ description: Dice game to learn Ruby.
34
+ email: zach.koek@gmail.com
35
+ executables:
36
+ - studio_game
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - LICENSE
41
+ - README
42
+ - bin/players.csv
43
+ - bin/studio_game
44
+ - lib/studio_game/auditable.rb
45
+ - lib/studio_game/berserk_player.rb
46
+ - lib/studio_game/clumsy_player.rb
47
+ - lib/studio_game/die.rb
48
+ - lib/studio_game/game.rb
49
+ - lib/studio_game/game_turn.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
+ homepage: https://github.com/zach-koek
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '2.3'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubygems_version: 3.2.22
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Dice game that rolls dice and adds points for a winner.
82
+ test_files:
83
+ - spec/studio_game/berserk_player_spec.rb
84
+ - spec/studio_game/clumsy_player_spec.rb
85
+ - spec/studio_game/game_spec.rb
86
+ - spec/studio_game/player_spec.rb
87
+ - spec/studio_game/treasure_trove_spec.rb